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

Side by Side Diff: components/proximity_auth/cryptauth/cryptauth_device_manager.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/proximity_auth/cryptauth/cryptauth_device_manager.h" 5 #include "components/proximity_auth/cryptauth/cryptauth_device_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility>
8 9
9 #include "base/base64url.h" 10 #include "base/base64url.h"
10 #include "base/prefs/pref_registry_simple.h" 11 #include "base/prefs/pref_registry_simple.h"
11 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
12 #include "base/prefs/scoped_user_pref_update.h" 13 #include "base/prefs/scoped_user_pref_update.h"
13 #include "components/proximity_auth/cryptauth/cryptauth_client.h" 14 #include "components/proximity_auth/cryptauth/cryptauth_client.h"
14 #include "components/proximity_auth/cryptauth/pref_names.h" 15 #include "components/proximity_auth/cryptauth/pref_names.h"
15 #include "components/proximity_auth/cryptauth/sync_scheduler_impl.h" 16 #include "components/proximity_auth/cryptauth/sync_scheduler_impl.h"
16 #include "components/proximity_auth/logging/logging.h" 17 #include "components/proximity_auth/logging/logging.h"
17 18
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 base::Base64UrlEncodePolicy::INCLUDE_PADDING, 52 base::Base64UrlEncodePolicy::INCLUDE_PADDING,
52 &device_name_b64); 53 &device_name_b64);
53 base::Base64UrlEncode(device.bluetooth_address(), 54 base::Base64UrlEncode(device.bluetooth_address(),
54 base::Base64UrlEncodePolicy::INCLUDE_PADDING, 55 base::Base64UrlEncodePolicy::INCLUDE_PADDING,
55 &bluetooth_address_b64); 56 &bluetooth_address_b64);
56 57
57 dictionary->SetString(kExternalDeviceKeyPublicKey, public_key_b64); 58 dictionary->SetString(kExternalDeviceKeyPublicKey, public_key_b64);
58 dictionary->SetString(kExternalDeviceKeyDeviceName, device_name_b64); 59 dictionary->SetString(kExternalDeviceKeyDeviceName, device_name_b64);
59 dictionary->SetString(kExternalDeviceKeyBluetoothAddress, 60 dictionary->SetString(kExternalDeviceKeyBluetoothAddress,
60 bluetooth_address_b64); 61 bluetooth_address_b64);
61 return dictionary.Pass(); 62 return dictionary;
62 } 63 }
63 64
64 // Converts an unlock key dictionary stored in user prefs to an 65 // Converts an unlock key dictionary stored in user prefs to an
65 // ExternalDeviceInfo proto. Returns true if the dictionary is valid, and the 66 // ExternalDeviceInfo proto. Returns true if the dictionary is valid, and the
66 // parsed proto is written to |external_device|. 67 // parsed proto is written to |external_device|.
67 bool DictionaryToUnlockKey(const base::DictionaryValue& dictionary, 68 bool DictionaryToUnlockKey(const base::DictionaryValue& dictionary,
68 cryptauth::ExternalDeviceInfo* external_device) { 69 cryptauth::ExternalDeviceInfo* external_device) {
69 std::string public_key_b64, device_name_b64, bluetooth_address_b64; 70 std::string public_key_b64, device_name_b64, bluetooth_address_b64;
70 if (!dictionary.GetString(kExternalDeviceKeyPublicKey, &public_key_b64) || 71 if (!dictionary.GetString(kExternalDeviceKeyPublicKey, &public_key_b64) ||
71 !dictionary.GetString(kExternalDeviceKeyDeviceName, &device_name_b64) || 72 !dictionary.GetString(kExternalDeviceKeyDeviceName, &device_name_b64) ||
(...skipping 25 matching lines...) Expand all
97 return true; 98 return true;
98 } 99 }
99 100
100 } // namespace 101 } // namespace
101 102
102 CryptAuthDeviceManager::CryptAuthDeviceManager( 103 CryptAuthDeviceManager::CryptAuthDeviceManager(
103 scoped_ptr<base::Clock> clock, 104 scoped_ptr<base::Clock> clock,
104 scoped_ptr<CryptAuthClientFactory> client_factory, 105 scoped_ptr<CryptAuthClientFactory> client_factory,
105 CryptAuthGCMManager* gcm_manager, 106 CryptAuthGCMManager* gcm_manager,
106 PrefService* pref_service) 107 PrefService* pref_service)
107 : clock_(clock.Pass()), 108 : clock_(std::move(clock)),
108 client_factory_(client_factory.Pass()), 109 client_factory_(std::move(client_factory)),
109 gcm_manager_(gcm_manager), 110 gcm_manager_(gcm_manager),
110 pref_service_(pref_service), 111 pref_service_(pref_service),
111 weak_ptr_factory_(this) { 112 weak_ptr_factory_(this) {
112 UpdateUnlockKeysFromPrefs(); 113 UpdateUnlockKeysFromPrefs();
113 } 114 }
114 115
115 CryptAuthDeviceManager::~CryptAuthDeviceManager() { 116 CryptAuthDeviceManager::~CryptAuthDeviceManager() {
116 gcm_manager_->RemoveObserver(this); 117 gcm_manager_->RemoveObserver(this);
117 } 118 }
118 119
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 PA_LOG(ERROR) << "Can not get dictionary in list of unlock keys " 260 PA_LOG(ERROR) << "Can not get dictionary in list of unlock keys "
260 << "(index=" << i << "):\n" << *unlock_key_list; 261 << "(index=" << i << "):\n" << *unlock_key_list;
261 } 262 }
262 } 263 }
263 } 264 }
264 265
265 void CryptAuthDeviceManager::OnSyncRequested( 266 void CryptAuthDeviceManager::OnSyncRequested(
266 scoped_ptr<SyncScheduler::SyncRequest> sync_request) { 267 scoped_ptr<SyncScheduler::SyncRequest> sync_request) {
267 FOR_EACH_OBSERVER(Observer, observers_, OnSyncStarted()); 268 FOR_EACH_OBSERVER(Observer, observers_, OnSyncStarted());
268 269
269 sync_request_ = sync_request.Pass(); 270 sync_request_ = std::move(sync_request);
270 cryptauth_client_ = client_factory_->CreateInstance(); 271 cryptauth_client_ = client_factory_->CreateInstance();
271 272
272 cryptauth::InvocationReason invocation_reason = 273 cryptauth::InvocationReason invocation_reason =
273 cryptauth::INVOCATION_REASON_UNKNOWN; 274 cryptauth::INVOCATION_REASON_UNKNOWN;
274 275
275 int reason_stored_in_prefs = 276 int reason_stored_in_prefs =
276 pref_service_->GetInteger(prefs::kCryptAuthDeviceSyncReason); 277 pref_service_->GetInteger(prefs::kCryptAuthDeviceSyncReason);
277 278
278 // If the sync attempt is not forced, it is acceptable for CryptAuth to return 279 // If the sync attempt is not forced, it is acceptable for CryptAuth to return
279 // a cached copy of the user's devices, rather taking a database hit for the 280 // a cached copy of the user's devices, rather taking a database hit for the
(...skipping 17 matching lines...) Expand all
297 request.set_invocation_reason(invocation_reason); 298 request.set_invocation_reason(invocation_reason);
298 request.set_allow_stale_read(is_sync_speculative); 299 request.set_allow_stale_read(is_sync_speculative);
299 cryptauth_client_->GetMyDevices( 300 cryptauth_client_->GetMyDevices(
300 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess, 301 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess,
301 weak_ptr_factory_.GetWeakPtr()), 302 weak_ptr_factory_.GetWeakPtr()),
302 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure, 303 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure,
303 weak_ptr_factory_.GetWeakPtr())); 304 weak_ptr_factory_.GetWeakPtr()));
304 } 305 }
305 306
306 } // namespace proximity_auth 307 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698