| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 leveldb::Env* env_override, | 82 leveldb::Env* env_override, |
| 83 base::SequencedTaskRunner* file_task_runner) | 83 base::SequencedTaskRunner* file_task_runner) |
| 84 : initialized_(false), | 84 : initialized_(false), |
| 85 file_task_runner_(file_task_runner), | 85 file_task_runner_(file_task_runner), |
| 86 tracker_db_(new TrackerDB(base_path, env_override)), | 86 tracker_db_(new TrackerDB(base_path, env_override)), |
| 87 current_change_seq_number_(0), | 87 current_change_seq_number_(0), |
| 88 num_changes_(0) { | 88 num_changes_(0) { |
| 89 } | 89 } |
| 90 | 90 |
| 91 LocalFileChangeTracker::~LocalFileChangeTracker() { | 91 LocalFileChangeTracker::~LocalFileChangeTracker() { |
| 92 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 92 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 93 tracker_db_.reset(); | 93 tracker_db_.reset(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void LocalFileChangeTracker::OnStartUpdate(const FileSystemURL& url) { | 96 void LocalFileChangeTracker::OnStartUpdate(const FileSystemURL& url) { |
| 97 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 97 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 98 if (base::ContainsKey(changes_, url) || | 98 if (base::ContainsKey(changes_, url) || |
| 99 base::ContainsKey(demoted_changes_, url)) { | 99 base::ContainsKey(demoted_changes_, url)) { |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 // TODO(nhiroki): propagate the error code (see http://crbug.com/152127). | 102 // TODO(nhiroki): propagate the error code (see http://crbug.com/152127). |
| 103 MarkDirtyOnDatabase(url); | 103 MarkDirtyOnDatabase(url); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void LocalFileChangeTracker::OnEndUpdate(const FileSystemURL& url) {} | 106 void LocalFileChangeTracker::OnEndUpdate(const FileSystemURL& url) {} |
| 107 | 107 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 131 SYNC_FILE_TYPE_DIRECTORY)); | 131 SYNC_FILE_TYPE_DIRECTORY)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void LocalFileChangeTracker::OnRemoveDirectory(const FileSystemURL& url) { | 134 void LocalFileChangeTracker::OnRemoveDirectory(const FileSystemURL& url) { |
| 135 RecordChange(url, FileChange(FileChange::FILE_CHANGE_DELETE, | 135 RecordChange(url, FileChange(FileChange::FILE_CHANGE_DELETE, |
| 136 SYNC_FILE_TYPE_DIRECTORY)); | 136 SYNC_FILE_TYPE_DIRECTORY)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void LocalFileChangeTracker::GetNextChangedURLs( | 139 void LocalFileChangeTracker::GetNextChangedURLs( |
| 140 std::deque<FileSystemURL>* urls, int max_urls) { | 140 std::deque<FileSystemURL>* urls, int max_urls) { |
| 141 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 141 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 142 DCHECK(urls); | 142 DCHECK(urls); |
| 143 urls->clear(); | 143 urls->clear(); |
| 144 // Mildly prioritizes the URLs that older changes and have not been updated | 144 // Mildly prioritizes the URLs that older changes and have not been updated |
| 145 // for a while. | 145 // for a while. |
| 146 for (ChangeSeqMap::iterator iter = change_seqs_.begin(); | 146 for (ChangeSeqMap::iterator iter = change_seqs_.begin(); |
| 147 iter != change_seqs_.end() && | 147 iter != change_seqs_.end() && |
| 148 (max_urls == 0 || urls->size() < static_cast<size_t>(max_urls)); | 148 (max_urls == 0 || urls->size() < static_cast<size_t>(max_urls)); |
| 149 ++iter) { | 149 ++iter) { |
| 150 urls->push_back(iter->second); | 150 urls->push_back(iter->second); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 void LocalFileChangeTracker::GetChangesForURL( | 154 void LocalFileChangeTracker::GetChangesForURL( |
| 155 const FileSystemURL& url, FileChangeList* changes) { | 155 const FileSystemURL& url, FileChangeList* changes) { |
| 156 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 156 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 157 DCHECK(changes); | 157 DCHECK(changes); |
| 158 changes->clear(); | 158 changes->clear(); |
| 159 FileChangeMap::iterator found = changes_.find(url); | 159 FileChangeMap::iterator found = changes_.find(url); |
| 160 if (found == changes_.end()) { | 160 if (found == changes_.end()) { |
| 161 found = demoted_changes_.find(url); | 161 found = demoted_changes_.find(url); |
| 162 if (found == demoted_changes_.end()) | 162 if (found == demoted_changes_.end()) |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 *changes = found->second.change_list; | 165 *changes = found->second.change_list; |
| 166 } | 166 } |
| 167 | 167 |
| 168 void LocalFileChangeTracker::ClearChangesForURL(const FileSystemURL& url) { | 168 void LocalFileChangeTracker::ClearChangesForURL(const FileSystemURL& url) { |
| 169 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 169 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 170 ClearDirtyOnDatabase(url); | 170 ClearDirtyOnDatabase(url); |
| 171 mirror_changes_.erase(url); | 171 mirror_changes_.erase(url); |
| 172 demoted_changes_.erase(url); | 172 demoted_changes_.erase(url); |
| 173 FileChangeMap::iterator found = changes_.find(url); | 173 FileChangeMap::iterator found = changes_.find(url); |
| 174 if (found == changes_.end()) | 174 if (found == changes_.end()) |
| 175 return; | 175 return; |
| 176 change_seqs_.erase(found->second.change_seq); | 176 change_seqs_.erase(found->second.change_seq); |
| 177 changes_.erase(found); | 177 changes_.erase(found); |
| 178 UpdateNumChanges(); | 178 UpdateNumChanges(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void LocalFileChangeTracker::CreateFreshMirrorForURL( | 181 void LocalFileChangeTracker::CreateFreshMirrorForURL( |
| 182 const storage::FileSystemURL& url) { | 182 const storage::FileSystemURL& url) { |
| 183 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 183 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 184 DCHECK(!base::ContainsKey(mirror_changes_, url)); | 184 DCHECK(!base::ContainsKey(mirror_changes_, url)); |
| 185 mirror_changes_[url] = ChangeInfo(); | 185 mirror_changes_[url] = ChangeInfo(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void LocalFileChangeTracker::RemoveMirrorAndCommitChangesForURL( | 188 void LocalFileChangeTracker::RemoveMirrorAndCommitChangesForURL( |
| 189 const storage::FileSystemURL& url) { | 189 const storage::FileSystemURL& url) { |
| 190 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 190 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 191 FileChangeMap::iterator found = mirror_changes_.find(url); | 191 FileChangeMap::iterator found = mirror_changes_.find(url); |
| 192 if (found == mirror_changes_.end()) | 192 if (found == mirror_changes_.end()) |
| 193 return; | 193 return; |
| 194 mirror_changes_.erase(found); | 194 mirror_changes_.erase(found); |
| 195 | 195 |
| 196 if (base::ContainsKey(changes_, url) || | 196 if (base::ContainsKey(changes_, url) || |
| 197 base::ContainsKey(demoted_changes_, url)) { | 197 base::ContainsKey(demoted_changes_, url)) { |
| 198 MarkDirtyOnDatabase(url); | 198 MarkDirtyOnDatabase(url); |
| 199 } else { | 199 } else { |
| 200 ClearDirtyOnDatabase(url); | 200 ClearDirtyOnDatabase(url); |
| 201 } | 201 } |
| 202 UpdateNumChanges(); | 202 UpdateNumChanges(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void LocalFileChangeTracker::ResetToMirrorAndCommitChangesForURL( | 205 void LocalFileChangeTracker::ResetToMirrorAndCommitChangesForURL( |
| 206 const storage::FileSystemURL& url) { | 206 const storage::FileSystemURL& url) { |
| 207 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 207 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 208 FileChangeMap::iterator found = mirror_changes_.find(url); | 208 FileChangeMap::iterator found = mirror_changes_.find(url); |
| 209 if (found == mirror_changes_.end() || found->second.change_list.empty()) { | 209 if (found == mirror_changes_.end() || found->second.change_list.empty()) { |
| 210 ClearChangesForURL(url); | 210 ClearChangesForURL(url); |
| 211 return; | 211 return; |
| 212 } | 212 } |
| 213 const ChangeInfo& info = found->second; | 213 const ChangeInfo& info = found->second; |
| 214 if (base::ContainsKey(demoted_changes_, url)) { | 214 if (base::ContainsKey(demoted_changes_, url)) { |
| 215 DCHECK(!base::ContainsKey(changes_, url)); | 215 DCHECK(!base::ContainsKey(changes_, url)); |
| 216 demoted_changes_[url] = info; | 216 demoted_changes_[url] = info; |
| 217 } else { | 217 } else { |
| 218 DCHECK(!base::ContainsKey(demoted_changes_, url)); | 218 DCHECK(!base::ContainsKey(demoted_changes_, url)); |
| 219 change_seqs_[info.change_seq] = url; | 219 change_seqs_[info.change_seq] = url; |
| 220 changes_[url] = info; | 220 changes_[url] = info; |
| 221 } | 221 } |
| 222 RemoveMirrorAndCommitChangesForURL(url); | 222 RemoveMirrorAndCommitChangesForURL(url); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void LocalFileChangeTracker::DemoteChangesForURL( | 225 void LocalFileChangeTracker::DemoteChangesForURL( |
| 226 const storage::FileSystemURL& url) { | 226 const storage::FileSystemURL& url) { |
| 227 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 227 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 228 | 228 |
| 229 FileChangeMap::iterator found = changes_.find(url); | 229 FileChangeMap::iterator found = changes_.find(url); |
| 230 if (found == changes_.end()) | 230 if (found == changes_.end()) |
| 231 return; | 231 return; |
| 232 DCHECK(!base::ContainsKey(demoted_changes_, url)); | 232 DCHECK(!base::ContainsKey(demoted_changes_, url)); |
| 233 change_seqs_.erase(found->second.change_seq); | 233 change_seqs_.erase(found->second.change_seq); |
| 234 demoted_changes_.insert(*found); | 234 demoted_changes_.insert(*found); |
| 235 changes_.erase(found); | 235 changes_.erase(found); |
| 236 UpdateNumChanges(); | 236 UpdateNumChanges(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void LocalFileChangeTracker::PromoteDemotedChangesForURL( | 239 void LocalFileChangeTracker::PromoteDemotedChangesForURL( |
| 240 const storage::FileSystemURL& url) { | 240 const storage::FileSystemURL& url) { |
| 241 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 241 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 242 | 242 |
| 243 FileChangeMap::iterator iter = demoted_changes_.find(url); | 243 FileChangeMap::iterator iter = demoted_changes_.find(url); |
| 244 if (iter == demoted_changes_.end()) | 244 if (iter == demoted_changes_.end()) |
| 245 return; | 245 return; |
| 246 | 246 |
| 247 FileChangeList::List change_list = iter->second.change_list.list(); | 247 FileChangeList::List change_list = iter->second.change_list.list(); |
| 248 // Make sure that this URL is in no queues. | 248 // Make sure that this URL is in no queues. |
| 249 DCHECK(!base::ContainsKey(change_seqs_, iter->second.change_seq)); | 249 DCHECK(!base::ContainsKey(change_seqs_, iter->second.change_seq)); |
| 250 DCHECK(!base::ContainsKey(changes_, url)); | 250 DCHECK(!base::ContainsKey(changes_, url)); |
| 251 | 251 |
| 252 change_seqs_[iter->second.change_seq] = url; | 252 change_seqs_[iter->second.change_seq] = url; |
| 253 changes_.insert(*iter); | 253 changes_.insert(*iter); |
| 254 demoted_changes_.erase(iter); | 254 demoted_changes_.erase(iter); |
| 255 UpdateNumChanges(); | 255 UpdateNumChanges(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool LocalFileChangeTracker::PromoteDemotedChanges() { | 258 bool LocalFileChangeTracker::PromoteDemotedChanges() { |
| 259 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 259 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 260 if (demoted_changes_.empty()) | 260 if (demoted_changes_.empty()) |
| 261 return false; | 261 return false; |
| 262 while (!demoted_changes_.empty()) { | 262 while (!demoted_changes_.empty()) { |
| 263 storage::FileSystemURL url = demoted_changes_.begin()->first; | 263 storage::FileSystemURL url = demoted_changes_.begin()->first; |
| 264 PromoteDemotedChangesForURL(url); | 264 PromoteDemotedChangesForURL(url); |
| 265 } | 265 } |
| 266 UpdateNumChanges(); | 266 UpdateNumChanges(); |
| 267 return true; | 267 return true; |
| 268 } | 268 } |
| 269 | 269 |
| 270 SyncStatusCode LocalFileChangeTracker::Initialize( | 270 SyncStatusCode LocalFileChangeTracker::Initialize( |
| 271 FileSystemContext* file_system_context) { | 271 FileSystemContext* file_system_context) { |
| 272 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 272 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 273 DCHECK(!initialized_); | 273 DCHECK(!initialized_); |
| 274 DCHECK(file_system_context); | 274 DCHECK(file_system_context); |
| 275 | 275 |
| 276 SyncStatusCode status = CollectLastDirtyChanges(file_system_context); | 276 SyncStatusCode status = CollectLastDirtyChanges(file_system_context); |
| 277 if (status == SYNC_STATUS_OK) | 277 if (status == SYNC_STATUS_OK) |
| 278 initialized_ = true; | 278 initialized_ = true; |
| 279 return status; | 279 return status; |
| 280 } | 280 } |
| 281 | 281 |
| 282 void LocalFileChangeTracker::ResetForFileSystem(const GURL& origin, | 282 void LocalFileChangeTracker::ResetForFileSystem(const GURL& origin, |
| 283 storage::FileSystemType type) { | 283 storage::FileSystemType type) { |
| 284 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 284 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 285 std::unique_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); | 285 std::unique_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); |
| 286 for (FileChangeMap::iterator iter = changes_.begin(); | 286 for (FileChangeMap::iterator iter = changes_.begin(); |
| 287 iter != changes_.end();) { | 287 iter != changes_.end();) { |
| 288 storage::FileSystemURL url = iter->first; | 288 storage::FileSystemURL url = iter->first; |
| 289 int change_seq = iter->second.change_seq; | 289 int change_seq = iter->second.change_seq; |
| 290 // Advance |iter| before calling ResetForURL to avoid the iterator | 290 // Advance |iter| before calling ResetForURL to avoid the iterator |
| 291 // invalidation in it. | 291 // invalidation in it. |
| 292 ++iter; | 292 ++iter; |
| 293 if (url.origin() == origin && url.type() == type) | 293 if (url.origin() == origin && url.type() == type) |
| 294 ResetForURL(url, change_seq, batch.get()); | 294 ResetForURL(url, change_seq, batch.get()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 310 tracker_db_->WriteBatch(std::move(batch)); | 310 tracker_db_->WriteBatch(std::move(batch)); |
| 311 UpdateNumChanges(); | 311 UpdateNumChanges(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void LocalFileChangeTracker::UpdateNumChanges() { | 314 void LocalFileChangeTracker::UpdateNumChanges() { |
| 315 base::AutoLock lock(num_changes_lock_); | 315 base::AutoLock lock(num_changes_lock_); |
| 316 num_changes_ = static_cast<int64_t>(change_seqs_.size()); | 316 num_changes_ = static_cast<int64_t>(change_seqs_.size()); |
| 317 } | 317 } |
| 318 | 318 |
| 319 void LocalFileChangeTracker::GetAllChangedURLs(FileSystemURLSet* urls) { | 319 void LocalFileChangeTracker::GetAllChangedURLs(FileSystemURLSet* urls) { |
| 320 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 320 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 321 std::deque<FileSystemURL> url_deque; | 321 std::deque<FileSystemURL> url_deque; |
| 322 GetNextChangedURLs(&url_deque, 0); | 322 GetNextChangedURLs(&url_deque, 0); |
| 323 urls->clear(); | 323 urls->clear(); |
| 324 urls->insert(url_deque.begin(), url_deque.end()); | 324 urls->insert(url_deque.begin(), url_deque.end()); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void LocalFileChangeTracker::DropAllChanges() { | 327 void LocalFileChangeTracker::DropAllChanges() { |
| 328 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 328 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 329 changes_.clear(); | 329 changes_.clear(); |
| 330 change_seqs_.clear(); | 330 change_seqs_.clear(); |
| 331 mirror_changes_.clear(); | 331 mirror_changes_.clear(); |
| 332 UpdateNumChanges(); | 332 UpdateNumChanges(); |
| 333 } | 333 } |
| 334 | 334 |
| 335 SyncStatusCode LocalFileChangeTracker::MarkDirtyOnDatabase( | 335 SyncStatusCode LocalFileChangeTracker::MarkDirtyOnDatabase( |
| 336 const FileSystemURL& url) { | 336 const FileSystemURL& url) { |
| 337 std::string serialized_url; | 337 std::string serialized_url; |
| 338 if (!SerializeSyncableFileSystemURL(url, &serialized_url)) | 338 if (!SerializeSyncableFileSystemURL(url, &serialized_url)) |
| 339 return SYNC_FILE_ERROR_INVALID_URL; | 339 return SYNC_FILE_ERROR_INVALID_URL; |
| 340 | 340 |
| 341 return tracker_db_->MarkDirty(serialized_url); | 341 return tracker_db_->MarkDirty(serialized_url); |
| 342 } | 342 } |
| 343 | 343 |
| 344 SyncStatusCode LocalFileChangeTracker::ClearDirtyOnDatabase( | 344 SyncStatusCode LocalFileChangeTracker::ClearDirtyOnDatabase( |
| 345 const FileSystemURL& url) { | 345 const FileSystemURL& url) { |
| 346 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 346 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 347 std::string serialized_url; | 347 std::string serialized_url; |
| 348 if (!SerializeSyncableFileSystemURL(url, &serialized_url)) | 348 if (!SerializeSyncableFileSystemURL(url, &serialized_url)) |
| 349 return SYNC_FILE_ERROR_INVALID_URL; | 349 return SYNC_FILE_ERROR_INVALID_URL; |
| 350 | 350 |
| 351 return tracker_db_->ClearDirty(serialized_url); | 351 return tracker_db_->ClearDirty(serialized_url); |
| 352 } | 352 } |
| 353 | 353 |
| 354 SyncStatusCode LocalFileChangeTracker::CollectLastDirtyChanges( | 354 SyncStatusCode LocalFileChangeTracker::CollectLastDirtyChanges( |
| 355 FileSystemContext* file_system_context) { | 355 FileSystemContext* file_system_context) { |
| 356 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 356 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 357 | 357 |
| 358 std::queue<FileSystemURL> dirty_files; | 358 std::queue<FileSystemURL> dirty_files; |
| 359 const SyncStatusCode status = tracker_db_->GetDirtyEntries(&dirty_files); | 359 const SyncStatusCode status = tracker_db_->GetDirtyEntries(&dirty_files); |
| 360 if (status != SYNC_STATUS_OK) | 360 if (status != SYNC_STATUS_OK) |
| 361 return status; | 361 return status; |
| 362 | 362 |
| 363 FileSystemFileUtil* file_util = | 363 FileSystemFileUtil* file_util = |
| 364 file_system_context->sandbox_delegate()->sync_file_util(); | 364 file_system_context->sandbox_delegate()->sync_file_util(); |
| 365 DCHECK(file_util); | 365 DCHECK(file_util); |
| 366 std::unique_ptr<FileSystemOperationContext> context( | 366 std::unique_ptr<FileSystemOperationContext> context( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 // TODO(nhiroki): handle file access error (http://crbug.com/155251). | 413 // TODO(nhiroki): handle file access error (http://crbug.com/155251). |
| 414 LOG(WARNING) << "Failed to access local file."; | 414 LOG(WARNING) << "Failed to access local file."; |
| 415 break; | 415 break; |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 return SYNC_STATUS_OK; | 418 return SYNC_STATUS_OK; |
| 419 } | 419 } |
| 420 | 420 |
| 421 void LocalFileChangeTracker::RecordChange( | 421 void LocalFileChangeTracker::RecordChange( |
| 422 const FileSystemURL& url, const FileChange& change) { | 422 const FileSystemURL& url, const FileChange& change) { |
| 423 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 423 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 424 int change_seq = current_change_seq_number_++; | 424 int change_seq = current_change_seq_number_++; |
| 425 if (base::ContainsKey(demoted_changes_, url)) { | 425 if (base::ContainsKey(demoted_changes_, url)) { |
| 426 RecordChangeToChangeMaps(url, change, change_seq, | 426 RecordChangeToChangeMaps(url, change, change_seq, |
| 427 &demoted_changes_, nullptr); | 427 &demoted_changes_, nullptr); |
| 428 } else { | 428 } else { |
| 429 RecordChangeToChangeMaps(url, change, change_seq, &changes_, &change_seqs_); | 429 RecordChangeToChangeMaps(url, change, change_seq, &changes_, &change_seqs_); |
| 430 } | 430 } |
| 431 if (base::ContainsKey(mirror_changes_, url)) { | 431 if (base::ContainsKey(mirror_changes_, url)) { |
| 432 RecordChangeToChangeMaps(url, change, change_seq, &mirror_changes_, | 432 RecordChangeToChangeMaps(url, change, change_seq, &mirror_changes_, |
| 433 nullptr); | 433 nullptr); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 if (!status.ok() && !status.IsNotFound()) { | 624 if (!status.ok() && !status.IsNotFound()) { |
| 625 HandleError(FROM_HERE, status); | 625 HandleError(FROM_HERE, status); |
| 626 db_status_ = LevelDBStatusToSyncStatusCode(status); | 626 db_status_ = LevelDBStatusToSyncStatusCode(status); |
| 627 db_.reset(); | 627 db_.reset(); |
| 628 return db_status_; | 628 return db_status_; |
| 629 } | 629 } |
| 630 return SYNC_STATUS_OK; | 630 return SYNC_STATUS_OK; |
| 631 } | 631 } |
| 632 | 632 |
| 633 } // namespace sync_file_system | 633 } // namespace sync_file_system |
| OLD | NEW |