OLD | NEW |
---|---|
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 Loading... | |
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) { |
Mattias Nissler (ping if slow)
2010/11/25 09:03:28
please also add kErrorDeviceManagementTokenInvalid
| |
112 << code << "), will retry in " | 112 LOG(WARNING) << "The device token was not recognized by the device manager," |
113 << (policy_refresh_error_delay_ms_/1000) << " seconds."; | 113 << " re-registering device."; |
114 ScheduleRefreshTask(policy_refresh_error_delay_ms_); | 114 token_fetcher_->Restart(); |
115 policy_refresh_error_delay_ms_ *= 2; | 115 } else { |
116 if (policy_refresh_rate_ms_ && | 116 LOG(WARNING) << "Could not provide policy from the device manager (error = " |
117 policy_refresh_rate_ms_ < policy_refresh_error_delay_ms_) { | 117 << code << "), will retry in " |
118 policy_refresh_error_delay_ms_ = policy_refresh_rate_ms_; | 118 << (policy_refresh_error_delay_ms_/1000) << " seconds."; |
119 ScheduleRefreshTask(policy_refresh_error_delay_ms_); | |
120 policy_refresh_error_delay_ms_ *= 2; | |
121 if (policy_refresh_rate_ms_ && | |
122 policy_refresh_rate_ms_ < policy_refresh_error_delay_ms_) { | |
123 policy_refresh_error_delay_ms_ = policy_refresh_rate_ms_; | |
124 } | |
119 } | 125 } |
120 } | 126 } |
121 | 127 |
122 void DeviceManagementPolicyProvider::OnTokenSuccess() { | 128 void DeviceManagementPolicyProvider::OnTokenSuccess() { |
123 if (policy_request_pending_) | 129 if (policy_request_pending_) |
124 return; | 130 return; |
125 SendPolicyRequest(); | 131 SendPolicyRequest(); |
126 } | 132 } |
127 | 133 |
128 void DeviceManagementPolicyProvider::OnTokenError() { | 134 void DeviceManagementPolicyProvider::OnTokenError() { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 const FilePath device_management_dir = user_data_dir.Append( | 236 const FilePath device_management_dir = user_data_dir.Append( |
231 FILE_PATH_LITERAL("Device Management")); | 237 FILE_PATH_LITERAL("Device Management")); |
232 if (!file_util::DirectoryExists(device_management_dir)) { | 238 if (!file_util::DirectoryExists(device_management_dir)) { |
233 if (!file_util::CreateDirectory(device_management_dir)) | 239 if (!file_util::CreateDirectory(device_management_dir)) |
234 NOTREACHED(); | 240 NOTREACHED(); |
235 } | 241 } |
236 return device_management_dir; | 242 return device_management_dir; |
237 } | 243 } |
238 | 244 |
239 } // namespace policy | 245 } // namespace policy |
OLD | NEW |