OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/policy/auto_enrollment_client.h" | 5 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop/message_loop_proxy.h" | |
12 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
13 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
14 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
15 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
16 #include "base/prefs/scoped_user_pref_update.h" | 15 #include "base/prefs/scoped_user_pref_update.h" |
| 16 #include "base/thread_task_runner_handle.h" |
17 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" | 17 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" |
18 #include "chrome/common/chrome_content_client.h" | 18 #include "chrome/common/chrome_content_client.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "components/policy/core/common/cloud/device_management_service.h" | 20 #include "components/policy/core/common/cloud/device_management_service.h" |
21 #include "components/policy/core/common/cloud/system_policy_request_context.h" | 21 #include "components/policy/core/common/cloud/system_policy_request_context.h" |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
23 #include "crypto/sha2.h" | 23 #include "crypto/sha2.h" |
24 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
25 #include "policy/proto/device_management_backend.pb.h" | 25 #include "policy/proto/device_management_backend.pb.h" |
26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 SendBucketDownloadRequest(); | 205 SendBucketDownloadRequest(); |
206 return true; | 206 return true; |
207 } | 207 } |
208 | 208 |
209 return false; | 209 return false; |
210 } | 210 } |
211 | 211 |
212 void AutoEnrollmentClient::ReportProgress(AutoEnrollmentState state) { | 212 void AutoEnrollmentClient::ReportProgress(AutoEnrollmentState state) { |
213 state_ = state; | 213 state_ = state; |
214 if (progress_callback_.is_null()) { | 214 if (progress_callback_.is_null()) { |
215 base::MessageLoopProxy::current()->DeleteSoon(FROM_HERE, this); | 215 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
216 } else { | 216 } else { |
217 progress_callback_.Run(state_); | 217 progress_callback_.Run(state_); |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 void AutoEnrollmentClient::NextStep() { | 221 void AutoEnrollmentClient::NextStep() { |
222 if (!RetryStep()) { | 222 if (!RetryStep()) { |
223 // Protocol finished successfully, report result. | 223 // Protocol finished successfully, report result. |
224 const RestoreMode restore_mode = GetRestoreMode(); | 224 const RestoreMode restore_mode = GetRestoreMode(); |
225 bool trigger_enrollment = | 225 bool trigger_enrollment = |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 const em::DeviceManagementResponse& response) { | 282 const em::DeviceManagementResponse& response) { |
283 UMA_HISTOGRAM_SPARSE_SLOWLY(kUMARequestStatus, status); | 283 UMA_HISTOGRAM_SPARSE_SLOWLY(kUMARequestStatus, status); |
284 if (status != DM_STATUS_SUCCESS) { | 284 if (status != DM_STATUS_SUCCESS) { |
285 LOG(ERROR) << "Auto enrollment error: " << status; | 285 LOG(ERROR) << "Auto enrollment error: " << status; |
286 if (status == DM_STATUS_REQUEST_FAILED) | 286 if (status == DM_STATUS_REQUEST_FAILED) |
287 UMA_HISTOGRAM_SPARSE_SLOWLY(kUMANetworkErrorCode, -net_error); | 287 UMA_HISTOGRAM_SPARSE_SLOWLY(kUMANetworkErrorCode, -net_error); |
288 request_job_.reset(); | 288 request_job_.reset(); |
289 | 289 |
290 // Abort if CancelAndDeleteSoon has been called meanwhile. | 290 // Abort if CancelAndDeleteSoon has been called meanwhile. |
291 if (progress_callback_.is_null()) { | 291 if (progress_callback_.is_null()) { |
292 base::MessageLoopProxy::current()->DeleteSoon(FROM_HERE, this); | 292 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
293 } else { | 293 } else { |
294 ReportProgress(status == DM_STATUS_REQUEST_FAILED | 294 ReportProgress(status == DM_STATUS_REQUEST_FAILED |
295 ? AUTO_ENROLLMENT_STATE_CONNECTION_ERROR | 295 ? AUTO_ENROLLMENT_STATE_CONNECTION_ERROR |
296 : AUTO_ENROLLMENT_STATE_SERVER_ERROR); | 296 : AUTO_ENROLLMENT_STATE_SERVER_ERROR); |
297 } | 297 } |
298 return; | 298 return; |
299 } | 299 } |
300 | 300 |
301 bool progress = (this->*handler)(status, net_error, response); | 301 bool progress = (this->*handler)(status, net_error, response); |
302 request_job_.reset(); | 302 request_job_.reset(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 base::TimeDelta delta = kZero; | 427 base::TimeDelta delta = kZero; |
428 if (!time_extra_start_.is_null()) | 428 if (!time_extra_start_.is_null()) |
429 delta = now - time_extra_start_; | 429 delta = now - time_extra_start_; |
430 // This samples |kZero| when there was no need for extra time, so that we can | 430 // This samples |kZero| when there was no need for extra time, so that we can |
431 // measure the ratio of users that succeeded without needing a delay to the | 431 // measure the ratio of users that succeeded without needing a delay to the |
432 // total users going through OOBE. | 432 // total users going through OOBE. |
433 UMA_HISTOGRAM_CUSTOM_TIMES(kUMAExtraTime, delta, kMin, kMax, kBuckets); | 433 UMA_HISTOGRAM_CUSTOM_TIMES(kUMAExtraTime, delta, kMin, kMax, kBuckets); |
434 } | 434 } |
435 | 435 |
436 } // namespace policy | 436 } // namespace policy |
OLD | NEW |