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

Unified Diff: chrome/browser/sync/engine/syncer_util.h

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
« no previous file with comments | « chrome/browser/sync/engine/syncer_unittest.cc ('k') | chrome/browser/sync/engine/syncer_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/syncer_util.h
===================================================================
--- chrome/browser/sync/engine/syncer_util.h (revision 102184)
+++ chrome/browser/sync/engine/syncer_util.h (working copy)
@@ -13,6 +13,7 @@
#include <string>
#include <vector>
+#include "build/build_config.h"
#include "chrome/browser/sync/engine/syncer.h"
#include "chrome/browser/sync/engine/syncer_types.h"
#include "chrome/browser/sync/syncable/syncable.h"
@@ -139,6 +140,43 @@
DISALLOW_IMPLICIT_CONSTRUCTORS(SyncerUtil);
};
+#ifndef OS_WIN
+
+// time.h on Linux and Mac both return seconds since the epoch, this should
+// be converted to milliseconds.
+inline int64 ServerTimeToClientTime(int64 server_time) {
+ return server_time / GG_LONGLONG(1000);
+}
+
+inline int64 ClientTimeToServerTime(int64 client_time) {
+ return client_time * GG_LONGLONG(1000);
+}
+
+// As we truncate server times on the client for posix and on the server for
+// windows we need two ClientAndServerTimeMatch fucntions.
+inline bool ClientAndServerTimeMatch(int64 client_time, int64 server_time) {
+ // Compare at the coarser timescale (client)
+ return client_time == ServerTimeToClientTime(server_time);
+}
+#else
+// The sync server uses Java Times (ms since 1970)
+// and the client uses FILETIMEs (ns since 1601) so we need to convert
+// between the timescales.
+// TODO(sync): Fix this. No need to use two timescales.
+inline int64 ServerTimeToClientTime(int64 server_time) {
+ return server_time * GG_LONGLONG(10000) + GG_LONGLONG(116444736000000000);
+}
+
+inline int64 ClientTimeToServerTime(int64 client_time) {
+ return (client_time - GG_LONGLONG(116444736000000000)) / GG_LONGLONG(10000);
+}
+
+inline bool ClientAndServerTimeMatch(int64 client_time, int64 server_time) {
+ // Compare at the coarser timescale (server)
+ return ClientTimeToServerTime(client_time) == server_time;
+}
+#endif
+
} // namespace browser_sync
#endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_UTIL_H_
« no previous file with comments | « chrome/browser/sync/engine/syncer_unittest.cc ('k') | chrome/browser/sync/engine/syncer_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698