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

Unified Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc

Issue 460503004: [SyncFS] Add last validate time in MDDB ver.4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work for a nit Created 6 years, 4 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_file_system/drive_backend/drive_backend_constants.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
index ae40a2b7f78c95b5336462506afa54b217fa3fcf..7520ee3d8f768ebc8450284e38a1a356e3dd73b0 100644
--- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
+++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
@@ -78,6 +78,10 @@
// # Demoted dirty tracker IDs
// key: "DEMOTED_DIRTY: " + <int64 'demoted_dirty_tracker_id'>
// value: <empty>
+//
+// # Timestamp when the last validation ran
+// key: "LAST_VALID"
+// value: <time_t 'last_valid_time'>
nhiroki 2014/08/15 11:03:15 I guess this should be int64 value and you may wan
namespace sync_file_system {
namespace drive_backend {
@@ -251,9 +255,6 @@ scoped_ptr<MetadataDatabaseIndexOnDisk>
MetadataDatabaseIndexOnDisk::Create(LevelDBWrapper* db) {
DCHECK(db);
- std::string version;
- db->Get(kDatabaseVersionKey, &version);
-
PutVersionToDB(kDatabaseOnDiskVersion, db);
// TODO(peria): It is not good to call RemoveUnreachableItems on every
// creation.
@@ -261,9 +262,6 @@ MetadataDatabaseIndexOnDisk::Create(LevelDBWrapper* db) {
scoped_ptr<MetadataDatabaseIndexOnDisk>
index(new MetadataDatabaseIndexOnDisk(db));
- if (version == "3")
- index->BuildTrackerIndexes();
-
return index.Pass();
}
@@ -727,8 +725,27 @@ MetadataDatabaseIndexOnDisk::MetadataDatabaseIndexOnDisk(LevelDBWrapper* db)
: db_(db) {
// TODO(peria): Add UMA to measure the number of FileMetadata, FileTracker,
// and AppRootId.
- // TODO(peria): If the DB version is 3, build up index lists.
service_metadata_ = InitializeServiceMetadata(db_);
+
+ // Check if index is valid, if no validations run in 7 days.
+ const int64 kThresholdToValidateInDays = 7;
+
+ int64 last_check_time = 0;
+ std::string value;
+ if (db_->Get(kLastValidationTimeKey, &value).ok())
+ base::StringToInt64(value, &last_check_time);
+ base::TimeDelta since_last_check =
+ base::Time::Now() - base::Time::FromInternalValue(last_check_time);
+ int64 since_last_check_in_days = since_last_check.InDays();
+ if (since_last_check_in_days >= kThresholdToValidateInDays ||
+ since_last_check_in_days < 0) {
+ // TODO(peria): Add UMA to check if the number of deleted entries and the
+ // number of built entries are different or not.
+ DeleteTrackerIndexes();
+ BuildTrackerIndexes();
+ db_->Put(kLastValidationTimeKey,
+ base::Int64ToString(base::Time::Now().ToInternalValue()));
+ }
}
void MetadataDatabaseIndexOnDisk::AddToAppIDIndex(const FileTracker& tracker) {
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/drive_backend_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698