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

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

Issue 5341004: Chrome should re-register device when DMServer doesn't recognize token (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review feedback Created 10 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_management_policy_provider_unittest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/device_management_policy_provider.h" 5 #include "chrome/browser/policy/device_management_policy_provider.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 NotifyStoreOfPolicyChange(); 101 NotifyStoreOfPolicyChange();
102 policy_request_pending_ = false; 102 policy_request_pending_ = false;
103 // Reset the error delay since policy fetching succeeded this time. 103 // Reset the error delay since policy fetching succeeded this time.
104 policy_refresh_error_delay_ms_ = kPolicyRefreshErrorDelayInMilliseconds; 104 policy_refresh_error_delay_ms_ = kPolicyRefreshErrorDelayInMilliseconds;
105 ScheduleRefreshTask(GetRefreshTaskDelay()); 105 ScheduleRefreshTask(GetRefreshTaskDelay());
106 } 106 }
107 107
108 void DeviceManagementPolicyProvider::OnError( 108 void DeviceManagementPolicyProvider::OnError(
109 DeviceManagementBackend::ErrorCode code) { 109 DeviceManagementBackend::ErrorCode code) {
110 policy_request_pending_ = false; 110 policy_request_pending_ = false;
111 LOG(WARNING) << "Could not provide policy from the device manager (error = " 111 if (code == DeviceManagementBackend::kErrorServiceDeviceNotFound ||
112 << code << "), will retry in " 112 code == DeviceManagementBackend::kErrorServiceManagementTokenInvalid) {
113 << (policy_refresh_error_delay_ms_/1000) << " seconds."; 113 LOG(WARNING) << "The device token was either invalid or unknown to the "
114 ScheduleRefreshTask(policy_refresh_error_delay_ms_); 114 << "device manager, re-registering device.";
115 policy_refresh_error_delay_ms_ *= 2; 115 token_fetcher_->Restart();
116 if (policy_refresh_rate_ms_ && 116 } else {
117 policy_refresh_rate_ms_ < policy_refresh_error_delay_ms_) { 117 LOG(WARNING) << "Could not provide policy from the device manager (error = "
118 policy_refresh_error_delay_ms_ = policy_refresh_rate_ms_; 118 << code << "), will retry in "
119 << (policy_refresh_error_delay_ms_/1000) << " seconds.";
120 ScheduleRefreshTask(policy_refresh_error_delay_ms_);
121 policy_refresh_error_delay_ms_ *= 2;
122 if (policy_refresh_rate_ms_ &&
123 policy_refresh_rate_ms_ < policy_refresh_error_delay_ms_) {
124 policy_refresh_error_delay_ms_ = policy_refresh_rate_ms_;
125 }
119 } 126 }
120 } 127 }
121 128
122 void DeviceManagementPolicyProvider::OnTokenSuccess() { 129 void DeviceManagementPolicyProvider::OnTokenSuccess() {
123 if (policy_request_pending_) 130 if (policy_request_pending_)
124 return; 131 return;
125 SendPolicyRequest(); 132 SendPolicyRequest();
126 } 133 }
127 134
128 void DeviceManagementPolicyProvider::OnTokenError() { 135 void DeviceManagementPolicyProvider::OnTokenError() {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 const FilePath device_management_dir = user_data_dir.Append( 237 const FilePath device_management_dir = user_data_dir.Append(
231 FILE_PATH_LITERAL("Device Management")); 238 FILE_PATH_LITERAL("Device Management"));
232 if (!file_util::DirectoryExists(device_management_dir)) { 239 if (!file_util::DirectoryExists(device_management_dir)) {
233 if (!file_util::CreateDirectory(device_management_dir)) 240 if (!file_util::CreateDirectory(device_management_dir))
234 NOTREACHED(); 241 NOTREACHED();
235 } 242 }
236 return device_management_dir; 243 return device_management_dir;
237 } 244 }
238 245
239 } // namespace policy 246 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/policy/device_management_policy_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698