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

Side by Side Diff: components/policy/core/common/cloud/policy_header_service.cc

Issue 1902633006: Convert //components/policy from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and use namespace alias 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/policy/core/common/cloud/policy_header_service.h" 5 #include "components/policy/core/common/cloud/policy_header_service.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/memory/ptr_util.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "components/policy/core/common/cloud/cloud_policy_store.h" 11 #include "components/policy/core/common/cloud/cloud_policy_store.h"
11 #include "components/policy/core/common/cloud/policy_header_io_helper.h" 12 #include "components/policy/core/common/cloud/policy_header_io_helper.h"
12 13
13 namespace { 14 namespace {
14 const char kUserDMTokenKey[] = "user_dmtoken"; 15 const char kUserDMTokenKey[] = "user_dmtoken";
15 const char kUserPolicyTokenKey[] = "user_policy_token"; 16 const char kUserPolicyTokenKey[] = "user_policy_token";
16 const char kVerificationKeyHashKey[] = "verification_key_id"; 17 const char kVerificationKeyHashKey[] = "verification_key_id";
17 } 18 }
18 19
(...skipping 12 matching lines...) Expand all
31 if (device_policy_store_) 32 if (device_policy_store_)
32 device_policy_store_->AddObserver(this); 33 device_policy_store_->AddObserver(this);
33 } 34 }
34 35
35 PolicyHeaderService::~PolicyHeaderService() { 36 PolicyHeaderService::~PolicyHeaderService() {
36 user_policy_store_->RemoveObserver(this); 37 user_policy_store_->RemoveObserver(this);
37 if (device_policy_store_) 38 if (device_policy_store_)
38 device_policy_store_->RemoveObserver(this); 39 device_policy_store_->RemoveObserver(this);
39 } 40 }
40 41
41 scoped_ptr<PolicyHeaderIOHelper> 42 std::unique_ptr<PolicyHeaderIOHelper>
42 PolicyHeaderService::CreatePolicyHeaderIOHelper( 43 PolicyHeaderService::CreatePolicyHeaderIOHelper(
43 scoped_refptr<base::SequencedTaskRunner> task_runner) { 44 scoped_refptr<base::SequencedTaskRunner> task_runner) {
44 std::string initial_header_value = CreateHeaderValue(); 45 std::string initial_header_value = CreateHeaderValue();
45 scoped_ptr<PolicyHeaderIOHelper> helper = make_scoped_ptr( 46 std::unique_ptr<PolicyHeaderIOHelper> helper = base::WrapUnique(
46 new PolicyHeaderIOHelper(server_url_, initial_header_value, task_runner)); 47 new PolicyHeaderIOHelper(server_url_, initial_header_value, task_runner));
47 helpers_.push_back(helper.get()); 48 helpers_.push_back(helper.get());
48 return helper; 49 return helper;
49 } 50 }
50 51
51 std::string PolicyHeaderService::CreateHeaderValue() { 52 std::string PolicyHeaderService::CreateHeaderValue() {
52 // If we have no user policy or no token, return an empty header. 53 // If we have no user policy or no token, return an empty header.
53 if (!user_policy_store_->has_policy() || 54 if (!user_policy_store_->has_policy() ||
54 !user_policy_store_->policy()->has_request_token()) { 55 !user_policy_store_->policy()->has_request_token()) {
55 return ""; 56 return "";
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 97
97 void PolicyHeaderService::OnStoreError(CloudPolicyStore* store) { 98 void PolicyHeaderService::OnStoreError(CloudPolicyStore* store) {
98 // Do nothing on errors. 99 // Do nothing on errors.
99 } 100 }
100 101
101 std::vector<PolicyHeaderIOHelper*> PolicyHeaderService::GetHelpersForTest() { 102 std::vector<PolicyHeaderIOHelper*> PolicyHeaderService::GetHelpersForTest() {
102 return helpers_; 103 return helpers_;
103 } 104 }
104 105
105 } // namespace policy 106 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698