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

Unified Diff: chrome/browser/sync/syncable/directory_backing_store.cc

Issue 7977034: Revert 102184 - [Sync] use base::Time in sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/syncable/directory_backing_store.cc
===================================================================
--- chrome/browser/sync/syncable/directory_backing_store.cc (revision 102184)
+++ chrome/browser/sync/syncable/directory_backing_store.cc (working copy)
@@ -6,6 +6,10 @@
#include "build/build_config.h"
+#if defined(OS_MACOSX)
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
#include <limits>
#include "base/file_util.h"
@@ -15,14 +19,12 @@
#include "base/stl_util.h"
#include "base/string_number_conversions.h"
#include "base/stringprintf.h"
-#include "base/time.h"
#include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
#include "chrome/browser/sync/protocol/service_constants.h"
#include "chrome/browser/sync/protocol/sync.pb.h"
#include "chrome/browser/sync/syncable/syncable-inl.h"
#include "chrome/browser/sync/syncable/syncable_columns.h"
#include "chrome/browser/sync/util/sqlite_utils.h"
-#include "chrome/browser/sync/util/time.h"
#include "chrome/common/random.h"
#include "third_party/sqlite/sqlite3.h"
@@ -42,7 +44,7 @@
// Increment this version whenever updating DB tables.
extern const int32 kCurrentDBVersion; // Global visibility for our unittest.
-const int32 kCurrentDBVersion = 77;
+const int32 kCurrentDBVersion = 76;
namespace {
@@ -74,11 +76,6 @@
for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) {
statement->bind_int64(index++, entry.ref(static_cast<Int64Field>(i)));
}
- for ( ; i < TIME_FIELDS_END; ++i) {
- statement->bind_int64(index++,
- browser_sync::TimeToProtoTime(
- entry.ref(static_cast<TimeField>(i))));
- }
for ( ; i < ID_FIELDS_END; ++i) {
statement->bind_string(index++, entry.ref(static_cast<IdField>(i)).s_);
}
@@ -100,18 +97,14 @@
int UnpackEntry(sqlite_utils::SQLStatement* statement, EntryKernel** kernel) {
*kernel = NULL;
int query_result = statement->step();
- if (query_result == SQLITE_ROW) {
- *kernel = new EntryKernel();
- DCHECK_EQ(statement->column_count(), static_cast<int>(FIELD_COUNT));
+ if (SQLITE_ROW == query_result) {
+ *kernel = new EntryKernel;
+ (*kernel)->clear_dirty(NULL);
+ DCHECK(statement->column_count() == static_cast<int>(FIELD_COUNT));
int i = 0;
for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) {
(*kernel)->put(static_cast<Int64Field>(i), statement->column_int64(i));
}
- for ( ; i < TIME_FIELDS_END; ++i) {
- (*kernel)->put(static_cast<TimeField>(i),
- browser_sync::ProtoTimeToTime(
- statement->column_int64(i)));
- }
for ( ; i < ID_FIELDS_END; ++i) {
(*kernel)->mutable_ref(static_cast<IdField>(i)).s_ =
statement->column_string(i);
@@ -127,8 +120,9 @@
(*kernel)->mutable_ref(static_cast<ProtoField>(i)).ParseFromArray(
statement->column_blob(i), statement->column_bytes(i));
}
+ ZeroFields((*kernel), i);
} else {
- DCHECK_EQ(query_result, SQLITE_DONE);
+ DCHECK(SQLITE_DONE == query_result);
(*kernel) = NULL;
}
return query_result;
@@ -484,13 +478,6 @@
version_on_disk = 76;
}
- // Version 77 standardized all time fields to ms since the Unix
- // epoch.
- if (version_on_disk == 76) {
- if (MigrateVersion76To77())
- version_on_disk = 77;
- }
-
// If one of the migrations requested it, drop columns that aren't current.
// It's only safe to do this after migrating all the way to the current
// version.
@@ -1102,35 +1089,6 @@
return true;
}
-bool DirectoryBackingStore::MigrateVersion76To77() {
- sqlite_utils::SQLStatement update_timestamps;
- // This change changes the format of stored timestamps to ms since
- // the Unix epoch.
-#if defined(OS_WIN)
-// On Windows, we used to store timestamps in FILETIME format (100s of
-// ns since Jan 1, 1601). Magic numbers taken from
-// http://stackoverflow.com/questions/5398557/java-library-for-dealing-with-win32-filetime
-// .
-#define TO_UNIX_TIME_MS(x) #x " = " #x " / 10000 - 11644473600000"
-#else
-// On other platforms, we used to store timestamps in time_t format (s
-// since the Unix epoch).
-#define TO_UNIX_TIME_MS(x) #x " = " #x " * 1000"
-#endif
- update_timestamps.prepare(
- load_dbhandle_,
- "UPDATE metas SET "
- TO_UNIX_TIME_MS(mtime) ", "
- TO_UNIX_TIME_MS(server_mtime) ", "
- TO_UNIX_TIME_MS(ctime) ", "
- TO_UNIX_TIME_MS(server_ctime));
-#undef TO_UNIX_TIME_MS
- if (update_timestamps.step() != SQLITE_DONE)
- return false;
- SetVersion(77);
- return true;
-}
-
int DirectoryBackingStore::CreateTables() {
VLOG(1) << "First run, creating tables";
// Create two little tables share_version and share_info
@@ -1185,7 +1143,7 @@
return result;
{
// Insert the entry for the root into the metas table.
- const int64 now = browser_sync::TimeToProtoTime(base::Time::Now());
+ const int64 now = Now();
sqlite_utils::SQLStatement statement;
statement.prepare(load_dbhandle_,
"INSERT INTO metas "

Powered by Google App Engine
This is Rietveld 408576698