OLD | NEW |
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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/metrics/histogram.h" |
13 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 16 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
16 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 17 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
17 #include "chrome/browser/policy/device_management_backend.h" | 18 #include "chrome/browser/policy/device_management_backend.h" |
18 #include "chrome/browser/policy/device_management_service.h" | 19 #include "chrome/browser/policy/device_management_service.h" |
| 20 #include "chrome/browser/policy/enterprise_metrics.h" |
19 #include "chrome/browser/policy/proto/device_management_constants.h" | 21 #include "chrome/browser/policy/proto/device_management_constants.h" |
20 | 22 |
21 // Domain names that are known not to be managed. | 23 // Domain names that are known not to be managed. |
22 // We don't register the device when such a user logs in. | 24 // We don't register the device when such a user logs in. |
23 static const char* kNonManagedDomains[] = { | 25 static const char* kNonManagedDomains[] = { |
24 "@googlemail.com", | 26 "@googlemail.com", |
25 "@gmail.com" | 27 "@gmail.com" |
26 }; | 28 }; |
27 | 29 |
28 // Checks the domain part of the given username against the list of known | 30 // Checks the domain part of the given username against the list of known |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if (response.response_size() > 0) { | 107 if (response.response_size() > 0) { |
106 if (response.response_size() > 1) { | 108 if (response.response_size() > 1) { |
107 LOG(WARNING) << "More than one policy in the response of the device " | 109 LOG(WARNING) << "More than one policy in the response of the device " |
108 << "management server, discarding."; | 110 << "management server, discarding."; |
109 } | 111 } |
110 if (response.response(0).error_code() != | 112 if (response.response(0).error_code() != |
111 DeviceManagementBackend::kErrorServicePolicyNotFound) { | 113 DeviceManagementBackend::kErrorServicePolicyNotFound) { |
112 cache_->SetPolicy(response.response(0)); | 114 cache_->SetPolicy(response.response(0)); |
113 SetState(STATE_POLICY_VALID); | 115 SetState(STATE_POLICY_VALID); |
114 } else { | 116 } else { |
| 117 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchBadResponse, |
| 118 kMetricPolicySize); |
115 SetState(STATE_POLICY_UNAVAILABLE); | 119 SetState(STATE_POLICY_UNAVAILABLE); |
116 } | 120 } |
| 121 } else { |
| 122 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchBadResponse, |
| 123 kMetricPolicySize); |
117 } | 124 } |
118 } | 125 } |
119 | 126 |
120 void CloudPolicyController::OnError(DeviceManagementBackend::ErrorCode code) { | 127 void CloudPolicyController::OnError(DeviceManagementBackend::ErrorCode code) { |
121 switch (code) { | 128 switch (code) { |
122 case DeviceManagementBackend::kErrorServiceDeviceNotFound: | 129 case DeviceManagementBackend::kErrorServiceDeviceNotFound: |
123 case DeviceManagementBackend::kErrorServiceManagementTokenInvalid: { | 130 case DeviceManagementBackend::kErrorServiceManagementTokenInvalid: { |
124 LOG(WARNING) << "The device token was either invalid or unknown to the " | 131 LOG(WARNING) << "The device token was either invalid or unknown to the " |
125 << "device manager, re-registering device."; | 132 << "device manager, re-registering device."; |
126 // Will retry fetching a token but gracefully backing off. | 133 // Will retry fetching a token but gracefully backing off. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 360 } |
354 | 361 |
355 int64 CloudPolicyController::GetRefreshDelay() { | 362 int64 CloudPolicyController::GetRefreshDelay() { |
356 int64 deviation = (kPolicyRefreshDeviationFactorPercent * | 363 int64 deviation = (kPolicyRefreshDeviationFactorPercent * |
357 policy_refresh_rate_ms_) / 100; | 364 policy_refresh_rate_ms_) / 100; |
358 deviation = std::min(deviation, kPolicyRefreshDeviationMaxInMilliseconds); | 365 deviation = std::min(deviation, kPolicyRefreshDeviationMaxInMilliseconds); |
359 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1); | 366 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1); |
360 } | 367 } |
361 | 368 |
362 } // namespace policy | 369 } // namespace policy |
OLD | NEW |