UM: Fix async callback handling.
A bug in EvaluationContext::OnValueChangedOrPollTimeout() causes
scheduling of a reevaluation to fail. We fix it by copying the callback
pointer to a local variable and clearing it prior to invoking the
callback.
This also adds a check in the evaluation context unit tests code to
ensure that the EC under test is actually being destroyed; this is
useful to ensure that unit tests are not leaking EC references, e.g. by
form of pending main loop events that are holding EC handles in
closures.
BUG=chromium:391037
TEST=New unit test fails before fix, succeeds after it.
Change-Id: I63486b80525ec19d0cd399c52eea39d991a4ff53
Reviewed-on: https://chromium-review.googlesource.com/206538
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/update_manager/evaluation_context.h b/update_manager/evaluation_context.h
index 3b2779e..5e36e8a 100644
--- a/update_manager/evaluation_context.h
+++ b/update_manager/evaluation_context.h
@@ -92,6 +92,8 @@
std::string DumpContext() const;
private:
+ friend class UmEvaluationContextTest;
+
// Removes all the Observers and timeout callbacks scheduled by
// RunOnValueChangeOrTimeout(). This method is idempotent.
void RemoveObserversAndTimeout();