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

Unified Diff: sync/internal_api/sync_db_util.cc

Issue 332923002: [sync] Add backup time in synced device info so that server can flag device (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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: sync/internal_api/sync_db_util.cc
diff --git a/sync/internal_api/sync_db_util.cc b/sync/internal_api/sync_db_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..95a9325ced1229178354155c6c8286119a358d15
--- /dev/null
+++ b/sync/internal_api/sync_db_util.cc
@@ -0,0 +1,38 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/internal_api/public/util/sync_db_util.h"
+
+#include "base/files/file_path.h"
+#include "base/single_thread_task_runner.h"
+#include "sql/connection.h"
+#include "sync/syncable/directory.h"
+
+namespace syncer {
+
+void CheckSyncDbLastModifiedTime(
+ const base::FilePath& sync_dir,
+ scoped_refptr<base::SingleThreadTaskRunner> callback_runner,
+ base::Callback<void(base::Time)> callback) {
+ const base::FilePath sync_db =
+ sync_dir.Append(syncable::Directory::kSyncDatabaseFilename);
+
+ base::File f(sync_db, base::File::FLAG_OPEN);
+ base::File::Info info;
+ if (!f.IsValid() || !f.GetInfo(&info)) {
+ callback_runner->PostTask(FROM_HERE, base::Bind(callback, base::Time()));
+ return;
+ }
+ f.Close();
+
+ sql::Connection db;
+ if (!db.Open(sync_db) || !db.QuickIntegrityCheck()) {
+ callback_runner->PostTask(FROM_HERE, base::Bind(callback, base::Time()));
+ } else {
+ callback_runner->PostTask(FROM_HERE,
+ base::Bind(callback, info.last_modified));
+ }
+}
+
+} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698