diff options
21 files changed, 71 insertions, 12 deletions
diff --git a/chrome/browser/chromeos/drive/job_scheduler.cc b/chrome/browser/chromeos/drive/job_scheduler.cc index be5a5df..38c0192 100644 --- a/chrome/browser/chromeos/drive/job_scheduler.cc +++ b/chrome/browser/chromeos/drive/job_scheduler.cc @@ -85,6 +85,7 @@ google_apis::CancelCallback RunUploadNewFile( params.local_file_path, params.title, params.content_type, + DriveUploader::UploadNewFileOptions(), params.callback, params.progress_callback); } diff --git a/chrome/browser/chromeos/drive/job_scheduler_unittest.cc b/chrome/browser/chromeos/drive/job_scheduler_unittest.cc index 9e990442..fb58dce 100644 --- a/chrome/browser/chromeos/drive/job_scheduler_unittest.cc +++ b/chrome/browser/chromeos/drive/job_scheduler_unittest.cc @@ -105,6 +105,7 @@ class CancelTestableFakeDriveService : public FakeDriveService { int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const google_apis::InitiateUploadCallback& callback) OVERRIDE { if (upload_new_file_cancelable_) return base::Bind(callback, google_apis::GDATA_CANCELLED, GURL()); @@ -113,6 +114,7 @@ class CancelTestableFakeDriveService : public FakeDriveService { content_length, parent_resource_id, title, + options, callback); } diff --git a/chrome/browser/drive/drive_api_service.cc b/chrome/browser/drive/drive_api_service.cc index e41b4cf..cf57a46 100644 --- a/chrome/browser/drive/drive_api_service.cc +++ b/chrome/browser/drive/drive_api_service.cc @@ -702,19 +702,22 @@ CancelCallback DriveAPIService::InitiateUploadNewFile( int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const InitiateUploadCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - return sender_->StartRequestWithRetry( - new InitiateUploadNewFileRequest( - sender_.get(), - url_generator_, - content_type, - content_length, - parent_resource_id, - title, - callback)); + InitiateUploadNewFileRequest* request = + new InitiateUploadNewFileRequest(sender_.get(), + url_generator_, + content_type, + content_length, + parent_resource_id, + title, + callback); + request->set_modified_date(options.modified_date); + request->set_last_viewed_by_me_date(options.last_viewed_by_me_date); + return sender_->StartRequestWithRetry(request); } CancelCallback DriveAPIService::InitiateUploadExistingFile( diff --git a/chrome/browser/drive/drive_api_service.h b/chrome/browser/drive/drive_api_service.h index b720bf6..9957db8 100644 --- a/chrome/browser/drive/drive_api_service.h +++ b/chrome/browser/drive/drive_api_service.h @@ -153,6 +153,7 @@ class DriveAPIService : public DriveServiceInterface, int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const google_apis::InitiateUploadCallback& callback) OVERRIDE; virtual google_apis::CancelCallback InitiateUploadExistingFile( const std::string& content_type, diff --git a/chrome/browser/drive/drive_service_interface.cc b/chrome/browser/drive/drive_service_interface.cc index 5770ec0..163cd23 100644 --- a/chrome/browser/drive/drive_service_interface.cc +++ b/chrome/browser/drive/drive_service_interface.cc @@ -6,6 +6,14 @@ namespace drive { +DriveServiceInterface::InitiateUploadNewFileOptions:: + InitiateUploadNewFileOptions() { +} + +DriveServiceInterface::InitiateUploadNewFileOptions:: + ~InitiateUploadNewFileOptions() { +} + DriveServiceInterface::InitiateUploadExistingFileOptions:: InitiateUploadExistingFileOptions() { } diff --git a/chrome/browser/drive/drive_service_interface.h b/chrome/browser/drive/drive_service_interface.h index 92fc1d6..9a2ed09 100644 --- a/chrome/browser/drive/drive_service_interface.h +++ b/chrome/browser/drive/drive_service_interface.h @@ -42,6 +42,20 @@ class DriveServiceObserver { // URLFetcher that runs on UI thread. class DriveServiceInterface { public: + // Optional parameters for InitiateUploadNewFile(). + struct InitiateUploadNewFileOptions { + InitiateUploadNewFileOptions(); + ~InitiateUploadNewFileOptions(); + + // modified_date of the file. + // Pass the null Time if you are not interested in setting this property. + base::Time modified_date; + + // last_viewed_by_me_date of the file. + // Pass the null Time if you are not interested in setting this property. + base::Time last_viewed_by_me_date; + }; + // Optional parameters for InitiateUploadExistingFile(). struct InitiateUploadExistingFileOptions { InitiateUploadExistingFileOptions(); @@ -61,11 +75,11 @@ class DriveServiceInterface { std::string title; // New modified_date of the file. - // Pass the null Time to keep the property unchanged. + // Pass the null Time if you are not interested in setting this property. base::Time modified_date; // New last_viewed_by_me_date of the file. - // Pass the null Time to keep the property unchanged. + // Pass the null Time if you are not interested in setting this property. base::Time last_viewed_by_me_date; }; @@ -336,6 +350,7 @@ class DriveServiceInterface { int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const google_apis::InitiateUploadCallback& callback) = 0; // Initiates uploading of an existing document/file. diff --git a/chrome/browser/drive/drive_uploader.cc b/chrome/browser/drive/drive_uploader.cc index 7a1845a..6ef9545 100644 --- a/chrome/browser/drive/drive_uploader.cc +++ b/chrome/browser/drive/drive_uploader.cc @@ -138,6 +138,7 @@ CancelCallback DriveUploader::UploadNewFile( const base::FilePath& local_file_path, const std::string& title, const std::string& content_type, + const UploadNewFileOptions& options, const UploadCompletionCallback& callback, const ProgressCallback& progress_callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -155,7 +156,8 @@ CancelCallback DriveUploader::UploadNewFile( base::Bind(&DriveUploader::StartInitiateUploadNewFile, weak_ptr_factory_.GetWeakPtr(), parent_resource_id, - title)); + title, + options)); } CancelCallback DriveUploader::UploadExistingFile( @@ -246,6 +248,7 @@ void DriveUploader::StartUploadFileAfterGetFileSize( void DriveUploader::StartInitiateUploadNewFile( const std::string& parent_resource_id, const std::string& title, + const UploadNewFileOptions& options, scoped_ptr<UploadFileInfo> upload_file_info) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -255,6 +258,7 @@ void DriveUploader::StartInitiateUploadNewFile( info_ptr->content_length, parent_resource_id, title, + options, base::Bind(&DriveUploader::OnUploadLocationReceived, weak_ptr_factory_.GetWeakPtr(), base::Passed(&upload_file_info))); diff --git a/chrome/browser/drive/drive_uploader.h b/chrome/browser/drive/drive_uploader.h index 47d1643..1fd8191 100644 --- a/chrome/browser/drive/drive_uploader.h +++ b/chrome/browser/drive/drive_uploader.h @@ -41,6 +41,8 @@ typedef base::Callback<void( class DriveUploaderInterface { public: + typedef DriveServiceInterface::InitiateUploadNewFileOptions + UploadNewFileOptions; typedef DriveServiceInterface::InitiateUploadExistingFileOptions UploadExistingFileOptions; @@ -73,6 +75,7 @@ class DriveUploaderInterface { const base::FilePath& local_file_path, const std::string& title, const std::string& content_type, + const UploadNewFileOptions& options, const UploadCompletionCallback& callback, const google_apis::ProgressCallback& progress_callback) = 0; @@ -121,6 +124,7 @@ class DriveUploader : public DriveUploaderInterface { const base::FilePath& local_file_path, const std::string& title, const std::string& content_type, + const UploadNewFileOptions& options, const UploadCompletionCallback& callback, const google_apis::ProgressCallback& progress_callback) OVERRIDE; virtual google_apis::CancelCallback UploadExistingFile( @@ -156,6 +160,7 @@ class DriveUploader : public DriveUploaderInterface { void StartInitiateUploadNewFile( const std::string& parent_resource_id, const std::string& title, + const UploadNewFileOptions& options, scoped_ptr<UploadFileInfo> upload_file_info); // Starts to initiate the existing file uploading. diff --git a/chrome/browser/drive/drive_uploader_unittest.cc b/chrome/browser/drive/drive_uploader_unittest.cc index d3a38f5..ccbbc97 100644 --- a/chrome/browser/drive/drive_uploader_unittest.cc +++ b/chrome/browser/drive/drive_uploader_unittest.cc @@ -79,6 +79,7 @@ class MockDriveServiceWithUploadExpectation : public DummyDriveService { int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const InitiateUploadCallback& callback) OVERRIDE { EXPECT_EQ(kTestDocumentTitle, title); EXPECT_EQ(kTestMimeType, content_type); @@ -211,6 +212,7 @@ class MockDriveServiceNoConnectionAtInitiate : public DummyDriveService { int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const InitiateUploadCallback& callback) OVERRIDE { base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, GDATA_NO_CONNECTION, GURL())); @@ -251,6 +253,7 @@ class MockDriveServiceNoConnectionAtResume : public DummyDriveService { int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const InitiateUploadCallback& callback) OVERRIDE { base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, HTTP_SUCCESS, GURL(kTestUploadNewFileURL))); diff --git a/chrome/browser/drive/dummy_drive_service.cc b/chrome/browser/drive/dummy_drive_service.cc index 038717c..0f04f59 100644 --- a/chrome/browser/drive/dummy_drive_service.cc +++ b/chrome/browser/drive/dummy_drive_service.cc @@ -157,6 +157,7 @@ CancelCallback DummyDriveService::InitiateUploadNewFile( int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const InitiateUploadCallback& callback) { return CancelCallback(); } CancelCallback DummyDriveService::InitiateUploadExistingFile( diff --git a/chrome/browser/drive/dummy_drive_service.h b/chrome/browser/drive/dummy_drive_service.h index aaefd9f..8258ed7 100644 --- a/chrome/browser/drive/dummy_drive_service.h +++ b/chrome/browser/drive/dummy_drive_service.h @@ -109,6 +109,7 @@ class DummyDriveService : public DriveServiceInterface { int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const google_apis::InitiateUploadCallback& callback) OVERRIDE; virtual google_apis::CancelCallback InitiateUploadExistingFile( const std::string& content_type, diff --git a/chrome/browser/drive/fake_drive_service.cc b/chrome/browser/drive/fake_drive_service.cc index cb70595..45f13dc 100644 --- a/chrome/browser/drive/fake_drive_service.cc +++ b/chrome/browser/drive/fake_drive_service.cc @@ -957,6 +957,7 @@ CancelCallback FakeDriveService::InitiateUploadNewFile( int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const InitiateUploadCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); diff --git a/chrome/browser/drive/fake_drive_service.h b/chrome/browser/drive/fake_drive_service.h index 6ead6e1..3eee223 100644 --- a/chrome/browser/drive/fake_drive_service.h +++ b/chrome/browser/drive/fake_drive_service.h @@ -203,6 +203,7 @@ class FakeDriveService : public DriveServiceInterface { int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const google_apis::InitiateUploadCallback& callback) OVERRIDE; virtual google_apis::CancelCallback InitiateUploadExistingFile( const std::string& content_type, diff --git a/chrome/browser/drive/fake_drive_service_unittest.cc b/chrome/browser/drive/fake_drive_service_unittest.cc index f78d260..70f78ad 100644 --- a/chrome/browser/drive/fake_drive_service_unittest.cc +++ b/chrome/browser/drive/fake_drive_service_unittest.cc @@ -1762,6 +1762,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadNewFile_Offline) { 13, "folder:1_folder_resource_id", "new file.foo", + FakeDriveService::InitiateUploadNewFileOptions(), test_util::CreateCopyResultCallback(&error, &upload_location)); base::RunLoop().RunUntilIdle(); @@ -1780,6 +1781,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadNewFile_NotFound) { 13, "non_existent", "new file.foo", + FakeDriveService::InitiateUploadNewFileOptions(), test_util::CreateCopyResultCallback(&error, &upload_location)); base::RunLoop().RunUntilIdle(); @@ -1798,6 +1800,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadNewFile) { 13, "folder:1_folder_resource_id", "new file.foo", + FakeDriveService::InitiateUploadNewFileOptions(), test_util::CreateCopyResultCallback(&error, &upload_location)); base::RunLoop().RunUntilIdle(); @@ -1897,6 +1900,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) { 15, "folder:1_folder_resource_id", "new file.foo", + FakeDriveService::InitiateUploadNewFileOptions(), test_util::CreateCopyResultCallback(&error, &upload_location)); base::RunLoop().RunUntilIdle(); @@ -1932,6 +1936,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NotFound) { 15, "folder:1_folder_resource_id", "new file.foo", + FakeDriveService::InitiateUploadNewFileOptions(), test_util::CreateCopyResultCallback(&error, &upload_location)); base::RunLoop().RunUntilIdle(); @@ -2038,6 +2043,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) { contents.size(), "folder:1_folder_resource_id", "new file.foo", + FakeDriveService::InitiateUploadNewFileOptions(), test_util::CreateCopyResultCallback(&error, &upload_location)); base::RunLoop().RunUntilIdle(); diff --git a/chrome/browser/drive/gdata_wapi_service.cc b/chrome/browser/drive/gdata_wapi_service.cc index a77fa01..1ed23cf 100644 --- a/chrome/browser/drive/gdata_wapi_service.cc +++ b/chrome/browser/drive/gdata_wapi_service.cc @@ -496,6 +496,7 @@ CancelCallback GDataWapiService::InitiateUploadNewFile( int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const InitiateUploadCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); diff --git a/chrome/browser/drive/gdata_wapi_service.h b/chrome/browser/drive/gdata_wapi_service.h index c36ed46..a450d4d 100644 --- a/chrome/browser/drive/gdata_wapi_service.h +++ b/chrome/browser/drive/gdata_wapi_service.h @@ -149,6 +149,7 @@ class GDataWapiService : public DriveServiceInterface, int64 content_length, const std::string& parent_resource_id, const std::string& title, + const InitiateUploadNewFileOptions& options, const google_apis::InitiateUploadCallback& callback) OVERRIDE; virtual google_apis::CancelCallback InitiateUploadExistingFile( const std::string& content_type, diff --git a/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc b/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc index 99cac26..b5159ba 100644 --- a/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc +++ b/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc @@ -114,6 +114,7 @@ GDataErrorCode FakeDriveServiceHelper::AddFile( drive_uploader_->UploadNewFile( parent_folder_id, temp_file, title, "application/octet-stream", + drive::DriveUploader::UploadNewFileOptions(), base::Bind(&UploadResultCallback, &error, &file), google_apis::ProgressCallback()); base::RunLoop().RunUntilIdle(); diff --git a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc index 6421ab1..87d3019 100644 --- a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc +++ b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.cc @@ -90,6 +90,7 @@ CancelCallback FakeDriveUploader::UploadNewFile( const base::FilePath& local_file_path, const std::string& title, const std::string& content_type, + const UploadNewFileOptions& options, const UploadCompletionCallback& callback, const ProgressCallback& progress_callback) { DCHECK(!callback.is_null()); diff --git a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h index e302ce7..24bd7d4 100644 --- a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h +++ b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h @@ -54,6 +54,7 @@ class FakeDriveUploader : public drive::DriveUploaderInterface { const base::FilePath& local_file_path, const std::string& title, const std::string& content_type, + const UploadNewFileOptions& options, const drive::UploadCompletionCallback& callback, const google_apis::ProgressCallback& progress_callback) OVERRIDE; virtual google_apis::CancelCallback UploadExistingFile( diff --git a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc index e1459c3..e786edc 100644 --- a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc +++ b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc @@ -564,6 +564,7 @@ void LocalToRemoteSyncer::UploadNewFile(const SyncStatusCallback& callback) { local_path_, title.AsUTF8Unsafe(), GetMimeTypeFromTitle(title), + drive::DriveUploader::UploadNewFileOptions(), base::Bind(&LocalToRemoteSyncer::DidUploadNewFile, weak_ptr_factory_.GetWeakPtr(), callback), diff --git a/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc b/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc index b1f83dc..947a397 100644 --- a/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc +++ b/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc @@ -537,6 +537,7 @@ void APIUtil::UploadNewFile(const std::string& directory_resource_id, local_file_path, title, mime_type, + drive::DriveUploader::UploadNewFileOptions(), base::Bind(&UploadResultAdapter, did_upload_callback), google_apis::ProgressCallback()); } |