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

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

Issue 98653002: [SyncFS] Update tracker on upload (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/local_to_remote_syncer.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 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 base::Bind(&LocalToRemoteSyncer::DidUploadExistingFile, 375 base::Bind(&LocalToRemoteSyncer::DidUploadExistingFile,
376 weak_ptr_factory_.GetWeakPtr(), 376 weak_ptr_factory_.GetWeakPtr(),
377 callback), 377 callback),
378 google_apis::ProgressCallback()); 378 google_apis::ProgressCallback());
379 } 379 }
380 380
381 void LocalToRemoteSyncer::DidUploadExistingFile( 381 void LocalToRemoteSyncer::DidUploadExistingFile(
382 const SyncStatusCallback& callback, 382 const SyncStatusCallback& callback,
383 google_apis::GDataErrorCode error, 383 google_apis::GDataErrorCode error,
384 const GURL&, 384 const GURL&,
385 scoped_ptr<google_apis::ResourceEntry>) { 385 scoped_ptr<google_apis::ResourceEntry> entry) {
386 if (error == google_apis::HTTP_PRECONDITION) { 386 if (error == google_apis::HTTP_PRECONDITION) {
387 // The remote file has unfetched remote change. Fetch latest metadata and 387 // The remote file has unfetched remote change. Fetch latest metadata and
388 // update database with it. 388 // update database with it.
389 // TODO(tzik): Consider adding local side low-priority dirtiness handling to 389 // TODO(tzik): Consider adding local side low-priority dirtiness handling to
390 // handle this as ListChangesTask. 390 // handle this as ListChangesTask.
391 UpdateRemoteMetadata(callback); 391 UpdateRemoteMetadata(callback);
392 return; 392 return;
393 } 393 }
394 394
395 callback.Run(GDataErrorCodeToSyncStatusCode(error)); 395 metadata_database()->UpdateByFileResource(
396 *drive::util::ConvertResourceEntryToFileResource(*entry),
397 base::Bind(&LocalToRemoteSyncer::DidUpdateMetadataForUpload,
kinuko 2013/12/02 09:05:39 We have DidUpdateDatabaseForUpload for UploadNewFi
tzik 2013/12/02 15:30:50 Renamed. Do DidUpdateDatabaseForUpload{NewFile,Exi
398 weak_ptr_factory_.GetWeakPtr(),
399 callback));
400 }
401
402 void LocalToRemoteSyncer::DidUpdateMetadataForUpload(
403 const SyncStatusCallback& callback,
404 SyncStatusCode status) {
405 if (status != SYNC_STATUS_OK) {
406 callback.Run(status);
407 return;
408 }
409
410 FileMetadata file;
411 bool should_success = metadata_database()->FindFileByFileID(
412 remote_file_tracker_->file_id(), &file);
413 if (should_success) {
414 NOTREACHED();
kinuko 2013/12/02 09:40:30 Hmm, I hit here in my local testing.
tzik 2013/12/02 15:30:50 ... That's broken, reversed. Fixed! Thanks!
415 callback.Run(SYNC_STATUS_FAILED);
416 return;
417 }
418
419 metadata_database()->UpdateTracker(
420 remote_file_tracker_->tracker_id(),
421 file.details(),
422 callback);
396 } 423 }
397 424
398 void LocalToRemoteSyncer::UpdateRemoteMetadata( 425 void LocalToRemoteSyncer::UpdateRemoteMetadata(
399 const SyncStatusCallback& callback) { 426 const SyncStatusCallback& callback) {
400 DCHECK(remote_file_tracker_); 427 DCHECK(remote_file_tracker_);
401 drive_service()->GetResourceEntry( 428 drive_service()->GetResourceEntry(
402 remote_file_tracker_->file_id(), 429 remote_file_tracker_->file_id(),
403 base::Bind(&LocalToRemoteSyncer::DidGetRemoteMetadata, 430 base::Bind(&LocalToRemoteSyncer::DidGetRemoteMetadata,
404 weak_ptr_factory_.GetWeakPtr(), 431 weak_ptr_factory_.GetWeakPtr(),
405 callback)); 432 callback));
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 set_used_network(true); 627 set_used_network(true);
601 return sync_context_->GetDriveUploader(); 628 return sync_context_->GetDriveUploader();
602 } 629 }
603 630
604 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { 631 MetadataDatabase* LocalToRemoteSyncer::metadata_database() {
605 return sync_context_->GetMetadataDatabase(); 632 return sync_context_->GetMetadataDatabase();
606 } 633 }
607 634
608 } // namespace drive_backend 635 } // namespace drive_backend
609 } // namespace sync_file_system 636 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698