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

Side by Side Diff: chrome/browser/sync/util/user_settings.cc

Issue 6873156: Move crypto_helpers from sync to base (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Move crypto_helpers to crypto instead of base. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This class isn't pretty. It's just a step better than globals, which is what 5 // This class isn't pretty. It's just a step better than globals, which is what
6 // these were previously. 6 // these were previously.
7 7
8 #include "chrome/browser/sync/util/user_settings.h" 8 #include "chrome/browser/sync/util/user_settings.h"
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 11
12 #if defined(OS_WIN) 12 #if defined(OS_WIN)
13 #include <windows.h> 13 #include <windows.h>
14 #endif 14 #endif
15 15
16 #include <limits> 16 #include <limits>
17 #include <string> 17 #include <string>
18 #include <vector> 18 #include <vector>
19 19
20 #include "base/file_util.h" 20 #include "base/file_util.h"
21 #include "base/string_util.h" 21 #include "base/string_util.h"
22 #include "chrome/browser/sync/syncable/directory_manager.h" // For migration. 22 #include "chrome/browser/sync/syncable/directory_manager.h" // For migration.
23 #include "chrome/browser/sync/util/crypto_helpers.h"
24 #include "chrome/browser/sync/util/data_encryption.h" 23 #include "chrome/browser/sync/util/data_encryption.h"
25 #include "chrome/common/sqlite_utils.h" 24 #include "chrome/common/sqlite_utils.h"
25 #include "crypto/md5_calculator.h"
26 #include "crypto/random.h"
26 27
27 using std::numeric_limits; 28 using std::numeric_limits;
28 using std::string; 29 using std::string;
29 using std::vector; 30 using std::vector;
30 31
31 using syncable::DirectoryManager; 32 using syncable::DirectoryManager;
32 33
33 namespace browser_sync { 34 namespace browser_sync {
34 35
35 void ExecOrDie(sqlite3* dbhandle, const char *query) { 36 void ExecOrDie(sqlite3* dbhandle, const char *query) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 UserSettings::~UserSettings() { 264 UserSettings::~UserSettings() {
264 if (dbhandle_) 265 if (dbhandle_)
265 sqlite3_close(dbhandle_); 266 sqlite3_close(dbhandle_);
266 } 267 }
267 268
268 const int32 kInvalidHash = 0xFFFFFFFF; 269 const int32 kInvalidHash = 0xFFFFFFFF;
269 270
270 // We use 10 bits of data from the MD5 digest as the hash. 271 // We use 10 bits of data from the MD5 digest as the hash.
271 const int32 kHashMask = 0x3FF; 272 const int32 kHashMask = 0x3FF;
272 273
273 int32 GetHashFromDigest(const vector<uint8>& digest) { 274 int32 GetHashFromDigest(const vector<uint8>& digest) {
agl 2011/04/26 13:59:37 Probably too late to change this now, but this fun
274 int32 hash = 0; 275 int32 hash = 0;
275 int32 mask = kHashMask; 276 int32 mask = kHashMask;
276 for (vector<uint8>::const_iterator i = digest.begin(); i != digest.end(); 277 for (vector<uint8>::const_iterator i = digest.begin(); i != digest.end();
277 ++i) { 278 ++i) {
278 hash = hash << 8; 279 hash = hash << 8;
279 hash = hash | (*i & kHashMask); 280 hash = hash | (*i & kHashMask);
280 mask = mask >> 8; 281 mask = mask >> 8;
281 if (0 == mask) 282 if (0 == mask)
282 break; 283 break;
283 } 284 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 query.prepare(dbhandle.get(), "SELECT email FROM cookies"); 449 query.prepare(dbhandle.get(), "SELECT email FROM cookies");
449 if (SQLITE_ROW == query.step()) { 450 if (SQLITE_ROW == query.step()) {
450 *username = query.column_string(0); 451 *username = query.column_string(0);
451 return true; 452 return true;
452 } else { 453 } else {
453 return false; 454 return false;
454 } 455 }
455 } 456 }
456 457
457 } // namespace browser_sync 458 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698