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

Unified Diff: chrome/browser/sync_file_system/local/local_file_change_tracker.cc

Issue 386373002: [SyncFS] Add per-URL promote of demoted changes in LocalFileChangeTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/local/local_file_change_tracker.h ('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/local/local_file_change_tracker.cc
diff --git a/chrome/browser/sync_file_system/local/local_file_change_tracker.cc b/chrome/browser/sync_file_system/local/local_file_change_tracker.cc
index 24d1e174479136629541ce659be2d4a41334bd12..61f39d35165529e4ba18e4460e226d98e2513937 100644
--- a/chrome/browser/sync_file_system/local/local_file_change_tracker.cc
+++ b/chrome/browser/sync_file_system/local/local_file_change_tracker.cc
@@ -131,8 +131,8 @@ void LocalFileChangeTracker::OnRemoveDirectory(const FileSystemURL& url) {
void LocalFileChangeTracker::GetNextChangedURLs(
std::deque<FileSystemURL>* urls, int max_urls) {
- DCHECK(urls);
DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
+ DCHECK(urls);
urls->clear();
// Mildly prioritizes the URLs that older changes and have not been updated
// for a while.
@@ -173,12 +173,14 @@ void LocalFileChangeTracker::ClearChangesForURL(const FileSystemURL& url) {
void LocalFileChangeTracker::CreateFreshMirrorForURL(
const fileapi::FileSystemURL& url) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
DCHECK(!ContainsKey(mirror_changes_, url));
mirror_changes_[url] = ChangeInfo();
}
void LocalFileChangeTracker::RemoveMirrorAndCommitChangesForURL(
const fileapi::FileSystemURL& url) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
FileChangeMap::iterator found = mirror_changes_.find(url);
if (found == mirror_changes_.end())
return;
@@ -193,6 +195,7 @@ void LocalFileChangeTracker::RemoveMirrorAndCommitChangesForURL(
void LocalFileChangeTracker::ResetToMirrorAndCommitChangesForURL(
const fileapi::FileSystemURL& url) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
FileChangeMap::iterator found = mirror_changes_.find(url);
if (found == mirror_changes_.end() || found->second.change_list.empty()) {
ClearChangesForURL(url);
@@ -206,6 +209,7 @@ void LocalFileChangeTracker::ResetToMirrorAndCommitChangesForURL(
void LocalFileChangeTracker::DemoteChangesForURL(
const fileapi::FileSystemURL& url) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
FileChangeMap::iterator found = changes_.find(url);
if (found == changes_.end())
return;
@@ -223,26 +227,34 @@ void LocalFileChangeTracker::DemoteChangesForURL(
}
}
-bool LocalFileChangeTracker::PromoteDemotedChanges() {
- if (demoted_changes_.empty())
- return false;
- for (FileChangeMap::iterator iter = demoted_changes_.begin();
- iter != demoted_changes_.end();) {
- fileapi::FileSystemURL url = iter->first;
- FileChangeList::List change_list = iter->second.change_list.list();
- demoted_changes_.erase(iter++);
+void LocalFileChangeTracker::PromoteDemotedChangesForURL(
+ const fileapi::FileSystemURL& url) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
- // Make sure that this URL is in no queues.
- DCHECK(!ContainsKey(changes_, url));
- DCHECK(!ContainsKey(demoted_changes_, url));
- DCHECK(!ContainsKey(mirror_changes_, url));
+ FileChangeMap::iterator iter = demoted_changes_.find(url);
+ if (iter == demoted_changes_.end())
+ return;
- while (!change_list.empty()) {
- RecordChange(url, change_list.front());
- change_list.pop_front();
- }
+ FileChangeList::List change_list = iter->second.change_list.list();
+ // Make sure that this URL is in no queues.
+ DCHECK(!ContainsKey(changes_, url));
+ DCHECK(!ContainsKey(demoted_changes_, url));
peria 2014/07/14 07:55:32 This DCHECK must fail. |url| is found from |demote
tzik 2014/07/14 08:03:49 Done.
+ DCHECK(!ContainsKey(mirror_changes_, url));
+
+ while (!change_list.empty()) {
+ RecordChange(url, change_list.front());
+ change_list.pop_front();
}
- demoted_changes_.clear();
+
+ demoted_changes_.erase(iter);
+}
+
+bool LocalFileChangeTracker::PromoteDemotedChanges() {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
+ if (demoted_changes_.empty())
+ return false;
+ while (!demoted_changes_.empty())
+ PromoteDemotedChangesForURL(demoted_changes_.begin()->first);
return true;
}
@@ -296,6 +308,7 @@ void LocalFileChangeTracker::UpdateNumChanges() {
}
void LocalFileChangeTracker::GetAllChangedURLs(FileSystemURLSet* urls) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
std::deque<FileSystemURL> url_deque;
GetNextChangedURLs(&url_deque, 0);
urls->clear();
@@ -303,6 +316,7 @@ void LocalFileChangeTracker::GetAllChangedURLs(FileSystemURLSet* urls) {
}
void LocalFileChangeTracker::DropAllChanges() {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
changes_.clear();
change_seqs_.clear();
mirror_changes_.clear();
@@ -319,6 +333,7 @@ SyncStatusCode LocalFileChangeTracker::MarkDirtyOnDatabase(
SyncStatusCode LocalFileChangeTracker::ClearDirtyOnDatabase(
const FileSystemURL& url) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
std::string serialized_url;
if (!SerializeSyncableFileSystemURL(url, &serialized_url))
return SYNC_FILE_ERROR_INVALID_URL;
@@ -407,6 +422,7 @@ void LocalFileChangeTracker::RecordChange(
UpdateNumChanges();
}
+// static
void LocalFileChangeTracker::RecordChangeToChangeMaps(
const FileSystemURL& url,
const FileChange& change,
« no previous file with comments | « chrome/browser/sync_file_system/local/local_file_change_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698