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

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

Issue 12389017: Added function DeleteOriginDirectory to RemoteFileSyncService interface that removes the remote cop… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase for commit Created 7 years, 9 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 (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_service.h" 5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (!file_util::Delete(file_path, true)) 74 if (!file_util::Delete(file_path, true))
75 LOG(ERROR) << "Leaked temporary file for Sync FileSystem: " 75 LOG(ERROR) << "Leaked temporary file for Sync FileSystem: "
76 << file_path.value(); 76 << file_path.value();
77 } 77 }
78 78
79 void EmptyStatusCallback(SyncStatusCode code) {} 79 void EmptyStatusCallback(SyncStatusCode code) {}
80 80
81 void DidRemoveOrigin(const GURL& origin, SyncStatusCode status) { 81 void DidRemoveOrigin(const GURL& origin, SyncStatusCode status) {
82 // TODO(calvinlo): Disable syncing if status not ok (http://crbug.com/171611). 82 // TODO(calvinlo): Disable syncing if status not ok (http://crbug.com/171611).
83 DCHECK_EQ(SYNC_STATUS_OK, status); 83 DCHECK_EQ(SYNC_STATUS_OK, status);
84 LOG(WARNING) << "Remove origin failed for: " << origin.spec() 84 if (status != SYNC_STATUS_OK) {
85 << " status=" << status; 85 LOG(WARNING) << "Remove origin failed for: " << origin.spec()
86 << " status=" << status;
87 }
86 } 88 }
87 89
88 FileChange CreateFileChange(bool is_deleted) { 90 FileChange CreateFileChange(bool is_deleted) {
89 if (is_deleted) { 91 if (is_deleted) {
90 return FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN); 92 return FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN);
91 } 93 }
92 return FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, SYNC_FILE_TYPE_FILE); 94 return FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, SYNC_FILE_TYPE_FILE);
93 } 95 }
94 96
95 } // namespace 97 } // namespace
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 pending_changes_.erase(itr->second.position_in_queue); 399 pending_changes_.erase(itr->second.position_in_queue);
398 origin_to_changes_map_.erase(found); 400 origin_to_changes_map_.erase(found);
399 } 401 }
400 pending_batch_sync_origins_.erase(origin); 402 pending_batch_sync_origins_.erase(origin);
401 403
402 metadata_store_->RemoveOrigin(origin, base::Bind( 404 metadata_store_->RemoveOrigin(origin, base::Bind(
403 &DriveFileSyncService::DidRemoveOriginOnMetadataStore, 405 &DriveFileSyncService::DidRemoveOriginOnMetadataStore,
404 AsWeakPtr(), base::Passed(&token), callback)); 406 AsWeakPtr(), base::Passed(&token), callback));
405 } 407 }
406 408
409 void DriveFileSyncService::DeleteOriginDirectory(
410 const GURL& origin,
411 const SyncStatusCallback& callback) {
412 scoped_ptr<TaskToken> token(GetToken(
413 FROM_HERE, TASK_TYPE_DATABASE, "Delete Origin Directory"));
414 if (!token) {
415 pending_tasks_.push_back(base::Bind(
416 &DriveFileSyncService::DeleteOriginDirectory,
417 AsWeakPtr(), origin, callback));
418 return;
419 }
420
421 // Convert origin's directory GURL to ResourceID and delete it. Expected MD5
422 // is empty to force delete (i.e. skip conflict resolution).
423 std::string resource_id = metadata_store_->GetResourceIdForOrigin(origin);
424 sync_client_->DeleteFile(
425 resource_id,
426 std::string(),
427 base::Bind(&DriveFileSyncService::DidDeleteOriginDirectory,
428 AsWeakPtr(), base::Passed(&token), callback));
429 }
430
407 void DriveFileSyncService::ProcessRemoteChange( 431 void DriveFileSyncService::ProcessRemoteChange(
408 RemoteChangeProcessor* processor, 432 RemoteChangeProcessor* processor,
409 const SyncFileCallback& callback) { 433 const SyncFileCallback& callback) {
410 scoped_ptr<TaskToken> token( 434 scoped_ptr<TaskToken> token(
411 GetToken(FROM_HERE, TASK_TYPE_DRIVE, "Process remote change")); 435 GetToken(FROM_HERE, TASK_TYPE_DRIVE, "Process remote change"));
412 if (!token) { 436 if (!token) {
413 pending_tasks_.push_back(base::Bind( 437 pending_tasks_.push_back(base::Bind(
414 &DriveFileSyncService::ProcessRemoteChange, AsWeakPtr(), 438 &DriveFileSyncService::ProcessRemoteChange, AsWeakPtr(),
415 processor, callback)); 439 processor, callback));
416 return; 440 return;
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 return; 991 return;
968 } 992 }
969 993
970 metadata_store_->AddBatchSyncOrigin(origin, resource_id); 994 metadata_store_->AddBatchSyncOrigin(origin, resource_id);
971 pending_batch_sync_origins_.insert(origin); 995 pending_batch_sync_origins_.insert(origin);
972 996
973 NotifyTaskDone(SYNC_STATUS_OK, token.Pass()); 997 NotifyTaskDone(SYNC_STATUS_OK, token.Pass());
974 callback.Run(SYNC_STATUS_OK); 998 callback.Run(SYNC_STATUS_OK);
975 } 999 }
976 1000
1001 void DriveFileSyncService::DidDeleteOriginDirectory(
1002 scoped_ptr<TaskToken> token,
1003 const SyncStatusCallback& callback,
1004 google_apis::GDataErrorCode error) {
1005 SyncStatusCode status = GDataErrorCodeToSyncStatusCodeWrapper(error);
1006 NotifyTaskDone(status, token.Pass());
1007 callback.Run(status);
1008 }
1009
977 void DriveFileSyncService::DidGetLargestChangeStampForBatchSync( 1010 void DriveFileSyncService::DidGetLargestChangeStampForBatchSync(
978 scoped_ptr<TaskToken> token, 1011 scoped_ptr<TaskToken> token,
979 const GURL& origin, 1012 const GURL& origin,
980 const std::string& resource_id, 1013 const std::string& resource_id,
981 google_apis::GDataErrorCode error, 1014 google_apis::GDataErrorCode error,
982 int64 largest_changestamp) { 1015 int64 largest_changestamp) {
983 if (error != google_apis::HTTP_SUCCESS) { 1016 if (error != google_apis::HTTP_SUCCESS) {
984 pending_batch_sync_origins_.insert(origin); 1017 pending_batch_sync_origins_.insert(origin);
985 // TODO(tzik): Refine this error code. 1018 // TODO(tzik): Refine this error code.
986 NotifyTaskDone(GDataErrorCodeToSyncStatusCodeWrapper(error), token.Pass()); 1019 NotifyTaskDone(GDataErrorCodeToSyncStatusCodeWrapper(error), token.Pass());
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 DCHECK_EQ(SYNC_ACTION_NONE, action_taken); 2069 DCHECK_EQ(SYNC_ACTION_NONE, action_taken);
2037 DCHECK_EQ(SYNC_DIRECTION_NONE, direction); 2070 DCHECK_EQ(SYNC_DIRECTION_NONE, direction);
2038 } 2071 }
2039 2072
2040 FOR_EACH_OBSERVER( 2073 FOR_EACH_OBSERVER(
2041 FileStatusObserver, file_status_observers_, 2074 FileStatusObserver, file_status_observers_,
2042 OnFileStatusChanged(url, sync_status, action_taken, direction)); 2075 OnFileStatusChanged(url, sync_status, action_taken, direction));
2043 } 2076 }
2044 2077
2045 } // namespace sync_file_system 2078 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_service.h ('k') | chrome/browser/sync_file_system/drive_metadata_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698