| 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/user_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 13 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
| 14 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chromeos/login/helper.h" | 18 #include "chrome/browser/chromeos/login/helper.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 base::TimeDelta initial_policy_fetch_timeout, | 86 base::TimeDelta initial_policy_fetch_timeout, |
| 86 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 87 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 87 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, | 88 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, |
| 88 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) | 89 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) |
| 89 : CloudPolicyManager(dm_protocol::kChromeUserPolicyType, | 90 : CloudPolicyManager(dm_protocol::kChromeUserPolicyType, |
| 90 std::string(), | 91 std::string(), |
| 91 store.get(), | 92 store.get(), |
| 92 task_runner, | 93 task_runner, |
| 93 file_task_runner, | 94 file_task_runner, |
| 94 io_task_runner), | 95 io_task_runner), |
| 95 store_(store.Pass()), | 96 store_(std::move(store)), |
| 96 external_data_manager_(external_data_manager.Pass()), | 97 external_data_manager_(std::move(external_data_manager)), |
| 97 component_policy_cache_path_(component_policy_cache_path), | 98 component_policy_cache_path_(component_policy_cache_path), |
| 98 wait_for_policy_fetch_(wait_for_policy_fetch), | 99 wait_for_policy_fetch_(wait_for_policy_fetch), |
| 99 policy_fetch_timeout_(false, false) { | 100 policy_fetch_timeout_(false, false) { |
| 100 time_init_started_ = base::Time::Now(); | 101 time_init_started_ = base::Time::Now(); |
| 101 if (wait_for_policy_fetch_ && !initial_policy_fetch_timeout.is_max()) { | 102 if (wait_for_policy_fetch_ && !initial_policy_fetch_timeout.is_max()) { |
| 102 policy_fetch_timeout_.Start( | 103 policy_fetch_timeout_.Start( |
| 103 FROM_HERE, | 104 FROM_HERE, |
| 104 initial_policy_fetch_timeout, | 105 initial_policy_fetch_timeout, |
| 105 base::Bind(&UserCloudPolicyManagerChromeOS::OnBlockingFetchTimeout, | 106 base::Bind(&UserCloudPolicyManagerChromeOS::OnBlockingFetchTimeout, |
| 106 base::Unretained(this))); | 107 base::Unretained(this))); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 125 // TODO(atwilson): Change this to use a UserPolicyRequestContext once | 126 // TODO(atwilson): Change this to use a UserPolicyRequestContext once |
| 126 // Connect() is called after profile initialization. http://crbug.com/323591 | 127 // Connect() is called after profile initialization. http://crbug.com/323591 |
| 127 request_context = new SystemPolicyRequestContext( | 128 request_context = new SystemPolicyRequestContext( |
| 128 system_request_context, GetUserAgent()); | 129 system_request_context, GetUserAgent()); |
| 129 } | 130 } |
| 130 scoped_ptr<CloudPolicyClient> cloud_policy_client(new CloudPolicyClient( | 131 scoped_ptr<CloudPolicyClient> cloud_policy_client(new CloudPolicyClient( |
| 131 std::string(), std::string(), kPolicyVerificationKeyHash, | 132 std::string(), std::string(), kPolicyVerificationKeyHash, |
| 132 device_management_service, request_context)); | 133 device_management_service, request_context)); |
| 133 CreateComponentCloudPolicyService(component_policy_cache_path_, | 134 CreateComponentCloudPolicyService(component_policy_cache_path_, |
| 134 request_context, cloud_policy_client.get()); | 135 request_context, cloud_policy_client.get()); |
| 135 core()->Connect(cloud_policy_client.Pass()); | 136 core()->Connect(std::move(cloud_policy_client)); |
| 136 client()->AddObserver(this); | 137 client()->AddObserver(this); |
| 137 | 138 |
| 138 external_data_manager_->Connect(request_context); | 139 external_data_manager_->Connect(request_context); |
| 139 | 140 |
| 140 // Determine the next step after the CloudPolicyService initializes. | 141 // Determine the next step after the CloudPolicyService initializes. |
| 141 if (service()->IsInitializationComplete()) { | 142 if (service()->IsInitializationComplete()) { |
| 142 OnInitializationCompleted(service()); | 143 OnInitializationCompleted(service()); |
| 143 } else { | 144 } else { |
| 144 service()->AddObserver(this); | 145 service()->AddObserver(this); |
| 145 } | 146 } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 // OnComponentCloudPolicyUpdated() once it's ready. | 418 // OnComponentCloudPolicyUpdated() once it's ready. |
| 418 return; | 419 return; |
| 419 } | 420 } |
| 420 | 421 |
| 421 core()->StartRefreshScheduler(); | 422 core()->StartRefreshScheduler(); |
| 422 core()->TrackRefreshDelayPref(local_state_, | 423 core()->TrackRefreshDelayPref(local_state_, |
| 423 policy_prefs::kUserPolicyRefreshRate); | 424 policy_prefs::kUserPolicyRefreshRate); |
| 424 } | 425 } |
| 425 | 426 |
| 426 } // namespace policy | 427 } // namespace policy |
| OLD | NEW |