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

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

Issue 1042803002: Drive: Move inner structures of DriveAPIService under drive namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests. Created 5 years, 8 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
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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 const std::string local_file_md5 = drive::util::GetMd5Digest(local_path_); 509 const std::string local_file_md5 = drive::util::GetMd5Digest(local_path_);
510 if (local_file_md5 == remote_file_tracker_->synced_details().md5()) { 510 if (local_file_md5 == remote_file_tracker_->synced_details().md5()) {
511 // Local file is not changed. 511 // Local file is not changed.
512 SyncCompleted(token.Pass(), SYNC_STATUS_OK); 512 SyncCompleted(token.Pass(), SYNC_STATUS_OK);
513 return; 513 return;
514 } 514 }
515 515
516 file_type_ = SYNC_FILE_TYPE_FILE; 516 file_type_ = SYNC_FILE_TYPE_FILE;
517 sync_action_ = SYNC_ACTION_UPDATED; 517 sync_action_ = SYNC_ACTION_UPDATED;
518 518
519 drive::DriveUploader::UploadExistingFileOptions options; 519 drive::UploadExistingFileOptions options;
520 options.etag = remote_file_tracker_->synced_details().etag(); 520 options.etag = remote_file_tracker_->synced_details().etag();
521 drive_uploader()->UploadExistingFile( 521 drive_uploader()->UploadExistingFile(
522 remote_file_tracker_->file_id(), 522 remote_file_tracker_->file_id(),
523 local_path_, 523 local_path_,
524 "application/octet_stream", 524 "application/octet_stream",
525 options, 525 options,
526 base::Bind(&LocalToRemoteSyncer::DidUploadExistingFile, 526 base::Bind(&LocalToRemoteSyncer::DidUploadExistingFile,
527 weak_ptr_factory_.GetWeakPtr(), base::Passed(&token)), 527 weak_ptr_factory_.GetWeakPtr(), base::Passed(&token)),
528 google_apis::ProgressCallback()); 528 google_apis::ProgressCallback());
529 } 529 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 SyncCompleted(token.Pass(), status); 635 SyncCompleted(token.Pass(), status);
636 } 636 }
637 637
638 void LocalToRemoteSyncer::UploadNewFile(scoped_ptr<SyncTaskToken> token) { 638 void LocalToRemoteSyncer::UploadNewFile(scoped_ptr<SyncTaskToken> token) {
639 DCHECK(remote_parent_folder_tracker_); 639 DCHECK(remote_parent_folder_tracker_);
640 640
641 file_type_ = SYNC_FILE_TYPE_FILE; 641 file_type_ = SYNC_FILE_TYPE_FILE;
642 sync_action_ = SYNC_ACTION_ADDED; 642 sync_action_ = SYNC_ACTION_ADDED;
643 base::FilePath title = storage::VirtualPath::BaseName(target_path_); 643 base::FilePath title = storage::VirtualPath::BaseName(target_path_);
644 drive_uploader()->UploadNewFile( 644 drive_uploader()->UploadNewFile(
645 remote_parent_folder_tracker_->file_id(), 645 remote_parent_folder_tracker_->file_id(), local_path_,
646 local_path_, 646 title.AsUTF8Unsafe(), GetMimeTypeFromTitle(title),
647 title.AsUTF8Unsafe(), 647 drive::UploadNewFileOptions(),
648 GetMimeTypeFromTitle(title),
649 drive::DriveUploader::UploadNewFileOptions(),
650 base::Bind(&LocalToRemoteSyncer::DidUploadNewFile, 648 base::Bind(&LocalToRemoteSyncer::DidUploadNewFile,
651 weak_ptr_factory_.GetWeakPtr(), 649 weak_ptr_factory_.GetWeakPtr(), base::Passed(&token)),
652 base::Passed(&token)),
653 google_apis::ProgressCallback()); 650 google_apis::ProgressCallback());
654 } 651 }
655 652
656 void LocalToRemoteSyncer::DidUploadNewFile( 653 void LocalToRemoteSyncer::DidUploadNewFile(
657 scoped_ptr<SyncTaskToken> token, 654 scoped_ptr<SyncTaskToken> token,
658 google_apis::DriveApiErrorCode error, 655 google_apis::DriveApiErrorCode error,
659 const GURL& upload_location, 656 const GURL& upload_location,
660 scoped_ptr<google_apis::FileResource> entry) { 657 scoped_ptr<google_apis::FileResource> entry) {
661 if (error == google_apis::HTTP_NOT_FOUND) 658 if (error == google_apis::HTTP_NOT_FOUND)
662 needs_remote_change_listing_ = true; 659 needs_remote_change_listing_ = true;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 set_used_network(true); 758 set_used_network(true);
762 return sync_context_->GetDriveUploader(); 759 return sync_context_->GetDriveUploader();
763 } 760 }
764 761
765 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { 762 MetadataDatabase* LocalToRemoteSyncer::metadata_database() {
766 return sync_context_->GetMetadataDatabase(); 763 return sync_context_->GetMetadataDatabase();
767 } 764 }
768 765
769 } // namespace drive_backend 766 } // namespace drive_backend
770 } // namespace sync_file_system 767 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698