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

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

Issue 6705031: Send policy blobs to session_manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 9 years, 9 months 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
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/device_token_fetcher.h" 5 #include "chrome/browser/policy/device_token_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/policy/cloud_policy_cache.h" 10 #include "chrome/browser/policy/cloud_policy_cache_base.h"
11 #include "chrome/browser/policy/device_management_service.h" 11 #include "chrome/browser/policy/device_management_service.h"
12 #include "chrome/browser/policy/proto/device_management_constants.h" 12 #include "chrome/browser/policy/proto/device_management_constants.h"
13 #include "chrome/browser/policy/proto/device_management_local.pb.h" 13 #include "chrome/browser/policy/proto/device_management_local.pb.h"
14 14
15 namespace { 15 namespace {
16 16
17 // Retry after 5 minutes (with exponential backoff) after token fetch errors. 17 // Retry after 5 minutes (with exponential backoff) after token fetch errors.
18 const int64 kTokenFetchErrorDelayMilliseconds = 5 * 60 * 1000; 18 const int64 kTokenFetchErrorDelayMilliseconds = 5 * 60 * 1000;
19 // Retry after max 3 hours after token fetch errors. 19 // Retry after max 3 hours after token fetch errors.
20 const int64 kTokenFetchErrorMaxDelayMilliseconds = 3 * 60 * 60 * 1000; 20 const int64 kTokenFetchErrorMaxDelayMilliseconds = 3 * 60 * 60 * 1000;
21 // For unmanaged devices, check once per day whether they're still unmanaged. 21 // For unmanaged devices, check once per day whether they're still unmanaged.
22 const int64 kUnmanagedDeviceRefreshRateMilliseconds = 24 * 60 * 60 * 1000; 22 const int64 kUnmanagedDeviceRefreshRateMilliseconds = 24 * 60 * 60 * 1000;
23 23
24 } // namespace 24 } // namespace
25 25
26 namespace policy { 26 namespace policy {
27 27
28 namespace em = enterprise_management; 28 namespace em = enterprise_management;
29 29
30 DeviceTokenFetcher::DeviceTokenFetcher( 30 DeviceTokenFetcher::DeviceTokenFetcher(
31 DeviceManagementService* service, 31 DeviceManagementService* service,
32 CloudPolicyCache* cache) 32 CloudPolicyCacheBase* cache)
33 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 33 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
34 Initialize(service, 34 Initialize(service,
35 cache, 35 cache,
36 kTokenFetchErrorDelayMilliseconds, 36 kTokenFetchErrorDelayMilliseconds,
37 kTokenFetchErrorMaxDelayMilliseconds, 37 kTokenFetchErrorMaxDelayMilliseconds,
38 kUnmanagedDeviceRefreshRateMilliseconds); 38 kUnmanagedDeviceRefreshRateMilliseconds);
39 } 39 }
40 40
41 DeviceTokenFetcher::DeviceTokenFetcher( 41 DeviceTokenFetcher::DeviceTokenFetcher(
42 DeviceManagementService* service, 42 DeviceManagementService* service,
43 CloudPolicyCache* cache, 43 CloudPolicyCacheBase* cache,
44 int64 token_fetch_error_delay_ms, 44 int64 token_fetch_error_delay_ms,
45 int64 token_fetch_error_max_delay_ms, 45 int64 token_fetch_error_max_delay_ms,
46 int64 unmanaged_device_refresh_rate_ms) 46 int64 unmanaged_device_refresh_rate_ms)
47 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 47 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
48 Initialize(service, 48 Initialize(service,
49 cache, 49 cache,
50 token_fetch_error_delay_ms, 50 token_fetch_error_delay_ms,
51 token_fetch_error_max_delay_ms, 51 token_fetch_error_max_delay_ms,
52 unmanaged_device_refresh_rate_ms); 52 unmanaged_device_refresh_rate_ms);
53 } 53 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 case DeviceManagementBackend::kErrorServiceDeviceNotFound: 129 case DeviceManagementBackend::kErrorServiceDeviceNotFound:
130 case DeviceManagementBackend::kErrorServiceManagementTokenInvalid: 130 case DeviceManagementBackend::kErrorServiceManagementTokenInvalid:
131 SetState(STATE_TEMPORARY_ERROR); 131 SetState(STATE_TEMPORARY_ERROR);
132 break; 132 break;
133 default: 133 default:
134 SetState(STATE_ERROR); 134 SetState(STATE_ERROR);
135 } 135 }
136 } 136 }
137 137
138 void DeviceTokenFetcher::Initialize(DeviceManagementService* service, 138 void DeviceTokenFetcher::Initialize(DeviceManagementService* service,
139 CloudPolicyCache* cache, 139 CloudPolicyCacheBase* cache,
140 int64 token_fetch_error_delay_ms, 140 int64 token_fetch_error_delay_ms,
141 int64 token_fetch_error_max_delay_ms, 141 int64 token_fetch_error_max_delay_ms,
142 int64 unmanaged_device_refresh_rate_ms) { 142 int64 unmanaged_device_refresh_rate_ms) {
143 service_ = service; 143 service_ = service;
144 cache_ = cache; 144 cache_ = cache;
145 token_fetch_error_delay_ms_ = token_fetch_error_delay_ms; 145 token_fetch_error_delay_ms_ = token_fetch_error_delay_ms;
146 token_fetch_error_max_delay_ms_ = token_fetch_error_max_delay_ms; 146 token_fetch_error_max_delay_ms_ = token_fetch_error_max_delay_ms;
147 effective_token_fetch_error_delay_ms_ = token_fetch_error_delay_ms; 147 effective_token_fetch_error_delay_ms_ = token_fetch_error_delay_ms;
148 unmanaged_device_refresh_rate_ms_ = unmanaged_device_refresh_rate_ms; 148 unmanaged_device_refresh_rate_ms_ = unmanaged_device_refresh_rate_ms;
149 state_ = STATE_INACTIVE; 149 state_ = STATE_INACTIVE;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 216 }
217 217
218 void DeviceTokenFetcher::CancelRetryTask() { 218 void DeviceTokenFetcher::CancelRetryTask() {
219 if (retry_task_) { 219 if (retry_task_) {
220 retry_task_->Cancel(); 220 retry_task_->Cancel();
221 retry_task_ = NULL; 221 retry_task_ = NULL;
222 } 222 }
223 } 223 }
224 224
225 } // namespace policy 225 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_token_fetcher.h ('k') | chrome/browser/policy/device_token_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698