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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_initializer.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iwyu fixes Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/device_cloud_policy_initializer.h" 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 17 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
17 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" 18 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
18 #include "chrome/browser/chromeos/policy/device_status_collector.h" 19 #include "chrome/browser/chromeos/policy/device_status_collector.h"
19 #include "chrome/browser/chromeos/policy/enrollment_config.h" 20 #include "chrome/browser/chromeos/policy/enrollment_config.h"
20 #include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.h" 21 #include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.h"
21 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" 22 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
22 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" 23 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 TryToCreateClient(); 203 TryToCreateClient();
203 } 204 }
204 205
205 void DeviceCloudPolicyInitializer::OnStoreError(CloudPolicyStore* store) { 206 void DeviceCloudPolicyInitializer::OnStoreError(CloudPolicyStore* store) {
206 // Do nothing. 207 // Do nothing.
207 } 208 }
208 209
209 void DeviceCloudPolicyInitializer::EnrollmentCompleted( 210 void DeviceCloudPolicyInitializer::EnrollmentCompleted(
210 const EnrollmentCallback& enrollment_callback, 211 const EnrollmentCallback& enrollment_callback,
211 EnrollmentStatus status) { 212 EnrollmentStatus status) {
212 scoped_ptr<CloudPolicyClient> client = enrollment_handler_->ReleaseClient(); 213 std::unique_ptr<CloudPolicyClient> client =
214 enrollment_handler_->ReleaseClient();
213 enrollment_handler_.reset(); 215 enrollment_handler_.reset();
214 216
215 if (status.status() == EnrollmentStatus::STATUS_SUCCESS) { 217 if (status.status() == EnrollmentStatus::STATUS_SUCCESS) {
216 StartConnection(std::move(client)); 218 StartConnection(std::move(client));
217 } else { 219 } else {
218 // Some attempts to create a client may be blocked because the enrollment 220 // Some attempts to create a client may be blocked because the enrollment
219 // was in progress. We give it a try again. 221 // was in progress. We give it a try again.
220 TryToCreateClient(); 222 TryToCreateClient();
221 } 223 }
222 224
223 if (!enrollment_callback.is_null()) 225 if (!enrollment_callback.is_null())
224 enrollment_callback.Run(status); 226 enrollment_callback.Run(status);
225 } 227 }
226 228
227 scoped_ptr<CloudPolicyClient> DeviceCloudPolicyInitializer::CreateClient( 229 std::unique_ptr<CloudPolicyClient> DeviceCloudPolicyInitializer::CreateClient(
228 DeviceManagementService* device_management_service) { 230 DeviceManagementService* device_management_service) {
229 scoped_refptr<net::URLRequestContextGetter> request_context = 231 scoped_refptr<net::URLRequestContextGetter> request_context =
230 new SystemPolicyRequestContext( 232 new SystemPolicyRequestContext(
231 g_browser_process->system_request_context(), GetUserAgent()); 233 g_browser_process->system_request_context(), GetUserAgent());
232 234
233 return make_scoped_ptr( 235 return base::WrapUnique(new CloudPolicyClient(
234 new CloudPolicyClient(DeviceCloudPolicyManagerChromeOS::GetMachineID(), 236 DeviceCloudPolicyManagerChromeOS::GetMachineID(),
235 DeviceCloudPolicyManagerChromeOS::GetMachineModel(), 237 DeviceCloudPolicyManagerChromeOS::GetMachineModel(),
236 kPolicyVerificationKeyHash, 238 kPolicyVerificationKeyHash, device_management_service, request_context));
237 device_management_service,
238 request_context));
239 } 239 }
240 240
241 void DeviceCloudPolicyInitializer::TryToCreateClient() { 241 void DeviceCloudPolicyInitializer::TryToCreateClient() {
242 if (!device_store_->is_initialized() || 242 if (!device_store_->is_initialized() ||
243 !device_store_->has_policy() || 243 !device_store_->has_policy() ||
244 state_keys_broker_->pending() || 244 state_keys_broker_->pending() ||
245 enrollment_handler_) { 245 enrollment_handler_) {
246 return; 246 return;
247 } 247 }
248 248
249 DeviceManagementService* service = nullptr; 249 DeviceManagementService* service = nullptr;
250 if (GetManagementMode(*device_store_->policy()) == 250 if (GetManagementMode(*device_store_->policy()) ==
251 MANAGEMENT_MODE_CONSUMER_MANAGED) { 251 MANAGEMENT_MODE_CONSUMER_MANAGED) {
252 service = consumer_service_; 252 service = consumer_service_;
253 } else if (GetManagementMode(*device_store_->policy()) == 253 } else if (GetManagementMode(*device_store_->policy()) ==
254 MANAGEMENT_MODE_ENTERPRISE_MANAGED) { 254 MANAGEMENT_MODE_ENTERPRISE_MANAGED) {
255 service = enterprise_service_; 255 service = enterprise_service_;
256 } 256 }
257 257
258 if (service) 258 if (service)
259 StartConnection(CreateClient(service)); 259 StartConnection(CreateClient(service));
260 } 260 }
261 261
262 void DeviceCloudPolicyInitializer::StartConnection( 262 void DeviceCloudPolicyInitializer::StartConnection(
263 scoped_ptr<CloudPolicyClient> client) { 263 std::unique_ptr<CloudPolicyClient> client) {
264 if (!manager_->core()->service()) 264 if (!manager_->core()->service())
265 manager_->StartConnection(std::move(client), install_attributes_); 265 manager_->StartConnection(std::move(client), install_attributes_);
266 } 266 }
267 267
268 } // namespace policy 268 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698