diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 05:13:05 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 05:13:05 +0000 |
commit | 4a63af5b5aefe6e4b7601b78ad288e969f4fedbe (patch) | |
tree | 99b2688cabd4b68ad58ae8d82dce3f58d5e21e76 /chrome | |
parent | 1b2e857f5ea03b06482ea4a739bb48f988f58460 (diff) | |
download | chromium_src-4a63af5b5aefe6e4b7601b78ad288e969f4fedbe.zip chromium_src-4a63af5b5aefe6e4b7601b78ad288e969f4fedbe.tar.gz chromium_src-4a63af5b5aefe6e4b7601b78ad288e969f4fedbe.tar.bz2 |
Bring GData file path to DocumentsService for upload/download operations.
GDataOperationRegistry needs this information to provide user-friendly list of in-flight operations.
BUG=chromium-os:27371
TEST=unit_test --gtest_filter='*GData*'
Review URL: https://chromiumcodereview.appspot.com/9705048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata.h | 10 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_browsertest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_file_system.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_file_system.h | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_mock.cc | 6 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_mock.h | 12 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_params.cc | 22 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_params.h | 9 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/gdata_uploader.cc | 4 |
11 files changed, 54 insertions, 24 deletions
diff --git a/chrome/browser/chromeos/gdata/gdata.cc b/chrome/browser/chromeos/gdata/gdata.cc index 1031d6f..9face27 100644 --- a/chrome/browser/chromeos/gdata/gdata.cc +++ b/chrome/browser/chromeos/gdata/gdata.cc @@ -1404,17 +1404,20 @@ void DocumentsService::GetDocuments(const GURL& url, } void DocumentsService::DownloadDocument( + const FilePath& virtual_path, const GURL& document_url, DocumentExportFormat format, const DownloadActionCallback& callback) { DownloadFile( + virtual_path, chrome_browser_net::AppendQueryParameter(document_url, "exportFormat", GetExportFormatParam(format)), callback); } -void DocumentsService::DownloadFile(const GURL& document_url, +void DocumentsService::DownloadFile(const FilePath& virtual_path, + const GURL& document_url, const DownloadActionCallback& callback) { StartOperationOnUIThread( new DownloadFileOperation(operation_registry_.get(), profile_, callback, diff --git a/chrome/browser/chromeos/gdata/gdata.h b/chrome/browser/chromeos/gdata/gdata.h index 8d478b7..88e9567 100644 --- a/chrome/browser/chromeos/gdata/gdata.h +++ b/chrome/browser/chromeos/gdata/gdata.h @@ -174,7 +174,8 @@ class DocumentsServiceInterface { // Upon completion, invokes |callback| with results on the calling thread. // // Can be called on any thread. - virtual void DownloadDocument(const GURL& content_url, + virtual void DownloadDocument(const FilePath& virtual_path, + const GURL& content_url, DocumentExportFormat format, const DownloadActionCallback& callback) = 0; @@ -234,7 +235,8 @@ class DocumentsServiceInterface { // |callback| with results on the calling thread. // // Can be called on any thread. - virtual void DownloadFile(const GURL& content_url, + virtual void DownloadFile(const FilePath& virtual_path, + const GURL& content_url, const DownloadActionCallback& callback) = 0; // Initiates uploading of a document/file. @@ -268,6 +270,7 @@ class DocumentsService virtual void DeleteDocument(const GURL& document_url, const EntryActionCallback& callback) OVERRIDE; virtual void DownloadDocument( + const FilePath& virtual_path, const GURL& content_url, DocumentExportFormat format, const DownloadActionCallback& callback) OVERRIDE; @@ -289,7 +292,8 @@ class DocumentsService virtual void CreateDirectory(const GURL& parent_content_url, const FilePath::StringType& directory_name, const GetDataCallback& callback) OVERRIDE; - virtual void DownloadFile(const GURL& content_url, + virtual void DownloadFile(const FilePath& virtual_path, + const GURL& content_url, const DownloadActionCallback& callback) OVERRIDE; virtual void InitiateUpload(const InitiateUploadParams& params, const InitiateUploadCallback& callback) OVERRIDE; diff --git a/chrome/browser/chromeos/gdata/gdata_browsertest.cc b/chrome/browser/chromeos/gdata/gdata_browsertest.cc index 4825ea9..634a6ad 100644 --- a/chrome/browser/chromeos/gdata/gdata_browsertest.cc +++ b/chrome/browser/chromeos/gdata/gdata_browsertest.cc @@ -66,6 +66,7 @@ IN_PROC_BROWSER_TEST_F(GDataTest, Download) { gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; std::string contents; service_->DownloadFile( + FilePath("/dummy/gdata/testfile.txt"), gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"), base::Bind(&TestDownloadCallback, &result, &contents)); ui_test_utils::RunMessageLoop(); @@ -82,6 +83,7 @@ IN_PROC_BROWSER_TEST_F(GDataTest, NonExistingDownload) { gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; std::string dummy_contents; service_->DownloadFile( + FilePath("/dummy/gdata/no-such-file.txt"), gdata_test_server_.GetURL("files/chromeos/gdata/no-such-file.txt"), base::Bind(&TestDownloadCallback, &result, &dummy_contents)); ui_test_utils::RunMessageLoop(); diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc index 301c1b5..ec52f06 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system.cc +++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc @@ -939,6 +939,7 @@ void GDataFileSystem::GetFile(const FilePath& file_path, // the caching layer is not implemented yet. For now, always download from // the cloud. documents_service_->DownloadFile( + file_info->GetFilePath(), file_info->content_url(), base::Bind(&GDataFileSystem::OnFileDownloaded, weak_ptr_factory_.GetWeakPtr(), @@ -950,6 +951,7 @@ void GDataFileSystem::InitiateUpload( const std::string& content_type, int64 content_length, const FilePath& destination_directory, + const FilePath& virtual_path, const InitiateUploadCallback& callback) { GURL destination_directory_url = GetUploadUrlForDirectory(destination_directory); @@ -968,7 +970,8 @@ void GDataFileSystem::InitiateUpload( InitiateUploadParams(file_name, content_type, content_length, - destination_directory_url), + destination_directory_url, + virtual_path), base::Bind(&GDataFileSystem::OnUploadLocationReceived, weak_ptr_factory_.GetWeakPtr(), callback, diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.h b/chrome/browser/chromeos/gdata/gdata_file_system.h index c539f58..3f0b842 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system.h +++ b/chrome/browser/chromeos/gdata/gdata_file_system.h @@ -270,6 +270,7 @@ class GDataFileSystem : public ProfileKeyedService { const std::string& content_type, int64 content_length, const FilePath& destination_directory, + const FilePath& virtual_path, const InitiateUploadCallback& callback); // Resumes upload operation for chunk of file defined in |params.. diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc index 3020bb6..9b0869d 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc +++ b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc @@ -1215,7 +1215,7 @@ TEST_F(GDataFileSystemTest, GetFile) { callback_helper_.get()); EXPECT_CALL(*mock_doc_service_, - DownloadFile(GURL("https://file_content_url/"), _)); + DownloadFile(_, GURL("https://file_content_url/"), _)); FilePath file_in_root(FILE_PATH_LITERAL("gdata/File 1.txt")); file_system_->GetFile(file_in_root, callback); diff --git a/chrome/browser/chromeos/gdata/gdata_mock.cc b/chrome/browser/chromeos/gdata/gdata_mock.cc index 4eae041..0f12e30 100644 --- a/chrome/browser/chromeos/gdata/gdata_mock.cc +++ b/chrome/browser/chromeos/gdata/gdata_mock.cc @@ -48,7 +48,7 @@ MockDocumentsService::MockDocumentsService() { .WillByDefault(Invoke(this, &MockDocumentsService::GetDocumentsStub)); ON_CALL(*this, DeleteDocument(_, _)) .WillByDefault(Invoke(this, &MockDocumentsService::DeleteDocumentStub)); - ON_CALL(*this, DownloadDocument(_, _, _)) + ON_CALL(*this, DownloadDocument(_, _, _, _)) .WillByDefault(Invoke(this, &MockDocumentsService::DownloadDocumentStub)); ON_CALL(*this, CopyDocument(_, _, _)) .WillByDefault(Invoke(this, &MockDocumentsService::CopyDocumentStub)); @@ -62,7 +62,7 @@ MockDocumentsService::MockDocumentsService() { Invoke(this, &MockDocumentsService::RemoveResourceFromDirectoryStub)); ON_CALL(*this, CreateDirectory(_, _, _)) .WillByDefault(Invoke(this, &MockDocumentsService::CreateDirectoryStub)); - ON_CALL(*this, DownloadFile(_, _)) + ON_CALL(*this, DownloadFile(_, _, _)) .WillByDefault(Invoke(this, &MockDocumentsService::DownloadFileStub)); // Fill in the default values for mock feeds. @@ -96,6 +96,7 @@ void MockDocumentsService::DeleteDocumentStub( } void MockDocumentsService::DownloadDocumentStub( + const FilePath& virtual_path, const GURL& content_url, DocumentExportFormat format, const DownloadActionCallback& callback) { @@ -152,6 +153,7 @@ void MockDocumentsService::CreateDirectoryStub( } void MockDocumentsService::DownloadFileStub( + const FilePath& virtual_path, const GURL& content_url, const DownloadActionCallback& callback) { base::MessageLoopProxy::current()->PostTask( diff --git a/chrome/browser/chromeos/gdata/gdata_mock.h b/chrome/browser/chromeos/gdata/gdata_mock.h index 8956404..451c62d 100644 --- a/chrome/browser/chromeos/gdata/gdata_mock.h +++ b/chrome/browser/chromeos/gdata/gdata_mock.h @@ -34,7 +34,8 @@ class MockDocumentsService : public DocumentsServiceInterface { const GetDataCallback& callback)); MOCK_METHOD2(DeleteDocument, void(const GURL& document_url, const EntryActionCallback& callback)); - MOCK_METHOD3(DownloadDocument, void(const GURL& content_url, + MOCK_METHOD4(DownloadDocument, void(const FilePath& virtual_path, + const GURL& content_url, DocumentExportFormat format, const DownloadActionCallback& callback)); MOCK_METHOD3(CopyDocument, void(const GURL& document_url, @@ -56,7 +57,8 @@ class MockDocumentsService : public DocumentsServiceInterface { void(const GURL& parent_content_url, const FilePath::StringType& directory_name, const GetDataCallback& callback)); - MOCK_METHOD2(DownloadFile, void(const GURL& content_url, + MOCK_METHOD3(DownloadFile, void(const FilePath& virtual_path, + const GURL& content_url, const DownloadActionCallback& callback)); MOCK_METHOD2(InitiateUpload, void(const InitiateUploadParams& upload_file_info, @@ -82,7 +84,8 @@ class MockDocumentsService : public DocumentsServiceInterface { // Will call |callback| with HTTP_SUCCESS, the given URL, and the host+path // portion of the URL as the temporary file path. - void DownloadDocumentStub(const GURL& content_url, + void DownloadDocumentStub(const FilePath& virtual_path, + const GURL& content_url, DocumentExportFormat format, const DownloadActionCallback& callback); @@ -116,7 +119,8 @@ class MockDocumentsService : public DocumentsServiceInterface { // Will call |callback| with HTTP_SUCCESS, the given URL, and the host+path // portion of the URL as the temporary file path. - void DownloadFileStub(const GURL& content_url, + void DownloadFileStub(const FilePath& virtual_path, + const GURL& content_url, const DownloadActionCallback& callback); void set_feed_data(base::Value* document_data) { diff --git a/chrome/browser/chromeos/gdata/gdata_params.cc b/chrome/browser/chromeos/gdata/gdata_params.cc index 1fbbe30b..5e9f3ce 100644 --- a/chrome/browser/chromeos/gdata/gdata_params.cc +++ b/chrome/browser/chromeos/gdata/gdata_params.cc @@ -25,11 +25,13 @@ InitiateUploadParams::InitiateUploadParams( const std::string& title, const std::string& content_type, int64 content_length, - const GURL& resumable_create_media_link) + const GURL& resumable_create_media_link, + const FilePath& virtual_path) : title(title), content_type(content_type), content_length(content_length), - resumable_create_media_link(resumable_create_media_link) { + resumable_create_media_link(resumable_create_media_link), + virtual_path(virtual_path) { } InitiateUploadParams::~InitiateUploadParams() { @@ -41,13 +43,15 @@ ResumeUploadParams::ResumeUploadParams(const std::string& title, int64 content_length, const std::string& content_type, scoped_refptr<net::IOBuffer> buf, - const GURL& upload_location) : title(title), - start_range(start_range), - end_range(end_range), - content_length(content_length), - content_type(content_type), - buf(buf), - upload_location(upload_location) { + const GURL& upload_location, + const FilePath& virtual_path) : title(title), + start_range(start_range), + end_range(end_range), + content_length(content_length), + content_type(content_type), + buf(buf), + upload_location(upload_location), + virtual_path(virtual_path) { } ResumeUploadParams::~ResumeUploadParams() { diff --git a/chrome/browser/chromeos/gdata/gdata_params.h b/chrome/browser/chromeos/gdata/gdata_params.h index 1d9682a..675383a 100644 --- a/chrome/browser/chromeos/gdata/gdata_params.h +++ b/chrome/browser/chromeos/gdata/gdata_params.h @@ -35,6 +35,7 @@ struct ResumeUploadResponse { int64 end_range_received; std::string resource_id; std::string md5_checksum; + FilePath virtual_path; }; // Struct for passing params needed for DocumentsService::ResumeUpload() calls. @@ -45,7 +46,8 @@ struct ResumeUploadParams { int64 content_length, const std::string& content_type, scoped_refptr<net::IOBuffer> buf, - const GURL& upload_location); + const GURL& upload_location, + const FilePath& virtual_path); ~ResumeUploadParams(); std::string title; // Title to be used for file to be uploaded. @@ -55,6 +57,7 @@ struct ResumeUploadParams { std::string content_type; // Content-Type of file. scoped_refptr<net::IOBuffer> buf; // Holds current content to be uploaded. GURL upload_location; // Url of where to upload the file to. + FilePath virtual_path; // Virtual GData path of the file seen in the UI. }; // Struct for passing params needed for DocumentsService::InitiateUpload() @@ -63,13 +66,15 @@ struct InitiateUploadParams { InitiateUploadParams(const std::string& title, const std::string& content_type, int64 content_length, - const GURL& resumable_create_media_link); + const GURL& resumable_create_media_link, + const FilePath& virtual_path); ~InitiateUploadParams(); std::string title; std::string content_type; int64 content_length; GURL resumable_create_media_link; + const FilePath& virtual_path; }; // Different callback types for various functionalities in DocumentsService. diff --git a/chrome/browser/chromeos/gdata/gdata_uploader.cc b/chrome/browser/chromeos/gdata/gdata_uploader.cc index 5325f8c..850c628 100644 --- a/chrome/browser/chromeos/gdata/gdata_uploader.cc +++ b/chrome/browser/chromeos/gdata/gdata_uploader.cc @@ -119,6 +119,7 @@ void GDataUploader::OpenCompletionCallback(const GURL& file_url, int result) { upload_file_info->content_type, upload_file_info->content_length, upload_file_info->gdata_path.DirName(), + upload_file_info->gdata_path, base::Bind(&GDataUploader::OnUploadLocationReceived, uploader_factory_.GetWeakPtr(), upload_file_info->file_url)); @@ -208,7 +209,8 @@ void GDataUploader::ReadCompletionCallback( upload_file_info->content_length, upload_file_info->content_type, upload_file_info->buf, - upload_file_info->upload_location), + upload_file_info->upload_location, + upload_file_info->gdata_path), base::Bind(&GDataUploader::OnResumeUploadResponseReceived, uploader_factory_.GetWeakPtr(), upload_file_info->file_url)); |