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

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_client.cc

Issue 12209115: Sync FileSystem: disable etag match on duplication recovery. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment, rename deletion function Created 7 years, 10 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
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/drive_file_sync_client.h" 5 #include "chrome/browser/sync_file_system/drive_file_sync_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <sstream> 9 #include <sstream>
10 #include <string> 10 #include <string>
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 // TODO(tzik): Replace published_time with creation time after we move to 817 // TODO(tzik): Replace published_time with creation time after we move to
818 // Drive API. 818 // Drive API.
819 if (entries[i]->published_time() < entries.back()->published_time()) 819 if (entries[i]->published_time() < entries.back()->published_time())
820 std::swap(entries[i], entries.back()); 820 std::swap(entries[i], entries.back());
821 } 821 }
822 822
823 scoped_ptr<google_apis::ResourceEntry> earliest_entry(entries.back()); 823 scoped_ptr<google_apis::ResourceEntry> earliest_entry(entries.back());
824 entries.back() = NULL; 824 entries.back() = NULL;
825 entries.get().pop_back(); 825 entries.get().pop_back();
826 826
827 DeleteEntries(entries.Pass(), 827 DeleteEntriesForEnsuringTitleUniqueness(
828 base::Bind(&EntryAdapter, base::Passed(&earliest_entry), 828 entries.Pass(),
829 callback)); 829 base::Bind(&EntryAdapter, base::Passed(&earliest_entry), callback));
830 return; 830 return;
831 } 831 }
832 832
833 DVLOG(2) << "no conflict detected"; 833 DVLOG(2) << "no conflict detected";
834 DCHECK_EQ(1u, entries.size()); 834 DCHECK_EQ(1u, entries.size());
835 scoped_ptr<google_apis::ResourceEntry> entry(entries.front()); 835 scoped_ptr<google_apis::ResourceEntry> entry(entries.front());
836 entries.weak_clear(); 836 entries.weak_clear();
837 callback.Run(google_apis::HTTP_FOUND, entry.Pass()); 837 callback.Run(google_apis::HTTP_FOUND, entry.Pass());
838 } 838 }
839 839
840 void DriveFileSyncClient::DeleteEntries( 840 void DriveFileSyncClient::DeleteEntriesForEnsuringTitleUniqueness(
841 ScopedVector<google_apis::ResourceEntry> entries, 841 ScopedVector<google_apis::ResourceEntry> entries,
842 const GDataErrorCallback& callback) { 842 const GDataErrorCallback& callback) {
843 DCHECK(CalledOnValidThread()); 843 DCHECK(CalledOnValidThread());
844 DVLOG(2) << "Cleaning up conflict on entry creation"; 844 DVLOG(2) << "Cleaning up conflict on entry creation";
845 845
846 if (entries.empty()) { 846 if (entries.empty()) {
847 callback.Run(google_apis::HTTP_SUCCESS); 847 callback.Run(google_apis::HTTP_SUCCESS);
848 return; 848 return;
849 } 849 }
850 850
851 scoped_ptr<google_apis::ResourceEntry> entry(entries.back()); 851 scoped_ptr<google_apis::ResourceEntry> entry(entries.back());
852 entries.back() = NULL; 852 entries.back() = NULL;
853 entries.get().pop_back(); 853 entries.get().pop_back();
854 854
855 // We don't care conflicts here as other clients may be also deleting this
856 // file, so passing an empty etag.
855 drive_service_->DeleteResource( 857 drive_service_->DeleteResource(
856 entry->resource_id(), 858 entry->resource_id(),
857 entry->etag(), 859 std::string(), // empty etag
858 base::Bind(&DriveFileSyncClient::DidDeleteEntry, AsWeakPtr(), 860 base::Bind(
859 base::Passed(&entries), callback)); 861 &DriveFileSyncClient::DidDeleteEntriesForEnsuringTitleUniqueness,
862 AsWeakPtr(), base::Passed(&entries), callback));
860 } 863 }
861 864
862 void DriveFileSyncClient::DidDeleteEntry( 865 void DriveFileSyncClient::DidDeleteEntriesForEnsuringTitleUniqueness(
863 ScopedVector<google_apis::ResourceEntry> entries, 866 ScopedVector<google_apis::ResourceEntry> entries,
864 const GDataErrorCallback& callback, 867 const GDataErrorCallback& callback,
865 google_apis::GDataErrorCode error) { 868 google_apis::GDataErrorCode error) {
866 DCHECK(CalledOnValidThread()); 869 DCHECK(CalledOnValidThread());
867 870
868 if (error != google_apis::HTTP_SUCCESS && 871 if (error != google_apis::HTTP_SUCCESS &&
869 error != google_apis::HTTP_NOT_FOUND) { 872 error != google_apis::HTTP_NOT_FOUND) {
870 DVLOG(2) << "Error on deleting file: " << error; 873 DVLOG(2) << "Error on deleting file: " << error;
871 callback.Run(error); 874 callback.Run(error);
872 return; 875 return;
873 } 876 }
874 877
875 DVLOG(2) << "Deletion completed"; 878 DVLOG(2) << "Deletion completed";
876 DeleteEntries(entries.Pass(), callback); 879 DeleteEntriesForEnsuringTitleUniqueness(entries.Pass(), callback);
877 } 880 }
878 881
879 } // namespace sync_file_system 882 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698