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

Side by Side Diff: chrome/browser/sync_file_system/local/local_file_sync_context.cc

Issue 23578026: Use SNAPSHOT sync mode for LocalSync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding shared locking for sync+sync conflict Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_context.h" 5 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h"
8 #include "base/location.h" 9 #include "base/location.h"
9 #include "base/platform_file.h" 10 #include "base/platform_file.h"
10 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "base/task_runner_util.h" 13 #include "base/task_runner_util.h"
13 #include "chrome/browser/sync_file_system/file_change.h" 14 #include "chrome/browser/sync_file_system/file_change.h"
14 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" 15 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h"
15 #include "chrome/browser/sync_file_system/local/local_origin_change_observer.h" 16 #include "chrome/browser/sync_file_system/local/local_origin_change_observer.h"
16 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" 17 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
17 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h " 18 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h "
18 #include "chrome/browser/sync_file_system/sync_file_metadata.h" 19 #include "chrome/browser/sync_file_system/sync_file_metadata.h"
19 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 20 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
20 #include "webkit/browser/fileapi/file_system_context.h" 21 #include "webkit/browser/fileapi/file_system_context.h"
21 #include "webkit/browser/fileapi/file_system_file_util.h" 22 #include "webkit/browser/fileapi/file_system_file_util.h"
22 #include "webkit/browser/fileapi/file_system_operation_context.h" 23 #include "webkit/browser/fileapi/file_system_operation_context.h"
23 #include "webkit/browser/fileapi/file_system_operation_runner.h" 24 #include "webkit/browser/fileapi/file_system_operation_runner.h"
25 #include "webkit/common/blob/scoped_file.h"
24 #include "webkit/common/fileapi/file_system_util.h" 26 #include "webkit/common/fileapi/file_system_util.h"
25 27
26 using fileapi::FileSystemContext; 28 using fileapi::FileSystemContext;
27 using fileapi::FileSystemFileUtil; 29 using fileapi::FileSystemFileUtil;
28 using fileapi::FileSystemOperation; 30 using fileapi::FileSystemOperation;
29 using fileapi::FileSystemOperationContext; 31 using fileapi::FileSystemOperationContext;
30 using fileapi::FileSystemURL; 32 using fileapi::FileSystemURL;
31 33
32 namespace sync_file_system { 34 namespace sync_file_system {
33 35
34 namespace { 36 namespace {
35 37
36 const int kMaxConcurrentSyncableOperation = 3; 38 const int kMaxConcurrentSyncableOperation = 3;
37 const int kNotifyChangesDurationInSec = 1; 39 const int kNotifyChangesDurationInSec = 1;
38 const int kMaxURLsToFetchForLocalSync = 5; 40 const int kMaxURLsToFetchForLocalSync = 5;
39 41
42 const base::FilePath::CharType kSnapshotDir[] = FILE_PATH_LITERAL("snapshots");
43
40 } // namespace 44 } // namespace
41 45
42 LocalFileSyncContext::LocalFileSyncContext( 46 LocalFileSyncContext::LocalFileSyncContext(
47 const base::FilePath& base_path,
43 base::SingleThreadTaskRunner* ui_task_runner, 48 base::SingleThreadTaskRunner* ui_task_runner,
44 base::SingleThreadTaskRunner* io_task_runner) 49 base::SingleThreadTaskRunner* io_task_runner)
45 : ui_task_runner_(ui_task_runner), 50 : local_base_path_(base_path.Append(FILE_PATH_LITERAL("local"))),
51 ui_task_runner_(ui_task_runner),
46 io_task_runner_(io_task_runner), 52 io_task_runner_(io_task_runner),
47 shutdown_on_ui_(false), 53 shutdown_on_ui_(false),
48 mock_notify_changes_duration_in_sec_(-1) { 54 mock_notify_changes_duration_in_sec_(-1) {
49 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 55 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
50 } 56 }
51 57
52 void LocalFileSyncContext::MaybeInitializeFileSystemContext( 58 void LocalFileSyncContext::MaybeInitializeFileSystemContext(
53 const GURL& source_url, 59 const GURL& source_url,
54 FileSystemContext* file_system_context, 60 FileSystemContext* file_system_context,
55 const SyncStatusCallback& callback) { 61 const SyncStatusCallback& callback) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 158
153 if (sync_finish_status == SYNC_STATUS_OK || 159 if (sync_finish_status == SYNC_STATUS_OK ||
154 sync_finish_status == SYNC_STATUS_HAS_CONFLICT) { 160 sync_finish_status == SYNC_STATUS_HAS_CONFLICT) {
155 // Commit the in-memory mirror change. 161 // Commit the in-memory mirror change.
156 backend->change_tracker()->ResetToMirrorAndCommitChangesForURL(url); 162 backend->change_tracker()->ResetToMirrorAndCommitChangesForURL(url);
157 } else { 163 } else {
158 // Abort in-memory mirror change. 164 // Abort in-memory mirror change.
159 backend->change_tracker()->RemoveMirrorAndCommitChangesForURL(url); 165 backend->change_tracker()->RemoveMirrorAndCommitChangesForURL(url);
160 } 166 }
161 167
168 // We've been keeping it in writing mode, so clear the writing counter
169 // to unblock sync activities.
170 io_task_runner_->PostTask(
171 FROM_HERE, base::Bind(&LocalFileSyncContext::EndWritingOnIOThread,
172 this, url));
173
162 // Call the completion callback on UI thread. 174 // Call the completion callback on UI thread.
163 ui_task_runner_->PostTask(FROM_HERE, done_callback); 175 ui_task_runner_->PostTask(FROM_HERE, done_callback);
164 } 176 }
165 177
166 void LocalFileSyncContext::ClearSyncFlagForURL(const FileSystemURL& url) { 178 void LocalFileSyncContext::ClearSyncFlagForURL(const FileSystemURL& url) {
167 // This is initially called on UI thread and to be relayed to IO thread. 179 // This is initially called on UI thread and to be relayed to IO thread.
168 io_task_runner_->PostTask( 180 io_task_runner_->PostTask(
169 FROM_HERE, 181 FROM_HERE,
170 base::Bind(&LocalFileSyncContext::EnableWritingOnIOThread, 182 base::Bind(&LocalFileSyncContext::ClearSyncFlagOnIOThread,
171 this, url, true /* may_have_updates */)); 183 this, url, false /* keep_url_in_writing */));
172 } 184 }
173 185
174 void LocalFileSyncContext::PrepareForSync( 186 void LocalFileSyncContext::PrepareForSync(
175 FileSystemContext* file_system_context, 187 FileSystemContext* file_system_context,
176 const FileSystemURL& url, 188 const FileSystemURL& url,
177 SyncMode sync_mode, 189 SyncMode sync_mode,
178 const LocalFileSyncInfoCallback& callback) { 190 const LocalFileSyncInfoCallback& callback) {
179 // This is initially called on UI thread and to be relayed to IO thread. 191 // This is initially called on UI thread and to be relayed to IO thread.
180 if (!io_task_runner_->RunsTasksOnCurrentThread()) { 192 if (!io_task_runner_->RunsTasksOnCurrentThread()) {
181 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 193 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (status != SYNC_STATUS_OK) 557 if (status != SYNC_STATUS_OK)
546 return status; 558 return status;
547 559
548 // Get all origins that have pending changes. 560 // Get all origins that have pending changes.
549 std::deque<FileSystemURL> urls; 561 std::deque<FileSystemURL> urls;
550 (*tracker_ptr)->GetNextChangedURLs(&urls, 0); 562 (*tracker_ptr)->GetNextChangedURLs(&urls, 0);
551 for (std::deque<FileSystemURL>::iterator iter = urls.begin(); 563 for (std::deque<FileSystemURL>::iterator iter = urls.begin();
552 iter != urls.end(); ++iter) { 564 iter != urls.end(); ++iter) {
553 origins_with_changes->insert(iter->origin()); 565 origins_with_changes->insert(iter->origin());
554 } 566 }
567
568 // Creates snapshot directory.
569 file_util::CreateDirectory(local_base_path_.Append(kSnapshotDir));
570
555 return status; 571 return status;
556 } 572 }
557 573
558 void LocalFileSyncContext::DidInitializeChangeTrackerOnIOThread( 574 void LocalFileSyncContext::DidInitializeChangeTrackerOnIOThread(
559 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, 575 scoped_ptr<LocalFileChangeTracker>* tracker_ptr,
560 const GURL& source_url, 576 const GURL& source_url,
561 FileSystemContext* file_system_context, 577 FileSystemContext* file_system_context,
562 std::set<GURL>* origins_with_changes, 578 std::set<GURL>* origins_with_changes,
563 SyncStatusCode status) { 579 SyncStatusCode status) {
564 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 580 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 } 644 }
629 645
630 void LocalFileSyncContext::TryPrepareForLocalSync( 646 void LocalFileSyncContext::TryPrepareForLocalSync(
631 FileSystemContext* file_system_context, 647 FileSystemContext* file_system_context,
632 std::deque<FileSystemURL>* urls, 648 std::deque<FileSystemURL>* urls,
633 const LocalFileSyncInfoCallback& callback) { 649 const LocalFileSyncInfoCallback& callback) {
634 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 650 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
635 DCHECK(urls); 651 DCHECK(urls);
636 652
637 if (shutdown_on_ui_) { 653 if (shutdown_on_ui_) {
638 callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo()); 654 callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo(),
655 scoped_ptr<webkit_blob::ScopedFile>());
639 return; 656 return;
640 } 657 }
641 658
642 if (urls->empty()) { 659 if (urls->empty()) {
643 callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, 660 callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, LocalFileSyncInfo(),
644 LocalFileSyncInfo()); 661 scoped_ptr<webkit_blob::ScopedFile>());
645 return; 662 return;
646 } 663 }
647 664
648 const FileSystemURL url = urls->front(); 665 const FileSystemURL url = urls->front();
649 urls->pop_front(); 666 urls->pop_front();
650 std::deque<FileSystemURL>* remaining = new std::deque<FileSystemURL>; 667 std::deque<FileSystemURL>* remaining = new std::deque<FileSystemURL>;
651 remaining->swap(*urls); 668 remaining->swap(*urls);
652 669
653 // TODO(kinuko): Call PrepareForSync with SYNC_SNAPSHOT when it becomes ready.
654 PrepareForSync( 670 PrepareForSync(
655 file_system_context, url, SYNC_EXCLUSIVE, 671 file_system_context, url, SYNC_SNAPSHOT,
656 base::Bind(&LocalFileSyncContext::DidTryPrepareForLocalSync, 672 base::Bind(&LocalFileSyncContext::DidTryPrepareForLocalSync,
657 this, make_scoped_refptr(file_system_context), 673 this, make_scoped_refptr(file_system_context),
658 base::Owned(remaining), callback)); 674 base::Owned(remaining), callback));
659 } 675 }
660 676
661 void LocalFileSyncContext::DidTryPrepareForLocalSync( 677 void LocalFileSyncContext::DidTryPrepareForLocalSync(
662 FileSystemContext* file_system_context, 678 FileSystemContext* file_system_context,
663 std::deque<FileSystemURL>* remaining_urls, 679 std::deque<FileSystemURL>* remaining_urls,
664 const LocalFileSyncInfoCallback& callback, 680 const LocalFileSyncInfoCallback& callback,
665 SyncStatusCode status, 681 SyncStatusCode status,
666 const LocalFileSyncInfo& sync_file_info) { 682 const LocalFileSyncInfo& sync_file_info,
683 scoped_ptr<webkit_blob::ScopedFile> snapshot) {
667 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 684 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
668 if (status != SYNC_STATUS_FILE_BUSY) { 685 if (status != SYNC_STATUS_FILE_BUSY) {
669 callback.Run(status, sync_file_info); 686 callback.Run(status, sync_file_info, snapshot.Pass());
670 return; 687 return;
671 } 688 }
672 // Recursively call TryPrepareForLocalSync with remaining_urls. 689 // Recursively call TryPrepareForLocalSync with remaining_urls.
673 TryPrepareForLocalSync(file_system_context, remaining_urls, callback); 690 TryPrepareForLocalSync(file_system_context, remaining_urls, callback);
674 } 691 }
675 692
676 void LocalFileSyncContext::DidGetWritingStatusForSync( 693 void LocalFileSyncContext::DidGetWritingStatusForSync(
677 FileSystemContext* file_system_context, 694 FileSystemContext* file_system_context,
678 SyncStatusCode status, 695 SyncStatusCode status,
679 const FileSystemURL& url, 696 const FileSystemURL& url,
680 SyncMode sync_mode, 697 SyncMode sync_mode,
681 const LocalFileSyncInfoCallback& callback) { 698 const LocalFileSyncInfoCallback& callback) {
682 // This gets called on UI thread and relays the task on FILE thread. 699 // This gets called on UI thread and relays the task on FILE thread.
683 DCHECK(file_system_context); 700 DCHECK(file_system_context);
684 if (!file_system_context->default_file_task_runner()-> 701 if (!file_system_context->default_file_task_runner()->
685 RunsTasksOnCurrentThread()) { 702 RunsTasksOnCurrentThread()) {
686 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 703 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
687 if (shutdown_on_ui_) { 704 if (shutdown_on_ui_) {
688 callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo()); 705 callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo(),
706 scoped_ptr<webkit_blob::ScopedFile>());
689 return; 707 return;
690 } 708 }
691 file_system_context->default_file_task_runner()->PostTask( 709 file_system_context->default_file_task_runner()->PostTask(
692 FROM_HERE, 710 FROM_HERE,
693 base::Bind(&LocalFileSyncContext::DidGetWritingStatusForSync, 711 base::Bind(&LocalFileSyncContext::DidGetWritingStatusForSync,
694 this, make_scoped_refptr(file_system_context), 712 this, make_scoped_refptr(file_system_context),
695 status, url, sync_mode, callback)); 713 status, url, sync_mode, callback));
696 return; 714 return;
697 } 715 }
698 716
699 SyncFileSystemBackend* backend = 717 SyncFileSystemBackend* backend =
700 SyncFileSystemBackend::GetBackend(file_system_context); 718 SyncFileSystemBackend::GetBackend(file_system_context);
701 DCHECK(backend); 719 DCHECK(backend);
702 DCHECK(backend->change_tracker()); 720 DCHECK(backend->change_tracker());
703 FileChangeList changes; 721 FileChangeList changes;
704 backend->change_tracker()->GetChangesForURL(url, &changes); 722 backend->change_tracker()->GetChangesForURL(url, &changes);
705 723
706 base::FilePath platform_path; 724 base::FilePath platform_path;
707 base::PlatformFileInfo file_info; 725 base::PlatformFileInfo file_info;
708 FileSystemFileUtil* file_util = 726 FileSystemFileUtil* file_util =
709 file_system_context->sandbox_delegate()->sync_file_util(); 727 file_system_context->sandbox_delegate()->sync_file_util();
710 DCHECK(file_util); 728 DCHECK(file_util);
711 729
712 base::PlatformFileError file_error = file_util->GetFileInfo( 730 base::PlatformFileError file_error = file_util->GetFileInfo(
713 make_scoped_ptr( 731 make_scoped_ptr(
714 new FileSystemOperationContext(file_system_context)).get(), 732 new FileSystemOperationContext(file_system_context)).get(),
715 url, 733 url,
716 &file_info, 734 &file_info,
717 &platform_path); 735 &platform_path);
736
737 scoped_ptr<webkit_blob::ScopedFile> snapshot;
718 if (file_error == base::PLATFORM_FILE_OK && sync_mode == SYNC_SNAPSHOT) { 738 if (file_error == base::PLATFORM_FILE_OK && sync_mode == SYNC_SNAPSHOT) {
719 // TODO(kinuko): creates a snapshot file. 739 base::FilePath snapshot_path;
740 file_util::CreateTemporaryFileInDir(local_base_path_.Append(kSnapshotDir),
741 &snapshot_path);
742 if (base::CopyFile(platform_path, snapshot_path)) {
743 platform_path = snapshot_path;
744 snapshot.reset(new webkit_blob::ScopedFile(
745 snapshot_path,
746 webkit_blob::ScopedFile::DELETE_ON_SCOPE_OUT,
747 file_system_context->default_file_task_runner()));
748 }
720 } 749 }
750
721 if (status == SYNC_STATUS_OK && 751 if (status == SYNC_STATUS_OK &&
722 file_error != base::PLATFORM_FILE_OK && 752 file_error != base::PLATFORM_FILE_OK &&
723 file_error != base::PLATFORM_FILE_ERROR_NOT_FOUND) 753 file_error != base::PLATFORM_FILE_ERROR_NOT_FOUND)
724 status = PlatformFileErrorToSyncStatusCode(file_error); 754 status = PlatformFileErrorToSyncStatusCode(file_error);
725 755
726 DCHECK(!file_info.is_symbolic_link); 756 DCHECK(!file_info.is_symbolic_link);
727 757
728 SyncFileType file_type = SYNC_FILE_TYPE_FILE; 758 SyncFileType file_type = SYNC_FILE_TYPE_FILE;
729 if (file_error == base::PLATFORM_FILE_ERROR_NOT_FOUND) 759 if (file_error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
730 file_type = SYNC_FILE_TYPE_UNKNOWN; 760 file_type = SYNC_FILE_TYPE_UNKNOWN;
731 else if (file_info.is_directory) 761 else if (file_info.is_directory)
732 file_type = SYNC_FILE_TYPE_DIRECTORY; 762 file_type = SYNC_FILE_TYPE_DIRECTORY;
733 763
734 // TODO(kinuko): returns the snapshot file path if snapshot is available.
735 LocalFileSyncInfo sync_file_info; 764 LocalFileSyncInfo sync_file_info;
736 sync_file_info.url = url; 765 sync_file_info.url = url;
737 sync_file_info.local_file_path = platform_path; 766 sync_file_info.local_file_path = platform_path;
738 sync_file_info.metadata.file_type = file_type; 767 sync_file_info.metadata.file_type = file_type;
739 sync_file_info.metadata.size = file_info.size; 768 sync_file_info.metadata.size = file_info.size;
740 sync_file_info.metadata.last_modified = file_info.last_modified; 769 sync_file_info.metadata.last_modified = file_info.last_modified;
741 sync_file_info.changes = changes; 770 sync_file_info.changes = changes;
742 771
743 if (status == SYNC_STATUS_OK) { 772 if (status == SYNC_STATUS_OK) {
744 if (!changes.empty()) { 773 if (!changes.empty()) {
745 // Now we create an empty mirror change record for URL (and we record 774 // Now we create an empty mirror change record for URL (and we record
746 // changes to both mirror and original records during sync), so that 775 // changes to both mirror and original records during sync), so that
747 // we can reset to the mirror when the sync succeeds. 776 // we can reset to the mirror when the sync succeeds.
748 backend->change_tracker()->CreateFreshMirrorForURL(url); 777 backend->change_tracker()->CreateFreshMirrorForURL(url);
749 } 778 }
750 779
751 // 'Unlock' the file if sync_mode is not SYNC_EXCLUSIVE. 780 // 'Unlock' the file if sync_mode is not SYNC_EXCLUSIVE.
781 // (But keep it in writing status so that no other sync starts on
782 // the same URL)
752 if (sync_mode != SYNC_EXCLUSIVE) { 783 if (sync_mode != SYNC_EXCLUSIVE) {
753 io_task_runner_->PostTask( 784 io_task_runner_->PostTask(
754 FROM_HERE, 785 FROM_HERE,
755 base::Bind(&LocalFileSyncContext::EnableWritingOnIOThread, 786 base::Bind(&LocalFileSyncContext::ClearSyncFlagOnIOThread,
756 this, url, false /* may_have_updates */)); 787 this, url, true /* keep_url_in_writing */));
757 } 788 }
758 } 789 }
759 790
760 ui_task_runner_->PostTask(FROM_HERE, 791 ui_task_runner_->PostTask(FROM_HERE,
761 base::Bind(callback, status, sync_file_info)); 792 base::Bind(callback, status, sync_file_info,
793 base::Passed(&snapshot)));
762 } 794 }
763 795
764 void LocalFileSyncContext::EnableWritingOnIOThread( 796 void LocalFileSyncContext::ClearSyncFlagOnIOThread(
765 const FileSystemURL& url, 797 const FileSystemURL& url,
766 bool may_have_updates) { 798 bool keep_url_in_writing) {
767 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 799 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
768 if (!sync_status()) { 800 if (!sync_status()) {
769 // The service might have been shut down. 801 // The service might have been shut down.
770 return; 802 return;
771 } 803 }
772 sync_status()->EndSyncing(url); 804 sync_status()->EndSyncing(url);
773 805
774 if (!may_have_updates) 806 if (keep_url_in_writing) {
807 // The caller will hold shared lock on this one.
808 sync_status()->StartWriting(url);
775 return; 809 return;
810 }
776 811
777 // Since a sync has finished the number of changes must have been updated. 812 // Since a sync has finished the number of changes must have been updated.
778 origins_with_pending_changes_.insert(url.origin()); 813 origins_with_pending_changes_.insert(url.origin());
779 ScheduleNotifyChangesUpdatedOnIOThread(); 814 ScheduleNotifyChangesUpdatedOnIOThread();
780 } 815 }
781 816
817 void LocalFileSyncContext::EndWritingOnIOThread(
818 const FileSystemURL& url) {
819 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
820 if (!sync_status()) {
821 // The service might have been shut down.
822 return;
823 }
824 sync_status()->EndWriting(url);
825 }
826
782 void LocalFileSyncContext::DidApplyRemoteChange( 827 void LocalFileSyncContext::DidApplyRemoteChange(
783 const FileSystemURL& url, 828 const FileSystemURL& url,
784 const SyncStatusCallback& callback_on_ui, 829 const SyncStatusCallback& callback_on_ui,
785 base::PlatformFileError file_error) { 830 base::PlatformFileError file_error) {
786 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 831 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
787 ui_task_runner_->PostTask( 832 ui_task_runner_->PostTask(
788 FROM_HERE, 833 FROM_HERE,
789 base::Bind(callback_on_ui, 834 base::Bind(callback_on_ui,
790 PlatformFileErrorToSyncStatusCode(file_error))); 835 PlatformFileErrorToSyncStatusCode(file_error)));
791 EnableWritingOnIOThread(url, true /* may_have_updates */); 836 ClearSyncFlagOnIOThread(url, false /* keep_url_in_writing */);
792 } 837 }
793 838
794 void LocalFileSyncContext::DidGetFileMetadata( 839 void LocalFileSyncContext::DidGetFileMetadata(
795 const SyncFileMetadataCallback& callback, 840 const SyncFileMetadataCallback& callback,
796 base::PlatformFileError file_error, 841 base::PlatformFileError file_error,
797 const base::PlatformFileInfo& file_info) { 842 const base::PlatformFileInfo& file_info) {
798 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 843 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
799 SyncFileMetadata metadata; 844 SyncFileMetadata metadata;
800 if (file_error == base::PLATFORM_FILE_OK) { 845 if (file_error == base::PLATFORM_FILE_OK) {
801 metadata.file_type = file_info.is_directory ? 846 metadata.file_type = file_info.is_directory ?
(...skipping 25 matching lines...) Expand all
827 return; 872 return;
828 } 873 }
829 874
830 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( 875 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
831 file_system_context, dest_url); 876 file_system_context, dest_url);
832 file_system_context->operation_runner()->CopyInForeignFile( 877 file_system_context->operation_runner()->CopyInForeignFile(
833 local_path, url_for_sync, callback); 878 local_path, url_for_sync, callback);
834 } 879 }
835 880
836 } // namespace sync_file_system 881 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698