| Index: chrome/browser/policy/cloud_policy_controller.cc
|
| diff --git a/chrome/browser/policy/cloud_policy_controller.cc b/chrome/browser/policy/cloud_policy_controller.cc
|
| index 25c340e750e01f9b12805907c182bbda48a688b0..ec127a260df136120cc4c202d19f21c3d1b223d6 100644
|
| --- a/chrome/browser/policy/cloud_policy_controller.cc
|
| +++ b/chrome/browser/policy/cloud_policy_controller.cc
|
| @@ -66,7 +66,8 @@ CloudPolicyController::CloudPolicyController(
|
| DeviceTokenFetcher* token_fetcher,
|
| CloudPolicyIdentityStrategy* identity_strategy,
|
| PolicyNotifier* notifier)
|
| - : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
|
| + : stop_after_token_fetch_(false),
|
| + ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
|
| Initialize(service,
|
| cache,
|
| token_fetcher,
|
| @@ -92,6 +93,10 @@ void CloudPolicyController::SetRefreshRate(int64 refresh_rate_milliseconds) {
|
| SetState(STATE_POLICY_VALID);
|
| }
|
|
|
| +void CloudPolicyController::StopAfterTokenFetch(bool enable) {
|
| + stop_after_token_fetch_ = enable;
|
| +}
|
| +
|
| void CloudPolicyController::Retry() {
|
| CancelDelayedWork();
|
| DoWork();
|
| @@ -306,7 +311,7 @@ void CloudPolicyController::SetState(
|
| base::Time last_refresh(cache_->last_policy_refresh_time());
|
| if (last_refresh.is_null())
|
| last_refresh = now;
|
| -
|
| + LOG(ERROR) << "$$$ state : " << state_;
|
| // Determine when to take the next step.
|
| bool inform_notifier_done = false;
|
| switch (state_) {
|
| @@ -318,12 +323,21 @@ void CloudPolicyController::SetState(
|
| case STATE_TOKEN_UNAVAILABLE:
|
| // The controller is not yet initialized and needs to immediately fetch
|
| // token and policy if present.
|
| + refresh_at = now;
|
| + break;
|
| case STATE_TOKEN_VALID:
|
| // Immediately try to fetch the token on initialization or policy after a
|
| // token update. Subsequent retries will respect the back-off strategy.
|
| - refresh_at = now;
|
| - // |notifier_| isn't informed about anything at this point, we wait for
|
| - // the result of the next action first.
|
| + if (!stop_after_token_fetch_) {
|
| + refresh_at = now;
|
| + LOG(ERROR) << "$$$ Will fetch!";
|
| + } else {
|
| + LOG(ERROR) << "$$$ Will notify!";
|
| + stop_after_token_fetch_ = false;
|
| + notifier_->Inform(CloudPolicySubsystem::TOKEN_FETCHED,
|
| + CloudPolicySubsystem::NO_DETAILS,
|
| + PolicyNotifier::POLICY_CONTROLLER);
|
| + }
|
| break;
|
| case STATE_POLICY_VALID:
|
| // Delay is only reset if the policy fetch operation was successful. This
|
|
|