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

Side by Side Diff: components/ownership/owner_settings_service.cc

Issue 1921923002: Convert //components/[o-t]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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 "components/ownership/owner_settings_service.h" 5 #include "components/ownership/owner_settings_service.h"
6 6
7 #include <cryptohi.h> 7 #include <cryptohi.h>
8 #include <keyhi.h> 8 #include <keyhi.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/task_runner.h" 16 #include "base/task_runner.h"
17 #include "base/task_runner_util.h" 17 #include "base/task_runner_util.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "components/ownership/owner_key_util.h" 19 #include "components/ownership/owner_key_util.h"
20 #include "crypto/scoped_nss_types.h" 20 #include "crypto/scoped_nss_types.h"
21 21
22 namespace em = enterprise_management; 22 namespace em = enterprise_management;
23 23
24 namespace ownership { 24 namespace ownership {
25 25
26 namespace { 26 namespace {
27 27
28 using ScopedSGNContext = 28 using ScopedSGNContext = std::unique_ptr<
29 scoped_ptr<SGNContext, 29 SGNContext,
30 crypto::NSSDestroyer1<SGNContext, SGN_DestroyContext, PR_TRUE>>; 30 crypto::NSSDestroyer1<SGNContext, SGN_DestroyContext, PR_TRUE>>;
31 31
32 scoped_ptr<em::PolicyFetchResponse> AssembleAndSignPolicy( 32 std::unique_ptr<em::PolicyFetchResponse> AssembleAndSignPolicy(
33 scoped_ptr<em::PolicyData> policy, 33 std::unique_ptr<em::PolicyData> policy,
34 SECKEYPrivateKey* private_key) { 34 SECKEYPrivateKey* private_key) {
35 // Assemble the policy. 35 // Assemble the policy.
36 scoped_ptr<em::PolicyFetchResponse> policy_response( 36 std::unique_ptr<em::PolicyFetchResponse> policy_response(
37 new em::PolicyFetchResponse()); 37 new em::PolicyFetchResponse());
38 if (!policy->SerializeToString(policy_response->mutable_policy_data())) { 38 if (!policy->SerializeToString(policy_response->mutable_policy_data())) {
39 LOG(ERROR) << "Failed to encode policy payload."; 39 LOG(ERROR) << "Failed to encode policy payload.";
40 return scoped_ptr<em::PolicyFetchResponse>(nullptr); 40 return nullptr;
41 } 41 }
42 42
43 ScopedSGNContext sign_context( 43 ScopedSGNContext sign_context(
44 SGN_NewContext(SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION, private_key)); 44 SGN_NewContext(SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION, private_key));
45 if (!sign_context) { 45 if (!sign_context) {
46 NOTREACHED(); 46 NOTREACHED();
47 return nullptr; 47 return nullptr;
48 } 48 }
49 49
50 SECItem signature_item; 50 SECItem signature_item;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (private_key_.get()) { 95 if (private_key_.get()) {
96 base::MessageLoop::current()->PostTask(FROM_HERE, 96 base::MessageLoop::current()->PostTask(FROM_HERE,
97 base::Bind(callback, IsOwner())); 97 base::Bind(callback, IsOwner()));
98 } else { 98 } else {
99 pending_is_owner_callbacks_.push_back(callback); 99 pending_is_owner_callbacks_.push_back(callback);
100 } 100 }
101 } 101 }
102 102
103 bool OwnerSettingsService::AssembleAndSignPolicyAsync( 103 bool OwnerSettingsService::AssembleAndSignPolicyAsync(
104 base::TaskRunner* task_runner, 104 base::TaskRunner* task_runner,
105 scoped_ptr<em::PolicyData> policy, 105 std::unique_ptr<em::PolicyData> policy,
106 const AssembleAndSignPolicyAsyncCallback& callback) { 106 const AssembleAndSignPolicyAsyncCallback& callback) {
107 DCHECK(thread_checker_.CalledOnValidThread()); 107 DCHECK(thread_checker_.CalledOnValidThread());
108 if (!task_runner || !IsOwner()) 108 if (!task_runner || !IsOwner())
109 return false; 109 return false;
110 return base::PostTaskAndReplyWithResult( 110 return base::PostTaskAndReplyWithResult(
111 task_runner, 111 task_runner,
112 FROM_HERE, 112 FROM_HERE,
113 base::Bind( 113 base::Bind(
114 &AssembleAndSignPolicy, base::Passed(&policy), private_key_->key()), 114 &AssembleAndSignPolicy, base::Passed(&policy), private_key_->key()),
115 callback); 115 callback);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 for (std::vector<IsOwnerCallback>::iterator it(is_owner_callbacks.begin()); 159 for (std::vector<IsOwnerCallback>::iterator it(is_owner_callbacks.begin());
160 it != is_owner_callbacks.end(); 160 it != is_owner_callbacks.end();
161 ++it) { 161 ++it) {
162 it->Run(is_owner); 162 it->Run(is_owner);
163 } 163 }
164 164
165 OnPostKeypairLoadedActions(); 165 OnPostKeypairLoadedActions();
166 } 166 }
167 167
168 } // namespace ownership 168 } // namespace ownership
OLDNEW
« no previous file with comments | « components/ownership/owner_settings_service.h ('k') | components/page_load_metrics/browser/metrics_web_contents_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698