| 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_sync_service.h" | 5 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 AsWeakPtr(), | 229 AsWeakPtr(), |
| 230 url, | 230 url, |
| 231 file_system_context, | 231 file_system_context, |
| 232 callback)); | 232 callback)); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 | 235 |
| 236 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); | 236 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); |
| 237 sync_context_->PrepareForSync( | 237 sync_context_->PrepareForSync( |
| 238 origin_to_contexts_[url.origin()], url, | 238 origin_to_contexts_[url.origin()], url, |
| 239 LocalFileSyncContext::SYNC_EXCLUSIVE, |
| 239 base::Bind(&PrepareForProcessRemoteChangeCallbackAdapter, callback)); | 240 base::Bind(&PrepareForProcessRemoteChangeCallbackAdapter, callback)); |
| 240 } | 241 } |
| 241 | 242 |
| 242 void LocalFileSyncService::ApplyRemoteChange( | 243 void LocalFileSyncService::ApplyRemoteChange( |
| 243 const FileChange& change, | 244 const FileChange& change, |
| 244 const base::FilePath& local_path, | 245 const base::FilePath& local_path, |
| 245 const FileSystemURL& url, | 246 const FileSystemURL& url, |
| 246 const SyncStatusCallback& callback) { | 247 const SyncStatusCallback& callback) { |
| 247 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); | 248 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); |
| 248 sync_context_->ApplyRemoteChange( | 249 sync_context_->ApplyRemoteChange( |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } | 412 } |
| 412 | 413 |
| 413 if (status == SYNC_FILE_ERROR_NOT_FOUND && | 414 if (status == SYNC_FILE_ERROR_NOT_FOUND && |
| 414 processed_change.change() == FileChange::FILE_CHANGE_DELETE) { | 415 processed_change.change() == FileChange::FILE_CHANGE_DELETE) { |
| 415 // This must be ok (and could happen). | 416 // This must be ok (and could happen). |
| 416 status = SYNC_STATUS_OK; | 417 status = SYNC_STATUS_OK; |
| 417 } | 418 } |
| 418 | 419 |
| 419 const FileSystemURL& url = sync_file_info.url; | 420 const FileSystemURL& url = sync_file_info.url; |
| 420 if (status != SYNC_STATUS_OK || changes.empty()) { | 421 if (status != SYNC_STATUS_OK || changes.empty()) { |
| 421 if (status == SYNC_STATUS_OK || status == SYNC_STATUS_HAS_CONFLICT) { | 422 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); |
| 422 // Clear the recorded changes for the URL if the sync was successfull | 423 sync_context_->CommitChangeStatusForURL( |
| 423 // OR has failed due to conflict (so that we won't stick to the same | 424 origin_to_contexts_[url.origin()], url, status, |
| 424 // conflicting file again and again). | 425 base::Bind(&LocalFileSyncService::RunLocalSyncCallback, |
| 425 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); | 426 AsWeakPtr(), status, url)); |
| 426 sync_context_->ClearChangesForURL( | |
| 427 origin_to_contexts_[url.origin()], url, | |
| 428 base::Bind(&LocalFileSyncService::RunLocalSyncCallback, | |
| 429 AsWeakPtr(), status, url)); | |
| 430 return; | |
| 431 } | |
| 432 RunLocalSyncCallback(status, url); | |
| 433 return; | 427 return; |
| 434 } | 428 } |
| 435 | 429 |
| 436 FileChange next_change = changes.front(); | 430 FileChange next_change = changes.front(); |
| 437 local_change_processor_->ApplyLocalChange( | 431 local_change_processor_->ApplyLocalChange( |
| 438 changes.front(), | 432 changes.front(), |
| 439 sync_file_info.local_file_path, | 433 sync_file_info.local_file_path, |
| 440 sync_file_info.metadata, | 434 sync_file_info.metadata, |
| 441 url, | 435 url, |
| 442 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, | 436 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, |
| 443 AsWeakPtr(), sync_file_info, | 437 AsWeakPtr(), sync_file_info, |
| 444 next_change, changes.PopAndGetNewList())); | 438 next_change, changes.PopAndGetNewList())); |
| 445 } | 439 } |
| 446 | 440 |
| 447 } // namespace sync_file_system | 441 } // namespace sync_file_system |
| OLD | NEW |