libchromeos: Fix CancelTask from the running task.

This patch removes the task_id from the map before running the user
provided callback, while keeping the ScheduledTask struct alive. This
makes CancelTask() return false when calling it from the same task you
are running.

BUG=None
TEST=Added unittest.

Change-Id: Id5e15a1111673f16a8ba9a0acfa2a46c1b64d5d1
Reviewed-on: https://chromium-review.googlesource.com/281060
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
2 files changed