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

Side by Side Diff: chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.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: rebase 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/login/easy_unlock/easy_unlock_key_manager.h" 5 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
6 6
7 #include <memory>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/ptr_util.h"
10 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
11 #include "base/values.h" 13 #include "base/values.h"
12 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h" 14 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h"
13 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h" 15 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h"
14 #include "components/proximity_auth/logging/logging.h" 16 #include "components/proximity_auth/logging/logging.h"
15 #include "components/signin/core/account_id/account_id.h" 17 #include "components/signin/core/account_id/account_id.h"
16 18
17 namespace chromeos { 19 namespace chromeos {
18 20
19 namespace { 21 namespace {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 111 }
110 112
111 // static 113 // static
112 void EasyUnlockKeyManager::DeviceDataToRemoteDeviceDictionary( 114 void EasyUnlockKeyManager::DeviceDataToRemoteDeviceDictionary(
113 const AccountId& account_id, 115 const AccountId& account_id,
114 const EasyUnlockDeviceKeyData& data, 116 const EasyUnlockDeviceKeyData& data,
115 base::DictionaryValue* dict) { 117 base::DictionaryValue* dict) {
116 dict->SetString(kKeyBluetoothAddress, data.bluetooth_address); 118 dict->SetString(kKeyBluetoothAddress, data.bluetooth_address);
117 dict->SetInteger(kKeyBluetoothType, static_cast<int>(data.bluetooth_type)); 119 dict->SetInteger(kKeyBluetoothType, static_cast<int>(data.bluetooth_type));
118 dict->SetString(kKeyPsk, data.psk); 120 dict->SetString(kKeyPsk, data.psk);
119 scoped_ptr<base::DictionaryValue> permit_record(new base::DictionaryValue); 121 std::unique_ptr<base::DictionaryValue> permit_record(
122 new base::DictionaryValue);
120 dict->Set(kKeyPermitRecord, permit_record.release()); 123 dict->Set(kKeyPermitRecord, permit_record.release());
121 dict->SetString(kKeyPermitId, data.public_key); 124 dict->SetString(kKeyPermitId, data.public_key);
122 dict->SetString(kKeyPermitData, data.public_key); 125 dict->SetString(kKeyPermitData, data.public_key);
123 dict->SetString(kKeyPermitType, kPermitTypeLicence); 126 dict->SetString(kKeyPermitType, kPermitTypeLicence);
124 dict->SetString(kKeyPermitPermitId, 127 dict->SetString(kKeyPermitPermitId,
125 base::StringPrintf(kPermitPermitIdFormat, 128 base::StringPrintf(kPermitPermitIdFormat,
126 account_id.GetUserEmail().c_str())); 129 account_id.GetUserEmail().c_str()));
127 } 130 }
128 131
129 // static 132 // static
(...skipping 29 matching lines...) Expand all
159 return true; 162 return true;
160 } 163 }
161 164
162 // static 165 // static
163 void EasyUnlockKeyManager::DeviceDataListToRemoteDeviceList( 166 void EasyUnlockKeyManager::DeviceDataListToRemoteDeviceList(
164 const AccountId& account_id, 167 const AccountId& account_id,
165 const EasyUnlockDeviceKeyDataList& data_list, 168 const EasyUnlockDeviceKeyDataList& data_list,
166 base::ListValue* device_list) { 169 base::ListValue* device_list) {
167 device_list->Clear(); 170 device_list->Clear();
168 for (size_t i = 0; i < data_list.size(); ++i) { 171 for (size_t i = 0; i < data_list.size(); ++i) {
169 scoped_ptr<base::DictionaryValue> device_dict(new base::DictionaryValue); 172 std::unique_ptr<base::DictionaryValue> device_dict(
173 new base::DictionaryValue);
170 DeviceDataToRemoteDeviceDictionary(account_id, data_list[i], 174 DeviceDataToRemoteDeviceDictionary(account_id, data_list[i],
171 device_dict.get()); 175 device_dict.get());
172 device_list->Append(device_dict.release()); 176 device_list->Append(device_dict.release());
173 } 177 }
174 } 178 }
175 179
176 // static 180 // static
177 bool EasyUnlockKeyManager::RemoteDeviceListToDeviceDataList( 181 bool EasyUnlockKeyManager::RemoteDeviceListToDeviceDataList(
178 const base::ListValue& device_list, 182 const base::ListValue& device_list,
179 EasyUnlockDeviceKeyDataList* data_list) { 183 EasyUnlockDeviceKeyDataList* data_list) {
(...skipping 19 matching lines...) Expand all
199 // static 203 // static
200 std::string EasyUnlockKeyManager::GetKeyLabel(size_t key_index) { 204 std::string EasyUnlockKeyManager::GetKeyLabel(size_t key_index) {
201 return base::StringPrintf("%s%zu", kKeyLabelPrefix, key_index); 205 return base::StringPrintf("%s%zu", kKeyLabelPrefix, key_index);
202 } 206 }
203 207
204 void EasyUnlockKeyManager::RunNextOperation() { 208 void EasyUnlockKeyManager::RunNextOperation() {
205 if (pending_write_operation_ || pending_read_operation_) 209 if (pending_write_operation_ || pending_read_operation_)
206 return; 210 return;
207 211
208 if (!write_operation_queue_.empty()) { 212 if (!write_operation_queue_.empty()) {
209 pending_write_operation_ = make_scoped_ptr(write_operation_queue_.front()); 213 pending_write_operation_ = base::WrapUnique(write_operation_queue_.front());
210 write_operation_queue_.pop_front(); 214 write_operation_queue_.pop_front();
211 pending_write_operation_->Start(); 215 pending_write_operation_->Start();
212 } else if (!read_operation_queue_.empty()) { 216 } else if (!read_operation_queue_.empty()) {
213 pending_read_operation_ = make_scoped_ptr(read_operation_queue_.front()); 217 pending_read_operation_ = base::WrapUnique(read_operation_queue_.front());
214 read_operation_queue_.pop_front(); 218 read_operation_queue_.pop_front();
215 pending_read_operation_->Start(); 219 pending_read_operation_->Start();
216 } 220 }
217 } 221 }
218 222
219 void EasyUnlockKeyManager::OnKeysRefreshed(const RefreshKeysCallback& callback, 223 void EasyUnlockKeyManager::OnKeysRefreshed(const RefreshKeysCallback& callback,
220 bool refresh_success) { 224 bool refresh_success) {
221 if (!callback.is_null()) 225 if (!callback.is_null())
222 callback.Run(refresh_success); 226 callback.Run(refresh_success);
223 227
224 DCHECK(pending_write_operation_); 228 DCHECK(pending_write_operation_);
225 pending_write_operation_.reset(); 229 pending_write_operation_.reset();
226 RunNextOperation(); 230 RunNextOperation();
227 } 231 }
228 232
229 void EasyUnlockKeyManager::OnKeysFetched( 233 void EasyUnlockKeyManager::OnKeysFetched(
230 const GetDeviceDataListCallback& callback, 234 const GetDeviceDataListCallback& callback,
231 bool fetch_success, 235 bool fetch_success,
232 const EasyUnlockDeviceKeyDataList& fetched_data) { 236 const EasyUnlockDeviceKeyDataList& fetched_data) {
233 if (!callback.is_null()) 237 if (!callback.is_null())
234 callback.Run(fetch_success, fetched_data); 238 callback.Run(fetch_success, fetched_data);
235 239
236 DCHECK(pending_read_operation_); 240 DCHECK(pending_read_operation_);
237 pending_read_operation_.reset(); 241 pending_read_operation_.reset();
238 RunNextOperation(); 242 RunNextOperation();
239 } 243 }
240 244
241 } // namespace chromeos 245 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698