Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/syncable/directory_backing_store.h" | 5 #include "sync/syncable/directory_backing_store.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/hash_tables.h" | 14 #include "base/hash_tables.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
| 18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
| 21 #include "base/time.h" | 21 #include "base/time.h" |
| 22 #include "sql/connection.h" | 22 #include "sql/connection.h" |
| 23 #include "sql/statement.h" | 23 #include "sql/statement.h" |
| 24 #include "sql/transaction.h" | 24 #include "sql/transaction.h" |
| 25 #include "sync/base/sync_export.h" | |
| 25 #include "sync/internal_api/public/base/node_ordinal.h" | 26 #include "sync/internal_api/public/base/node_ordinal.h" |
| 26 #include "sync/protocol/bookmark_specifics.pb.h" | 27 #include "sync/protocol/bookmark_specifics.pb.h" |
| 27 #include "sync/protocol/sync.pb.h" | 28 #include "sync/protocol/sync.pb.h" |
| 28 #include "sync/syncable/syncable-inl.h" | 29 #include "sync/syncable/syncable-inl.h" |
| 29 #include "sync/syncable/syncable_columns.h" | 30 #include "sync/syncable/syncable_columns.h" |
| 30 #include "sync/util/time.h" | 31 #include "sync/util/time.h" |
| 31 | 32 |
| 32 using std::string; | 33 using std::string; |
| 33 | 34 |
| 34 namespace syncer { | 35 namespace syncer { |
| 35 namespace syncable { | 36 namespace syncable { |
| 36 | 37 |
| 37 // This just has to be big enough to hold an UPDATE or INSERT statement that | 38 // This just has to be big enough to hold an UPDATE or INSERT statement that |
| 38 // modifies all the columns in the entry table. | 39 // modifies all the columns in the entry table. |
| 39 static const string::size_type kUpdateStatementBufferSize = 2048; | 40 static const string::size_type kUpdateStatementBufferSize = 2048; |
| 40 | 41 |
| 42 // Global visibility for our unittest. | |
| 43 SYNC_EXPORT_PRIVATE extern const int32 kCurrentDBVersion; | |
|
rlarocque
2012/12/22 02:00:49
There should be no need for extern declarations in
Raghu Simha
2012/12/22 02:25:02
Done.
| |
| 44 | |
| 41 // Increment this version whenever updating DB tables. | 45 // Increment this version whenever updating DB tables. |
| 42 extern const int32 kCurrentDBVersion; // Global visibility for our unittest. | |
| 43 const int32 kCurrentDBVersion = 85; | 46 const int32 kCurrentDBVersion = 85; |
| 44 | 47 |
| 45 // Iterate over the fields of |entry| and bind each to |statement| for | 48 // Iterate over the fields of |entry| and bind each to |statement| for |
| 46 // updating. Returns the number of args bound. | 49 // updating. Returns the number of args bound. |
| 47 void BindFields(const EntryKernel& entry, | 50 void BindFields(const EntryKernel& entry, |
| 48 sql::Statement* statement) { | 51 sql::Statement* statement) { |
| 49 int index = 0; | 52 int index = 0; |
| 50 int i = 0; | 53 int i = 0; |
| 51 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { | 54 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { |
| 52 statement->BindInt64(index++, entry.ref(static_cast<Int64Field>(i))); | 55 statement->BindInt64(index++, entry.ref(static_cast<Int64Field>(i))); |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1310 bool prev_exists = (ids_set.find(entry->ref(PREV_ID).value()) != end); | 1313 bool prev_exists = (ids_set.find(entry->ref(PREV_ID).value()) != end); |
| 1311 bool parent_exists = (ids_set.find(entry->ref(PARENT_ID).value()) != end); | 1314 bool parent_exists = (ids_set.find(entry->ref(PARENT_ID).value()) != end); |
| 1312 bool next_exists = (ids_set.find(entry->ref(NEXT_ID).value()) != end); | 1315 bool next_exists = (ids_set.find(entry->ref(NEXT_ID).value()) != end); |
| 1313 is_ok = is_ok && prev_exists && parent_exists && next_exists; | 1316 is_ok = is_ok && prev_exists && parent_exists && next_exists; |
| 1314 } | 1317 } |
| 1315 return is_ok; | 1318 return is_ok; |
| 1316 } | 1319 } |
| 1317 | 1320 |
| 1318 } // namespace syncable | 1321 } // namespace syncable |
| 1319 } // namespace syncer | 1322 } // namespace syncer |
| OLD | NEW |