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

Side by Side Diff: sync/util/cryptographer.cc

Issue 1539843002: Convert Pass()→std::move() in sync/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/util/cryptographer.h" 5 #include "sync/util/cryptographer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "base/base64.h" 10 #include "base/base64.h"
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "sync/protocol/nigori_specifics.pb.h" 13 #include "sync/protocol/nigori_specifics.pb.h"
13 #include "sync/util/encryptor.h" 14 #include "sync/util/encryptor.h"
14 15
15 namespace syncer { 16 namespace syncer {
16 17
17 const char kNigoriTag[] = "google_chrome_nigori"; 18 const char kNigoriTag[] = "google_chrome_nigori";
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 bool Cryptographer::AddKey(const KeyParams& params) { 165 bool Cryptographer::AddKey(const KeyParams& params) {
165 // Create the new Nigori and make it the default encryptor. 166 // Create the new Nigori and make it the default encryptor.
166 scoped_ptr<Nigori> nigori(new Nigori); 167 scoped_ptr<Nigori> nigori(new Nigori);
167 if (!nigori->InitByDerivation(params.hostname, 168 if (!nigori->InitByDerivation(params.hostname,
168 params.username, 169 params.username,
169 params.password)) { 170 params.password)) {
170 NOTREACHED(); // Invalid username or password. 171 NOTREACHED(); // Invalid username or password.
171 return false; 172 return false;
172 } 173 }
173 return AddKeyImpl(nigori.Pass(), true); 174 return AddKeyImpl(std::move(nigori), true);
174 } 175 }
175 176
176 bool Cryptographer::AddNonDefaultKey(const KeyParams& params) { 177 bool Cryptographer::AddNonDefaultKey(const KeyParams& params) {
177 DCHECK(is_initialized()); 178 DCHECK(is_initialized());
178 // Create the new Nigori and add it to the keybag. 179 // Create the new Nigori and add it to the keybag.
179 scoped_ptr<Nigori> nigori(new Nigori); 180 scoped_ptr<Nigori> nigori(new Nigori);
180 if (!nigori->InitByDerivation(params.hostname, 181 if (!nigori->InitByDerivation(params.hostname,
181 params.username, 182 params.username,
182 params.password)) { 183 params.password)) {
183 NOTREACHED(); // Invalid username or password. 184 NOTREACHED(); // Invalid username or password.
184 return false; 185 return false;
185 } 186 }
186 return AddKeyImpl(nigori.Pass(), false); 187 return AddKeyImpl(std::move(nigori), false);
187 } 188 }
188 189
189 bool Cryptographer::AddKeyFromBootstrapToken( 190 bool Cryptographer::AddKeyFromBootstrapToken(
190 const std::string& restored_bootstrap_token) { 191 const std::string& restored_bootstrap_token) {
191 // Create the new Nigori and make it the default encryptor. 192 // Create the new Nigori and make it the default encryptor.
192 std::string serialized_nigori_key = UnpackBootstrapToken( 193 std::string serialized_nigori_key = UnpackBootstrapToken(
193 restored_bootstrap_token); 194 restored_bootstrap_token);
194 return ImportNigoriKey(serialized_nigori_key); 195 return ImportNigoriKey(serialized_nigori_key);
195 } 196 }
196 197
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if (!key.ParseFromString(serialized_nigori_key)) 370 if (!key.ParseFromString(serialized_nigori_key))
370 return false; 371 return false;
371 372
372 scoped_ptr<Nigori> nigori(new Nigori); 373 scoped_ptr<Nigori> nigori(new Nigori);
373 if (!nigori->InitByImport(key.user_key(), key.encryption_key(), 374 if (!nigori->InitByImport(key.user_key(), key.encryption_key(),
374 key.mac_key())) { 375 key.mac_key())) {
375 NOTREACHED(); 376 NOTREACHED();
376 return false; 377 return false;
377 } 378 }
378 379
379 if (!AddKeyImpl(nigori.Pass(), true)) 380 if (!AddKeyImpl(std::move(nigori), true))
380 return false; 381 return false;
381 return true; 382 return true;
382 } 383 }
383 384
384 } // namespace syncer 385 } // namespace syncer
OLDNEW
« sync/internal_api/model_type_store_impl_unittest.cc ('K') | « sync/tools/sync_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698