Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: chrome/browser/policy/cloud_policy_controller.cc

Issue 8773034: Clean up error handling and timestamp initialization for cloud policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/policy/device_policy_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/policy/cloud_policy_controller.h" 5 #include "chrome/browser/policy/cloud_policy_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 void CloudPolicyController::OnError(DeviceManagementBackend::ErrorCode code) { 133 void CloudPolicyController::OnError(DeviceManagementBackend::ErrorCode code) {
134 switch (code) { 134 switch (code) {
135 case DeviceManagementBackend::kErrorServiceDeviceNotFound: 135 case DeviceManagementBackend::kErrorServiceDeviceNotFound:
136 case DeviceManagementBackend::kErrorServiceDeviceIdConflict: 136 case DeviceManagementBackend::kErrorServiceDeviceIdConflict:
137 case DeviceManagementBackend::kErrorServiceManagementTokenInvalid: { 137 case DeviceManagementBackend::kErrorServiceManagementTokenInvalid: {
138 LOG(WARNING) << "The device token was either invalid or unknown to the " 138 LOG(WARNING) << "The device token was either invalid or unknown to the "
139 << "device manager, re-registering device."; 139 << "device manager, re-registering device.";
140 // Will retry fetching a token but gracefully backing off. 140 // Will retry fetching a token but gracefully backing off.
141 SetState(STATE_TOKEN_ERROR); 141 SetState(STATE_TOKEN_ERROR);
142 break; 142 return;
143 } 143 }
144 case DeviceManagementBackend::kErrorServiceInvalidSerialNumber: { 144 case DeviceManagementBackend::kErrorServiceInvalidSerialNumber: {
145 VLOG(1) << "The device is no longer enlisted for the domain."; 145 VLOG(1) << "The device is no longer enlisted for the domain.";
146 token_fetcher_->SetSerialNumberInvalidState(); 146 token_fetcher_->SetSerialNumberInvalidState();
147 SetState(STATE_TOKEN_ERROR); 147 SetState(STATE_TOKEN_ERROR);
148 break; 148 return;
149 } 149 }
150 case DeviceManagementBackend::kErrorServiceManagementNotSupported: { 150 case DeviceManagementBackend::kErrorServiceManagementNotSupported: {
151 VLOG(1) << "The device is no longer managed."; 151 VLOG(1) << "The device is no longer managed.";
152 token_fetcher_->SetUnmanagedState(); 152 token_fetcher_->SetUnmanagedState();
153 SetState(STATE_TOKEN_UNMANAGED); 153 SetState(STATE_TOKEN_UNMANAGED);
154 break; 154 return;
155 } 155 }
156 case DeviceManagementBackend::kErrorServicePolicyNotFound: 156 case DeviceManagementBackend::kErrorServicePolicyNotFound:
157 case DeviceManagementBackend::kErrorRequestInvalid: 157 case DeviceManagementBackend::kErrorRequestInvalid:
158 case DeviceManagementBackend::kErrorServiceActivationPending: 158 case DeviceManagementBackend::kErrorServiceActivationPending:
159 case DeviceManagementBackend::kErrorResponseDecoding: 159 case DeviceManagementBackend::kErrorResponseDecoding:
160 case DeviceManagementBackend::kErrorHttpStatus: { 160 case DeviceManagementBackend::kErrorHttpStatus: {
161 VLOG(1) << "An error in the communication with the policy server occurred" 161 VLOG(1) << "An error in the communication with the policy server occurred"
162 << ", will retry in a few hours."; 162 << ", will retry in a few hours.";
163 SetState(STATE_POLICY_UNAVAILABLE); 163 SetState(STATE_POLICY_UNAVAILABLE);
164 break; 164 return;
165 } 165 }
166 case DeviceManagementBackend::kErrorRequestFailed: 166 case DeviceManagementBackend::kErrorRequestFailed:
167 case DeviceManagementBackend::kErrorTemporaryUnavailable: { 167 case DeviceManagementBackend::kErrorTemporaryUnavailable: {
168 VLOG(1) << "A temporary error in the communication with the policy server" 168 VLOG(1) << "A temporary error in the communication with the policy server"
169 << " occurred."; 169 << " occurred.";
170 }
171 default:
172 // Will retry last operation but gracefully backing off. 170 // Will retry last operation but gracefully backing off.
173 SetState(STATE_POLICY_ERROR); 171 SetState(STATE_POLICY_ERROR);
172 return;
173 }
174 } 174 }
175
176 NOTREACHED();
177 SetState(STATE_POLICY_ERROR);
175 } 178 }
176 179
177 void CloudPolicyController::OnDeviceTokenChanged() { 180 void CloudPolicyController::OnDeviceTokenChanged() {
178 if (data_store_->device_token().empty()) 181 if (data_store_->device_token().empty())
179 SetState(STATE_TOKEN_UNAVAILABLE); 182 SetState(STATE_TOKEN_UNAVAILABLE);
180 else 183 else
181 SetState(STATE_TOKEN_VALID); 184 SetState(STATE_TOKEN_VALID);
182 } 185 }
183 186
184 void CloudPolicyController::OnCredentialsChanged() { 187 void CloudPolicyController::OnCredentialsChanged() {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 384 }
382 385
383 int64 CloudPolicyController::GetRefreshDelay() { 386 int64 CloudPolicyController::GetRefreshDelay() {
384 int64 deviation = (kPolicyRefreshDeviationFactorPercent * 387 int64 deviation = (kPolicyRefreshDeviationFactorPercent *
385 policy_refresh_rate_ms_) / 100; 388 policy_refresh_rate_ms_) / 100;
386 deviation = std::min(deviation, kPolicyRefreshDeviationMaxInMilliseconds); 389 deviation = std::min(deviation, kPolicyRefreshDeviationMaxInMilliseconds);
387 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1); 390 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1);
388 } 391 }
389 392
390 } // namespace policy 393 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/policy/device_policy_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698