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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc

Issue 101223003: SyncFS: Handle HTTP_CONFLICT as Precondition error (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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_backend/conflict_resolver.cc ('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 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/drive_backend/local_to_remote_syncer.h " 5 #include "chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h "
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 base::Bind(&LocalToRemoteSyncer::DidDeleteRemoteFile, 328 base::Bind(&LocalToRemoteSyncer::DidDeleteRemoteFile,
329 weak_ptr_factory_.GetWeakPtr(), 329 weak_ptr_factory_.GetWeakPtr(),
330 callback)); 330 callback));
331 } 331 }
332 332
333 void LocalToRemoteSyncer::DidDeleteRemoteFile( 333 void LocalToRemoteSyncer::DidDeleteRemoteFile(
334 const SyncStatusCallback& callback, 334 const SyncStatusCallback& callback,
335 google_apis::GDataErrorCode error) { 335 google_apis::GDataErrorCode error) {
336 if (error != google_apis::HTTP_SUCCESS && 336 if (error != google_apis::HTTP_SUCCESS &&
337 error != google_apis::HTTP_NOT_FOUND && 337 error != google_apis::HTTP_NOT_FOUND &&
338 error != google_apis::HTTP_PRECONDITION) { 338 error != google_apis::HTTP_PRECONDITION &&
339 error != google_apis::HTTP_CONFLICT) {
339 callback.Run(GDataErrorCodeToSyncStatusCode(error)); 340 callback.Run(GDataErrorCodeToSyncStatusCode(error));
340 return; 341 return;
341 } 342 }
342 343
343 // Handle NOT_FOUND case as SUCCESS case. 344 // Handle NOT_FOUND case as SUCCESS case.
344 // For PRECONDITION case, the remote file is modified since the last sync 345 // For PRECONDITION / CONFLICT case, the remote file is modified since the
345 // completed. As our policy for deletion-modification conflict resolution, 346 // last sync completed. As our policy for deletion-modification conflict
346 // ignore the local deletion. 347 // resolution, ignore the local deletion.
347 callback.Run(SYNC_STATUS_OK); 348 callback.Run(SYNC_STATUS_OK);
348 } 349 }
349 350
350 void LocalToRemoteSyncer::UploadExistingFile( 351 void LocalToRemoteSyncer::UploadExistingFile(
351 const SyncStatusCallback& callback) { 352 const SyncStatusCallback& callback) {
352 DCHECK(remote_file_tracker_); 353 DCHECK(remote_file_tracker_);
353 DCHECK(remote_file_tracker_->has_synced_details()); 354 DCHECK(remote_file_tracker_->has_synced_details());
354 355
355 base::PostTaskAndReplyWithResult( 356 base::PostTaskAndReplyWithResult(
356 sync_context_->GetBlockingTaskRunner(), FROM_HERE, 357 sync_context_->GetBlockingTaskRunner(), FROM_HERE,
(...skipping 22 matching lines...) Expand all
379 weak_ptr_factory_.GetWeakPtr(), 380 weak_ptr_factory_.GetWeakPtr(),
380 callback), 381 callback),
381 google_apis::ProgressCallback()); 382 google_apis::ProgressCallback());
382 } 383 }
383 384
384 void LocalToRemoteSyncer::DidUploadExistingFile( 385 void LocalToRemoteSyncer::DidUploadExistingFile(
385 const SyncStatusCallback& callback, 386 const SyncStatusCallback& callback,
386 google_apis::GDataErrorCode error, 387 google_apis::GDataErrorCode error,
387 const GURL&, 388 const GURL&,
388 scoped_ptr<google_apis::ResourceEntry> entry) { 389 scoped_ptr<google_apis::ResourceEntry> entry) {
389 if (error == google_apis::HTTP_PRECONDITION) { 390 if (error == google_apis::HTTP_PRECONDITION ||
391 error == google_apis::HTTP_CONFLICT) {
390 // The remote file has unfetched remote change. Fetch latest metadata and 392 // The remote file has unfetched remote change. Fetch latest metadata and
391 // update database with it. 393 // update database with it.
392 // TODO(tzik): Consider adding local side low-priority dirtiness handling to 394 // TODO(tzik): Consider adding local side low-priority dirtiness handling to
393 // handle this as ListChangesTask. 395 // handle this as ListChangesTask.
394 UpdateRemoteMetadata(callback); 396 UpdateRemoteMetadata(callback);
395 return; 397 return;
396 } 398 }
397 399
398 metadata_database()->UpdateByFileResource( 400 metadata_database()->UpdateByFileResource(
399 *drive::util::ConvertResourceEntryToFileResource(*entry), 401 *drive::util::ConvertResourceEntryToFileResource(*entry),
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 set_used_network(true); 634 set_used_network(true);
633 return sync_context_->GetDriveUploader(); 635 return sync_context_->GetDriveUploader();
634 } 636 }
635 637
636 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { 638 MetadataDatabase* LocalToRemoteSyncer::metadata_database() {
637 return sync_context_->GetMetadataDatabase(); 639 return sync_context_->GetMetadataDatabase();
638 } 640 }
639 641
640 } // namespace drive_backend 642 } // namespace drive_backend
641 } // namespace sync_file_system 643 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698