OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 5 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 mirror_changes_.erase(url); | 218 mirror_changes_.erase(url); |
219 change_seqs_.erase(found->second.change_seq); | 219 change_seqs_.erase(found->second.change_seq); |
220 changes_.erase(found); | 220 changes_.erase(found); |
221 | 221 |
222 FileChangeList::List change_list = changes.list(); | 222 FileChangeList::List change_list = changes.list(); |
223 while (!change_list.empty()) { | 223 while (!change_list.empty()) { |
224 RecordChangeToChangeMaps(url, change_list.front(), 0, | 224 RecordChangeToChangeMaps(url, change_list.front(), 0, |
225 &demoted_changes_, NULL); | 225 &demoted_changes_, NULL); |
226 change_list.pop_front(); | 226 change_list.pop_front(); |
227 } | 227 } |
| 228 UpdateNumChanges(); |
228 } | 229 } |
229 | 230 |
230 void LocalFileChangeTracker::PromoteDemotedChangesForURL( | 231 void LocalFileChangeTracker::PromoteDemotedChangesForURL( |
231 const fileapi::FileSystemURL& url) { | 232 const fileapi::FileSystemURL& url) { |
232 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 233 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); |
233 | 234 |
234 FileChangeMap::iterator iter = demoted_changes_.find(url); | 235 FileChangeMap::iterator iter = demoted_changes_.find(url); |
235 if (iter == demoted_changes_.end()) | 236 if (iter == demoted_changes_.end()) |
236 return; | 237 return; |
237 | 238 |
(...skipping 11 matching lines...) Expand all Loading... |
249 } | 250 } |
250 | 251 |
251 bool LocalFileChangeTracker::PromoteDemotedChanges() { | 252 bool LocalFileChangeTracker::PromoteDemotedChanges() { |
252 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 253 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); |
253 if (demoted_changes_.empty()) | 254 if (demoted_changes_.empty()) |
254 return false; | 255 return false; |
255 while (!demoted_changes_.empty()) { | 256 while (!demoted_changes_.empty()) { |
256 fileapi::FileSystemURL url = demoted_changes_.begin()->first; | 257 fileapi::FileSystemURL url = demoted_changes_.begin()->first; |
257 PromoteDemotedChangesForURL(url); | 258 PromoteDemotedChangesForURL(url); |
258 } | 259 } |
| 260 UpdateNumChanges(); |
259 return true; | 261 return true; |
260 } | 262 } |
261 | 263 |
262 SyncStatusCode LocalFileChangeTracker::Initialize( | 264 SyncStatusCode LocalFileChangeTracker::Initialize( |
263 FileSystemContext* file_system_context) { | 265 FileSystemContext* file_system_context) { |
264 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 266 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); |
265 DCHECK(!initialized_); | 267 DCHECK(!initialized_); |
266 DCHECK(file_system_context); | 268 DCHECK(file_system_context); |
267 | 269 |
268 SyncStatusCode status = CollectLastDirtyChanges(file_system_context); | 270 SyncStatusCode status = CollectLastDirtyChanges(file_system_context); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 GetNextChangedURLs(&url_deque, 0); | 316 GetNextChangedURLs(&url_deque, 0); |
315 urls->clear(); | 317 urls->clear(); |
316 urls->insert(url_deque.begin(), url_deque.end()); | 318 urls->insert(url_deque.begin(), url_deque.end()); |
317 } | 319 } |
318 | 320 |
319 void LocalFileChangeTracker::DropAllChanges() { | 321 void LocalFileChangeTracker::DropAllChanges() { |
320 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 322 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); |
321 changes_.clear(); | 323 changes_.clear(); |
322 change_seqs_.clear(); | 324 change_seqs_.clear(); |
323 mirror_changes_.clear(); | 325 mirror_changes_.clear(); |
| 326 UpdateNumChanges(); |
324 } | 327 } |
325 | 328 |
326 SyncStatusCode LocalFileChangeTracker::MarkDirtyOnDatabase( | 329 SyncStatusCode LocalFileChangeTracker::MarkDirtyOnDatabase( |
327 const FileSystemURL& url) { | 330 const FileSystemURL& url) { |
328 std::string serialized_url; | 331 std::string serialized_url; |
329 if (!SerializeSyncableFileSystemURL(url, &serialized_url)) | 332 if (!SerializeSyncableFileSystemURL(url, &serialized_url)) |
330 return SYNC_FILE_ERROR_INVALID_URL; | 333 return SYNC_FILE_ERROR_INVALID_URL; |
331 | 334 |
332 return tracker_db_->MarkDirty(serialized_url); | 335 return tracker_db_->MarkDirty(serialized_url); |
333 } | 336 } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 if (!status.ok() && !status.IsNotFound()) { | 593 if (!status.ok() && !status.IsNotFound()) { |
591 HandleError(FROM_HERE, status); | 594 HandleError(FROM_HERE, status); |
592 db_status_ = LevelDBStatusToSyncStatusCode(status); | 595 db_status_ = LevelDBStatusToSyncStatusCode(status); |
593 db_.reset(); | 596 db_.reset(); |
594 return db_status_; | 597 return db_status_; |
595 } | 598 } |
596 return SYNC_STATUS_OK; | 599 return SYNC_STATUS_OK; |
597 } | 600 } |
598 | 601 |
599 } // namespace sync_file_system | 602 } // namespace sync_file_system |
OLD | NEW |