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

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

Issue 7105018: UMA metrics for cloud policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win build, rebased Created 9 years, 5 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/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/metrics/histogram.h"
12 #include "chrome/browser/policy/cloud_policy_cache_base.h" 13 #include "chrome/browser/policy/cloud_policy_cache_base.h"
13 #include "chrome/browser/policy/device_management_service.h" 14 #include "chrome/browser/policy/device_management_service.h"
15 #include "chrome/browser/policy/enterprise_metrics.h"
14 #include "chrome/browser/policy/proto/device_management_constants.h" 16 #include "chrome/browser/policy/proto/device_management_constants.h"
15 #include "chrome/browser/policy/proto/device_management_local.pb.h" 17 #include "chrome/browser/policy/proto/device_management_local.pb.h"
16 18
17 namespace { 19 namespace {
18 20
19 // Retry after 5 minutes (with exponential backoff) after token fetch errors. 21 // Retry after 5 minutes (with exponential backoff) after token fetch errors.
20 const int64 kTokenFetchErrorDelayMilliseconds = 5 * 60 * 1000; 22 const int64 kTokenFetchErrorDelayMilliseconds = 5 * 60 * 1000;
21 // Retry after max 3 hours after token fetch errors. 23 // Retry after max 3 hours after token fetch errors.
22 const int64 kTokenFetchErrorMaxDelayMilliseconds = 3 * 60 * 60 * 1000; 24 const int64 kTokenFetchErrorMaxDelayMilliseconds = 3 * 60 * 60 * 1000;
23 // For unmanaged devices, check once per day whether they're still unmanaged. 25 // For unmanaged devices, check once per day whether they're still unmanaged.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 114 }
113 115
114 void DeviceTokenFetcher::RemoveObserver( 116 void DeviceTokenFetcher::RemoveObserver(
115 DeviceTokenFetcher::Observer* observer) { 117 DeviceTokenFetcher::Observer* observer) {
116 observer_list_.RemoveObserver(observer); 118 observer_list_.RemoveObserver(observer);
117 } 119 }
118 120
119 void DeviceTokenFetcher::HandleRegisterResponse( 121 void DeviceTokenFetcher::HandleRegisterResponse(
120 const em::DeviceRegisterResponse& response) { 122 const em::DeviceRegisterResponse& response) {
121 if (response.has_device_management_token()) { 123 if (response.has_device_management_token()) {
124 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchOK,
125 kMetricTokenSize);
122 device_token_ = response.device_management_token(); 126 device_token_ = response.device_management_token();
123 SetState(STATE_TOKEN_AVAILABLE); 127 SetState(STATE_TOKEN_AVAILABLE);
124 } else { 128 } else {
125 NOTREACHED(); 129 NOTREACHED();
130 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchBadResponse,
131 kMetricTokenSize);
126 SetState(STATE_ERROR); 132 SetState(STATE_ERROR);
127 } 133 }
128 } 134 }
129 135
130 void DeviceTokenFetcher::OnError(DeviceManagementBackend::ErrorCode code) { 136 void DeviceTokenFetcher::OnError(DeviceManagementBackend::ErrorCode code) {
131 switch (code) { 137 switch (code) {
132 case DeviceManagementBackend::kErrorServiceManagementNotSupported: 138 case DeviceManagementBackend::kErrorServiceManagementNotSupported:
133 cache_->SetUnmanaged(); 139 cache_->SetUnmanaged();
134 SetState(STATE_UNMANAGED); 140 SetState(STATE_UNMANAGED);
135 break; 141 break;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 case STATE_UNMANAGED: 244 case STATE_UNMANAGED:
239 case STATE_ERROR: 245 case STATE_ERROR:
240 case STATE_TEMPORARY_ERROR: 246 case STATE_TEMPORARY_ERROR:
241 case STATE_BAD_AUTH: 247 case STATE_BAD_AUTH:
242 FetchTokenInternal(); 248 FetchTokenInternal();
243 break; 249 break;
244 } 250 }
245 } 251 }
246 252
247 } // namespace policy 253 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_policy_cache.cc ('k') | chrome/browser/policy/enterprise_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698