PM: Blocking policy requests cannot be called synchronously.
Policy requests that may return EvalStatus::kAskMeAgainLater are
considered blocking and should only be called asynchronously. It is
therefore an error to call a policy returning this value via
UpdateManager::PolicyRequest(), and so we kill the program with an
assertion (DCHECK) if this happens; for release builds, a warning log is
emitted.
Note: the associated death test builds and runs iff DCHECK is enabled.
BUG=None
TEST=Unit tests.
Change-Id: I75e2f5e4498f85857aff41778df0300d7c8898e7
Reviewed-on: https://chromium-review.googlesource.com/200760
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/update_manager/update_manager.h b/update_manager/update_manager.h
index b3dfc7f..8c96d7b 100644
--- a/update_manager/update_manager.h
+++ b/update_manager/update_manager.h
@@ -34,11 +34,10 @@
// |policy_method|.
//
// When the policy request succeeds, the |result| is set and the method
- // returns EvalStatus::kSucceeded, otherwise, the |result| may not be set.
- // Also, if the policy implementation should block, this method returns
- // immediately with EvalStatus::kAskMeAgainLater. In case of failure
- // EvalStatus::kFailed is returned and the |error| message is set, which must
- // not be NULL.
+ // returns EvalStatus::kSucceeded, otherwise, the |result| may not be set. A
+ // policy called with this method should not block (i.e. return
+ // EvalStatus::kAskMeAgainLater), which is considered a programming error. On
+ // failure, EvalStatus::kFailed is returned.
//
// An example call to this method is:
// um.PolicyRequest(&Policy::SomePolicyMethod, &bool_result, arg1, arg2);
@@ -77,7 +76,7 @@
private:
FRIEND_TEST(UmUpdateManagerTest, PolicyRequestCallsPolicy);
FRIEND_TEST(UmUpdateManagerTest, PolicyRequestCallsDefaultOnError);
- FRIEND_TEST(UmUpdateManagerTest, PolicyRequestDoesntBlock);
+ FRIEND_TEST(UmUpdateManagerTest, PolicyRequestDoesntBlockDeathTest);
FRIEND_TEST(UmUpdateManagerTest, AsyncPolicyRequestDelaysEvaluation);
// EvaluatePolicy() evaluates the passed |policy_method| method on the current