OLD | NEW |
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 #include "chrome/browser/sync/syncable/directory_backing_store.h" | 5 #include "chrome/browser/sync/syncable/directory_backing_store.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_MACOSX) | 9 #if defined(OS_MACOSX) |
10 #include <CoreFoundation/CoreFoundation.h> | 10 #include <CoreFoundation/CoreFoundation.h> |
11 #endif | 11 #endif |
12 | 12 |
13 #include <limits> | 13 #include <limits> |
14 | 14 |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/hash_tables.h" | 16 #include "base/hash_tables.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/stl_util-inl.h" | 19 #include "base/stl_util-inl.h" |
20 #include "base/string_number_conversions.h" | 20 #include "base/string_number_conversions.h" |
21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
22 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 22 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
23 #include "chrome/browser/sync/protocol/service_constants.h" | 23 #include "chrome/browser/sync/protocol/service_constants.h" |
24 #include "chrome/browser/sync/protocol/sync.pb.h" | 24 #include "chrome/browser/sync/protocol/sync.pb.h" |
25 #include "chrome/browser/sync/syncable/syncable-inl.h" | 25 #include "chrome/browser/sync/syncable/syncable-inl.h" |
26 #include "chrome/browser/sync/syncable/syncable_columns.h" | 26 #include "chrome/browser/sync/syncable/syncable_columns.h" |
27 #include "chrome/browser/sync/util/crypto_helpers.h" | 27 #include "chrome/common/random.h" |
28 #include "chrome/common/sqlite_utils.h" | 28 #include "chrome/common/sqlite_utils.h" |
29 #include "third_party/sqlite/sqlite3.h" | 29 #include "third_party/sqlite/sqlite3.h" |
30 | 30 |
31 // Sometimes threads contend on the DB lock itself, especially when one thread | 31 // Sometimes threads contend on the DB lock itself, especially when one thread |
32 // is calling SaveChanges. In the worst case scenario, the user can put his | 32 // is calling SaveChanges. In the worst case scenario, the user can put his |
33 // laptop to sleep during db contention, and wake up the laptop days later, so | 33 // laptop to sleep during db contention, and wake up the laptop days later, so |
34 // infinity seems like the best choice here. | 34 // infinity seems like the best choice here. |
35 const int kDirectoryBackingStoreBusyTimeoutMs = std::numeric_limits<int>::max(); | 35 const int kDirectoryBackingStoreBusyTimeoutMs = std::numeric_limits<int>::max(); |
36 | 36 |
37 using std::string; | 37 using std::string; |
(...skipping 16 matching lines...) Expand all Loading... |
54 if (SQLITE_OK != result) | 54 if (SQLITE_OK != result) |
55 return result; | 55 return result; |
56 do { | 56 do { |
57 result = statement.step(); | 57 result = statement.step(); |
58 } while (SQLITE_ROW == result); | 58 } while (SQLITE_ROW == result); |
59 | 59 |
60 return result; | 60 return result; |
61 } | 61 } |
62 | 62 |
63 string GenerateCacheGUID() { | 63 string GenerateCacheGUID() { |
64 return Generate128BitRandomHexString(); | 64 return Generate128BitRandomBase64String(); |
65 } | 65 } |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 | 69 |
70 // Iterate over the fields of |entry| and bind each to |statement| for | 70 // Iterate over the fields of |entry| and bind each to |statement| for |
71 // updating. Returns the number of args bound. | 71 // updating. Returns the number of args bound. |
72 int BindFields(const EntryKernel& entry, SQLStatement* statement) { | 72 int BindFields(const EntryKernel& entry, SQLStatement* statement) { |
73 int index = 0; | 73 int index = 0; |
74 int i = 0; | 74 int i = 0; |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 "id TEXT primary key, " | 1237 "id TEXT primary key, " |
1238 "name TEXT, " | 1238 "name TEXT, " |
1239 "store_birthday TEXT, " | 1239 "store_birthday TEXT, " |
1240 "db_create_version TEXT, " | 1240 "db_create_version TEXT, " |
1241 "db_create_time INT, " | 1241 "db_create_time INT, " |
1242 "next_id INT default -2, " | 1242 "next_id INT default -2, " |
1243 "cache_guid TEXT )"); | 1243 "cache_guid TEXT )"); |
1244 return ExecQuery(load_dbhandle_, query.c_str()); | 1244 return ExecQuery(load_dbhandle_, query.c_str()); |
1245 } | 1245 } |
1246 } // namespace syncable | 1246 } // namespace syncable |
OLD | NEW |