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

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: Cleaned up 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
« no previous file with comments | « sync/tools/sync_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8
9 #include <algorithm> 8 #include <algorithm>
9 #include <utility>
10 10
11 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "sync/protocol/nigori_specifics.pb.h" 13 #include "sync/protocol/nigori_specifics.pb.h"
14 #include "sync/util/encryptor.h" 14 #include "sync/util/encryptor.h"
15 15
16 namespace syncer { 16 namespace syncer {
17 17
18 const char kNigoriTag[] = "google_chrome_nigori"; 18 const char kNigoriTag[] = "google_chrome_nigori";
19 19
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 bool Cryptographer::AddKey(const KeyParams& params) { 165 bool Cryptographer::AddKey(const KeyParams& params) {
166 // Create the new Nigori and make it the default encryptor. 166 // Create the new Nigori and make it the default encryptor.
167 scoped_ptr<Nigori> nigori(new Nigori); 167 scoped_ptr<Nigori> nigori(new Nigori);
168 if (!nigori->InitByDerivation(params.hostname, 168 if (!nigori->InitByDerivation(params.hostname,
169 params.username, 169 params.username,
170 params.password)) { 170 params.password)) {
171 NOTREACHED(); // Invalid username or password. 171 NOTREACHED(); // Invalid username or password.
172 return false; 172 return false;
173 } 173 }
174 return AddKeyImpl(nigori.Pass(), true); 174 return AddKeyImpl(std::move(nigori), true);
175 } 175 }
176 176
177 bool Cryptographer::AddNonDefaultKey(const KeyParams& params) { 177 bool Cryptographer::AddNonDefaultKey(const KeyParams& params) {
178 DCHECK(is_initialized()); 178 DCHECK(is_initialized());
179 // Create the new Nigori and add it to the keybag. 179 // Create the new Nigori and add it to the keybag.
180 scoped_ptr<Nigori> nigori(new Nigori); 180 scoped_ptr<Nigori> nigori(new Nigori);
181 if (!nigori->InitByDerivation(params.hostname, 181 if (!nigori->InitByDerivation(params.hostname,
182 params.username, 182 params.username,
183 params.password)) { 183 params.password)) {
184 NOTREACHED(); // Invalid username or password. 184 NOTREACHED(); // Invalid username or password.
185 return false; 185 return false;
186 } 186 }
187 return AddKeyImpl(nigori.Pass(), false); 187 return AddKeyImpl(std::move(nigori), false);
188 } 188 }
189 189
190 bool Cryptographer::AddKeyFromBootstrapToken( 190 bool Cryptographer::AddKeyFromBootstrapToken(
191 const std::string& restored_bootstrap_token) { 191 const std::string& restored_bootstrap_token) {
192 // Create the new Nigori and make it the default encryptor. 192 // Create the new Nigori and make it the default encryptor.
193 std::string serialized_nigori_key = UnpackBootstrapToken( 193 std::string serialized_nigori_key = UnpackBootstrapToken(
194 restored_bootstrap_token); 194 restored_bootstrap_token);
195 return ImportNigoriKey(serialized_nigori_key); 195 return ImportNigoriKey(serialized_nigori_key);
196 } 196 }
197 197
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 if (!key.ParseFromString(serialized_nigori_key)) 370 if (!key.ParseFromString(serialized_nigori_key))
371 return false; 371 return false;
372 372
373 scoped_ptr<Nigori> nigori(new Nigori); 373 scoped_ptr<Nigori> nigori(new Nigori);
374 if (!nigori->InitByImport(key.user_key(), key.encryption_key(), 374 if (!nigori->InitByImport(key.user_key(), key.encryption_key(),
375 key.mac_key())) { 375 key.mac_key())) {
376 NOTREACHED(); 376 NOTREACHED();
377 return false; 377 return false;
378 } 378 }
379 379
380 if (!AddKeyImpl(nigori.Pass(), true)) 380 if (!AddKeyImpl(std::move(nigori), true))
381 return false; 381 return false;
382 return true; 382 return true;
383 } 383 }
384 384
385 } // namespace syncer 385 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/tools/sync_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698