update_engine: Add locations to the MessageLoop calls.

When running the unittests with --v=1, this patch will show the location
where the tasks were posted to the FakeMessageLoop.

BUG=brillo:91
TEST=Ran unittest with --v=1

Change-Id: I0f9b0a3b67a40c26965a396258f1bd45e38f5ba3
Reviewed-on: https://chromium-review.googlesource.com/280568
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/update_manager/evaluation_context.cc b/update_manager/evaluation_context.cc
index 856c5cd..66275de 100644
--- a/update_manager/evaluation_context.cc
+++ b/update_manager/evaluation_context.cc
@@ -10,6 +10,7 @@
 
 #include <base/bind.h>
 #include <base/json/json_writer.h>
+#include <base/location.h>
 #include <base/strings/string_util.h>
 #include <base/values.h>
 
@@ -204,6 +205,7 @@
     DLOG(INFO) << "Waiting for timeout in "
                << chromeos_update_engine::utils::FormatTimeDelta(timeout);
     timeout_event_ = MessageLoop::current()->PostDelayedTask(
+        FROM_HERE,
         base::Bind(&EvaluationContext::OnTimeout,
                    weak_ptr_factory_.GetWeakPtr()),
         timeout);
diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index 0ba9594..2b59026 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -323,14 +323,15 @@
 // Test that timed events fired after removal of the EvaluationContext don't
 // crash.
 TEST_F(UmEvaluationContextTest, TimeoutEventAfterDeleteTest) {
-  FakeVariable<string> fake_short_poll_var = {"fake_short_poll", TimeDelta()};
+  FakeVariable<string> fake_short_poll_var = {"fake_short_poll",
+                                              TimeDelta::FromSeconds(1)};
   fake_short_poll_var.reset(new string("Polled value"));
   eval_ctx_->GetValue(&fake_short_poll_var);
   bool value = false;
   EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(Bind(&SetTrue, &value)));
   // Remove the last reference to the EvaluationContext and run the loop for
-  // 1 second to give time to the main loop to trigger the timeout Event (of 0
-  // seconds). Our callback should not be called because the EvaluationContext
+  // 10 seconds to give time to the main loop to trigger the timeout Event (of 1
+  // second). Our callback should not be called because the EvaluationContext
   // was removed before the timeout event is attended.
   eval_ctx_ = nullptr;
   MessageLoopRunUntil(MessageLoop::current(),
diff --git a/update_manager/real_device_policy_provider.cc b/update_manager/real_device_policy_provider.cc
index 557987f..6f484f7 100644
--- a/update_manager/real_device_policy_provider.cc
+++ b/update_manager/real_device_policy_provider.cc
@@ -6,6 +6,7 @@
 
 #include <stdint.h>
 
+#include <base/location.h>
 #include <base/logging.h>
 #include <base/time/time.h>
 #include <chromeos/dbus/service_constants.h>
@@ -85,6 +86,7 @@
 void RealDevicePolicyProvider::RefreshDevicePolicyAndReschedule() {
   RefreshDevicePolicy();
   scheduled_refresh_ = MessageLoop::current()->PostDelayedTask(
+      FROM_HERE,
       base::Bind(&RealDevicePolicyProvider::RefreshDevicePolicyAndReschedule,
                  base::Unretained(this)),
       TimeDelta::FromMinutes(kDevicePolicyRefreshRateInMinutes));
diff --git a/update_manager/update_manager-inl.h b/update_manager/update_manager-inl.h
index 9463c76..b8fef28 100644
--- a/update_manager/update_manager-inl.h
+++ b/update_manager/update_manager-inl.h
@@ -9,6 +9,7 @@
 #include <string>
 
 #include <base/bind.h>
+#include <base/location.h>
 #include <chromeos/message_loops/message_loop.h>
 
 #include "update_engine/update_manager/evaluation_context.h"
@@ -144,7 +145,7 @@
   base::Closure eval_callback = base::Bind(
       &UpdateManager::OnPolicyReadyToEvaluate<R, ExpectedArgs...>,
       base::Unretained(this), ec, callback, policy_method, args...);
-  chromeos::MessageLoop::current()->PostTask(eval_callback);
+  chromeos::MessageLoop::current()->PostTask(FROM_HERE, eval_callback);
 }
 
 }  // namespace chromeos_update_manager
diff --git a/update_manager/variable.h b/update_manager/variable.h
index 9f80461..7ce2af8 100644
--- a/update_manager/variable.h
+++ b/update_manager/variable.h
@@ -10,6 +10,7 @@
 #include <string>
 
 #include <base/bind.h>
+#include <base/location.h>
 #include <base/logging.h>
 #include <base/time/time.h>
 #include <chromeos/message_loops/message_loop.h>
@@ -108,6 +109,7 @@
     // first the list of observers.
     if (!observer_list_.empty()) {
       chromeos::MessageLoop::current()->PostTask(
+          FROM_HERE,
           base::Bind(&BaseVariable::OnValueChangedNotification,
                      base::Unretained(this)));
     }