diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 01:17:16 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 01:17:16 +0000 |
commit | 5d9226721d2933a3eaa5fd7a27387d5cc010d3a9 (patch) | |
tree | 1ca0a03f2470092427679c61afd4acbfc727fe54 | |
parent | fee7b59ea7dfacffea9e25f29606a0de353ce70a (diff) | |
download | chromium_src-5d9226721d2933a3eaa5fd7a27387d5cc010d3a9.zip chromium_src-5d9226721d2933a3eaa5fd7a27387d5cc010d3a9.tar.gz chromium_src-5d9226721d2933a3eaa5fd7a27387d5cc010d3a9.tar.bz2 |
clean-up: Purge ambiguous uses of the term "Document".
In Drive/GData code, sometimes it meant a hosted document like
Spreadsheet, and sometimes meant general entries (regular files /
hosted documents / collections) on Drive. This patch disambiguates
them by the following 5 renamings.
- DocumentEntry => ResourceEntry.
- GetDocuments => GetResourceList.
- DownloadDocument => DownloadHostedDocument.
- CopyDocument => CopyHostedDocument.
- DeleteDocument => DeleteResource.
Along the way, also clarified some parameter names.
- {document_url, resource_url} => {edit_url, content_url}
BUG=164090
TBR=sky@chromium.org
(tbr for chrome_browser gyp change)
Review URL: https://codereview.chromium.org/11468019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172018 0039d316-1c4b-4281-b951-d872f2087c98
54 files changed, 825 insertions, 830 deletions
diff --git a/chrome/browser/chromeos/drive/document_entry_conversion.h b/chrome/browser/chromeos/drive/document_entry_conversion.h deleted file mode 100644 index afa157e..0000000 --- a/chrome/browser/chromeos/drive/document_entry_conversion.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DOCUMENT_ENTRY_CONVERSION_H_ -#define CHROME_BROWSER_CHROMEOS_DRIVE_DOCUMENT_ENTRY_CONVERSION_H_ - -#include <string> - -#include "base/memory/scoped_ptr.h" - -class GURL; - -namespace google_apis { -class DocumentEntry; -} - -namespace drive { - -class DriveEntryProto; - -// Converts a google_apis::DocumentEntry into a DriveEntryProto. -DriveEntryProto ConvertDocumentEntryToDriveEntryProto( - const google_apis::DocumentEntry& document_entry); - -} // namespace drive - -#endif // CHROME_BROWSER_CHROMEOS_DRIVE_DOCUMENT_ENTRY_CONVERSION_H_ diff --git a/chrome/browser/chromeos/drive/drive_api_service.cc b/chrome/browser/chromeos/drive/drive_api_service.cc index 9234e92..152aacc 100644 --- a/chrome/browser/chromeos/drive/drive_api_service.cc +++ b/chrome/browser/chromeos/drive/drive_api_service.cc @@ -93,7 +93,7 @@ DriveAPIService::GetProgressStatusList() const { return operation_registry()->GetProgressStatusList(); } -void DriveAPIService::GetDocuments( +void DriveAPIService::GetResourceList( const GURL& url, int64 start_changestamp, const std::string& search_query, @@ -143,7 +143,7 @@ void DriveAPIService::GetChangelist( callback)); } -void DriveAPIService::GetDocumentEntry( +void DriveAPIService::GetResourceEntry( const std::string& resource_id, const google_apis::GetDataCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -178,10 +178,10 @@ void DriveAPIService::GetApplicationInfo( callback)); } -void DriveAPIService::DownloadDocument( +void DriveAPIService::DownloadHostedDocument( const FilePath& virtual_path, const FilePath& local_cache_path, - const GURL& document_url, + const GURL& content_url, google_apis::DocumentExportFormat format, const google_apis::DownloadActionCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -194,7 +194,7 @@ void DriveAPIService::DownloadDocument( void DriveAPIService::DownloadFile( const FilePath& virtual_path, const FilePath& local_cache_path, - const GURL& document_url, + const GURL& content_url, const google_apis::DownloadActionCallback& download_action_callback, const google_apis::GetContentCallback& get_content_callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -205,8 +205,8 @@ void DriveAPIService::DownloadFile( NOTREACHED(); } -void DriveAPIService::DeleteDocument( - const GURL& document_url, +void DriveAPIService::DeleteResource( + const GURL& edit_url, const google_apis::EntryActionCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -226,7 +226,7 @@ void DriveAPIService::AddNewDirectory( NOTREACHED(); } -void DriveAPIService::CopyDocument( +void DriveAPIService::CopyHostedDocument( const std::string& resource_id, const FilePath::StringType& new_name, const google_apis::GetDataCallback& callback) { @@ -238,7 +238,7 @@ void DriveAPIService::CopyDocument( } void DriveAPIService::RenameResource( - const GURL& resource_url, + const GURL& edit_url, const FilePath::StringType& new_name, const google_apis::EntryActionCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -250,7 +250,7 @@ void DriveAPIService::RenameResource( void DriveAPIService::AddResourceToDirectory( const GURL& parent_content_url, - const GURL& resource_url, + const GURL& edit_url, const google_apis::EntryActionCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -291,7 +291,7 @@ void DriveAPIService::ResumeUpload( } void DriveAPIService::AuthorizeApp( - const GURL& resource_url, + const GURL& edit_url, const std::string& app_ids, const google_apis::GetDataCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); diff --git a/chrome/browser/chromeos/drive/drive_api_service.h b/chrome/browser/chromeos/drive/drive_api_service.h index b1ed7eea..50bc5c5 100644 --- a/chrome/browser/chromeos/drive/drive_api_service.h +++ b/chrome/browser/chromeos/drive/drive_api_service.h @@ -58,14 +58,14 @@ class DriveAPIService : public google_apis::DriveServiceInterface, const OVERRIDE; virtual bool HasAccessToken() const OVERRIDE; virtual bool HasRefreshToken() const OVERRIDE; - virtual void GetDocuments( + virtual void GetResourceList( const GURL& feed_url, int64 start_changestamp, const std::string& search_query, bool shared_with_me, const std::string& directory_resource_id, const google_apis::GetDataCallback& callback) OVERRIDE; - virtual void GetDocumentEntry( + virtual void GetResourceEntry( const std::string& resource_id, const google_apis::GetDataCallback& callback) OVERRIDE; @@ -73,10 +73,10 @@ class DriveAPIService : public google_apis::DriveServiceInterface, const google_apis::GetDataCallback& callback) OVERRIDE; virtual void GetApplicationInfo( const google_apis::GetDataCallback& callback) OVERRIDE; - virtual void DeleteDocument( - const GURL& document_url, + virtual void DeleteResource( + const GURL& edit_url, const google_apis::EntryActionCallback& callback) OVERRIDE; - virtual void DownloadDocument( + virtual void DownloadHostedDocument( const FilePath& virtual_path, const FilePath& local_cache_path, const GURL& content_url, @@ -88,17 +88,17 @@ class DriveAPIService : public google_apis::DriveServiceInterface, const GURL& content_url, const google_apis::DownloadActionCallback& download_action_callback, const google_apis::GetContentCallback& get_content_callback) OVERRIDE; - virtual void CopyDocument( + virtual void CopyHostedDocument( const std::string& resource_id, const FilePath::StringType& new_name, const google_apis::GetDataCallback& callback) OVERRIDE; virtual void RenameResource( - const GURL& document_url, + const GURL& edit_url, const FilePath::StringType& new_name, const google_apis::EntryActionCallback& callback) OVERRIDE; virtual void AddResourceToDirectory( const GURL& parent_content_url, - const GURL& resource_url, + const GURL& edit_url, const google_apis::EntryActionCallback& callback) OVERRIDE; virtual void RemoveResourceFromDirectory( const GURL& parent_content_url, @@ -115,7 +115,7 @@ class DriveAPIService : public google_apis::DriveServiceInterface, const google_apis::ResumeUploadParams& params, const google_apis::ResumeUploadCallback& callback) OVERRIDE; virtual void AuthorizeApp( - const GURL& resource_url, + const GURL& edit_url, const std::string& app_id, const google_apis::GetDataCallback& callback) OVERRIDE; diff --git a/chrome/browser/chromeos/drive/drive_feed_loader.cc b/chrome/browser/chromeos/drive/drive_feed_loader.cc index f1cf3ce..b13f21e 100644 --- a/chrome/browser/chromeos/drive/drive_feed_loader.cc +++ b/chrome/browser/chromeos/drive/drive_feed_loader.cc @@ -182,7 +182,7 @@ struct DriveFeedLoader::LoadFeedParams { bool load_subsequent_feeds; const LoadFeedListCallback feed_load_callback; ScopedVector<google_apis::DocumentFeed> feed_list; - scoped_ptr<GetDocumentsUiState> ui_state; + scoped_ptr<GetResourceListUiState> ui_state; }; // Defines set of parameters sent to callback OnProtoLoaded(). @@ -228,8 +228,8 @@ struct DriveFeedLoader::UpdateMetadataParams { // the current update state. In order to make users comfortable, // we increment the number of fetched documents with more frequent but smaller // steps than actual fetching. -struct DriveFeedLoader::GetDocumentsUiState { - explicit GetDocumentsUiState(base::TimeTicks start_time) +struct DriveFeedLoader::GetResourceListUiState { + explicit GetResourceListUiState(base::TimeTicks start_time) : num_fetched_documents(0), num_showing_documents(0), start_time(start_time), @@ -248,7 +248,7 @@ struct DriveFeedLoader::GetDocumentsUiState { // Time elapsed since the feed fetching was started. base::TimeDelta feed_fetching_elapsed_time; - base::WeakPtrFactory<GetDocumentsUiState> weak_ptr_factory; + base::WeakPtrFactory<GetResourceListUiState> weak_ptr_factory; }; DriveFeedLoader::DriveFeedLoader( @@ -405,7 +405,7 @@ void DriveFeedLoader::LoadFromServer(scoped_ptr<LoadFeedParams> params) { // base::Passed() may get evaluated first, so get a pointer to params. LoadFeedParams* params_ptr = params.get(); if (google_apis::util::IsDriveV2ApiEnabled()) { - scheduler_->GetDocuments( + scheduler_->GetResourceList( params_ptr->feed_to_load, params_ptr->start_changestamp, std::string(), // No search query. @@ -416,13 +416,13 @@ void DriveFeedLoader::LoadFromServer(scoped_ptr<LoadFeedParams> params) { base::Passed(¶ms), start_time)); } else { - scheduler_->GetDocuments( + scheduler_->GetResourceList( params_ptr->feed_to_load, params_ptr->start_changestamp, params_ptr->search_query, params_ptr->shared_with_me, params_ptr->directory_resource_id, - base::Bind(&DriveFeedLoader::OnGetDocuments, + base::Bind(&DriveFeedLoader::OnGetResourceList, weak_ptr_factory_.GetWeakPtr(), base::Passed(¶ms), start_time)); @@ -477,10 +477,10 @@ void DriveFeedLoader::UpdateMetadataFromFeedAfterLoadFromServer( params.callback)); } -void DriveFeedLoader::OnGetDocuments(scoped_ptr<LoadFeedParams> params, - base::TimeTicks start_time, - google_apis::GDataErrorCode status, - scoped_ptr<base::Value> data) { +void DriveFeedLoader::OnGetResourceList(scoped_ptr<LoadFeedParams> params, + base::TimeTicks start_time, + google_apis::GDataErrorCode status, + scoped_ptr<base::Value> data) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (params->feed_list.empty()) { @@ -536,9 +536,9 @@ void DriveFeedLoader::OnParseFeed( // Check if we need to collect more data to complete the directory list. if (has_next_feed_url && !next_feed_url.is_empty()) { // Post an UI update event to make the UI smoother. - GetDocumentsUiState* ui_state = params->ui_state.get(); + GetResourceListUiState* ui_state = params->ui_state.get(); if (ui_state == NULL) { - ui_state = new GetDocumentsUiState(base::TimeTicks::Now()); + ui_state = new GetResourceListUiState(base::TimeTicks::Now()); params->ui_state.reset(ui_state); } DCHECK(ui_state); @@ -559,13 +559,13 @@ void DriveFeedLoader::OnParseFeed( // pointer so we can use it bellow. LoadFeedParams* params_ptr = params.get(); // Kick off the remaining part of the feeds. - scheduler_->GetDocuments( + scheduler_->GetResourceList( next_feed_url, params_ptr->start_changestamp, params_ptr->search_query, params_ptr->shared_with_me, params_ptr->directory_resource_id, - base::Bind(&DriveFeedLoader::OnGetDocuments, + base::Bind(&DriveFeedLoader::OnGetResourceList, weak_ptr_factory_.GetWeakPtr(), base::Passed(¶ms), start_time)); @@ -640,9 +640,9 @@ void DriveFeedLoader::OnGetChangelist(scoped_ptr<LoadFeedParams> params, // Check if we need to collect more data to complete the directory list. if (has_next_feed) { // Post an UI update event to make the UI smoother. - GetDocumentsUiState* ui_state = params->ui_state.get(); + GetResourceListUiState* ui_state = params->ui_state.get(); if (ui_state == NULL) { - ui_state = new GetDocumentsUiState(base::TimeTicks::Now()); + ui_state = new GetResourceListUiState(base::TimeTicks::Now()); params->ui_state.reset(ui_state); } DCHECK(ui_state); @@ -662,7 +662,7 @@ void DriveFeedLoader::OnGetChangelist(scoped_ptr<LoadFeedParams> params, // Kick off the remaining part of the feeds. // Extract the pointer so we can use it bellow. LoadFeedParams* params_ptr = params.get(); - scheduler_->GetDocuments( + scheduler_->GetResourceList( current_feed->next_link(), params_ptr->start_changestamp, std::string(), // No search query. @@ -687,7 +687,7 @@ void DriveFeedLoader::OnGetChangelist(scoped_ptr<LoadFeedParams> params, } void DriveFeedLoader::OnNotifyDocumentFeedFetched( - base::WeakPtr<GetDocumentsUiState> ui_state) { + base::WeakPtr<GetResourceListUiState> ui_state) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!ui_state) { diff --git a/chrome/browser/chromeos/drive/drive_feed_loader.h b/chrome/browser/chromeos/drive/drive_feed_loader.h index 4df78d6..af2d2e9 100644 --- a/chrome/browser/chromeos/drive/drive_feed_loader.h +++ b/chrome/browser/chromeos/drive/drive_feed_loader.h @@ -99,7 +99,7 @@ class DriveFeedLoader { bool refreshing() const { return refreshing_; } private: - struct GetDocumentsUiState; + struct GetResourceListUiState; struct LoadFeedParams; struct LoadRootFeedParams; struct UpdateMetadataParams; @@ -138,20 +138,20 @@ class DriveFeedLoader { const ScopedVector<google_apis::DocumentFeed>& feed_list, DriveFileError error); - // Callback for handling response from |GDataWapiService::GetDocuments|. + // Callback for handling response from |GDataWapiService::GetResourceList|. // Invokes |callback| when done. // |callback| must not be null. - void OnGetDocuments(scoped_ptr<LoadFeedParams> params, - base::TimeTicks start_time, - google_apis::GDataErrorCode status, - scoped_ptr<base::Value> data); + void OnGetResourceList(scoped_ptr<LoadFeedParams> params, + base::TimeTicks start_time, + google_apis::GDataErrorCode status, + scoped_ptr<base::Value> data); // Callback for handling results of feed parse. void OnParseFeed(scoped_ptr<LoadFeedParams> params, base::TimeTicks start_time, scoped_ptr<google_apis::DocumentFeed> current_feed); - // Callback for handling response from |DriveAPIService::GetDocuments|. + // Callback for handling response from |DriveAPIService::GetResourceList|. // Invokes |callback| when done. // |callback| must not be null. void OnGetChangelist(scoped_ptr<LoadFeedParams> params, @@ -162,8 +162,9 @@ class DriveFeedLoader { // Save filesystem to disk. void SaveFileSystem(); - // Callback for handling UI updates caused by document fetching. - void OnNotifyDocumentFeedFetched(base::WeakPtr<GetDocumentsUiState> ui_state); + // Callback for handling UI updates caused by feed fetching. + void OnNotifyDocumentFeedFetched( + base::WeakPtr<GetResourceListUiState> ui_state); // Callback for DriveFeedProcessor::ApplyFeeds. void NotifyDirectoryChanged(bool should_notify, diff --git a/chrome/browser/chromeos/drive/drive_feed_processor.cc b/chrome/browser/chromeos/drive/drive_feed_processor.cc index 6e1fc1b..5caaff3 100644 --- a/chrome/browser/chromeos/drive/drive_feed_processor.cc +++ b/chrome/browser/chromeos/drive/drive_feed_processor.cc @@ -5,10 +5,10 @@ #include <utility> #include "base/metrics/histogram.h" -#include "chrome/browser/chromeos/drive/document_entry_conversion.h" #include "chrome/browser/chromeos/drive/drive.pb.h" #include "chrome/browser/chromeos/drive/drive_feed_processor.h" #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" +#include "chrome/browser/chromeos/drive/resource_entry_conversion.h" #include "content/public/browser/browser_thread.h" using content::BrowserThread; @@ -305,7 +305,7 @@ void DriveFeedProcessor::FeedToEntryProtoMap( const google_apis::DocumentFeed* feed = feed_list[i]; // Get upload url from the root feed. Links for all other collections will - // be handled in ConvertDocumentEntryToDriveEntryProto. + // be handled in ConvertResourceEntryToDriveEntryProto. if (i == 0) { const google_apis::Link* root_feed_upload_link = feed->GetLinkByType( google_apis::Link::LINK_RESUMABLE_CREATE_MEDIA); @@ -317,8 +317,8 @@ void DriveFeedProcessor::FeedToEntryProtoMap( } for (size_t j = 0; j < feed->entries().size(); ++j) { - const google_apis::DocumentEntry* doc = feed->entries()[j]; - DriveEntryProto entry_proto = ConvertDocumentEntryToDriveEntryProto(*doc); + const google_apis::ResourceEntry* doc = feed->entries()[j]; + DriveEntryProto entry_proto = ConvertResourceEntryToDriveEntryProto(*doc); // Some document entries don't map into files (i.e. sites). if (entry_proto.resource_id().empty()) continue; diff --git a/chrome/browser/chromeos/drive/drive_file_system.cc b/chrome/browser/chromeos/drive/drive_file_system.cc index 38a087a3..c1955059 100644 --- a/chrome/browser/chromeos/drive/drive_file_system.cc +++ b/chrome/browser/chromeos/drive/drive_file_system.cc @@ -14,7 +14,6 @@ #include "base/stringprintf.h" #include "base/threading/sequenced_worker_pool.h" #include "base/values.h" -#include "chrome/browser/chromeos/drive/document_entry_conversion.h" #include "chrome/browser/chromeos/drive/drive.pb.h" #include "chrome/browser/chromeos/drive/drive_cache.h" #include "chrome/browser/chromeos/drive/drive_feed_loader.h" @@ -25,6 +24,7 @@ #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" #include "chrome/browser/chromeos/drive/file_system/move_operation.h" #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" +#include "chrome/browser/chromeos/drive/resource_entry_conversion.h" #include "chrome/browser/google_apis/drive_api_parser.h" #include "chrome/browser/google_apis/drive_api_util.h" #include "chrome/browser/google_apis/drive_service_interface.h" @@ -959,14 +959,14 @@ void DriveFileSystem::OnGetFileFromCache( // - if we have enough space, start downloading the file from the server GetFileFromCacheParams params(in_params); params.cache_file_path = cache_file_path; - drive_service_->GetDocumentEntry( + drive_service_->GetResourceEntry( params.resource_id, - base::Bind(&DriveFileSystem::OnGetDocumentEntry, + base::Bind(&DriveFileSystem::OnGetResourceEntry, ui_weak_ptr_, params)); } -void DriveFileSystem::OnGetDocumentEntry(const GetFileFromCacheParams& params, +void DriveFileSystem::OnGetResourceEntry(const GetFileFromCacheParams& params, google_apis::GDataErrorCode status, scoped_ptr<base::Value> data) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -981,13 +981,13 @@ void DriveFileSystem::OnGetDocumentEntry(const GetFileFromCacheParams& params, return; } - scoped_ptr<google_apis::DocumentEntry> doc_entry; + scoped_ptr<google_apis::ResourceEntry> doc_entry; if (!google_apis::util::IsDriveV2ApiEnabled()) { - doc_entry = google_apis::DocumentEntry::ExtractAndParse(*data); + doc_entry = google_apis::ResourceEntry::ExtractAndParse(*data); } else { scoped_ptr<google_apis::FileResource> file_resource = google_apis::FileResource::CreateFrom(*data); - doc_entry = google_apis::DocumentEntry::CreateFromFileResource( + doc_entry = google_apis::ResourceEntry::CreateFromFileResource( *file_resource); } @@ -1376,8 +1376,8 @@ void DriveFileSystem::AddNewDirectory( resource_metadata_->AddEntryToDirectory( params.created_directory_path.DirName(), - scoped_ptr<google_apis::DocumentEntry>( - google_apis::DocumentEntry::ExtractAndParse(*data)), + scoped_ptr<google_apis::ResourceEntry>( + google_apis::ResourceEntry::ExtractAndParse(*data)), base::Bind(&DriveFileSystem::ContinueCreateDirectory, ui_weak_ptr_, params)); @@ -1440,7 +1440,7 @@ void DriveFileSystem::OnSearch( const base::Closure callback = base::Bind( search_callback, DRIVE_FILE_OK, next_feed, base::Passed(&result_vec)); - const ScopedVector<google_apis::DocumentEntry>& entries = feed->entries(); + const ScopedVector<google_apis::ResourceEntry>& entries = feed->entries(); if (entries.empty()) { callback.Run(); return; @@ -1453,7 +1453,7 @@ void DriveFileSystem::OnSearch( // Run the callback if this is the last iteration of the loop. const bool should_run_callback = (i + 1 == entries.size()); resource_metadata_->RefreshEntryProto( - ConvertDocumentEntryToDriveEntryProto(*entries[i]), + ConvertResourceEntryToDriveEntryProto(*entries[i]), base::Bind(&DriveFileSystem::AddToSearchResults, ui_weak_ptr_, results, @@ -1775,7 +1775,7 @@ void DriveFileSystem::ContinueFindFirstMissingParentDirectory( void DriveFileSystem::AddUploadedFile( const FilePath& directory_path, - scoped_ptr<google_apis::DocumentEntry> doc_entry, + scoped_ptr<google_apis::ResourceEntry> doc_entry, const FilePath& file_content_path, const FileOperationCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); diff --git a/chrome/browser/chromeos/drive/drive_file_system.h b/chrome/browser/chromeos/drive/drive_file_system.h index 9cbf598..ab529bc 100644 --- a/chrome/browser/chromeos/drive/drive_file_system.h +++ b/chrome/browser/chromeos/drive/drive_file_system.h @@ -129,7 +129,7 @@ class DriveFileSystem : public DriveFileSystemInterface, virtual void GetAvailableSpace( const GetAvailableSpaceCallback& callback) OVERRIDE; virtual void AddUploadedFile(const FilePath& directory_path, - scoped_ptr<google_apis::DocumentEntry> doc_entry, + scoped_ptr<google_apis::ResourceEntry> doc_entry, const FilePath& file_content_path, const FileOperationCallback& callback) OVERRIDE; virtual DriveFileSystemMetadata GetMetadata() const OVERRIDE; @@ -426,16 +426,16 @@ class DriveFileSystem : public DriveFileSystemInterface, DriveFileError error, const FilePath& cache_file_path); - // Callback for |drive_service_->GetDocumentEntry|. - // It is called before file download. If GetDocumentEntry was successful, + // Callback for |drive_service_->GetResourceEntry|. + // It is called before file download. If GetResourceEntry was successful, // file download procedure is started for the file. The file is downloaded // from the content url extracted from the fetched metadata. - void OnGetDocumentEntry(const GetFileFromCacheParams& params, + void OnGetResourceEntry(const GetFileFromCacheParams& params, google_apis::GDataErrorCode status, scoped_ptr<base::Value> data); // Check available space using file size from the fetched metadata. Called - // from OnGetDocumentEntry after RefreshFile is complete. + // from OnGetResourceEntry after RefreshFile is complete. void CheckForSpaceBeforeDownload( const GetFileFromCacheParams& params, int64 file_size, diff --git a/chrome/browser/chromeos/drive/drive_file_system_interface.h b/chrome/browser/chromeos/drive/drive_file_system_interface.h index b7e0b29..d726dcc8f 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_interface.h +++ b/chrome/browser/chromeos/drive/drive_file_system_interface.h @@ -14,7 +14,7 @@ #include "chrome/browser/google_apis/gdata_wapi_operations.h" namespace google_apis { -class DocumentEntry; +class ResourceEntry; } namespace drive { @@ -335,7 +335,7 @@ class DriveFileSystemInterface { // |callback| will be called on the UI thread upon completion of operation. // |callback| must not be null. virtual void AddUploadedFile(const FilePath& directory_path, - scoped_ptr<google_apis::DocumentEntry> doc_entry, + scoped_ptr<google_apis::ResourceEntry> doc_entry, const FilePath& file_content_path, const FileOperationCallback& callback) = 0; diff --git a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc index 57e49dd..02c509d 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc @@ -83,21 +83,21 @@ void DriveSearchCallback( } // Action used to set mock expectations for -// DriveServiceInterface::GetDocumentEntry(). -ACTION_P2(MockGetDocumentEntry, status, value) { +// DriveServiceInterface::GetResourceEntry(). +ACTION_P2(MockGetResourceEntry, status, value) { base::MessageLoopProxy::current()->PostTask(FROM_HERE, base::Bind(arg1, status, base::Passed(value))); } // Action used to set mock expectations for -// DriveFileSystem::CopyDocument(). -ACTION_P2(MockCopyDocument, status, value) { +// DriveFileSystem::CopyHostedDocument(). +ACTION_P2(MockCopyHostedDocument, status, value) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, base::Bind(arg2, status, base::Passed(value))); } -ACTION(MockFailingGetDocuments) { +ACTION(MockFailingGetResourceList) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, base::Bind(arg5, google_apis::GDATA_NO_CONNECTION, @@ -140,8 +140,8 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile("gdata/uploaded_file.json"); - scoped_ptr<google_apis::DocumentEntry> document_entry( - google_apis::DocumentEntry::ExtractAndParse(*value)); + scoped_ptr<google_apis::ResourceEntry> resource_entry( + google_apis::ResourceEntry::ExtractAndParse(*value)); base::MessageLoopProxy::current()->PostTask( FROM_HERE, @@ -149,7 +149,7 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface { google_apis::DRIVE_UPLOAD_OK, drive_file_path, local_file_path, - base::Passed(&document_entry))); + base::Passed(&resource_entry))); const int kUploadId = 123; return kUploadId; @@ -185,10 +185,10 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface { DCHECK_EQ("drive/File 1.txt", drive_file_path.value()); const std::string kResourceId = "file:2_file_resource_id"; - // Create a google_apis::DocumentEntry, which is needed to return a value + // Create a google_apis::ResourceEntry, which is needed to return a value // from this function. TODO(satorux): This should be cleaned // up. crbug.com/134240. - scoped_ptr<google_apis::DocumentEntry> document_entry; + scoped_ptr<google_apis::ResourceEntry> resource_entry; scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile("gdata/root_feed.json"); if (!value.get()) @@ -204,11 +204,11 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface { if (entry_list->GetDictionary(i, &entry) && entry->GetString("gd$resourceId.$t", &resource_id) && resource_id == kResourceId) { - document_entry = google_apis::DocumentEntry::CreateFrom(*entry); + resource_entry = google_apis::ResourceEntry::CreateFrom(*entry); } } } - if (!document_entry) + if (!resource_entry) return -1; base::MessageLoopProxy::current()->PostTask( @@ -217,7 +217,7 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface { google_apis::DRIVE_UPLOAD_OK, drive_file_path, local_file_path, - base::Passed(&document_entry))); + base::Passed(&resource_entry))); const int kUploadId = 123; return kUploadId; @@ -372,7 +372,7 @@ class DriveFileSystemTest : public testing::Test { bool RemoveEntry(const FilePath& file_path) { DriveFileError error; - EXPECT_CALL(*mock_drive_service_, DeleteDocument(_, _)).Times(AnyNumber()); + EXPECT_CALL(*mock_drive_service_, DeleteResource(_, _)).Times(AnyNumber()); file_system_->Remove( file_path, false, base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error)); @@ -644,10 +644,10 @@ class DriveFileSystemTest : public testing::Test { } } - void SetExpectationsForGetDocumentEntry(scoped_ptr<base::Value>* document, + void SetExpectationsForGetResourceEntry(scoped_ptr<base::Value>* document, const std::string& resource_id) { - EXPECT_CALL(*mock_drive_service_, GetDocumentEntry(resource_id, _)) - .WillOnce(MockGetDocumentEntry(google_apis::HTTP_SUCCESS, document)); + EXPECT_CALL(*mock_drive_service_, GetResourceEntry(resource_id, _)) + .WillOnce(MockGetResourceEntry(google_apis::HTTP_SUCCESS, document)); } // Loads serialized proto file from GCache, and makes sure the root @@ -909,7 +909,7 @@ TEST_F(DriveFileSystemTest, DuplicatedAsyncInitialization) { EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); EXPECT_CALL(*mock_drive_service_, - GetDocuments(Eq(GURL()), _, _, _, _, _)).Times(1); + GetResourceList(Eq(GURL()), _, _, _, _, _)).Times(1); EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); @@ -1248,11 +1248,11 @@ TEST_F(DriveFileSystemTest, CachedFeedLoadingThenServerFeedLoading) { SaveTestFileSystem(USE_SERVER_TIMESTAMP); // SaveTestFileSystem and "account_metadata.json" have the same changestamp, - // so no request for new feeds (i.e., call to GetDocuments) should happen. + // so no request for new feeds (i.e., call to GetResourceList) should happen. // Account metadata is already set up in MockDriveService's constructor. EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); - EXPECT_CALL(*mock_drive_service_, GetDocuments(_, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mock_drive_service_, GetResourceList(_, _, _, _, _, _)).Times(0); // Kicks loading of cached file system and query for server update. EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1")))); @@ -1277,10 +1277,10 @@ TEST_F(DriveFileSystemTest, OfflineCachedFeedLoading) { EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); - // Make GetDocuments fail for simulating offline situation. This will leave + // Make GetResourceList fail for simulating offline situation. This will leave // the file system "loaded from cache, but not synced with server" state. - EXPECT_CALL(*mock_drive_service_, GetDocuments(_, _, _, _, _, _)) - .WillOnce(MockFailingGetDocuments()); + EXPECT_CALL(*mock_drive_service_, GetResourceList(_, _, _, _, _, _)) + .WillOnce(MockFailingGetResourceList()); // Kicks loading of cached file system and query for server update. EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1")))); @@ -1293,7 +1293,7 @@ TEST_F(DriveFileSystemTest, OfflineCachedFeedLoading) { "gdata/account_metadata.json").release()); EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); - EXPECT_CALL(*mock_drive_service_, GetDocuments(_, _, _, _, _, _)).Times(1); + EXPECT_CALL(*mock_drive_service_, GetResourceList(_, _, _, _, _, _)).Times(1); file_system_->CheckForUpdates(); // Expected value from reading gdata/basic_feed.json. @@ -1330,8 +1330,8 @@ TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile("gdata/document_to_download.json"); - scoped_ptr<google_apis::DocumentEntry> document_entry( - google_apis::DocumentEntry::ExtractAndParse(*value)); + scoped_ptr<google_apis::ResourceEntry> resource_entry( + google_apis::ResourceEntry::ExtractAndParse(*value)); // Transfer the local file to Drive. file_system_->TransferFileFromLocalToRemote( @@ -1369,15 +1369,15 @@ TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_HostedDocument) { EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); - // We'll copy a hosted document using CopyDocument. + // We'll copy a hosted document using CopyHostedDocument. // ".gdoc" suffix should be stripped when copying. scoped_ptr<base::Value> document = google_apis::test_util::LoadJSONFile("gdata/uploaded_document.json"); EXPECT_CALL(*mock_drive_service_, - CopyDocument(kResourceId, - FILE_PATH_LITERAL("Document 1"), - _)) - .WillOnce(MockCopyDocument(google_apis::HTTP_SUCCESS, &document)); + CopyHostedDocument(kResourceId, + FILE_PATH_LITERAL("Document 1"), + _)) + .WillOnce(MockCopyHostedDocument(google_apis::HTTP_SUCCESS, &document)); // We'll then add the hosted document to the destination directory. EXPECT_CALL(*mock_drive_service_, AddResourceToDirectory(_, _, _)).Times(1); @@ -1427,7 +1427,7 @@ TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_RegularFile) { // We will read content url from the result. scoped_ptr<base::Value> document = google_apis::test_util::LoadJSONFile("gdata/document_to_download.json"); - SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); + SetExpectationsForGetResourceEntry(&document, "file:2_file_resource_id"); // The file is obtained with the mock DriveService. EXPECT_CALL(*mock_drive_service_, @@ -2043,7 +2043,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { // We will read content url from the result. scoped_ptr<base::Value> document = google_apis::test_util::LoadJSONFile("gdata/document_to_download.json"); - SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); + SetExpectationsForGetResourceEntry(&document, "file:2_file_resource_id"); // The file is obtained with the mock DriveService. EXPECT_CALL(*mock_drive_service_, @@ -2084,7 +2084,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { // We will read content url from the result. scoped_ptr<base::Value> document = google_apis::test_util::LoadJSONFile("gdata/document_to_download.json"); - SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); + SetExpectationsForGetResourceEntry(&document, "file:2_file_resource_id"); // The file is not obtained with the mock DriveService, because of no space. EXPECT_CALL(*mock_drive_service_, @@ -2140,7 +2140,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { // We will read content url from the result. scoped_ptr<base::Value> document = google_apis::test_util::LoadJSONFile("gdata/document_to_download.json"); - SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); + SetExpectationsForGetResourceEntry(&document, "file:2_file_resource_id"); // The file is obtained with the mock DriveService, because of we freed up the // space. @@ -2193,7 +2193,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpaceButBecomeFull) { // We will read content url from the result. scoped_ptr<base::Value> document = google_apis::test_util::LoadJSONFile("gdata/document_to_download.json"); - SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); + SetExpectationsForGetResourceEntry(&document, "file:2_file_resource_id"); // The file is obtained with the mock DriveService. EXPECT_CALL(*mock_drive_service_, @@ -2237,7 +2237,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { DriveCache::CACHE_TYPE_TMP); // Make sure we don't fetch metadata for downloading file. - EXPECT_CALL(*mock_drive_service_, GetDocumentEntry(_, _)).Times(0); + EXPECT_CALL(*mock_drive_service_, GetResourceEntry(_, _)).Times(0); // Make sure we don't call downloads at all. EXPECT_CALL(*mock_drive_service_, @@ -2300,7 +2300,7 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId) { // We will read content url from the result. scoped_ptr<base::Value> document = google_apis::test_util::LoadJSONFile("gdata/document_to_download.json"); - SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); + SetExpectationsForGetResourceEntry(&document, "file:2_file_resource_id"); // The file is obtained with the mock DriveService, because it's not stored in // the cache. @@ -2494,10 +2494,10 @@ TEST_F(DriveFileSystemTest, ContentSearch) { mock_drive_service_->set_search_result("gdata/search_result_feed.json"); - // There should be only one GetDocuments request, even though search result + // There should be only one GetResourceList request, even though search result // feed has next feed url. - EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "foo", _, _, _)) - .Times(1); + EXPECT_CALL(*mock_drive_service_, GetResourceList(Eq(GURL()), _, "foo", _, _, + _)).Times(1); const SearchResultPair kExpectedResults[] = { { "drive/Directory 1/SubDirectory File 1.txt", false }, @@ -2522,10 +2522,10 @@ TEST_F(DriveFileSystemTest, ContentSearchWithNewEntry) { mock_drive_service_->set_search_result( "gdata/search_result_with_new_entry_feed.json"); - // There should be only one GetDocuments request, even though search result + // There should be only one GetResourceList request, even though search result // feed has next feed url. - EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "foo", _, _, _)) - .Times(1); + EXPECT_CALL(*mock_drive_service_, GetResourceList(Eq(GURL()), _, "foo", _, _, + _)).Times(1); // As the result of the first Search(), only entries in the current file // system snapshot are expected to be returned. @@ -2537,7 +2537,7 @@ TEST_F(DriveFileSystemTest, ContentSearchWithNewEntry) { // This will cause notification to observers (e.g., File Browser) so that // they can request search again. EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); - EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "", _, _, _)) + EXPECT_CALL(*mock_drive_service_, GetResourceList(Eq(GURL()), _, "", _, _, _)) .Times(1); EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( @@ -2568,8 +2568,8 @@ TEST_F(DriveFileSystemTest, ContentSearchEmptyResult) { mock_drive_service_->set_search_result("gdata/empty_feed.json"); - EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "foo", _, _, _)) - .Times(1); + EXPECT_CALL(*mock_drive_service_, GetResourceList(Eq(GURL()), _, "foo", _, _, + _)).Times(1); const SearchResultPair* expected_results = NULL; @@ -2601,8 +2601,8 @@ TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) { // kWAPIRootDirectoryResourceIdForTesting // is used here as the root ID is set in DriveFeedLoader::UpdateFromFeed(). EXPECT_CALL(*mock_drive_service_, - GetDocuments(Eq(GURL()), _, _, _, kWAPIRootDirectoryResourceId, - _)) + GetResourceList(Eq(GURL()), _, _, _, kWAPIRootDirectoryResourceId, + _)) .Times(1); // We'll notify the directory change to the observer. EXPECT_CALL(*mock_directory_observer_, @@ -2647,7 +2647,7 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { // We will read content url from the result. scoped_ptr<base::Value> document = google_apis::test_util::LoadJSONFile("gdata/document_to_download.json"); - SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); + SetExpectationsForGetResourceEntry(&document, "file:2_file_resource_id"); // The file is obtained with the mock DriveService. EXPECT_CALL(*mock_drive_service_, diff --git a/chrome/browser/chromeos/drive/drive_resource_metadata.cc b/chrome/browser/chromeos/drive/drive_resource_metadata.cc index f7d54c0..01f8720 100644 --- a/chrome/browser/chromeos/drive/drive_resource_metadata.cc +++ b/chrome/browser/chromeos/drive/drive_resource_metadata.cc @@ -11,9 +11,9 @@ #include "base/sequenced_task_runner.h" #include "base/string_number_conversions.h" #include "base/tracked_objects.h" -#include "chrome/browser/chromeos/drive/document_entry_conversion.h" #include "chrome/browser/chromeos/drive/drive.pb.h" #include "chrome/browser/chromeos/drive/drive_files.h" +#include "chrome/browser/chromeos/drive/resource_entry_conversion.h" #include "chrome/browser/google_apis/gdata_wapi_parser.h" #include "chrome/browser/google_apis/time_util.h" #include "content/public/browser/browser_thread.h" @@ -236,7 +236,7 @@ void DriveResourceMetadata::ClearRoot() { void DriveResourceMetadata::AddEntryToDirectory( const FilePath& directory_path, - scoped_ptr<google_apis::DocumentEntry> doc_entry, + scoped_ptr<google_apis::ResourceEntry> doc_entry, const FileMoveCallback& callback) { DCHECK(!directory_path.empty()); DCHECK(!callback.is_null()); @@ -260,7 +260,7 @@ void DriveResourceMetadata::AddEntryToDirectory( AddEntryToDirectoryInternal( directory, - ConvertDocumentEntryToDriveEntryProto(*doc_entry), + ConvertResourceEntryToDriveEntryProto(*doc_entry), callback); } @@ -499,7 +499,7 @@ void DriveResourceMetadata::GetEntryInfoPairByPaths( } void DriveResourceMetadata::RefreshFile( - scoped_ptr<google_apis::DocumentEntry> doc_entry, + scoped_ptr<google_apis::ResourceEntry> doc_entry, const GetEntryInfoWithFilePathCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -510,7 +510,7 @@ void DriveResourceMetadata::RefreshFile( return; } - RefreshEntryProto(ConvertDocumentEntryToDriveEntryProto( + RefreshEntryProto(ConvertResourceEntryToDriveEntryProto( *doc_entry), callback); } diff --git a/chrome/browser/chromeos/drive/drive_resource_metadata.h b/chrome/browser/chromeos/drive/drive_resource_metadata.h index 326534a..f52408c 100644 --- a/chrome/browser/chromeos/drive/drive_resource_metadata.h +++ b/chrome/browser/chromeos/drive/drive_resource_metadata.h @@ -22,7 +22,7 @@ class SequencedTaskRunner; } namespace google_apis { -class DocumentEntry; +class ResourceEntry; } namespace drive { @@ -152,7 +152,7 @@ class DriveResourceMetadata { // callback asynchronously. // |callback| must not be null. void AddEntryToDirectory(const FilePath& directory_path, - scoped_ptr<google_apis::DocumentEntry> doc_entry, + scoped_ptr<google_apis::ResourceEntry> doc_entry, const FileMoveCallback& callback); // Add |entry_proto| to the metadata tree, based on its parent_resource_id. @@ -215,7 +215,7 @@ class DriveResourceMetadata { // with |doc_entry|. // |callback| must not be null. // TODO(achuith): Deprecate this in favor of RefreshEntryProto above. - void RefreshFile(scoped_ptr<google_apis::DocumentEntry> doc_entry, + void RefreshFile(scoped_ptr<google_apis::ResourceEntry> doc_entry, const GetEntryInfoWithFilePathCallback& callback); // Removes all child files of |directory| and replaces them with diff --git a/chrome/browser/chromeos/drive/drive_scheduler.cc b/chrome/browser/chromeos/drive/drive_scheduler.cc index 3e55b50..78f6521 100644 --- a/chrome/browser/chromeos/drive/drive_scheduler.cc +++ b/chrome/browser/chromeos/drive/drive_scheduler.cc @@ -122,7 +122,7 @@ void DriveScheduler::Copy(const FilePath& src_file_path, StartJobLoop(); } -void DriveScheduler::GetDocuments( +void DriveScheduler::GetResourceList( const GURL& feed_url, int64 start_changestamp, const std::string& search_query, @@ -133,7 +133,7 @@ void DriveScheduler::GetDocuments( DCHECK(!callback.is_null()); scoped_ptr<QueueEntry> new_job( - new QueueEntry(TYPE_GET_DOCUMENTS, FilePath())); + new QueueEntry(TYPE_GET_RESOURCE_LIST, FilePath())); new_job->feed_url = feed_url; new_job->start_changestamp = start_changestamp; new_job->search_query = search_query; @@ -297,8 +297,8 @@ void DriveScheduler::DoJobLoop() { } break; - case TYPE_GET_DOCUMENTS: { - drive_service_->GetDocuments( + case TYPE_GET_RESOURCE_LIST: { + drive_service_->GetResourceList( queue_entry->feed_url, queue_entry->start_changestamp, queue_entry->search_query, diff --git a/chrome/browser/chromeos/drive/drive_scheduler.h b/chrome/browser/chromeos/drive/drive_scheduler.h index 5f8c2ba..2fd5393 100644 --- a/chrome/browser/chromeos/drive/drive_scheduler.h +++ b/chrome/browser/chromeos/drive/drive_scheduler.h @@ -36,7 +36,7 @@ class DriveScheduler TYPE_GET_ACCOUNT_METADATA, TYPE_GET_APPLICATION_INFO, TYPE_COPY, - TYPE_GET_DOCUMENTS, + TYPE_GET_RESOURCE_LIST, TYPE_MOVE, TYPE_REMOVE, TYPE_TRANSFER_LOCAL_TO_REMOTE, @@ -102,14 +102,14 @@ class DriveScheduler const FilePath& dest_file_path, const FileOperationCallback& callback); - // Adds a GetDocuments operation to the queue. + // Adds a GetResourceList operation to the queue. // |callback| must not be null. - void GetDocuments(const GURL& feed_url, - int64 start_changestamp, - const std::string& search_query, - bool shared_with_me, - const std::string& directory_resource_id, - const google_apis::GetDataCallback& callback); + void GetResourceList(const GURL& feed_url, + int64 start_changestamp, + const std::string& search_query, + bool shared_with_me, + const std::string& directory_resource_id, + const google_apis::GetDataCallback& callback); // Adds a transfer operation to the queue. // |callback| must not be null. @@ -176,9 +176,9 @@ class DriveScheduler // TYPE_REMOVE bool is_recursive; - // Parameters for GetDocuments(). + // Parameters for GetResourceList(). // Used by: - // TYPE_GET_DOCUMENTS + // TYPE_GET_RESOURCE_LIST GURL feed_url; int64 start_changestamp; std::string search_query; @@ -189,7 +189,7 @@ class DriveScheduler // Used by: // TYPE_GET_ACCOUNT_METADATA, // TYPE_GET_APPLICATION_INFO, - // TYPE_GET_DOCUMENTS + // TYPE_GET_RESOURCE_LIST google_apis::GetDataCallback get_data_callback; }; diff --git a/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc b/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc index b9929f8..b0a94c6 100644 --- a/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc @@ -62,12 +62,12 @@ class FakeDriveService : public DriveServiceInterface { return true; } - virtual void GetDocuments(const GURL& feed_url, - int64 start_changestamp, - const std::string& search_query, - bool shared_with_me, - const std::string& directory_resource_id, - const GetDataCallback& callback) { + virtual void GetResourceList(const GURL& feed_url, + int64 start_changestamp, + const std::string& search_query, + bool shared_with_me, + const std::string& directory_resource_id, + const GetDataCallback& callback) { // TODO: Make this more flexible. if (feed_url == GURL("http://example.com/gdata/root_feed.json")) { // Make some sample data. @@ -91,7 +91,7 @@ class FakeDriveService : public DriveServiceInterface { } } - virtual void GetDocumentEntry(const std::string& resource_id, + virtual void GetResourceEntry(const std::string& resource_id, const GetDataCallback& callback) { } @@ -113,29 +113,29 @@ class FakeDriveService : public DriveServiceInterface { GetAccountMetadata(callback); } - virtual void DeleteDocument(const GURL& document_url, + virtual void DeleteResource(const GURL& edit_url, const EntryActionCallback& callback) { } - virtual void DownloadDocument(const FilePath& virtual_path, - const FilePath& local_cache_path, - const GURL& content_url, - DocumentExportFormat format, - const DownloadActionCallback& callback) { + virtual void DownloadHostedDocument(const FilePath& virtual_path, + const FilePath& local_cache_path, + const GURL& content_url, + DocumentExportFormat format, + const DownloadActionCallback& callback) { } - virtual void CopyDocument(const std::string& resource_id, - const FilePath::StringType& new_name, - const GetDataCallback& callback) { + virtual void CopyHostedDocument(const std::string& resource_id, + const FilePath::StringType& new_name, + const GetDataCallback& callback) { } - virtual void RenameResource(const GURL& resource_url, + virtual void RenameResource(const GURL& edit_url, const FilePath::StringType& new_name, const EntryActionCallback& callback) { } virtual void AddResourceToDirectory(const GURL& parent_content_url, - const GURL& resource_url, + const GURL& edit_url, const EntryActionCallback& callback) { } @@ -166,7 +166,7 @@ class FakeDriveService : public DriveServiceInterface { const ResumeUploadCallback& callback) { } - virtual void AuthorizeApp(const GURL& resource_url, + virtual void AuthorizeApp(const GURL& edit_url, const std::string& app_id, const GetDataCallback& callback) { } @@ -425,13 +425,13 @@ TEST_F(DriveSchedulerTest, GetAccountMetadata) { } -TEST_F(DriveSchedulerTest, GetDocuments) { +TEST_F(DriveSchedulerTest, GetResourceList) { ConnectToWifi(); google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; scoped_ptr<base::Value> value; - scheduler_->GetDocuments( + scheduler_->GetResourceList( GURL("http://example.com/gdata/root_feed.json"), 0, std::string(), diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc b/chrome/browser/chromeos/drive/file_system/copy_operation.cc index d6a83ed..914f5aa2 100644 --- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc @@ -20,7 +20,7 @@ #include "net/base/mime_util.h" using content::BrowserThread; -using google_apis::DocumentEntry; +using google_apis::ResourceEntry; using google_apis::GDataErrorCode; namespace drive { @@ -64,7 +64,7 @@ DriveFileError GetLocalFileInfoOnBlockingPool( std::string GetDocumentResourceIdOnBlockingPool( const FilePath& local_file_path) { std::string result; - if (DocumentEntry::HasHostedDocumentExtension(local_file_path)) { + if (ResourceEntry::HasHostedDocumentExtension(local_file_path)) { std::string error; DictionaryValue* dict_value = NULL; JSONFileValueSerializer serializer(local_file_path); @@ -212,7 +212,7 @@ void CopyOperation::TransferRegularFile( base::Owned(content_type))); } -void CopyOperation::CopyDocumentToDirectory( +void CopyOperation::CopyHostedDocumentToDirectory( const FilePath& dir_path, const std::string& resource_id, const FilePath::StringType& new_name, @@ -220,16 +220,16 @@ void CopyOperation::CopyDocumentToDirectory( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - drive_service_->CopyDocument( + drive_service_->CopyHostedDocument( resource_id, new_name, - base::Bind(&CopyOperation::OnCopyDocumentCompleted, + base::Bind(&CopyOperation::OnCopyHostedDocumentCompleted, weak_ptr_factory_.GetWeakPtr(), dir_path, callback)); } -void CopyOperation::OnCopyDocumentCompleted( +void CopyOperation::OnCopyHostedDocumentCompleted( const FilePath& dir_path, const FileOperationCallback& callback, GDataErrorCode status, @@ -248,7 +248,7 @@ void CopyOperation::OnCopyDocumentCompleted( // destination directory by MoveEntryFromRootDirectory(). metadata_->AddEntryToDirectory( FilePath(kDriveRootDirectory), - scoped_ptr<DocumentEntry>(DocumentEntry::ExtractAndParse(*data)), + scoped_ptr<ResourceEntry>(ResourceEntry::ExtractAndParse(*data)), base::Bind(&CopyOperation::MoveEntryFromRootDirectory, weak_ptr_factory_.GetWeakPtr(), dir_path, @@ -379,12 +379,12 @@ void CopyOperation::CopyAfterGetEntryInfoPair( } if (src_file_proto->file_specific_info().is_hosted_document()) { - CopyDocumentToDirectory(dest_file_path.DirName(), - src_file_proto->resource_id(), - // Drop the document extension, which should not be - // in the document title. - dest_file_path.BaseName().RemoveExtension().value(), - callback); + CopyHostedDocumentToDirectory( + dest_file_path.DirName(), + src_file_proto->resource_id(), + // Drop the document extension, which should not be in the title. + dest_file_path.BaseName().RemoveExtension().value(), + callback); return; } @@ -484,13 +484,13 @@ void CopyOperation::OnTransferCompleted( google_apis::DriveUploadError error, const FilePath& drive_path, const FilePath& file_path, - scoped_ptr<DocumentEntry> document_entry) { + scoped_ptr<ResourceEntry> resource_entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error == google_apis::DRIVE_UPLOAD_OK && document_entry.get()) { + if (error == google_apis::DRIVE_UPLOAD_OK && resource_entry.get()) { drive_file_system_->AddUploadedFile(drive_path.DirName(), - document_entry.Pass(), + resource_entry.Pass(), file_path, callback); } else { @@ -546,7 +546,7 @@ void CopyOperation::TransferFileForResourceId( // Otherwise, copy the document on the server side and add the new copy // to the destination directory (collection). - CopyDocumentToDirectory( + CopyHostedDocumentToDirectory( remote_dest_file_path.DirName(), resource_id, // Drop the document extension, which should not be diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.h b/chrome/browser/chromeos/drive/file_system/copy_operation.h index 8aa1380..8fe36a2 100644 --- a/chrome/browser/chromeos/drive/file_system/copy_operation.h +++ b/chrome/browser/chromeos/drive/file_system/copy_operation.h @@ -104,22 +104,22 @@ class CopyOperation { const std::string& unused_mime_type, DriveFileType file_type); - // Copies a document with |resource_id| to the directory at |dir_path| + // Copies a hosted document with |resource_id| to the directory at |dir_path| // and names the copied document as |new_name|. // // Can be called from UI thread. |callback| is run on the calling thread. // |callback| must not be null. - void CopyDocumentToDirectory(const FilePath& dir_path, - const std::string& resource_id, - const FilePath::StringType& new_name, - const FileOperationCallback& callback); + void CopyHostedDocumentToDirectory(const FilePath& dir_path, + const std::string& resource_id, + const FilePath::StringType& new_name, + const FileOperationCallback& callback); // Callback for handling document copy attempt. // |callback| must not be null. - void OnCopyDocumentCompleted(const FilePath& dir_path, - const FileOperationCallback& callback, - google_apis::GDataErrorCode status, - scoped_ptr<base::Value> data); + void OnCopyHostedDocumentCompleted(const FilePath& dir_path, + const FileOperationCallback& callback, + google_apis::GDataErrorCode status, + scoped_ptr<base::Value> data); // Moves a file or directory at |file_path| in the root directory to // another directory at |dir_path|. This function does nothing if @@ -194,7 +194,7 @@ class CopyOperation { google_apis::DriveUploadError error, const FilePath& drive_path, const FilePath& file_path, - scoped_ptr<google_apis::DocumentEntry> document_entry); + scoped_ptr<google_apis::ResourceEntry> resource_entry); // Part of TransferFileFromLocalToRemote(). Called after // GetEntryInfoByPath() is complete. diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.cc b/chrome/browser/chromeos/drive/file_system/remove_operation.cc index aae5c1f..58d7afd 100644 --- a/chrome/browser/chromeos/drive/file_system/remove_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.cc @@ -73,7 +73,7 @@ void RemoveOperation::RemoveAfterGetEntryInfo( return; } - drive_service_->DeleteDocument( + drive_service_->DeleteResource( GURL(entry_proto->edit_url()), base::Bind(&RemoveOperation::RemoveResourceLocally, weak_ptr_factory_.GetWeakPtr(), diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.h b/chrome/browser/chromeos/drive/file_system/remove_operation.h index 3054ceb..8149d61a 100644 --- a/chrome/browser/chromeos/drive/file_system/remove_operation.h +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.h @@ -54,7 +54,7 @@ class RemoveOperation { DriveFileError error, scoped_ptr<DriveEntryProto> entry_proto); - // Callback for DriveServiceInterface::DeleteDocument. Removes the entry with + // Callback for DriveServiceInterface::DeleteResource. Removes the entry with // |resource_id| from the local snapshot of the filesystem and the cache. // |callback| must not be null. void RemoveResourceLocally( diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.cc b/chrome/browser/chromeos/drive/file_system/update_operation.cc index 4e06288..d0741bf 100644 --- a/chrome/browser/chromeos/drive/file_system/update_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/update_operation.cc @@ -145,7 +145,7 @@ void UpdateOperation::OnUpdatedFileUploaded( google_apis::DriveUploadError error, const FilePath& drive_path, const FilePath& file_path, - scoped_ptr<google_apis::DocumentEntry> document_entry) { + scoped_ptr<google_apis::ResourceEntry> resource_entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -156,7 +156,7 @@ void UpdateOperation::OnUpdatedFileUploaded( } metadata_->RefreshFile( - document_entry.Pass(), + resource_entry.Pass(), base::Bind(&UpdateOperation::OnUpdatedFileRefreshed, weak_ptr_factory_.GetWeakPtr(), callback)); } diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.h b/chrome/browser/chromeos/drive/file_system/update_operation.h index 0349a5e..135d474 100644 --- a/chrome/browser/chromeos/drive/file_system/update_operation.h +++ b/chrome/browser/chromeos/drive/file_system/update_operation.h @@ -91,7 +91,7 @@ class UpdateOperation { google_apis::DriveUploadError error, const FilePath& gdata_path, const FilePath& file_path, - scoped_ptr<google_apis::DocumentEntry> document_entry); + scoped_ptr<google_apis::ResourceEntry> resource_entry); // Part of UpdateFileByResourceId(). // |callback| must not be null. diff --git a/chrome/browser/chromeos/drive/mock_drive_file_system.h b/chrome/browser/chromeos/drive/mock_drive_file_system.h index f1b32c8..44a3800 100644 --- a/chrome/browser/chromeos/drive/mock_drive_file_system.h +++ b/chrome/browser/chromeos/drive/mock_drive_file_system.h @@ -93,7 +93,7 @@ class MockDriveFileSystem : public DriveFileSystemInterface { void(const GetAvailableSpaceCallback& callback)); // This function is not mockable by gmock because scoped_ptr is not supported. virtual void AddUploadedFile(const FilePath& file, - scoped_ptr<google_apis::DocumentEntry> entry, + scoped_ptr<google_apis::ResourceEntry> entry, const FilePath& file_content_path, const FileOperationCallback& callback) OVERRIDE { } diff --git a/chrome/browser/chromeos/drive/document_entry_conversion.cc b/chrome/browser/chromeos/drive/resource_entry_conversion.cc index eb730a0..4ae904b 100644 --- a/chrome/browser/chromeos/drive/document_entry_conversion.cc +++ b/chrome/browser/chromeos/drive/resource_entry_conversion.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/drive/document_entry_conversion.h" +#include "chrome/browser/chromeos/drive/resource_entry_conversion.h" #include "base/logging.h" #include "base/string_util.h" @@ -15,8 +15,8 @@ namespace drive { -DriveEntryProto ConvertDocumentEntryToDriveEntryProto( - const google_apis::DocumentEntry& doc) { +DriveEntryProto ConvertResourceEntryToDriveEntryProto( + const google_apis::ResourceEntry& doc) { DriveEntryProto entry_proto; // For regular files, the 'filename' and 'title' attribute in the metadata diff --git a/chrome/browser/chromeos/drive/resource_entry_conversion.h b/chrome/browser/chromeos/drive/resource_entry_conversion.h new file mode 100644 index 0000000..eb51f22 --- /dev/null +++ b/chrome/browser/chromeos/drive/resource_entry_conversion.h @@ -0,0 +1,22 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_ +#define CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_ + +namespace google_apis { +class ResourceEntry; +} + +namespace drive { + +class DriveEntryProto; + +// Converts a google_apis::ResourceEntry into a DriveEntryProto. +DriveEntryProto ConvertResourceEntryToDriveEntryProto( + const google_apis::ResourceEntry& resource_entry); + +} // namespace drive + +#endif // CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_ diff --git a/chrome/browser/chromeos/drive/document_entry_conversion_unittest.cc b/chrome/browser/chromeos/drive/resource_entry_conversion_unittest.cc index c85378e..b9fefda 100644 --- a/chrome/browser/chromeos/drive/document_entry_conversion_unittest.cc +++ b/chrome/browser/chromeos/drive/resource_entry_conversion_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/drive/document_entry_conversion.h" +#include "chrome/browser/chromeos/drive/resource_entry_conversion.h" #include "base/file_path.h" #include "base/values.h" @@ -14,17 +14,17 @@ namespace drive { -TEST(DocumentEntryConversionTest, ConvertDocumentEntryToDriveEntryProto_File) { +TEST(ResourceEntryConversionTest, ConvertResourceEntryToDriveEntryProto_File) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile("gdata/file_entry.json"); ASSERT_TRUE(value.get()); - scoped_ptr<google_apis::DocumentEntry> document_entry( - google_apis::DocumentEntry::ExtractAndParse(*value)); - ASSERT_TRUE(document_entry.get()); + scoped_ptr<google_apis::ResourceEntry> resource_entry( + google_apis::ResourceEntry::ExtractAndParse(*value)); + ASSERT_TRUE(resource_entry.get()); DriveEntryProto entry_proto = - ConvertDocumentEntryToDriveEntryProto(*document_entry); + ConvertResourceEntryToDriveEntryProto(*resource_entry); EXPECT_EQ("File 1.mp3", entry_proto.title()); EXPECT_EQ("File 1.mp3", entry_proto.base_name()); @@ -75,18 +75,18 @@ TEST(DocumentEntryConversionTest, ConvertDocumentEntryToDriveEntryProto_File) { EXPECT_FALSE(entry_proto.file_info().is_directory()); } -TEST(DocumentEntryConversionTest, - ConvertDocumentEntryToDriveEntryProto_HostedDocument) { +TEST(ResourceEntryConversionTest, + ConvertResourceEntryToDriveEntryProto_HostedDocument) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile("gdata/hosted_document_entry.json"); ASSERT_TRUE(value.get()); - scoped_ptr<google_apis::DocumentEntry> document_entry( - google_apis::DocumentEntry::ExtractAndParse(*value)); - ASSERT_TRUE(document_entry.get()); + scoped_ptr<google_apis::ResourceEntry> resource_entry( + google_apis::ResourceEntry::ExtractAndParse(*value)); + ASSERT_TRUE(resource_entry.get()); DriveEntryProto entry_proto = - ConvertDocumentEntryToDriveEntryProto(*document_entry); + ConvertResourceEntryToDriveEntryProto(*resource_entry); EXPECT_EQ("Document 1", entry_proto.title()); EXPECT_EQ("Document 1.gdoc", entry_proto.base_name()); // The suffix added. @@ -159,18 +159,18 @@ TEST(DocumentEntryConversionTest, EXPECT_FALSE(entry_proto.file_info().is_directory()); } -TEST(DocumentEntryConversionTest, - ConvertDocumentEntryToDriveEntryProto_Directory) { +TEST(ResourceEntryConversionTest, + ConvertResourceEntryToDriveEntryProto_Directory) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile("gdata/directory_entry.json"); ASSERT_TRUE(value.get()); - scoped_ptr<google_apis::DocumentEntry> document_entry( - google_apis::DocumentEntry::ExtractAndParse(*value)); - ASSERT_TRUE(document_entry.get()); + scoped_ptr<google_apis::ResourceEntry> resource_entry( + google_apis::ResourceEntry::ExtractAndParse(*value)); + ASSERT_TRUE(resource_entry.get()); DriveEntryProto entry_proto = - ConvertDocumentEntryToDriveEntryProto(*document_entry); + ConvertResourceEntryToDriveEntryProto(*resource_entry); EXPECT_EQ("Sub Directory Folder", entry_proto.title()); EXPECT_EQ("Sub Directory Folder", entry_proto.base_name()); @@ -236,19 +236,19 @@ TEST(DocumentEntryConversionTest, EXPECT_TRUE(entry_proto.file_info().is_directory()); } -TEST(DocumentEntryConversionTest, - ConvertDocumentEntryToDriveEntryProto_DeletedHostedDocument) { +TEST(ResourceEntryConversionTest, + ConvertResourceEntryToDriveEntryProto_DeletedHostedDocument) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile( "gdata/deleted_hosted_document_entry.json"); ASSERT_TRUE(value.get()); - scoped_ptr<google_apis::DocumentEntry> document_entry( - google_apis::DocumentEntry::ExtractAndParse(*value)); - ASSERT_TRUE(document_entry.get()); + scoped_ptr<google_apis::ResourceEntry> resource_entry( + google_apis::ResourceEntry::ExtractAndParse(*value)); + ASSERT_TRUE(resource_entry.get()); DriveEntryProto entry_proto = - ConvertDocumentEntryToDriveEntryProto(*document_entry); + ConvertResourceEntryToDriveEntryProto(*resource_entry); EXPECT_EQ("Deleted document", entry_proto.title()); EXPECT_EQ("Deleted document.gdoc", entry_proto.base_name()); diff --git a/chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc b/chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc index 9496c83..320bed7 100644 --- a/chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc +++ b/chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc @@ -166,7 +166,7 @@ TEST_F(StaleCacheFilesRemoverTest, RemoveStaleCacheFiles) { // Verify that the corresponding file entry doesn't exist. EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(2); - EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "", _, _, _)) + EXPECT_CALL(*mock_drive_service_, GetResourceList(Eq(GURL()), _, "", _, _, _)) .Times(2); EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); diff --git a/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc b/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc index 0efa08e..e09e69d 100644 --- a/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc +++ b/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc @@ -143,14 +143,14 @@ ACTION_P2(MockCreateDirectoryCallback, status, value) { base::Bind(arg2, status, base::Passed(value))); } -// Action used to set mock expecteations for GetDocuments. -ACTION_P2(MockGetDocumentsCallback, status, value) { +// Action used to set mock expectations for GetResourceList. +ACTION_P2(MockGetResourceListCallback, status, value) { base::MessageLoopProxy::current()->PostTask(FROM_HERE, base::Bind(arg5, status, base::Passed(value))); } -// Action used to mock expectations fo GetDocumentEntry. -ACTION_P2(MockGetDocumentEntryCallback, status, value) { +// Action used to mock expectations for GetResourceEntry. +ACTION_P2(MockGetResourceEntryCallback, status, value) { base::MessageLoopProxy::current()->PostTask(FROM_HERE, base::Bind(arg1, status, base::Passed(value))); } @@ -390,9 +390,9 @@ IN_PROC_BROWSER_TEST_F(RemoteFileSystemExtensionApiTest, // Remote filesystem should first request root feed from gdata server. scoped_ptr<base::Value> documents_value(LoadJSONFile(kTestRootFeed)); EXPECT_CALL(*mock_drive_service_, - GetDocuments(_, _, _, _, _, _)) - .WillOnce(MockGetDocumentsCallback(google_apis::HTTP_SUCCESS, - &documents_value)); + GetResourceList(_, _, _, _, _, _)) + .WillOnce(MockGetResourceListCallback(google_apis::HTTP_SUCCESS, + &documents_value)); // When file browser tries to read the file, remote filesystem should detect // that the cached file is not present on the disk and download it. Mocked @@ -404,12 +404,12 @@ IN_PROC_BROWSER_TEST_F(RemoteFileSystemExtensionApiTest, scoped_ptr<base::Value> document_to_download_value( LoadJSONFile(kTestDocumentToDownloadEntry)); EXPECT_CALL(*mock_drive_service_, - GetDocumentEntry("file:1_file_resource_id", _)) - .WillOnce(MockGetDocumentEntryCallback(google_apis::HTTP_SUCCESS, + GetResourceEntry("file:1_file_resource_id", _)) + .WillOnce(MockGetResourceEntryCallback(google_apis::HTTP_SUCCESS, &document_to_download_value)); // We expect to download url defined in document entry returned by - // GetDocumentEntry mock implementation. + // GetResourceEntry mock implementation. EXPECT_CALL(*mock_drive_service_, DownloadFile(_, _, GURL("https://file_content_url_changed"), _, _)) @@ -430,9 +430,9 @@ IN_PROC_BROWSER_TEST_F(RemoteFileSystemExtensionApiTest, ContentSearch) { // First, test will get drive root directory, to init file system. scoped_ptr<base::Value> documents_value(LoadJSONFile(kTestRootFeed)); EXPECT_CALL(*mock_drive_service_, - GetDocuments(_, _, "", _, _, _)) - .WillOnce(MockGetDocumentsCallback(google_apis::HTTP_SUCCESS, - &documents_value)); + GetResourceList(_, _, "", _, _, _)) + .WillOnce(MockGetResourceListCallback(google_apis::HTTP_SUCCESS, + &documents_value)); // Search results will be returned in two parts: // 1. Search will be given empty initial feed url. The returned feed will @@ -448,26 +448,26 @@ IN_PROC_BROWSER_TEST_F(RemoteFileSystemExtensionApiTest, ContentSearch) { AddNextFeedURLToFeedValue("https://next_feed", first_search_value.get())); EXPECT_CALL(*mock_drive_service_, - GetDocuments(GURL(), _, "foo", _, _, _)) - .WillOnce(MockGetDocumentsCallback(google_apis::HTTP_SUCCESS, - &first_search_value)); + GetResourceList(GURL(), _, "foo", _, _, _)) + .WillOnce(MockGetResourceListCallback(google_apis::HTTP_SUCCESS, + &first_search_value)); scoped_ptr<base::Value> second_search_value(LoadJSONFile(kTestRootFeed)); EXPECT_CALL(*mock_drive_service_, - GetDocuments(GURL("https://next_feed"), _, "foo", _, _, _)) - .WillOnce(MockGetDocumentsCallback(google_apis::HTTP_SUCCESS, - &second_search_value)); + GetResourceList(GURL("https://next_feed"), _, "foo", _, _, _)) + .WillOnce(MockGetResourceListCallback(google_apis::HTTP_SUCCESS, + &second_search_value)); // Test will try to create a snapshot of the returned file. scoped_ptr<base::Value> document_to_download_value( LoadJSONFile(kTestDocumentToDownloadEntry)); EXPECT_CALL(*mock_drive_service_, - GetDocumentEntry("file:1_file_resource_id", _)) - .WillOnce(MockGetDocumentEntryCallback(google_apis::HTTP_SUCCESS, + GetResourceEntry("file:1_file_resource_id", _)) + .WillOnce(MockGetResourceEntryCallback(google_apis::HTTP_SUCCESS, &document_to_download_value)); // We expect to download url defined in document entry returned by - // GetDocumentEntry mock implementation. + // GetResourceEntry mock implementation. EXPECT_CALL(*mock_drive_service_, DownloadFile(_, _, GURL("https://file_content_url_changed"), _, _)) diff --git a/chrome/browser/google_apis/base_operations.h b/chrome/browser/google_apis/base_operations.h index 17e44ff..c20cc49 100644 --- a/chrome/browser/google_apis/base_operations.h +++ b/chrome/browser/google_apis/base_operations.h @@ -194,7 +194,7 @@ class EntryActionOperation : public UrlFetchOperationBase { //============================== GetDataOperation ============================== -// Callback type for DocumentServiceInterface::GetDocuments. +// Callback type for DocumentServiceInterface::GetResourceList. // Note: feed_data argument should be passed using base::Passed(&feed_data), not // feed_data.Pass(). typedef base::Callback<void(GDataErrorCode error, diff --git a/chrome/browser/google_apis/drive_api_parser_unittest.cc b/chrome/browser/google_apis/drive_api_parser_unittest.cc index eb1ea5b..e7ecf7d 100644 --- a/chrome/browser/google_apis/drive_api_parser_unittest.cc +++ b/chrome/browser/google_apis/drive_api_parser_unittest.cc @@ -254,8 +254,8 @@ TEST(DriveAPIParserTest, ChangeListParser) { EXPECT_EQ("1Pc8jzfU1ErbN_eucMMqdqzY3eBm0v8sxXm_1CtLxABC", change1.file_id()); EXPECT_EQ(change1.file_id(), change1.file().file_id()); - scoped_ptr<DocumentEntry> entry1( - DocumentEntry::CreateFromChangeResource(change1)); + scoped_ptr<ResourceEntry> entry1( + ResourceEntry::CreateFromChangeResource(change1)); EXPECT_EQ(change1.file_id(), entry1->resource_id()); EXPECT_EQ(change1.is_deleted(), entry1->deleted()); @@ -265,8 +265,8 @@ TEST(DriveAPIParserTest, ChangeListParser) { EXPECT_EQ("0B4v7G8yEYAWHUmRrU2lMS2hLABC", change2.file_id()); EXPECT_EQ(change2.file_id(), change2.file().file_id()); - scoped_ptr<DocumentEntry> entry2( - DocumentEntry::CreateFromChangeResource(change2)); + scoped_ptr<ResourceEntry> entry2( + ResourceEntry::CreateFromChangeResource(change2)); EXPECT_EQ(change2.file_id(), entry2->resource_id()); EXPECT_EQ(change2.is_deleted(), entry2->deleted()); @@ -276,8 +276,8 @@ TEST(DriveAPIParserTest, ChangeListParser) { EXPECT_EQ("0B4v7G8yEYAWHYW1OcExsUVZLABC", change3.file_id()); EXPECT_EQ(change3.file_id(), change3.file().file_id()); - scoped_ptr<DocumentEntry> entry3( - DocumentEntry::CreateFromChangeResource(change3)); + scoped_ptr<ResourceEntry> entry3( + ResourceEntry::CreateFromChangeResource(change3)); EXPECT_EQ(change3.file_id(), entry3->resource_id()); EXPECT_EQ(change3.is_deleted(), entry3->deleted()); @@ -287,8 +287,8 @@ TEST(DriveAPIParserTest, ChangeListParser) { EXPECT_EQ("ABCv7G8yEYAWHc3Y5X0hMSkJYXYZ", change4.file_id()); EXPECT_TRUE(change4.is_deleted()); - scoped_ptr<DocumentEntry> entry4( - DocumentEntry::CreateFromChangeResource(change4)); + scoped_ptr<ResourceEntry> entry4( + ResourceEntry::CreateFromChangeResource(change4)); EXPECT_EQ(change4.file_id(), entry4->resource_id()); EXPECT_EQ(change4.is_deleted(), entry4->deleted()); } diff --git a/chrome/browser/google_apis/drive_service_interface.h b/chrome/browser/google_apis/drive_service_interface.h index 4a43c3f..a4e85994 100644 --- a/chrome/browser/google_apis/drive_service_interface.h +++ b/chrome/browser/google_apis/drive_service_interface.h @@ -62,9 +62,6 @@ class DriveServiceObserver { // // All functions must be called on UI thread. DriveService is built on top of // URLFetcher that runs on UI thread. -// -// TODO(zel,benchan): Make the terminology/naming convention (e.g. file vs -// document vs resource, directory vs collection) more consistent and precise. class DriveServiceInterface { public: virtual ~DriveServiceInterface() {} @@ -103,10 +100,11 @@ class DriveServiceInterface { // Document access: - // Fetches the document feed from |feed_url| with |start_changestamp|. If this - // URL is empty, the call will fetch the default root or change document feed. - // |start_changestamp| specifies the starting point from change feeds only. - // Value different than 0, it would trigger delta feed fetching. + // Fetches a feed from |feed_url|. If this URL is empty, the call will fetch + // from the default URL. When |start_changestamp| is 0, the default behavior + // is to fetch the resource list feed containing the list of all entries. If + // |start_changestamp| > 0, the default is to fetch the change list feed + // containing the updates from the specified changestamp. // // |search_query| specifies search query to be sent to the server. It will be // used only if |start_changestamp| is 0. If empty string is passed, @@ -119,18 +117,18 @@ class DriveServiceInterface { // Upon completion, invokes |callback| with results on the calling thread. // TODO(haruki): Refactor this function: crbug.com/160932 // |callback| must not be null. - virtual void GetDocuments(const GURL& feed_url, - int64 start_changestamp, - const std::string& search_query, - bool shared_with_me, - const std::string& directory_resource_id, - const GetDataCallback& callback) = 0; + virtual void GetResourceList(const GURL& feed_url, + int64 start_changestamp, + const std::string& search_query, + bool shared_with_me, + const std::string& directory_resource_id, + const GetDataCallback& callback) = 0; // Fetches single entry metadata from server. The entry's resource id equals // |resource_id|. // Upon completion, invokes |callback| with results on the calling thread. // |callback| must not be null. - virtual void GetDocumentEntry(const std::string& resource_id, + virtual void GetResourceEntry(const std::string& resource_id, const GetDataCallback& callback) = 0; // Gets the account metadata from the server using the default account @@ -144,46 +142,46 @@ class DriveServiceInterface { // |callback| must not be null. virtual void GetApplicationInfo(const GetDataCallback& callback) = 0; - // Deletes a document identified by its 'self' |url| and |etag|. + // Deletes a resource identified by its |edit_url|. // Upon completion, invokes |callback| with results on the calling thread. // |callback| must not be null. - virtual void DeleteDocument(const GURL& document_url, + virtual void DeleteResource(const GURL& edit_url, const EntryActionCallback& callback) = 0; // Downloads a document identified by its |content_url| in a given |format|. // Upon completion, invokes |callback| with results on the calling thread. // |callback| must not be null. - virtual void DownloadDocument(const FilePath& virtual_path, - const FilePath& local_cache_path, - const GURL& content_url, - DocumentExportFormat format, - const DownloadActionCallback& callback) = 0; + virtual void DownloadHostedDocument( + const FilePath& virtual_path, + const FilePath& local_cache_path, + const GURL& content_url, + DocumentExportFormat format, + const DownloadActionCallback& callback) = 0; - // Makes a copy of a document identified by its |resource_id|. + // Makes a copy of a hosted document identified by its |resource_id|. // The copy is named as the UTF-8 encoded |new_name| and is not added to any // collection. Use AddResourceToDirectory() to add the copy to a collection // when needed. Upon completion, invokes |callback| with results on the // calling thread. // |callback| must not be null. - virtual void CopyDocument(const std::string& resource_id, - const FilePath::StringType& new_name, - const GetDataCallback& callback) = 0; + virtual void CopyHostedDocument(const std::string& resource_id, + const FilePath::StringType& new_name, + const GetDataCallback& callback) = 0; - // Renames a document or collection identified by its 'self' link - // |document_url| to the UTF-8 encoded |new_name|. Upon completion, + // Renames a document or collection identified by its |edit_url| + // to the UTF-8 encoded |new_name|. Upon completion, // invokes |callback| with results on the calling thread. // |callback| must not be null. - virtual void RenameResource(const GURL& resource_url, + virtual void RenameResource(const GURL& edit_url, const FilePath::StringType& new_name, const EntryActionCallback& callback) = 0; // Adds a resource (document, file, or collection) identified by its - // 'self' link |resource_url| to a collection with a content link - // |parent_content_url|. Upon completion, invokes |callback| with - // results on the calling thread. + // |edit_url| to a collection with a content link |parent_content_url|. + // Upon completion, invokes |callback| with results on the calling thread. // |callback| must not be null. virtual void AddResourceToDirectory(const GURL& parent_content_url, - const GURL& resource_url, + const GURL& edit_url, const EntryActionCallback& callback) = 0; // Removes a resource (document, file, collection) identified by its @@ -236,7 +234,7 @@ class DriveServiceInterface { // Authorizes a Drive app with the id |app_id| to open the given document. // Upon completion, invokes |callback| with results on the calling thread. // |callback| must not be null. - virtual void AuthorizeApp(const GURL& resource_url, + virtual void AuthorizeApp(const GURL& edit_url, const std::string& app_id, const GetDataCallback& callback) = 0; }; diff --git a/chrome/browser/google_apis/drive_uploader.cc b/chrome/browser/google_apis/drive_uploader.cc index 27a6ec3..5d85e99 100644 --- a/chrome/browser/google_apis/drive_uploader.cc +++ b/chrome/browser/google_apis/drive_uploader.cc @@ -489,7 +489,7 @@ void DriveUploader::ResumeUpload(int upload_id) { void DriveUploader::OnResumeUploadResponseReceived( int upload_id, const ResumeUploadResponse& response, - scoped_ptr<DocumentEntry> entry) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); UploadFileInfo* upload_file_info = GetUploadFileInfo(upload_id); diff --git a/chrome/browser/google_apis/drive_uploader.h b/chrome/browser/google_apis/drive_uploader.h index 4b7d6ea..5bb3fcd 100644 --- a/chrome/browser/google_apis/drive_uploader.h +++ b/chrome/browser/google_apis/drive_uploader.h @@ -34,7 +34,7 @@ typedef base::Callback<void( DriveUploadError error, const FilePath& drive_path, const FilePath& file_path, - scoped_ptr<DocumentEntry> document_entry)> + scoped_ptr<ResourceEntry> resource_entry)> UploadCompletionCallback; // Callback to be invoked once the uploader is ready to upload. @@ -227,7 +227,7 @@ class DriveUploader : public DriveUploaderInterface { int num_file_open_tries; // Number of times we've tried to open this file. // Will be set once the upload is complete. - scoped_ptr<DocumentEntry> entry; + scoped_ptr<ResourceEntry> entry; // Callback to be invoked once the uploader is ready to upload. UploaderReadyCallback ready_callback; @@ -275,7 +275,7 @@ class DriveUploader : public DriveUploaderInterface { void OnResumeUploadResponseReceived( int upload_id, const ResumeUploadResponse& response, - scoped_ptr<DocumentEntry> entry); + scoped_ptr<ResourceEntry> entry); // Initiate the upload. void InitiateUpload(UploadFileInfo* uploader_file_info); diff --git a/chrome/browser/google_apis/drive_uploader_unittest.cc b/chrome/browser/google_apis/drive_uploader_unittest.cc index 2488621..bbeb54f 100644 --- a/chrome/browser/google_apis/drive_uploader_unittest.cc +++ b/chrome/browser/google_apis/drive_uploader_unittest.cc @@ -83,15 +83,15 @@ class MockDriveServiceBase : public DriveServiceInterface { NOTREACHED(); return false; } - virtual void GetDocuments(const GURL& feed_url, - int64 start_changestamp, - const std::string& search_query, - bool shared_with_me, - const std::string& directory_resource_id, - const GetDataCallback& callback) OVERRIDE { + virtual void GetResourceList(const GURL& feed_url, + int64 start_changestamp, + const std::string& search_query, + bool shared_with_me, + const std::string& directory_resource_id, + const GetDataCallback& callback) OVERRIDE { NOTREACHED(); } - virtual void GetDocumentEntry(const std::string& resource_id, + virtual void GetResourceEntry(const std::string& resource_id, const GetDataCallback& callback) OVERRIDE { NOTREACHED(); } @@ -101,11 +101,11 @@ class MockDriveServiceBase : public DriveServiceInterface { virtual void GetApplicationInfo(const GetDataCallback& callback) OVERRIDE { NOTREACHED(); } - virtual void DeleteDocument(const GURL& document_url, + virtual void DeleteResource(const GURL& edit_url, const EntryActionCallback& callback) OVERRIDE { NOTREACHED(); } - virtual void DownloadDocument( + virtual void DownloadHostedDocument( const FilePath& virtual_path, const FilePath& local_cache_path, const GURL& content_url, @@ -113,19 +113,19 @@ class MockDriveServiceBase : public DriveServiceInterface { const DownloadActionCallback& callback) OVERRIDE { NOTREACHED(); } - virtual void CopyDocument(const std::string& resource_id, - const FilePath::StringType& new_name, - const GetDataCallback& callback) OVERRIDE { + virtual void CopyHostedDocument(const std::string& resource_id, + const FilePath::StringType& new_name, + const GetDataCallback& callback) OVERRIDE { NOTREACHED(); } - virtual void RenameResource(const GURL& resource_url, + virtual void RenameResource(const GURL& edit_url, const FilePath::StringType& new_name, const EntryActionCallback& callback) OVERRIDE { NOTREACHED(); } virtual void AddResourceToDirectory( const GURL& parent_content_url, - const GURL& resource_url, + const GURL& edit_url, const EntryActionCallback& callback) OVERRIDE { NOTREACHED(); } @@ -148,7 +148,7 @@ class MockDriveServiceBase : public DriveServiceInterface { const GetContentCallback& get_content_callback) OVERRIDE { NOTREACHED(); } - virtual void AuthorizeApp(const GURL& resource_url, + virtual void AuthorizeApp(const GURL& edit_url, const std::string& app_id, const GetDataCallback& callback) OVERRIDE { NOTREACHED(); @@ -228,7 +228,7 @@ class MockDriveServiceWithUploadExpectation : public MockDriveServiceBase { // Callback with response. ResumeUploadResponse response; - scoped_ptr<DocumentEntry> entry; + scoped_ptr<ResourceEntry> entry; if (received_bytes_ == params.content_length) { response = ResumeUploadResponse( params.upload_mode == UPLOAD_NEW_FILE ? HTTP_CREATED : HTTP_SUCCESS, @@ -236,7 +236,7 @@ class MockDriveServiceWithUploadExpectation : public MockDriveServiceBase { base::DictionaryValue dict; dict.Set("id.$t", new base::StringValue(kTestDummyId)); - entry = DocumentEntry::CreateFrom(dict); + entry = ResourceEntry::CreateFrom(dict); } else { response = ResumeUploadResponse(HTTP_RESUME_INCOMPLETE, 0, params.end_range); @@ -282,7 +282,7 @@ class MockDriveServiceNoConnectionAtResume : public MockDriveServiceBase { MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, ResumeUploadResponse(GDATA_NO_CONNECTION, -1, -1), - base::Passed(scoped_ptr<DocumentEntry>()))); + base::Passed(scoped_ptr<ResourceEntry>()))); } }; @@ -320,7 +320,7 @@ struct UploadCompletionCallbackResult { DriveUploadError error; FilePath drive_path; FilePath file_path; - scoped_ptr<DocumentEntry> document_entry; + scoped_ptr<ResourceEntry> resource_entry; }; // Copies the result from UploadCompletionCallback and quit the message loop. @@ -329,11 +329,11 @@ void CopyResultsFromUploadCompletionCallbackAndQuit( DriveUploadError error, const FilePath& drive_path, const FilePath& file_path, - scoped_ptr<DocumentEntry> document_entry) { + scoped_ptr<ResourceEntry> resource_entry) { out->error = error; out->drive_path = drive_path; out->file_path = file_path; - out->document_entry = document_entry.Pass(); + out->resource_entry = resource_entry.Pass(); MessageLoop::current()->Quit(); } @@ -363,8 +363,8 @@ TEST_F(DriveUploaderTest, UploadExisting0KB) { EXPECT_EQ(DRIVE_UPLOAD_OK, out.error); EXPECT_EQ(FilePath::FromUTF8Unsafe(kTestDrivePath), out.drive_path); EXPECT_EQ(local_path, out.file_path); - ASSERT_TRUE(out.document_entry); - EXPECT_EQ(kTestDummyId, out.document_entry->id()); + ASSERT_TRUE(out.resource_entry); + EXPECT_EQ(kTestDummyId, out.resource_entry->id()); } TEST_F(DriveUploaderTest, UploadExisting512KB) { @@ -392,8 +392,8 @@ TEST_F(DriveUploaderTest, UploadExisting512KB) { EXPECT_EQ(DRIVE_UPLOAD_OK, out.error); EXPECT_EQ(FilePath::FromUTF8Unsafe(kTestDrivePath), out.drive_path); EXPECT_EQ(local_path, out.file_path); - ASSERT_TRUE(out.document_entry); - EXPECT_EQ(kTestDummyId, out.document_entry->id()); + ASSERT_TRUE(out.resource_entry); + EXPECT_EQ(kTestDummyId, out.resource_entry->id()); } TEST_F(DriveUploaderTest, UploadExisting1234KB) { @@ -421,8 +421,8 @@ TEST_F(DriveUploaderTest, UploadExisting1234KB) { EXPECT_EQ(DRIVE_UPLOAD_OK, out.error); EXPECT_EQ(FilePath::FromUTF8Unsafe(kTestDrivePath), out.drive_path); EXPECT_EQ(local_path, out.file_path); - ASSERT_TRUE(out.document_entry); - EXPECT_EQ(kTestDummyId, out.document_entry->id()); + ASSERT_TRUE(out.resource_entry); + EXPECT_EQ(kTestDummyId, out.resource_entry->id()); } TEST_F(DriveUploaderTest, UploadNew1234KB) { @@ -456,8 +456,8 @@ TEST_F(DriveUploaderTest, UploadNew1234KB) { EXPECT_EQ(DRIVE_UPLOAD_OK, out.error); EXPECT_EQ(FilePath::FromUTF8Unsafe(kTestDrivePath), out.drive_path); EXPECT_EQ(local_path, out.file_path); - ASSERT_TRUE(out.document_entry); - EXPECT_EQ(kTestDummyId, out.document_entry->id()); + ASSERT_TRUE(out.resource_entry); + EXPECT_EQ(kTestDummyId, out.resource_entry->id()); } TEST_F(DriveUploaderTest, InitiateUploadFail) { diff --git a/chrome/browser/google_apis/gdata_wapi_operations.cc b/chrome/browser/google_apis/gdata_wapi_operations.cc index 73b14e5..52c37e0 100644 --- a/chrome/browser/google_apis/gdata_wapi_operations.cc +++ b/chrome/browser/google_apis/gdata_wapi_operations.cc @@ -124,7 +124,7 @@ GetResourceListOperation::GetResourceListOperation( GetResourceListOperation::~GetResourceListOperation() {} GURL GetResourceListOperation::GetURL() const { - return url_generator_.GenerateDocumentListUrl(override_url_, + return url_generator_.GenerateResourceListUrl(override_url_, start_changestamp_, search_string_, shared_with_me_, @@ -148,7 +148,7 @@ GetResourceEntryOperation::GetResourceEntryOperation( GetResourceEntryOperation::~GetResourceEntryOperation() {} GURL GetResourceEntryOperation::GetURL() const { - return url_generator_.GenerateDocumentEntryUrl(resource_id_); + return url_generator_.GenerateResourceEntryUrl(resource_id_); } //========================= GetAccountMetadataOperation ======================== @@ -290,7 +290,7 @@ GURL CreateDirectoryOperation::GetURL() const { if (!parent_content_url_.is_empty()) return GDataWapiUrlGenerator::AddStandardUrlParams(parent_content_url_); - return url_generator_.GenerateDocumentListRootUrl(); + return url_generator_.GenerateResourceListRootUrl(); } URLFetcher::RequestType @@ -346,7 +346,7 @@ URLFetcher::RequestType CopyHostedDocumentOperation::GetRequestType() const { } GURL CopyHostedDocumentOperation::GetURL() const { - return url_generator_.GenerateDocumentListRootUrl(); + return url_generator_.GenerateResourceListRootUrl(); } bool CopyHostedDocumentOperation::GetContentData( @@ -474,11 +474,11 @@ void AuthorizeAppOperation::ParseResponse( const std::string& data) { // Parse entry XML. XmlReader xml_reader; - scoped_ptr<DocumentEntry> entry; + scoped_ptr<ResourceEntry> entry; if (xml_reader.Load(data)) { while (xml_reader.Read()) { - if (xml_reader.NodeName() == DocumentEntry::GetEntryNodeName()) { - entry = DocumentEntry::CreateFromXml(&xml_reader); + if (xml_reader.NodeName() == ResourceEntry::GetEntryNodeName()) { + entry = ResourceEntry::CreateFromXml(&xml_reader); break; } } @@ -540,7 +540,7 @@ GURL AddResourceToDirectoryOperation::GetURL() const { if (!parent_content_url_.is_empty()) return GDataWapiUrlGenerator::AddStandardUrlParams(parent_content_url_); - return url_generator_.GenerateDocumentListRootUrl(); + return url_generator_.GenerateResourceListRootUrl(); } URLFetcher::RequestType @@ -737,7 +737,7 @@ void ResumeUploadOperation::ProcessURLFetchResults(const URLFetcher* source) { net::HttpResponseHeaders* hdrs = source->GetResponseHeaders(); int64 start_range_received = -1; int64 end_range_received = -1; - scoped_ptr<DocumentEntry> entry; + scoped_ptr<ResourceEntry> entry; if (code == HTTP_RESUME_INCOMPLETE) { // Retrieve value of the first "Range" header. @@ -769,8 +769,8 @@ void ResumeUploadOperation::ProcessURLFetchResults(const URLFetcher* source) { XmlReader xml_reader; if (xml_reader.Load(response_content)) { while (xml_reader.Read()) { - if (xml_reader.NodeName() == DocumentEntry::GetEntryNodeName()) { - entry = DocumentEntry::CreateFromXml(&xml_reader); + if (xml_reader.NodeName() == ResourceEntry::GetEntryNodeName()) { + entry = ResourceEntry::CreateFromXml(&xml_reader); break; } } @@ -807,7 +807,7 @@ void ResumeUploadOperation::NotifySuccessToOperationRegistry() { } void ResumeUploadOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { - scoped_ptr<DocumentEntry> entry; + scoped_ptr<ResourceEntry> entry; callback_.Run(ResumeUploadResponse(code, 0, 0), entry.Pass()); } diff --git a/chrome/browser/google_apis/gdata_wapi_operations.h b/chrome/browser/google_apis/gdata_wapi_operations.h index 806daf3..adbd4e1 100644 --- a/chrome/browser/google_apis/gdata_wapi_operations.h +++ b/chrome/browser/google_apis/gdata_wapi_operations.h @@ -20,7 +20,7 @@ class URLRequestContextGetter; namespace google_apis { class GDataWapiUrlGenerator; -class DocumentEntry; +class ResourceEntry; //============================ GetResourceListOperation ======================== @@ -126,8 +126,8 @@ class GetAccountMetadataOperation : public GetDataOperation { //============================ DownloadFileOperation =========================== -// Callback type for DownloadDocument/DownloadFile DocumentServiceInterface -// calls. +// Callback type for DownloadHostedDocument/DownloadFile +// DocumentServiceInterface calls. typedef base::Callback<void(GDataErrorCode error, const FilePath& temp_file)> DownloadActionCallback; @@ -531,7 +531,7 @@ struct ResumeUploadParams { // Callback type for DocumentServiceInterface::ResumeUpload. typedef base::Callback<void( const ResumeUploadResponse& response, - scoped_ptr<DocumentEntry> new_entry)> ResumeUploadCallback; + scoped_ptr<ResourceEntry> new_entry)> ResumeUploadCallback; // This class performs the operation for resuming the upload of a file. // More specifically, this operation uploads a chunk of data carried in |buf| diff --git a/chrome/browser/google_apis/gdata_wapi_operations_unittest.cc b/chrome/browser/google_apis/gdata_wapi_operations_unittest.cc index ed43866..1017946 100644 --- a/chrome/browser/google_apis/gdata_wapi_operations_unittest.cc +++ b/chrome/browser/google_apis/gdata_wapi_operations_unittest.cc @@ -77,9 +77,9 @@ void CopyResultFromInitiateUploadCallbackAndQuit( // Copies the result from ResumeUploadCallback and quit the message loop. void CopyResultFromResumeUploadCallbackAndQuit( ResumeUploadResponse* out_response, - scoped_ptr<DocumentEntry>* out_new_entry, + scoped_ptr<ResourceEntry>* out_new_entry, const ResumeUploadResponse& response, - scoped_ptr<DocumentEntry> new_entry) { + scoped_ptr<ResourceEntry> new_entry) { *out_response = response; *out_new_entry = new_entry.Pass(); MessageLoop::current()->Quit(); @@ -942,7 +942,7 @@ TEST_F(GDataWapiOperationsTest, UploadNewFile) { FilePath::FromUTF8Unsafe("drive/newfile.txt")); ResumeUploadResponse response; - scoped_ptr<DocumentEntry> new_entry; + scoped_ptr<ResourceEntry> new_entry; ResumeUploadOperation* resume_operation = new ResumeUploadOperation( &operation_registry_, @@ -1053,7 +1053,7 @@ TEST_F(GDataWapiOperationsTest, UploadNewLargeFile) { FilePath::FromUTF8Unsafe("drive/newfile.txt")); ResumeUploadResponse response; - scoped_ptr<DocumentEntry> new_entry; + scoped_ptr<ResourceEntry> new_entry; ResumeUploadOperation* resume_operation = new ResumeUploadOperation( &operation_registry_, @@ -1163,7 +1163,7 @@ TEST_F(GDataWapiOperationsTest, UploadNewEmptyFile) { FilePath::FromUTF8Unsafe("drive/newfile.txt")); ResumeUploadResponse response; - scoped_ptr<DocumentEntry> new_entry; + scoped_ptr<ResourceEntry> new_entry; ResumeUploadOperation* resume_operation = new ResumeUploadOperation( &operation_registry_, @@ -1256,7 +1256,7 @@ TEST_F(GDataWapiOperationsTest, UploadExistingFile) { FilePath::FromUTF8Unsafe("drive/existingfile.txt")); ResumeUploadResponse response; - scoped_ptr<DocumentEntry> new_entry; + scoped_ptr<ResourceEntry> new_entry; ResumeUploadOperation* resume_operation = new ResumeUploadOperation( &operation_registry_, diff --git a/chrome/browser/google_apis/gdata_wapi_parser.cc b/chrome/browser/google_apis/gdata_wapi_parser.cc index 527df9b..2a786f1 100644 --- a/chrome/browser/google_apis/gdata_wapi_parser.cc +++ b/chrome/browser/google_apis/gdata_wapi_parser.cc @@ -588,9 +588,9 @@ void FeedEntry::RegisterJSONConverter( } //////////////////////////////////////////////////////////////////////////////// -// DocumentEntry implementation +// ResourceEntry implementation -DocumentEntry::DocumentEntry() +ResourceEntry::ResourceEntry() : kind_(ENTRY_KIND_UNKNOWN), file_size_(0), deleted_(false), @@ -598,16 +598,16 @@ DocumentEntry::DocumentEntry() changestamp_(0) { } -DocumentEntry::~DocumentEntry() { +ResourceEntry::~ResourceEntry() { } -bool DocumentEntry::HasFieldPresent(const base::Value* value, +bool ResourceEntry::HasFieldPresent(const base::Value* value, bool* result) { *result = (value != NULL); return true; } -bool DocumentEntry::ParseChangestamp(const base::Value* value, +bool ResourceEntry::ParseChangestamp(const base::Value* value, int64* result) { DCHECK(result); if (!value) { @@ -624,46 +624,46 @@ bool DocumentEntry::ParseChangestamp(const base::Value* value, } // static -void DocumentEntry::RegisterJSONConverter( - base::JSONValueConverter<DocumentEntry>* converter) { +void ResourceEntry::RegisterJSONConverter( + base::JSONValueConverter<ResourceEntry>* converter) { // Inherit the parent registrations. FeedEntry::RegisterJSONConverter( reinterpret_cast<base::JSONValueConverter<FeedEntry>*>(converter)); converter->RegisterStringField( - kResourceIdField, &DocumentEntry::resource_id_); - converter->RegisterStringField(kIDField, &DocumentEntry::id_); - converter->RegisterStringField(kTitleTField, &DocumentEntry::title_); + kResourceIdField, &ResourceEntry::resource_id_); + converter->RegisterStringField(kIDField, &ResourceEntry::id_); + converter->RegisterStringField(kTitleTField, &ResourceEntry::title_); converter->RegisterCustomField<base::Time>( - kPublishedField, &DocumentEntry::published_time_, + kPublishedField, &ResourceEntry::published_time_, &util::GetTimeFromString); converter->RegisterCustomField<base::Time>( - kLastViewedField, &DocumentEntry::last_viewed_time_, + kLastViewedField, &ResourceEntry::last_viewed_time_, &util::GetTimeFromString); converter->RegisterRepeatedMessage( - kFeedLinkField, &DocumentEntry::feed_links_); - converter->RegisterNestedField(kContentField, &DocumentEntry::content_); + kFeedLinkField, &ResourceEntry::feed_links_); + converter->RegisterNestedField(kContentField, &ResourceEntry::content_); // File properties. If the document type is not a normal file, then // that's no problem because those feed must not have these fields // themselves, which does not report errors. - converter->RegisterStringField(kFileNameField, &DocumentEntry::filename_); - converter->RegisterStringField(kMD5Field, &DocumentEntry::file_md5_); + converter->RegisterStringField(kFileNameField, &ResourceEntry::filename_); + converter->RegisterStringField(kMD5Field, &ResourceEntry::file_md5_); converter->RegisterCustomField<int64>( - kSizeField, &DocumentEntry::file_size_, &base::StringToInt64); + kSizeField, &ResourceEntry::file_size_, &base::StringToInt64); converter->RegisterStringField( - kSuggestedFileNameField, &DocumentEntry::suggested_filename_); + kSuggestedFileNameField, &ResourceEntry::suggested_filename_); // Deleted are treated as 'trashed' items on web client side. Removed files // are gone for good. We treat both cases as 'deleted' for this client. converter->RegisterCustomValueField<bool>( - kDeletedField, &DocumentEntry::deleted_, &DocumentEntry::HasFieldPresent); + kDeletedField, &ResourceEntry::deleted_, &ResourceEntry::HasFieldPresent); converter->RegisterCustomValueField<bool>( - kRemovedField, &DocumentEntry::removed_, &DocumentEntry::HasFieldPresent); + kRemovedField, &ResourceEntry::removed_, &ResourceEntry::HasFieldPresent); converter->RegisterCustomValueField<int64>( - kChangestampField, &DocumentEntry::changestamp_, - &DocumentEntry::ParseChangestamp); + kChangestampField, &ResourceEntry::changestamp_, + &ResourceEntry::ParseChangestamp); } -std::string DocumentEntry::GetHostedDocumentExtension() const { +std::string ResourceEntry::GetHostedDocumentExtension() const { for (size_t i = 0; i < arraysize(kEntryKindMap); i++) { if (kEntryKindMap[i].kind == kind_) { if (kEntryKindMap[i].extension) @@ -676,7 +676,7 @@ std::string DocumentEntry::GetHostedDocumentExtension() const { } // static -bool DocumentEntry::HasHostedDocumentExtension(const FilePath& file) { +bool ResourceEntry::HasHostedDocumentExtension(const FilePath& file) { #if defined(OS_WIN) std::string file_extension = WideToUTF8(file.Extension()); #else @@ -691,7 +691,7 @@ bool DocumentEntry::HasHostedDocumentExtension(const FilePath& file) { } // static -DriveEntryKind DocumentEntry::GetEntryKindFromTerm( +DriveEntryKind ResourceEntry::GetEntryKindFromTerm( const std::string& term) { if (!StartsWithASCII(term, kTermPrefix, false)) { DVLOG(1) << "Unexpected term prefix term " << term; @@ -708,7 +708,7 @@ DriveEntryKind DocumentEntry::GetEntryKindFromTerm( } // static -int DocumentEntry::ClassifyEntryKind(DriveEntryKind kind) { +int ResourceEntry::ClassifyEntryKind(DriveEntryKind kind) { int classes = 0; // All DriveEntryKind members are listed here, so the compiler catches if a @@ -752,7 +752,7 @@ int DocumentEntry::ClassifyEntryKind(DriveEntryKind kind) { return classes; } -void DocumentEntry::FillRemainingFields() { +void ResourceEntry::FillRemainingFields() { // Set |kind_| and |labels_| based on the |categories_| in the class. // JSONValueConverter does not have the ability to catch an element in a list // based on a predicate. Thus we need to iterate over |categories_| and @@ -767,24 +767,24 @@ void DocumentEntry::FillRemainingFields() { } // static -scoped_ptr<DocumentEntry> DocumentEntry::ExtractAndParse( +scoped_ptr<ResourceEntry> ResourceEntry::ExtractAndParse( const base::Value& value) { const base::DictionaryValue* as_dict = NULL; const base::DictionaryValue* entry_dict = NULL; if (value.GetAsDictionary(&as_dict) && as_dict->GetDictionary(kEntryField, &entry_dict)) { - return DocumentEntry::CreateFrom(*entry_dict); + return ResourceEntry::CreateFrom(*entry_dict); } - return scoped_ptr<DocumentEntry>(); + return scoped_ptr<ResourceEntry>(); } // static -scoped_ptr<DocumentEntry> DocumentEntry::CreateFrom(const base::Value& value) { - base::JSONValueConverter<DocumentEntry> converter; - scoped_ptr<DocumentEntry> entry(new DocumentEntry()); +scoped_ptr<ResourceEntry> ResourceEntry::CreateFrom(const base::Value& value) { + base::JSONValueConverter<ResourceEntry> converter; + scoped_ptr<ResourceEntry> entry(new ResourceEntry()); if (!converter.Convert(value, entry.get())) { DVLOG(1) << "Invalid document entry!"; - return scoped_ptr<DocumentEntry>(); + return scoped_ptr<ResourceEntry>(); } entry->FillRemainingFields(); @@ -792,11 +792,11 @@ scoped_ptr<DocumentEntry> DocumentEntry::CreateFrom(const base::Value& value) { } // static. -scoped_ptr<DocumentEntry> DocumentEntry::CreateFromXml(XmlReader* xml_reader) { +scoped_ptr<ResourceEntry> ResourceEntry::CreateFromXml(XmlReader* xml_reader) { if (xml_reader->NodeName() != kEntryNode) - return scoped_ptr<DocumentEntry>(); + return scoped_ptr<ResourceEntry>(); - scoped_ptr<DocumentEntry> entry(new DocumentEntry); + scoped_ptr<ResourceEntry> entry(new ResourceEntry); xml_reader->NodeAttribute(kETagAttr, &entry->etag_); if (!xml_reader->Read()) @@ -883,11 +883,11 @@ scoped_ptr<DocumentEntry> DocumentEntry::CreateFromXml(XmlReader* xml_reader) { } // static -scoped_ptr<DocumentEntry> DocumentEntry::CreateFromFileResource( +scoped_ptr<ResourceEntry> ResourceEntry::CreateFromFileResource( const FileResource& file) { - scoped_ptr<DocumentEntry> entry(new DocumentEntry()); + scoped_ptr<ResourceEntry> entry(new ResourceEntry()); - // DocumentEntry + // ResourceEntry entry->resource_id_ = file.file_id(); entry->id_ = file.file_id(); entry->kind_ = file.GetKind(); @@ -952,9 +952,9 @@ scoped_ptr<DocumentEntry> DocumentEntry::CreateFromFileResource( } // static -scoped_ptr<DocumentEntry> DocumentEntry::CreateFromChangeResource( +scoped_ptr<ResourceEntry> ResourceEntry::CreateFromChangeResource( const ChangeResource& change) { - scoped_ptr<DocumentEntry> entry = CreateFromFileResource(change.file()); + scoped_ptr<ResourceEntry> entry = CreateFromFileResource(change.file()); entry->resource_id_ = change.file_id(); // If |is_deleted()| returns true, the file is removed from Drive. @@ -964,7 +964,7 @@ scoped_ptr<DocumentEntry> DocumentEntry::CreateFromChangeResource( } // static -std::string DocumentEntry::GetEntryNodeName() { +std::string ResourceEntry::GetEntryNodeName() { return kEntryNode; } @@ -1006,9 +1006,9 @@ bool DocumentFeed::Parse(const base::Value& value) { return false; } - ScopedVector<DocumentEntry>::iterator iter = entries_.begin(); + ScopedVector<ResourceEntry>::iterator iter = entries_.begin(); while (iter != entries_.end()) { - DocumentEntry* entry = (*iter); + ResourceEntry* entry = (*iter); entry->FillRemainingFields(); ++iter; } @@ -1049,7 +1049,7 @@ scoped_ptr<DocumentFeed> DocumentFeed::CreateFromChangeList( const ChangeResource& change = **iter; largest_changestamp = std::max(largest_changestamp, change.change_id()); feed->entries_.push_back( - DocumentEntry::CreateFromChangeResource(change).release()); + ResourceEntry::CreateFromChangeResource(change).release()); ++iter; } feed->largest_changestamp_ = largest_changestamp; @@ -1067,7 +1067,7 @@ bool DocumentFeed::GetNextFeedURL(GURL* url) const { return false; } -void DocumentFeed::ReleaseEntries(std::vector<DocumentEntry*>* entries) { +void DocumentFeed::ReleaseEntries(std::vector<ResourceEntry*>* entries) { entries_.release(entries); } diff --git a/chrome/browser/google_apis/gdata_wapi_parser.h b/chrome/browser/google_apis/gdata_wapi_parser.h index 99395e1..20c3e56 100644 --- a/chrome/browser/google_apis/gdata_wapi_parser.h +++ b/chrome/browser/google_apis/gdata_wapi_parser.h @@ -100,7 +100,7 @@ class Link { const std::string& mime_type() const { return mime_type_; } private: - friend class DocumentEntry; + friend class ResourceEntry; // Converts value of link.rel into LinkType. Outputs to |type| and returns // true when |rel| has a valid value. Otherwise does nothing and returns // false. @@ -145,7 +145,7 @@ class FeedLink { const GURL& href() const { return href_; } private: - friend class DocumentEntry; + friend class ResourceEntry; // Converts value of gd$feedLink.rel into FeedLinkType enum. // Outputs to |result| and returns true when |rel| has a valid // value. Otherwise does nothing and returns false. @@ -175,7 +175,7 @@ class Author { const std::string& email() const { return email_; } private: - friend class DocumentEntry; + friend class ResourceEntry; string16 name_; std::string email_; @@ -212,7 +212,7 @@ class Category { const std::string& term() const { return term_; } private: - friend class DocumentEntry; + friend class ResourceEntry; // Converts category scheme into CategoryType enum. For example, // http://schemas.google.com/g/2005#kind => Category::CATEGORY_KIND // Returns false and does not change |result| when |scheme| has an @@ -243,7 +243,7 @@ class Content { const std::string& mime_type() const { return mime_type_; } private: - friend class DocumentEntry; + friend class ResourceEntry; GURL url_; std::string mime_type_; @@ -338,9 +338,9 @@ class FeedEntry { }; // Document feed entry. -class DocumentEntry : public FeedEntry { +class ResourceEntry : public FeedEntry { public: - virtual ~DocumentEntry(); + virtual ~ResourceEntry(); // Extracts "entry" dictionary from the JSON value, and parse the contents, // using CreateFrom(). Returns NULL on failure. The input JSON data, coming @@ -353,25 +353,25 @@ class DocumentEntry : public FeedEntry { // } // // The caller should delete the returned object. - static scoped_ptr<DocumentEntry> ExtractAndParse(const base::Value& value); + static scoped_ptr<ResourceEntry> ExtractAndParse(const base::Value& value); // Creates document entry from parsed JSON Value. You should call // this instead of instantiating JSONValueConverter by yourself // because this method does some post-process for some fields. See // FillRemainingFields comment and implementation for the details. - static scoped_ptr<DocumentEntry> CreateFrom(const base::Value& value); + static scoped_ptr<ResourceEntry> CreateFrom(const base::Value& value); // Creates document entry from parsed XML. - static scoped_ptr<DocumentEntry> CreateFromXml(XmlReader* xml_reader); + static scoped_ptr<ResourceEntry> CreateFromXml(XmlReader* xml_reader); // Creates document entry from FileResource. // TODO(kochi): This should go away soon. http://crbug.com/142293 - static scoped_ptr<DocumentEntry> CreateFromFileResource( + static scoped_ptr<ResourceEntry> CreateFromFileResource( const FileResource& file); // Creates document entry from ChangeResource. // Todo(Kochi): This should go away soon. http://crbug.com/142293 - static scoped_ptr<DocumentEntry> CreateFromChangeResource( + static scoped_ptr<ResourceEntry> CreateFromChangeResource( const ChangeResource& change); // Returns name of entry node. @@ -380,7 +380,7 @@ class DocumentEntry : public FeedEntry { // Registers the mapping between JSON field names and the members in // this class. static void RegisterJSONConverter( - base::JSONValueConverter<DocumentEntry>* converter); + base::JSONValueConverter<ResourceEntry>* converter); // Sets true to |result| if the field exists. // Always returns true even when the field does not exist. @@ -495,11 +495,11 @@ class DocumentEntry : public FeedEntry { static int ClassifyEntryKind(DriveEntryKind kind); private: - friend class base::internal::RepeatedMessageConverter<DocumentEntry>; + friend class base::internal::RepeatedMessageConverter<ResourceEntry>; friend class DocumentFeed; friend class ResumeUploadOperation; - DocumentEntry(); + ResourceEntry(); // Fills the remaining fields where JSONValueConverter cannot catch. void FillRemainingFields(); @@ -528,7 +528,7 @@ class DocumentEntry : public FeedEntry { bool removed_; int64 changestamp_; - DISALLOW_COPY_AND_ASSIGN(DocumentEntry); + DISALLOW_COPY_AND_ASSIGN(ResourceEntry); }; // Document feed represents a list of entries. The feed is paginated and @@ -552,7 +552,7 @@ class DocumentFeed : public FeedEntry { // Creates feed from parsed JSON Value. You should call this // instead of instantiating JSONValueConverter by yourself because // this method does some post-process for some fields. See - // FillRemainingFields comment and implementation in DocumentEntry + // FillRemainingFields comment and implementation in ResourceEntry // class for the details. static scoped_ptr<DocumentFeed> CreateFrom(const base::Value& value); // Variant of CreateFrom() above, creates feed from parsed ChangeList. @@ -570,11 +570,11 @@ class DocumentFeed : public FeedEntry { bool GetNextFeedURL(GURL* url) const; // List of document entries. - const ScopedVector<DocumentEntry>& entries() const { return entries_; } + const ScopedVector<ResourceEntry>& entries() const { return entries_; } // Releases entries_ into |entries|. This is a transfer of ownership, so the // caller is responsible for deleting the elements of |entries|. - void ReleaseEntries(std::vector<DocumentEntry*>* entries); + void ReleaseEntries(std::vector<ResourceEntry*>* entries); // Start index of the document entry list. int start_index() const { return start_index_; } @@ -596,7 +596,7 @@ class DocumentFeed : public FeedEntry { // Return false if parsing fails. bool Parse(const base::Value& value); - ScopedVector<DocumentEntry> entries_; + ScopedVector<ResourceEntry> entries_; int start_index_; int items_per_page_; std::string title_; @@ -700,7 +700,7 @@ class AccountMetadataFeed { // Creates feed from parsed JSON Value. You should call this // instead of instantiating JSONValueConverter by yourself because // this method does some post-process for some fields. See - // FillRemainingFields comment and implementation in DocumentEntry + // FillRemainingFields comment and implementation in ResourceEntry // class for the details. static scoped_ptr<AccountMetadataFeed> CreateFrom(const base::Value& value); diff --git a/chrome/browser/google_apis/gdata_wapi_parser_unittest.cc b/chrome/browser/google_apis/gdata_wapi_parser_unittest.cc index 006cb96..aa85102 100644 --- a/chrome/browser/google_apis/gdata_wapi_parser_unittest.cc +++ b/chrome/browser/google_apis/gdata_wapi_parser_unittest.cc @@ -27,7 +27,7 @@ namespace google_apis { class GDataWAPIParserTest : public testing::Test { protected: - static DocumentEntry* LoadDocumentEntryFromXml(const std::string& filename) { + static ResourceEntry* LoadResourceEntryFromXml(const std::string& filename) { FilePath path; std::string error; PathService::Get(chrome::DIR_TEST_DATA, &path); @@ -43,10 +43,10 @@ class GDataWAPIParserTest : public testing::Test { NOTREACHED() << "Invalid xml:\n" << contents; return NULL; } - scoped_ptr<DocumentEntry> entry; + scoped_ptr<ResourceEntry> entry; while (reader.Read()) { if (reader.NodeName() == "entry") { - entry = DocumentEntry::CreateFromXml(&reader); + entry = ResourceEntry::CreateFromXml(&reader); break; } } @@ -98,7 +98,7 @@ TEST_F(GDataWAPIParserTest, DocumentFeedJsonParser) { ASSERT_EQ(4U, feed->entries().size()); // Check a folder entry. - const DocumentEntry* folder_entry = feed->entries()[0]; + const ResourceEntry* folder_entry = feed->entries()[0]; ASSERT_TRUE(folder_entry); EXPECT_EQ(ENTRY_KIND_FOLDER, folder_entry->kind()); EXPECT_EQ("\"HhMOFgcNHSt7ImBr\"", folder_entry->etag()); @@ -140,7 +140,7 @@ TEST_F(GDataWAPIParserTest, DocumentFeedJsonParser) { EXPECT_EQ("application/atom+xml", entry1_edit_link->mime_type()); // Check a file entry. - const DocumentEntry* file_entry = feed->entries()[1]; + const ResourceEntry* file_entry = feed->entries()[1]; ASSERT_TRUE(file_entry); EXPECT_EQ(ENTRY_KIND_FILE, file_entry->kind()); EXPECT_EQ(ASCIIToUTF16("filename.m4a"), file_entry->filename()); @@ -170,15 +170,15 @@ TEST_F(GDataWAPIParserTest, DocumentFeedJsonParser) { EXPECT_EQ("", file_unknown_link->app_id()); // Check a file entry. - const DocumentEntry* document_entry = feed->entries()[2]; - ASSERT_TRUE(document_entry); - EXPECT_EQ(ENTRY_KIND_DOCUMENT, document_entry->kind()); - EXPECT_TRUE(document_entry->is_hosted_document()); - EXPECT_TRUE(document_entry->is_google_document()); - EXPECT_FALSE(document_entry->is_external_document()); + const ResourceEntry* resource_entry = feed->entries()[2]; + ASSERT_TRUE(resource_entry); + EXPECT_EQ(ENTRY_KIND_DOCUMENT, resource_entry->kind()); + EXPECT_TRUE(resource_entry->is_hosted_document()); + EXPECT_TRUE(resource_entry->is_google_document()); + EXPECT_FALSE(resource_entry->is_external_document()); // Check an external document entry. - const DocumentEntry* app_entry = feed->entries()[3]; + const ResourceEntry* app_entry = feed->entries()[3]; ASSERT_TRUE(app_entry); EXPECT_EQ(ENTRY_KIND_EXTERNAL_APP, app_entry->kind()); EXPECT_TRUE(app_entry->is_hosted_document()); @@ -188,8 +188,8 @@ TEST_F(GDataWAPIParserTest, DocumentFeedJsonParser) { // Test document feed parsing. -TEST_F(GDataWAPIParserTest, DocumentEntryXmlParser) { - scoped_ptr<DocumentEntry> entry(LoadDocumentEntryFromXml("entry.xml")); +TEST_F(GDataWAPIParserTest, ResourceEntryXmlParser) { + scoped_ptr<ResourceEntry> entry(LoadResourceEntryFromXml("entry.xml")); ASSERT_TRUE(entry.get()); EXPECT_EQ(ENTRY_KIND_FILE, entry->kind()); @@ -337,59 +337,59 @@ TEST_F(GDataWAPIParserTest, AccountMetadataFeedParser) { EXPECT_EQ(0U, second_app->secondary_extensions().size()); } -// Test file extension checking in DocumentEntry::HasDocumentExtension(). -TEST_F(GDataWAPIParserTest, DocumentEntryHasDocumentExtension) { - EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( +// Test file extension checking in ResourceEntry::HasDocumentExtension(). +TEST_F(GDataWAPIParserTest, ResourceEntryHasDocumentExtension) { + EXPECT_TRUE(ResourceEntry::HasHostedDocumentExtension( FilePath(FILE_PATH_LITERAL("Test.gdoc")))); - EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( + EXPECT_TRUE(ResourceEntry::HasHostedDocumentExtension( FilePath(FILE_PATH_LITERAL("Test.gsheet")))); - EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( + EXPECT_TRUE(ResourceEntry::HasHostedDocumentExtension( FilePath(FILE_PATH_LITERAL("Test.gslides")))); - EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( + EXPECT_TRUE(ResourceEntry::HasHostedDocumentExtension( FilePath(FILE_PATH_LITERAL("Test.gdraw")))); - EXPECT_TRUE(DocumentEntry::HasHostedDocumentExtension( + EXPECT_TRUE(ResourceEntry::HasHostedDocumentExtension( FilePath(FILE_PATH_LITERAL("Test.gtable")))); - EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension( + EXPECT_FALSE(ResourceEntry::HasHostedDocumentExtension( FilePath(FILE_PATH_LITERAL("Test.tar.gz")))); - EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension( + EXPECT_FALSE(ResourceEntry::HasHostedDocumentExtension( FilePath(FILE_PATH_LITERAL("Test.txt")))); - EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension( + EXPECT_FALSE(ResourceEntry::HasHostedDocumentExtension( FilePath(FILE_PATH_LITERAL("Test")))); - EXPECT_FALSE(DocumentEntry::HasHostedDocumentExtension( + EXPECT_FALSE(ResourceEntry::HasHostedDocumentExtension( FilePath(FILE_PATH_LITERAL("")))); } -TEST_F(GDataWAPIParserTest, DocumentEntryClassifyEntryKind) { - EXPECT_EQ(DocumentEntry::KIND_OF_NONE, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_UNKNOWN)); - EXPECT_EQ(DocumentEntry::KIND_OF_NONE, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_ITEM)); - EXPECT_EQ(DocumentEntry::KIND_OF_NONE, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_SITE)); - EXPECT_EQ(DocumentEntry::KIND_OF_GOOGLE_DOCUMENT | - DocumentEntry::KIND_OF_HOSTED_DOCUMENT, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_DOCUMENT)); - EXPECT_EQ(DocumentEntry::KIND_OF_GOOGLE_DOCUMENT | - DocumentEntry::KIND_OF_HOSTED_DOCUMENT, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_SPREADSHEET)); - EXPECT_EQ(DocumentEntry::KIND_OF_GOOGLE_DOCUMENT | - DocumentEntry::KIND_OF_HOSTED_DOCUMENT, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_PRESENTATION)); - EXPECT_EQ(DocumentEntry::KIND_OF_GOOGLE_DOCUMENT | - DocumentEntry::KIND_OF_HOSTED_DOCUMENT, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_DRAWING)); - EXPECT_EQ(DocumentEntry::KIND_OF_GOOGLE_DOCUMENT | - DocumentEntry::KIND_OF_HOSTED_DOCUMENT, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_TABLE)); - EXPECT_EQ(DocumentEntry::KIND_OF_EXTERNAL_DOCUMENT | - DocumentEntry::KIND_OF_HOSTED_DOCUMENT, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_EXTERNAL_APP)); - EXPECT_EQ(DocumentEntry::KIND_OF_FOLDER, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FOLDER)); - EXPECT_EQ(DocumentEntry::KIND_OF_FILE, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_FILE)); - EXPECT_EQ(DocumentEntry::KIND_OF_FILE, - DocumentEntry::ClassifyEntryKind(ENTRY_KIND_PDF)); +TEST_F(GDataWAPIParserTest, ResourceEntryClassifyEntryKind) { + EXPECT_EQ(ResourceEntry::KIND_OF_NONE, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_UNKNOWN)); + EXPECT_EQ(ResourceEntry::KIND_OF_NONE, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_ITEM)); + EXPECT_EQ(ResourceEntry::KIND_OF_NONE, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_SITE)); + EXPECT_EQ(ResourceEntry::KIND_OF_GOOGLE_DOCUMENT | + ResourceEntry::KIND_OF_HOSTED_DOCUMENT, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_DOCUMENT)); + EXPECT_EQ(ResourceEntry::KIND_OF_GOOGLE_DOCUMENT | + ResourceEntry::KIND_OF_HOSTED_DOCUMENT, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_SPREADSHEET)); + EXPECT_EQ(ResourceEntry::KIND_OF_GOOGLE_DOCUMENT | + ResourceEntry::KIND_OF_HOSTED_DOCUMENT, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_PRESENTATION)); + EXPECT_EQ(ResourceEntry::KIND_OF_GOOGLE_DOCUMENT | + ResourceEntry::KIND_OF_HOSTED_DOCUMENT, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_DRAWING)); + EXPECT_EQ(ResourceEntry::KIND_OF_GOOGLE_DOCUMENT | + ResourceEntry::KIND_OF_HOSTED_DOCUMENT, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_TABLE)); + EXPECT_EQ(ResourceEntry::KIND_OF_EXTERNAL_DOCUMENT | + ResourceEntry::KIND_OF_HOSTED_DOCUMENT, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_EXTERNAL_APP)); + EXPECT_EQ(ResourceEntry::KIND_OF_FOLDER, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_FOLDER)); + EXPECT_EQ(ResourceEntry::KIND_OF_FILE, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_FILE)); + EXPECT_EQ(ResourceEntry::KIND_OF_FILE, + ResourceEntry::ClassifyEntryKind(ENTRY_KIND_PDF)); } } // namespace google_apis diff --git a/chrome/browser/google_apis/gdata_wapi_service.cc b/chrome/browser/google_apis/gdata_wapi_service.cc index b04b92e..afc7480 100644 --- a/chrome/browser/google_apis/gdata_wapi_service.cc +++ b/chrome/browser/google_apis/gdata_wapi_service.cc @@ -134,7 +134,7 @@ OperationProgressStatusList GDataWapiService::GetProgressStatusList() const { return operation_registry()->GetProgressStatusList(); } -void GDataWapiService::GetDocuments( +void GDataWapiService::GetResourceList( const GURL& url, int64 start_changestamp, const std::string& search_query, @@ -158,7 +158,7 @@ void GDataWapiService::GetDocuments( callback)); } -void GDataWapiService::GetDocumentEntry( +void GDataWapiService::GetResourceEntry( const std::string& resource_id, const GetDataCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -189,10 +189,10 @@ void GDataWapiService::GetApplicationInfo( GetAccountMetadata(callback); } -void GDataWapiService::DownloadDocument( +void GDataWapiService::DownloadHostedDocument( const FilePath& virtual_path, const FilePath& local_cache_path, - const GURL& document_url, + const GURL& edit_url, DocumentExportFormat format, const DownloadActionCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -201,7 +201,7 @@ void GDataWapiService::DownloadDocument( DownloadFile( virtual_path, local_cache_path, - chrome_common_net::AppendQueryParameter(document_url, + chrome_common_net::AppendQueryParameter(edit_url, "exportFormat", GetExportFormatParam(format)), callback, @@ -211,7 +211,7 @@ void GDataWapiService::DownloadDocument( void GDataWapiService::DownloadFile( const FilePath& virtual_path, const FilePath& local_cache_path, - const GURL& document_url, + const GURL& content_url, const DownloadActionCallback& download_action_callback, const GetContentCallback& get_content_callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -222,13 +222,14 @@ void GDataWapiService::DownloadFile( new DownloadFileOperation(operation_registry(), url_request_context_getter_, download_action_callback, - get_content_callback, document_url, + get_content_callback, + content_url, virtual_path, local_cache_path)); } -void GDataWapiService::DeleteDocument( - const GURL& document_url, +void GDataWapiService::DeleteResource( + const GURL& edit_url, const EntryActionCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -237,7 +238,7 @@ void GDataWapiService::DeleteDocument( new DeleteResourceOperation(operation_registry(), url_request_context_getter_, callback, - document_url)); + edit_url)); } void GDataWapiService::AddNewDirectory( @@ -256,7 +257,7 @@ void GDataWapiService::AddNewDirectory( directory_name)); } -void GDataWapiService::CopyDocument( +void GDataWapiService::CopyHostedDocument( const std::string& resource_id, const FilePath::StringType& new_name, const GetDataCallback& callback) { @@ -273,7 +274,7 @@ void GDataWapiService::CopyDocument( } void GDataWapiService::RenameResource( - const GURL& resource_url, + const GURL& edit_url, const FilePath::StringType& new_name, const EntryActionCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -283,13 +284,13 @@ void GDataWapiService::RenameResource( new RenameResourceOperation(operation_registry(), url_request_context_getter_, callback, - resource_url, + edit_url, new_name)); } void GDataWapiService::AddResourceToDirectory( const GURL& parent_content_url, - const GURL& resource_url, + const GURL& edit_url, const EntryActionCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -300,7 +301,7 @@ void GDataWapiService::AddResourceToDirectory( url_generator_, callback, parent_content_url, - resource_url)); + edit_url)); } void GDataWapiService::RemoveResourceFromDirectory( @@ -348,7 +349,7 @@ void GDataWapiService::ResumeUpload(const ResumeUploadParams& params, params)); } -void GDataWapiService::AuthorizeApp(const GURL& resource_url, +void GDataWapiService::AuthorizeApp(const GURL& edit_url, const std::string& app_id, const GetDataCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -358,7 +359,7 @@ void GDataWapiService::AuthorizeApp(const GURL& resource_url, new AuthorizeAppOperation(operation_registry(), url_request_context_getter_, callback, - resource_url, + edit_url, app_id)); } diff --git a/chrome/browser/google_apis/gdata_wapi_service.h b/chrome/browser/google_apis/gdata_wapi_service.h index 4367ded..56c1e79 100644 --- a/chrome/browser/google_apis/gdata_wapi_service.h +++ b/chrome/browser/google_apis/gdata_wapi_service.h @@ -59,22 +59,22 @@ class GDataWapiService : public DriveServiceInterface, virtual OperationProgressStatusList GetProgressStatusList() const OVERRIDE; virtual bool HasAccessToken() const OVERRIDE; virtual bool HasRefreshToken() const OVERRIDE; - virtual void GetDocuments(const GURL& feed_url, - int64 start_changestamp, - const std::string& search_query, - bool shared_with_me, - const std::string& directory_resource_id, - const GetDataCallback& callback) OVERRIDE; - virtual void GetDocumentEntry(const std::string& resource_id, + virtual void GetResourceList(const GURL& feed_url, + int64 start_changestamp, + const std::string& search_query, + bool shared_with_me, + const std::string& directory_resource_id, + const GetDataCallback& callback) OVERRIDE; + virtual void GetResourceEntry(const std::string& resource_id, const GetDataCallback& callback) OVERRIDE; virtual void GetAccountMetadata(const GetDataCallback& callback) OVERRIDE; virtual void GetApplicationInfo(const GetDataCallback& callback) OVERRIDE; - virtual void DeleteDocument(const GURL& document_url, + virtual void DeleteResource(const GURL& edit_url, const EntryActionCallback& callback) OVERRIDE; - virtual void DownloadDocument( + virtual void DownloadHostedDocument( const FilePath& virtual_path, const FilePath& local_cache_path, - const GURL& content_url, + const GURL& edit_url, DocumentExportFormat format, const DownloadActionCallback& callback) OVERRIDE; virtual void DownloadFile( @@ -83,17 +83,17 @@ class GDataWapiService : public DriveServiceInterface, const GURL& content_url, const DownloadActionCallback& download_action_callback, const GetContentCallback& get_content_callback) OVERRIDE; - virtual void CopyDocument( + virtual void CopyHostedDocument( const std::string& resource_id, const FilePath::StringType& new_name, const GetDataCallback& callback) OVERRIDE; virtual void RenameResource( - const GURL& document_url, + const GURL& edit_url, const FilePath::StringType& new_name, const EntryActionCallback& callback) OVERRIDE; virtual void AddResourceToDirectory( const GURL& parent_content_url, - const GURL& resource_url, + const GURL& edit_url, const EntryActionCallback& callback) OVERRIDE; virtual void RemoveResourceFromDirectory( const GURL& parent_content_url, @@ -110,7 +110,7 @@ class GDataWapiService : public DriveServiceInterface, const ResumeUploadParams& params, const ResumeUploadCallback& callback) OVERRIDE; virtual void AuthorizeApp( - const GURL& resource_url, + const GURL& edit_url, const std::string& app_id, const GetDataCallback& callback) OVERRIDE; diff --git a/chrome/browser/google_apis/gdata_wapi_url_generator.cc b/chrome/browser/google_apis/gdata_wapi_url_generator.cc index 32024fa..eec9bcb 100644 --- a/chrome/browser/google_apis/gdata_wapi_url_generator.cc +++ b/chrome/browser/google_apis/gdata_wapi_url_generator.cc @@ -13,21 +13,21 @@ namespace google_apis { namespace { -// URL requesting documents list that belong to the authenticated user only +// URL requesting resource list that belong to the authenticated user only // (handled with '/-/mine' part). -const char kGetDocumentListURLForAllDocuments[] = +const char kGetResourceListURLForAllDocuments[] = "/feeds/default/private/full/-/mine"; -// URL requesting documents list in a particular directory specified by "%s" +// URL requesting resource list in a particular directory specified by "%s" // that belong to the authenticated user only (handled with '/-/mine' part). -const char kGetDocumentListURLForDirectoryFormat[] = +const char kGetResourceListURLForDirectoryFormat[] = "/feeds/default/private/full/%s/contents/-/mine"; -// URL requesting single document entry whose resource id is specified by "%s". -const char kGetDocumentEntryURLFormat[] = "/feeds/default/private/full/%s"; +// URL requesting single resource entry whose resource id is specified by "%s". +const char kGetResourceEntryURLFormat[] = "/feeds/default/private/full/%s"; -// Root document list url. -const char kDocumentListRootURL[] = "/feeds/default/private/full"; +// Root resource list url. +const char kResourceListRootURL[] = "/feeds/default/private/full"; // Metadata feed with things like user quota. const char kAccountMetadataURL[] = "/feeds/metadata/default"; @@ -44,7 +44,7 @@ const int kMaxDocumentsPerSearchFeed = 50; #endif // URL requesting documents list that shared to the authenticated user only -const char kGetDocumentListURLForSharedWithMe[] = +const char kGetResourceListURLForSharedWithMe[] = "/feeds/default/private/full/-/shared-with-me"; // URL requesting documents list of changes to documents collections. @@ -116,7 +116,7 @@ GDataWapiUrlGenerator::GDataWapiUrlGenerator(const GURL& base_url) GDataWapiUrlGenerator::~GDataWapiUrlGenerator() { } -GURL GDataWapiUrlGenerator::GenerateDocumentListUrl( +GURL GDataWapiUrlGenerator::GenerateResourceListUrl( const GURL& override_url, int start_changestamp, const std::string& search_string, @@ -130,32 +130,32 @@ GURL GDataWapiUrlGenerator::GenerateDocumentListUrl( if (!override_url.is_empty()) { url = override_url; } else if (shared_with_me) { - url = base_url_.Resolve(kGetDocumentListURLForSharedWithMe); + url = base_url_.Resolve(kGetResourceListURLForSharedWithMe); } else if (start_changestamp > 0) { // The start changestamp shouldn't be used for a search. DCHECK(search_string.empty()); url = base_url_.Resolve(kGetChangesListURL); } else if (!directory_resource_id.empty()) { url = base_url_.Resolve( - base::StringPrintf(kGetDocumentListURLForDirectoryFormat, + base::StringPrintf(kGetResourceListURLForDirectoryFormat, net::EscapePath( directory_resource_id).c_str())); } else { - url = base_url_.Resolve(kGetDocumentListURLForAllDocuments); + url = base_url_.Resolve(kGetResourceListURLForAllDocuments); } return AddFeedUrlParams(url, max_docs, start_changestamp, search_string); } -GURL GDataWapiUrlGenerator::GenerateDocumentEntryUrl( +GURL GDataWapiUrlGenerator::GenerateResourceEntryUrl( const std::string& resource_id) const { GURL result = base_url_.Resolve( - base::StringPrintf(kGetDocumentEntryURLFormat, + base::StringPrintf(kGetResourceEntryURLFormat, net::EscapePath(resource_id).c_str())); return AddStandardUrlParams(result); } -GURL GDataWapiUrlGenerator::GenerateDocumentListRootUrl() const { - return AddStandardUrlParams(base_url_.Resolve(kDocumentListRootURL)); +GURL GDataWapiUrlGenerator::GenerateResourceListRootUrl() const { + return AddStandardUrlParams(base_url_.Resolve(kResourceListRootURL)); } GURL GDataWapiUrlGenerator::GenerateAccountMetadataUrl() const { diff --git a/chrome/browser/google_apis/gdata_wapi_url_generator.h b/chrome/browser/google_apis/gdata_wapi_url_generator.h index eadb00a..f3be060 100644 --- a/chrome/browser/google_apis/gdata_wapi_url_generator.h +++ b/chrome/browser/google_apis/gdata_wapi_url_generator.h @@ -44,7 +44,7 @@ class GDataWapiUrlGenerator { int changestamp, const std::string& search_string); - // Generates a URL for getting the documents list feed. + // Generates a URL for getting the resource list feed. // // override_url: // By default, a hard-coded base URL of the WAPI server is used. @@ -67,20 +67,20 @@ class GDataWapiUrlGenerator { // If |directory_resource_id| is non-empty, a URL for fetching documents in // a particular directory is generated. // - GURL GenerateDocumentListUrl( + GURL GenerateResourceListUrl( const GURL& override_url, int start_changestamp, const std::string& search_string, bool shared_with_me, const std::string& directory_resource_id) const; - // Generates a URL for getting the document entry of the given resource ID. - GURL GenerateDocumentEntryUrl(const std::string& resource_id) const; + // Generates a URL for getting the resource entry of the given resource ID. + GURL GenerateResourceEntryUrl(const std::string& resource_id) const; - // Generates a URL for getting the root document list feed. + // Generates a URL for getting the root resource list feed. // Used to make changes in the root directory (ex. create a directory in the // root directory) - GURL GenerateDocumentListRootUrl() const; + GURL GenerateResourceListRootUrl() const; // Generates a URL for getting the account metadata feed. GURL GenerateAccountMetadataUrl() const; diff --git a/chrome/browser/google_apis/gdata_wapi_url_generator_unittest.cc b/chrome/browser/google_apis/gdata_wapi_url_generator_unittest.cc index c50a2f6..f8fa234 100644 --- a/chrome/browser/google_apis/gdata_wapi_url_generator_unittest.cc +++ b/chrome/browser/google_apis/gdata_wapi_url_generator_unittest.cc @@ -69,13 +69,13 @@ TEST_F(GDataWapiUrlGeneratorTest, AddFeedUrlParams) { ).spec()); } -TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) { - // This is the very basic URL for the GetDocuments operation. +TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) { + // This is the very basic URL for the GetResourceList operation. EXPECT_EQ( "https://docs.google.com/feeds/default/private/full/-/mine" "?v=3&alt=json&showfolders=true&max-results=500" "&include-installed-apps=true", - url_generator_.GenerateDocumentListUrl(GURL(), // override_url, + url_generator_.GenerateResourceListUrl(GURL(), // override_url, 0, // start_changestamp, "", // search_string, false, // shared_with_me, @@ -88,7 +88,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) { "http://localhost/" "?v=3&alt=json&showfolders=true&max-results=500" "&include-installed-apps=true", - url_generator_.GenerateDocumentListUrl( + url_generator_.GenerateResourceListUrl( GURL("http://localhost/"), // override_url, 0, // start_changestamp, "", // search_string, @@ -103,7 +103,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) { "?v=3&alt=json&showfolders=true&max-results=500" "&include-installed-apps=true" "&start-index=100", - url_generator_.GenerateDocumentListUrl(GURL(), // override_url, + url_generator_.GenerateResourceListUrl(GURL(), // override_url, 100, // start_changestamp, "", // search_string, false, // shared_with_me, @@ -116,7 +116,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) { "https://docs.google.com/feeds/default/private/full/-/mine" "?v=3&alt=json&showfolders=true&max-results=50" "&include-installed-apps=true&q=foo", - url_generator_.GenerateDocumentListUrl(GURL(), // override_url, + url_generator_.GenerateResourceListUrl(GURL(), // override_url, 0, // start_changestamp, "foo", // search_string, false, // shared_with_me, @@ -129,7 +129,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) { "https://docs.google.com/feeds/default/private/full/-/shared-with-me" "?v=3&alt=json&showfolders=true&max-results=500" "&include-installed-apps=true", - url_generator_.GenerateDocumentListUrl(GURL(), // override_url, + url_generator_.GenerateResourceListUrl(GURL(), // override_url, 0, // start_changestamp, "", // search_string, true, // shared_with_me, @@ -142,7 +142,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) { "https://docs.google.com/feeds/default/private/full/XXX/contents/-/mine" "?v=3&alt=json&showfolders=true&max-results=500" "&include-installed-apps=true", - url_generator_.GenerateDocumentListUrl(GURL(), // override_url, + url_generator_.GenerateResourceListUrl(GURL(), // override_url, 0, // start_changestamp, "", // search_string, false, // shared_with_me, @@ -150,16 +150,16 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) { ).spec()); } -TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentEntryUrl) { +TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceEntryUrl) { EXPECT_EQ( "https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json", - url_generator_.GenerateDocumentEntryUrl("XXX").spec()); + url_generator_.GenerateResourceEntryUrl("XXX").spec()); } -TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListRootUrl) { +TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListRootUrl) { EXPECT_EQ( "https://docs.google.com/feeds/default/private/full?v=3&alt=json", - url_generator_.GenerateDocumentListRootUrl().spec()); + url_generator_.GenerateResourceListRootUrl().spec()); } TEST_F(GDataWapiUrlGeneratorTest, GenerateAccountMetadataUrl) { diff --git a/chrome/browser/google_apis/mock_drive_service.cc b/chrome/browser/google_apis/mock_drive_service.cc index 87bc0ad..2322577 100644 --- a/chrome/browser/google_apis/mock_drive_service.cc +++ b/chrome/browser/google_apis/mock_drive_service.cc @@ -24,16 +24,17 @@ namespace google_apis { MockDriveService::MockDriveService() { ON_CALL(*this, GetProgressStatusList()) .WillByDefault(Return(OperationProgressStatusList())); - ON_CALL(*this, GetDocuments(_, _, _, _, _, _)) - .WillByDefault(Invoke(this, &MockDriveService::GetDocumentsStub)); + ON_CALL(*this, GetResourceList(_, _, _, _, _, _)) + .WillByDefault(Invoke(this, &MockDriveService::GetResourceListStub)); ON_CALL(*this, GetAccountMetadata(_)) .WillByDefault(Invoke(this, &MockDriveService::GetAccountMetadataStub)); - ON_CALL(*this, DeleteDocument(_, _)) - .WillByDefault(Invoke(this, &MockDriveService::DeleteDocumentStub)); - ON_CALL(*this, DownloadDocument(_, _, _, _, _)) - .WillByDefault(Invoke(this, &MockDriveService::DownloadDocumentStub)); - ON_CALL(*this, CopyDocument(_, _, _)) - .WillByDefault(Invoke(this, &MockDriveService::CopyDocumentStub)); + ON_CALL(*this, DeleteResource(_, _)) + .WillByDefault(Invoke(this, &MockDriveService::DeleteResourceStub)); + ON_CALL(*this, DownloadHostedDocument(_, _, _, _, _)) + .WillByDefault( + Invoke(this, &MockDriveService::DownloadHostedDocumentStub)); + ON_CALL(*this, CopyHostedDocument(_, _, _)) + .WillByDefault(Invoke(this, &MockDriveService::CopyHostedDocumentStub)); ON_CALL(*this, RenameResource(_, _, _)) .WillByDefault(Invoke(this, &MockDriveService::RenameResourceStub)); ON_CALL(*this, AddResourceToDirectory(_, _, _)) @@ -62,7 +63,7 @@ void MockDriveService::set_search_result( search_result_ = test_util::LoadJSONFile(search_result_feed); } -void MockDriveService::GetDocumentsStub( +void MockDriveService::GetResourceListStub( const GURL& feed_url, int64 start_changestamp, const std::string& search_string, @@ -90,15 +91,15 @@ void MockDriveService::GetAccountMetadataStub( base::Passed(&account_metadata_))); } -void MockDriveService::DeleteDocumentStub( - const GURL& document_url, +void MockDriveService::DeleteResourceStub( + const GURL& edit_url, const EntryActionCallback& callback) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, base::Bind(callback, HTTP_SUCCESS)); } -void MockDriveService::DownloadDocumentStub( +void MockDriveService::DownloadHostedDocumentStub( const FilePath& virtual_path, const FilePath& local_tmp_path, const GURL& content_url, @@ -109,7 +110,7 @@ void MockDriveService::DownloadDocumentStub( base::Bind(callback, HTTP_SUCCESS, local_tmp_path)); } -void MockDriveService::CopyDocumentStub( +void MockDriveService::CopyHostedDocumentStub( const std::string& resource_id, const FilePath::StringType& new_name, const GetDataCallback& callback) { @@ -120,7 +121,7 @@ void MockDriveService::CopyDocumentStub( } void MockDriveService::RenameResourceStub( - const GURL& resource_url, + const GURL& edit_url, const FilePath::StringType& new_name, const EntryActionCallback& callback) { base::MessageLoopProxy::current()->PostTask( @@ -130,7 +131,7 @@ void MockDriveService::RenameResourceStub( void MockDriveService::AddResourceToDirectoryStub( const GURL& parent_content_url, - const GURL& resource_url, + const GURL& edit_url, const EntryActionCallback& callback) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, diff --git a/chrome/browser/google_apis/mock_drive_service.h b/chrome/browser/google_apis/mock_drive_service.h index f4e9187..aed548d 100644 --- a/chrome/browser/google_apis/mock_drive_service.h +++ b/chrome/browser/google_apis/mock_drive_service.h @@ -27,73 +27,73 @@ class MockDriveService : public DriveServiceInterface { MOCK_METHOD1(Initialize, void(Profile* profile)); MOCK_METHOD1(AddObserver, void(DriveServiceObserver* observer)); MOCK_METHOD1(RemoveObserver, - void(DriveServiceObserver* observer)); + void(DriveServiceObserver* observer)); MOCK_CONST_METHOD0(CanStartOperation, bool()); MOCK_METHOD0(CancelAll, void(void)); MOCK_METHOD1(CancelForFilePath, bool(const FilePath& file_path)); MOCK_CONST_METHOD0(GetProgressStatusList, - OperationProgressStatusList()); - MOCK_METHOD6(GetDocuments, - void(const GURL& feed_url, - int64 start_changestamp, - const std::string& search_string, - bool shared_with_me, - const std::string& directory_resource_id, - const GetDataCallback& callback)); - MOCK_METHOD2(GetDocumentEntry, - void(const std::string& resource_id, - const GetDataCallback& callback)); + OperationProgressStatusList()); + MOCK_METHOD6(GetResourceList, + void(const GURL& feed_url, + int64 start_changestamp, + const std::string& search_string, + bool shared_with_me, + const std::string& directory_resource_id, + const GetDataCallback& callback)); + MOCK_METHOD2(GetResourceEntry, + void(const std::string& resource_id, + const GetDataCallback& callback)); MOCK_METHOD1(GetAccountMetadata, - void(const GetDataCallback& callback)); + void(const GetDataCallback& callback)); MOCK_METHOD1(GetApplicationInfo, - void(const GetDataCallback& callback)); - MOCK_METHOD2(DeleteDocument, - void(const GURL& document_url, - const EntryActionCallback& callback)); - MOCK_METHOD5(DownloadDocument, - void(const FilePath& virtual_path, - const FilePath& local_cache_path, - const GURL& content_url, - DocumentExportFormat format, - const DownloadActionCallback& callback)); - MOCK_METHOD3(CopyDocument, - void(const std::string& resource_id, - const FilePath::StringType& new_name, - const GetDataCallback& callback)); + void(const GetDataCallback& callback)); + MOCK_METHOD2(DeleteResource, + void(const GURL& edit_url, + const EntryActionCallback& callback)); + MOCK_METHOD5(DownloadHostedDocument, + void(const FilePath& virtual_path, + const FilePath& local_cache_path, + const GURL& content_url, + DocumentExportFormat format, + const DownloadActionCallback& callback)); + MOCK_METHOD3(CopyHostedDocument, + void(const std::string& resource_id, + const FilePath::StringType& new_name, + const GetDataCallback& callback)); MOCK_METHOD3(RenameResource, - void(const GURL& resource_url, - const FilePath::StringType& new_name, - const EntryActionCallback& callback)); + void(const GURL& edit_url, + const FilePath::StringType& new_name, + const EntryActionCallback& callback)); MOCK_METHOD3(AddResourceToDirectory, - void(const GURL& parent_content_url, - const GURL& resource_url, - const EntryActionCallback& callback)); + void(const GURL& parent_content_url, + const GURL& edit_url, + const EntryActionCallback& callback)); MOCK_METHOD3(RemoveResourceFromDirectory, - void(const GURL& parent_content_url, - const std::string& resource_id, - const EntryActionCallback& callback)); + void(const GURL& parent_content_url, + const std::string& resource_id, + const EntryActionCallback& callback)); MOCK_METHOD3(AddNewDirectory, - void(const GURL& parent_content_url, - const FilePath::StringType& directory_name, - const GetDataCallback& callback)); + void(const GURL& parent_content_url, + const FilePath::StringType& directory_name, + const GetDataCallback& callback)); MOCK_METHOD5( DownloadFile, void(const FilePath& virtual_path, - const FilePath& local_cache_path, - const GURL& content_url, - const DownloadActionCallback& - donwload_action_callback, - const GetContentCallback& get_content_callback)); + const FilePath& local_cache_path, + const GURL& content_url, + const DownloadActionCallback& + donwload_action_callback, + const GetContentCallback& get_content_callback)); MOCK_METHOD2(InitiateUpload, - void(const InitiateUploadParams& upload_file_info, - const InitiateUploadCallback& callback)); + void(const InitiateUploadParams& upload_file_info, + const InitiateUploadCallback& callback)); MOCK_METHOD2(ResumeUpload, - void(const ResumeUploadParams& upload_file_info, - const ResumeUploadCallback& callback)); + void(const ResumeUploadParams& upload_file_info, + const ResumeUploadCallback& callback)); MOCK_METHOD3(AuthorizeApp, - void(const GURL& resource_url, - const std::string& app_id, - const GetDataCallback& callback)); + void(const GURL& edit_url, + const std::string& app_id, + const GetDataCallback& callback)); MOCK_CONST_METHOD0(HasAccessToken, bool()); MOCK_CONST_METHOD0(HasRefreshToken, bool()); @@ -121,24 +121,24 @@ class MockDriveService : public DriveServiceInterface { // Will call |callback| with HTTP_SUCCESS and a StringValue with the current // value of |feed_data_|. - void GetDocumentsStub(const GURL& feed_url, - int64 start_changestamp, - const std::string& search_string, - bool shared_with_me, - const std::string& directory_resource_id, - const GetDataCallback& callback); + void GetResourceListStub(const GURL& feed_url, + int64 start_changestamp, + const std::string& search_string, + bool shared_with_me, + const std::string& directory_resource_id, + const GetDataCallback& callback); // Will call |callback| with HTTP_SUCCESS and a StringValue with the current // value of |account_metadata_|. void GetAccountMetadataStub(const GetDataCallback& callback); // Will call |callback| with HTTP_SUCCESS. - void DeleteDocumentStub(const GURL& document_url, - const EntryActionCallback& callback); + void DeleteResourceStub(const GURL& edit_url, + const EntryActionCallback& callback); // Will call |callback| with HTTP_SUCCESS, the given URL, and the host+path // portion of the URL as the temporary file path. - void DownloadDocumentStub( + void DownloadHostedDocumentStub( const FilePath& virtual_path, const FilePath& local_tmp_path, const GURL& content_url, @@ -147,19 +147,19 @@ class MockDriveService : public DriveServiceInterface { // Will call |callback| with HTTP_SUCCESS and the current value of // |document_data_|. - void CopyDocumentStub(const std::string& resource_id, - const FilePath::StringType& new_name, - const GetDataCallback& callback); + void CopyHostedDocumentStub(const std::string& resource_id, + const FilePath::StringType& new_name, + const GetDataCallback& callback); // Will call |callback| with HTTP_SUCCESS. - void RenameResourceStub(const GURL& document_url, - const FilePath::StringType& new_name, - const EntryActionCallback& callback); + void RenameResourceStub(const GURL& edit_url, + const FilePath::StringType& new_name, + const EntryActionCallback& callback); // Will call |callback| with HTTP_SUCCESS. void AddResourceToDirectoryStub( const GURL& parent_content_url, - const GURL& resource_url, + const GURL& edit_url, const EntryActionCallback& callback); // Will call |callback| with HTTP_SUCCESS. @@ -171,8 +171,8 @@ class MockDriveService : public DriveServiceInterface { // Will call |callback| with HTTP_SUCCESS and the current value of // |directory_data_|. void CreateDirectoryStub(const GURL& parent_content_url, - const FilePath::StringType& directory_name, - const GetDataCallback& callback); + const FilePath::StringType& directory_name, + const GetDataCallback& callback); // Will call |callback| with HTTP_SUCCESS, the given URL, and the host+path // portion of the URL as the temporary file path. If |file_data_| is not null, @@ -187,21 +187,21 @@ class MockDriveService : public DriveServiceInterface { // Account meta data to be returned from GetAccountMetadata. scoped_ptr<base::Value> account_metadata_; - // Feed data to be returned from GetDocuments. + // Feed data to be returned from GetResourceList. scoped_ptr<base::Value> feed_data_; // Feed data to be returned from CreateDirectory. scoped_ptr<base::Value> directory_data_; - // Feed data to be returned from CopyDocument. + // Feed data to be returned from CopyHostedDocument. scoped_ptr<base::Value> document_data_; - // Feed data to be returned from GetDocuments if the search path is specified. - // The feed contains subset of the root_feed. + // Feed data to be returned from GetResourceList if the search path is + // specified. The feed contains subset of the root_feed. scoped_ptr<base::Value> search_result_; // File data to be written to the local temporary file when - // DownloadDocumentStub is called. + // DownloadHostedDocumentStub is called. scoped_ptr<std::string> file_data_; }; diff --git a/chrome/browser/sync_file_system/drive_file_sync_client.cc b/chrome/browser/sync_file_system/drive_file_sync_client.cc index 82069ae..0ecec26 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_client.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_client.cc @@ -48,11 +48,11 @@ bool HasParentLinkTo(const ScopedVector<google_apis::Link>& links, return should_not_have_parent; } -google_apis::DocumentEntry* GetDocumentByTitleAndParent( - const ScopedVector<google_apis::DocumentEntry>& entries, +google_apis::ResourceEntry* GetDocumentByTitleAndParent( + const ScopedVector<google_apis::ResourceEntry>& entries, const GURL& parent_link, const string16& title) { - typedef ScopedVector<google_apis::DocumentEntry>::const_iterator iterator; + typedef ScopedVector<google_apis::ResourceEntry>::const_iterator iterator; for (iterator itr = entries.begin(); itr != entries.end(); ++itr) { if ((*itr)->title() == title && HasParentLinkTo((*itr)->links(), parent_link)) { @@ -162,7 +162,7 @@ void DriveFileSyncClient::DidGetDirectory( GURL parent_link; if (!parent_resource_id.empty()) parent_link = ResourceIdToResourceLink(parent_resource_id); - google_apis::DocumentEntry* entry = GetDocumentByTitleAndParent( + google_apis::ResourceEntry* entry = GetDocumentByTitleAndParent( feed->entries(), parent_link, ASCIIToUTF16(directory_name)); if (!entry) { if (parent_resource_id.empty()) { @@ -174,7 +174,7 @@ void DriveFileSyncClient::DidGetDirectory( AsWeakPtr(), callback)); return; } - drive_service_->GetDocumentEntry( + drive_service_->GetResourceEntry( parent_resource_id, base::Bind( &DriveFileSyncClient::DidGetParentDirectoryForCreateDirectory, @@ -203,8 +203,8 @@ void DriveFileSyncClient::DidGetParentDirectoryForCreateDirectory( } DCHECK(data); - scoped_ptr<google_apis::DocumentEntry> entry( - google_apis::DocumentEntry::ExtractAndParse(*data)); + scoped_ptr<google_apis::ResourceEntry> entry( + google_apis::ResourceEntry::ExtractAndParse(*data)); if (!entry) { callback.Run(google_apis::GDATA_PARSE_ERROR, std::string()); return; @@ -232,8 +232,8 @@ void DriveFileSyncClient::DidCreateDirectory( // TODO(tzik): Confirm if there's no confliction. If another client tried // to create the directory, we might make duplicated directories. - scoped_ptr<google_apis::DocumentEntry> entry( - google_apis::DocumentEntry::ExtractAndParse(*data)); + scoped_ptr<google_apis::ResourceEntry> entry( + google_apis::ResourceEntry::ExtractAndParse(*data)); DCHECK(entry); callback.Run(error, entry->resource_id()); } @@ -247,13 +247,13 @@ void DriveFileSyncClient::GetLargestChangeStamp( AsWeakPtr(), callback)); } -void DriveFileSyncClient::GetDocumentEntry( +void DriveFileSyncClient::GetResourceEntry( const std::string& resource_id, - const DocumentEntryCallback& callback) { + const ResourceEntryCallback& callback) { DCHECK(CalledOnValidThread()); - drive_service_->GetDocumentEntry( + drive_service_->GetResourceEntry( resource_id, - base::Bind(&DriveFileSyncClient::DidGetDocumentEntryData, + base::Bind(&DriveFileSyncClient::DidGetResourceEntryData, AsWeakPtr(), callback)); } @@ -278,7 +278,7 @@ void DriveFileSyncClient::SearchFilesInDirectory( const std::string& search_query, const DocumentFeedCallback& callback) { DCHECK(CalledOnValidThread()); - drive_service_->GetDocuments( + drive_service_->GetResourceList( GURL(), // feed_url 0, // start_changestamp search_query, @@ -299,7 +299,7 @@ void DriveFileSyncClient::ListFiles(const std::string& directory_resource_id, void DriveFileSyncClient::ListChanges(int64 start_changestamp, const DocumentFeedCallback& callback) { DCHECK(CalledOnValidThread()); - drive_service_->GetDocuments( + drive_service_->GetResourceList( GURL(), // feed_url start_changestamp, std::string(), // search_query @@ -313,7 +313,7 @@ void DriveFileSyncClient::ContinueListing( const GURL& feed_url, const DocumentFeedCallback& callback) { DCHECK(CalledOnValidThread()); - drive_service_->GetDocuments( + drive_service_->GetResourceList( feed_url, 0, // start_changestamp std::string(), // search_query @@ -329,9 +329,9 @@ void DriveFileSyncClient::DownloadFile( const FilePath& local_file_path, const DownloadFileCallback& callback) { DCHECK(CalledOnValidThread()); - drive_service_->GetDocumentEntry( + drive_service_->GetResourceEntry( resource_id, - base::Bind(&DriveFileSyncClient::DidGetDocumentEntryData, + base::Bind(&DriveFileSyncClient::DidGetResourceEntryData, AsWeakPtr(), base::Bind(&DriveFileSyncClient::DownloadFileInternal, AsWeakPtr(), local_file_md5, local_file_path, @@ -345,9 +345,9 @@ void DriveFileSyncClient::UploadNewFile( int64 file_size, const UploadFileCallback& callback) { DCHECK(CalledOnValidThread()); - drive_service_->GetDocumentEntry( + drive_service_->GetResourceEntry( directory_resource_id, - base::Bind(&DriveFileSyncClient::DidGetDocumentEntryData, + base::Bind(&DriveFileSyncClient::DidGetResourceEntryData, AsWeakPtr(), base::Bind(&DriveFileSyncClient::UploadNewFileInternal, AsWeakPtr(), local_file_path, title, file_size, @@ -361,9 +361,9 @@ void DriveFileSyncClient::UploadExistingFile( int64 file_size, const UploadFileCallback& callback) { DCHECK(CalledOnValidThread()); - drive_service_->GetDocumentEntry( + drive_service_->GetResourceEntry( resource_id, - base::Bind(&DriveFileSyncClient::DidGetDocumentEntryData, + base::Bind(&DriveFileSyncClient::DidGetResourceEntryData, AsWeakPtr(), base::Bind(&DriveFileSyncClient::UploadExistingFileInternal, AsWeakPtr(), remote_file_md5, local_file_path, @@ -375,9 +375,9 @@ void DriveFileSyncClient::DeleteFile( const std::string& remote_file_md5, const GDataErrorCallback& callback) { DCHECK(CalledOnValidThread()); - drive_service_->GetDocumentEntry( + drive_service_->GetResourceEntry( resource_id, - base::Bind(&DriveFileSyncClient::DidGetDocumentEntryData, + base::Bind(&DriveFileSyncClient::DidGetResourceEntryData, AsWeakPtr(), base::Bind(&DriveFileSyncClient::DeleteFileInternal, AsWeakPtr(), remote_file_md5, callback))); @@ -396,7 +396,7 @@ GURL DriveFileSyncClient::DirectoryTitleToOrigin(const std::string& title) { GURL DriveFileSyncClient::ResourceIdToResourceLink( const std::string& resource_id) const { - return url_generator_.GenerateDocumentEntryUrl(resource_id); + return url_generator_.GenerateResourceEntryUrl(resource_id); } void DriveFileSyncClient::OnReadyToPerformOperations() { @@ -431,20 +431,20 @@ void DriveFileSyncClient::DidGetDocumentFeedData( callback.Run(error, feed.Pass()); } -void DriveFileSyncClient::DidGetDocumentEntryData( - const DocumentEntryCallback& callback, +void DriveFileSyncClient::DidGetResourceEntryData( + const ResourceEntryCallback& callback, google_apis::GDataErrorCode error, scoped_ptr<base::Value> data) { DCHECK(CalledOnValidThread()); if (error != google_apis::HTTP_SUCCESS) { - callback.Run(error, scoped_ptr<google_apis::DocumentEntry>()); + callback.Run(error, scoped_ptr<google_apis::ResourceEntry>()); return; } DCHECK(data); - scoped_ptr<google_apis::DocumentEntry> entry( - google_apis::DocumentEntry::ExtractAndParse(*data)); + scoped_ptr<google_apis::ResourceEntry> entry( + google_apis::ResourceEntry::ExtractAndParse(*data)); if (!entry) error = google_apis::GDATA_PARSE_ERROR; callback.Run(error, entry.Pass()); @@ -482,7 +482,7 @@ void DriveFileSyncClient::DownloadFileInternal( const FilePath& local_file_path, const DownloadFileCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> entry) { + scoped_ptr<google_apis::ResourceEntry> entry) { DCHECK(CalledOnValidThread()); if (error != google_apis::HTTP_SUCCESS) { @@ -498,7 +498,7 @@ void DriveFileSyncClient::DownloadFileInternal( } // TODO(nhiroki): support ETag. Currently we assume there is no change between - // GetDocumentEntry and DownloadFile call. + // GetResourceEntry and DownloadFile call. drive_service_->DownloadFile( FilePath(kDummyDrivePath), local_file_path, @@ -523,7 +523,7 @@ void DriveFileSyncClient::UploadNewFileInternal( int64 file_size, const UploadFileCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> parent_directory_entry) { + scoped_ptr<google_apis::ResourceEntry> parent_directory_entry) { DCHECK(CalledOnValidThread()); if (error != google_apis::HTTP_SUCCESS) { @@ -557,7 +557,7 @@ void DriveFileSyncClient::UploadExistingFileInternal( int64 file_size, const UploadFileCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> entry) { + scoped_ptr<google_apis::ResourceEntry> entry) { DCHECK(CalledOnValidThread()); if (error != google_apis::HTTP_SUCCESS) { @@ -579,7 +579,7 @@ void DriveFileSyncClient::UploadExistingFileInternal( mime_type = kMimeTypeOctetStream; // TODO(nhiroki): support ETag. Currently we assume there is no change between - // GetDocumentEntry and UploadExistingFile call. + // GetResourceEntry and UploadExistingFile call. drive_uploader_->UploadExistingFile( entry->GetLinkByType( google_apis::Link::LINK_RESUMABLE_EDIT_MEDIA)->href(), @@ -596,7 +596,7 @@ void DriveFileSyncClient::DidUploadFile( google_apis::DriveUploadError error, const FilePath& drive_path, const FilePath& file_path, - scoped_ptr<google_apis::DocumentEntry> entry) { + scoped_ptr<google_apis::ResourceEntry> entry) { DCHECK(CalledOnValidThread()); // Convert DriveUploadError to GDataErrorCode. @@ -627,7 +627,7 @@ void DriveFileSyncClient::DeleteFileInternal( const std::string& remote_file_md5, const GDataErrorCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> entry) { + scoped_ptr<google_apis::ResourceEntry> entry) { DCHECK(CalledOnValidThread()); if (error != google_apis::HTTP_SUCCESS) { @@ -645,8 +645,8 @@ void DriveFileSyncClient::DeleteFileInternal( // Move the file to trash (don't delete it completely). // TODO(nhiroki): support ETag. Currently we assume there is no change between - // GetDocumentEntry and DeleteFile call. - drive_service_->DeleteDocument( + // GetResourceEntry and DeleteFile call. + drive_service_->DeleteResource( GURL(entry->GetLinkByType(google_apis::Link::LINK_SELF)->href()), base::Bind(&DriveFileSyncClient::DidDeleteFile, AsWeakPtr(), callback)); diff --git a/chrome/browser/sync_file_system/drive_file_sync_client.h b/chrome/browser/sync_file_system/drive_file_sync_client.h index 02c40a5..b69d6bb 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_client.h +++ b/chrome/browser/sync_file_system/drive_file_sync_client.h @@ -66,8 +66,8 @@ class DriveFileSyncClient scoped_ptr<google_apis::DocumentFeed> feed)> DocumentFeedCallback; typedef base::Callback<void(google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> entry)> - DocumentEntryCallback; + scoped_ptr<google_apis::ResourceEntry> entry)> + ResourceEntryCallback; explicit DriveFileSyncClient(Profile* profile); virtual ~DriveFileSyncClient(); @@ -99,10 +99,10 @@ class DriveFileSyncClient // Upon completion, invokes |callback|. void GetLargestChangeStamp(const ChangeStampCallback& callback); - // Fetches the document entry for the file identified by |resource_id|. + // Fetches the resource entry for the file identified by |resource_id|. // Upon completion, invokes |callback|. - void GetDocumentEntry(const std::string& resource_id, - const DocumentEntryCallback& callback); + void GetResourceEntry(const std::string& resource_id, + const ResourceEntryCallback& callback); // Lists files in the directory identified by |resource_id|. // Upon completion, invokes |callback|. @@ -223,7 +223,7 @@ class DriveFileSyncClient google_apis::GDataErrorCode error, scoped_ptr<base::Value> data); - void DidGetDocumentEntryData(const DocumentEntryCallback& callback, + void DidGetResourceEntryData(const ResourceEntryCallback& callback, google_apis::GDataErrorCode error, scoped_ptr<base::Value> data); @@ -231,7 +231,7 @@ class DriveFileSyncClient const FilePath& local_file_path, const DownloadFileCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> entry); + scoped_ptr<google_apis::ResourceEntry> entry); void DidDownloadFile(const std::string& downloaded_file_md5, const DownloadFileCallback& callback, @@ -244,7 +244,7 @@ class DriveFileSyncClient int64 file_size, const UploadFileCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> parent_directory_entry); + scoped_ptr<google_apis::ResourceEntry> parent_directory_entry); void UploadExistingFileInternal( const std::string& remote_file_md5, @@ -252,18 +252,18 @@ class DriveFileSyncClient int64 file_size, const UploadFileCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> entry); + scoped_ptr<google_apis::ResourceEntry> entry); void DidUploadFile(const UploadFileCallback& callback, google_apis::DriveUploadError error, const FilePath& drive_path, const FilePath& file_path, - scoped_ptr<google_apis::DocumentEntry> entry); + scoped_ptr<google_apis::ResourceEntry> entry); void DeleteFileInternal(const std::string& remote_file_md5, const GDataErrorCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> entry); + scoped_ptr<google_apis::ResourceEntry> entry); void DidDeleteFile(const GDataErrorCallback& callback, google_apis::GDataErrorCode error); diff --git a/chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc b/chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc index ace4d7c..3679380 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_client_unittest.cc @@ -21,7 +21,7 @@ using ::testing::StrictMock; using ::testing::_; -using google_apis::DocumentEntry; +using google_apis::ResourceEntry; using google_apis::DocumentFeed; using google_apis::DriveServiceInterface; using google_apis::DriveUploaderInterface; @@ -61,8 +61,8 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface { scoped_ptr<base::Value> file_entry_data( google_apis::test_util::LoadJSONFile( "gdata/file_entry.json").Pass()); - scoped_ptr<DocumentEntry> file_entry( - DocumentEntry::ExtractAndParse(*file_entry_data)); + scoped_ptr<ResourceEntry> file_entry( + ResourceEntry::ExtractAndParse(*file_entry_data)); base::MessageLoopProxy::current()->PostTask( FROM_HERE, @@ -102,8 +102,8 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface { scoped_ptr<base::Value> file_entry_data( google_apis::test_util::LoadJSONFile( "gdata/file_entry.json").Pass()); - scoped_ptr<DocumentEntry> file_entry( - DocumentEntry::ExtractAndParse(*file_entry_data)); + scoped_ptr<ResourceEntry> file_entry( + ResourceEntry::ExtractAndParse(*file_entry_data)); base::MessageLoopProxy::current()->PostTask( FROM_HERE, @@ -299,14 +299,14 @@ TEST_F(DriveFileSyncClientTest, GetSyncRoot) { scoped_ptr<base::Value> found_result(google_apis::test_util::LoadJSONFile( "sync_file_system/sync_root_found.json").Pass()); - // Expected to call GetDocuments from GetDriveDirectoryForSyncRoot. + // Expected to call GetResourceList from GetDriveDirectoryForSyncRoot. EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), // feed_url - 0, // start_changestamp - FormatTitleQuery(kSyncRootDirectoryName), - false, // shared_with_me - std::string(), // directory_resource_id, - _)) + GetResourceList(GURL(), // feed_url + 0, // start_changestamp + FormatTitleQuery(kSyncRootDirectoryName), + false, // shared_with_me + std::string(), // directory_resource_id, + _)) .WillOnce(InvokeGetDataCallback5(google_apis::HTTP_SUCCESS, base::Passed(&found_result))); @@ -328,14 +328,14 @@ TEST_F(DriveFileSyncClientTest, CreateSyncRoot) { scoped_ptr<base::Value> created_result(google_apis::test_util::LoadJSONFile( "sync_file_system/sync_root_created.json").Pass()); - // Expected to call GetDocuments from GetDriveDirectoryForSyncRoot. + // Expected to call GetResourceList from GetDriveDirectoryForSyncRoot. EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), // feed_urlc - 0, // start_changestamp - FormatTitleQuery(kSyncRootDirectoryName), - false, // shared_with_me - std::string(), // directory_resource_id - _)) + GetResourceList(GURL(), // feed_urlc + 0, // start_changestamp + FormatTitleQuery(kSyncRootDirectoryName), + false, // shared_with_me + std::string(), // directory_resource_id + _)) .WillOnce(InvokeGetDataCallback5(google_apis::HTTP_SUCCESS, base::Passed(¬_found_result))); @@ -369,14 +369,14 @@ TEST_F(DriveFileSyncClientTest, GetOriginDirectory) { scoped_ptr<base::Value> found_result(google_apis::test_util::LoadJSONFile( "sync_file_system/origin_directory_found.json").Pass()); - // Expected to call GetDocuments from GetDriveDirectoryForOrigin. + // Expected to call GetResourceList from GetDriveDirectoryForOrigin. EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), // feed_url - 0, // start_changestamp - FormatOriginQuery(kOrigin), - false, // shared_with_me - kParentResourceId, - _)) + GetResourceList(GURL(), // feed_url + 0, // start_changestamp + FormatOriginQuery(kOrigin), + false, // shared_with_me + kParentResourceId, + _)) .WillOnce(InvokeGetDataCallback5(google_apis::HTTP_SUCCESS, base::Passed(&found_result))); @@ -407,20 +407,20 @@ TEST_F(DriveFileSyncClientTest, CreateOriginDirectory) { testing::InSequence sequence; - // Expected to call GetDocuments from GetDriveDirectoryForOrigin. + // Expected to call GetResourceList from GetDriveDirectoryForOrigin. EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), // feed_url - 0, // start_changestamp - FormatOriginQuery(kOrigin), - false, // shared_with_me - kParentResourceId, // directory_resource_id - _)) + GetResourceList(GURL(), // feed_url + 0, // start_changestamp + FormatOriginQuery(kOrigin), + false, // shared_with_me + kParentResourceId, // directory_resource_id + _)) .WillOnce(InvokeGetDataCallback5(google_apis::HTTP_SUCCESS, base::Passed(¬_found_result))); - // Expected to call GetDocumentEntry from GetDriveDirectoryForOrigin. + // Expected to call GetResourceEntry from GetDriveDirectoryForOrigin. EXPECT_CALL(*mock_drive_service(), - GetDocumentEntry(kParentResourceId, _)) + GetResourceEntry(kParentResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&got_parent_result))); @@ -481,26 +481,26 @@ TEST_F(DriveFileSyncClientTest, ListFiles) { testing::InSequence sequence; - // Expected to call GetDocuments from ListFiles. + // Expected to call GetResourceList from ListFiles. EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), // feed_url - 0, // start_changestamp - std::string(), // search_query - false, // shared_with_me - kDirectoryResourceId, - _)) + GetResourceList(GURL(), // feed_url + 0, // start_changestamp + std::string(), // search_query + false, // shared_with_me + kDirectoryResourceId, + _)) .WillOnce(InvokeGetDataCallback5(google_apis::HTTP_SUCCESS, base::Passed(&first_result))) .RetiresOnSaturation(); - // Expected to call GetDocuments from ContinueListing. + // Expected to call GetResourceList from ContinueListing. EXPECT_CALL(*mock_drive_service(), - GetDocuments(kFeedURL, - 0, // start_changestamp - std::string(), // search_query - false, // shared_with_me - std::string(), // directory_resource_id - _)) + GetResourceList(kFeedURL, + 0, // start_changestamp + std::string(), // search_query + false, // shared_with_me + std::string(), // directory_resource_id + _)) .WillOnce(InvokeGetDataCallback5(google_apis::HTTP_SUCCESS, base::Passed(&following_result))) .RetiresOnSaturation(); @@ -542,26 +542,26 @@ TEST_F(DriveFileSyncClientTest, ListChanges) { testing::InSequence sequence; - // Expected to call GetDocuments from ListFiles. + // Expected to call GetResourceList from ListFiles. EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), - 0, // start_changestamp - std::string(), // search_query - false, // shared_with_me - kDirectoryResourceId, // directory_resource_id - _)) + GetResourceList(GURL(), + 0, // start_changestamp + std::string(), // search_query + false, // shared_with_me + kDirectoryResourceId, // directory_resource_id + _)) .WillOnce(InvokeGetDataCallback5(google_apis::HTTP_SUCCESS, base::Passed(&first_result))) .RetiresOnSaturation(); - // Expected to call GetDocuments from ListChanges. + // Expected to call GetResourceList from ListChanges. EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), - kStartChangestamp, - std::string(), // search_query - false, // shared_with_me - std::string(), // directory_resource_id - _)) + GetResourceList(GURL(), + kStartChangestamp, + std::string(), // search_query + false, // shared_with_me + std::string(), // directory_resource_id + _)) .WillOnce(InvokeGetDataCallback5(google_apis::HTTP_SUCCESS, base::Passed(&following_result))) .RetiresOnSaturation(); @@ -598,20 +598,20 @@ TEST_F(DriveFileSyncClientTest, DownloadFile) { scoped_ptr<base::Value> file_entry_data( google_apis::test_util::LoadJSONFile("gdata/file_entry.json").Pass()); - scoped_ptr<DocumentEntry> entry( - DocumentEntry::ExtractAndParse(*file_entry_data)); + scoped_ptr<ResourceEntry> entry( + ResourceEntry::ExtractAndParse(*file_entry_data)); testing::InSequence sequence; - // Expected to call GetDocumentEntry from DriveFileSyncClient::UploadNewFile. + // Expected to call GetResourceEntry from DriveFileSyncClient::UploadNewFile. EXPECT_CALL(*mock_drive_service(), - GetDocumentEntry(kResourceId, _)) + GetResourceEntry(kResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&file_entry_data))) .RetiresOnSaturation(); // Expected to call DriveUploaderInterface::DownloadFile from - // DidGetDocumentEntryForDownloadFile. + // DidGetResourceEntryForDownloadFile. EXPECT_CALL(*mock_drive_service(), DownloadFile(_, // drive_path kLocalFilePath, @@ -642,8 +642,8 @@ TEST_F(DriveFileSyncClientTest, DownloadFileInNotModified) { scoped_ptr<base::Value> file_entry_data( google_apis::test_util::LoadJSONFile("gdata/file_entry.json").Pass()); - scoped_ptr<DocumentEntry> entry( - DocumentEntry::ExtractAndParse(*file_entry_data)); + scoped_ptr<ResourceEntry> entry( + ResourceEntry::ExtractAndParse(*file_entry_data)); // Since local file's hash value is equal to remote file's one, it is expected // to cancel download the file and to return NOT_MODIFIED status code. @@ -651,9 +651,9 @@ TEST_F(DriveFileSyncClientTest, DownloadFileInNotModified) { testing::InSequence sequence; - // Expected to call GetDocumentEntry from DriveFileSyncClient::UploadNewFile. + // Expected to call GetResourceEntry from DriveFileSyncClient::UploadNewFile. EXPECT_CALL(*mock_drive_service(), - GetDocumentEntry(kResourceId, _)) + GetResourceEntry(kResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&file_entry_data))) .RetiresOnSaturation(); @@ -681,16 +681,16 @@ TEST_F(DriveFileSyncClientTest, UploadNewFile) { scoped_ptr<base::Value> dir_entry_data(google_apis::test_util::LoadJSONFile( "gdata/directory_entry.json").Pass()); - scoped_ptr<DocumentEntry> dir_entry( - DocumentEntry::ExtractAndParse(*dir_entry_data)); + scoped_ptr<ResourceEntry> dir_entry( + ResourceEntry::ExtractAndParse(*dir_entry_data)); const GURL link_url = dir_entry->GetLinkByType(Link::LINK_RESUMABLE_CREATE_MEDIA)->href(); testing::InSequence sequence; - // Expected to call GetDocumentEntry from DriveFileSyncClient::UploadNewFile. + // Expected to call GetResourceEntry from DriveFileSyncClient::UploadNewFile. EXPECT_CALL(*mock_drive_service(), - GetDocumentEntry(kDirectoryResourceId, _)) + GetResourceEntry(kDirectoryResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&dir_entry_data))) .RetiresOnSaturation(); @@ -717,18 +717,18 @@ TEST_F(DriveFileSyncClientTest, UploadExistingFile) { scoped_ptr<base::Value> file_entry_data( google_apis::test_util::LoadJSONFile("gdata/file_entry.json").Pass()); - scoped_ptr<DocumentEntry> entry( - DocumentEntry::ExtractAndParse(*file_entry_data)); + scoped_ptr<ResourceEntry> entry( + ResourceEntry::ExtractAndParse(*file_entry_data)); const std::string expected_remote_file_md5 = entry->file_md5(); const GURL link_url = entry->GetLinkByType(Link::LINK_RESUMABLE_EDIT_MEDIA)->href(); testing::InSequence sequence; - // Expected to call GetDocumentEntry from + // Expected to call GetResourceEntry from // DriveFileSyncClient::UploadExistingFile. EXPECT_CALL(*mock_drive_service(), - GetDocumentEntry(kResourceId, _)) + GetResourceEntry(kResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&file_entry_data))) .RetiresOnSaturation(); @@ -759,15 +759,15 @@ TEST_F(DriveFileSyncClientTest, UploadExistingFileInConflict) { scoped_ptr<base::Value> file_entry_data( google_apis::test_util::LoadJSONFile("gdata/file_entry.json").Pass()); - scoped_ptr<DocumentEntry> entry( - DocumentEntry::ExtractAndParse(*file_entry_data)); + scoped_ptr<ResourceEntry> entry( + ResourceEntry::ExtractAndParse(*file_entry_data)); testing::InSequence sequence; - // Expected to call GetDocumentEntry from + // Expected to call GetResourceEntry from // DriveFileSyncClient::UploadExistingFile. EXPECT_CALL(*mock_drive_service(), - GetDocumentEntry(kResourceId, _)) + GetResourceEntry(kResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&file_entry_data))) .RetiresOnSaturation(); @@ -792,22 +792,22 @@ TEST_F(DriveFileSyncClientTest, DeleteFile) { scoped_ptr<base::Value> file_entry_data( google_apis::test_util::LoadJSONFile("gdata/file_entry.json").Pass()); - scoped_ptr<DocumentEntry> entry( - DocumentEntry::ExtractAndParse(*file_entry_data)); + scoped_ptr<ResourceEntry> entry( + ResourceEntry::ExtractAndParse(*file_entry_data)); const std::string kExpectedRemoteFileMD5 = entry->file_md5(); testing::InSequence sequence; - // Expected to call GetDocumentEntry from DriveFileSyncClient::DeleteFile. - EXPECT_CALL(*mock_drive_service(), GetDocumentEntry(kResourceId, _)) + // Expected to call GetResourceEntry from DriveFileSyncClient::DeleteFile. + EXPECT_CALL(*mock_drive_service(), GetResourceEntry(kResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&file_entry_data))) .RetiresOnSaturation(); - // Expected to call DriveUploaderInterface::DeleteDocument from - // DidGetDocumentEntryForDeleteFile. + // Expected to call DriveUploaderInterface::DeleteResource from + // DidGetResourceEntryForDeleteFile. EXPECT_CALL(*mock_drive_service(), - DeleteDocument(entry->GetLinkByType(Link::LINK_SELF)->href(), _)) + DeleteResource(entry->GetLinkByType(Link::LINK_SELF)->href(), _)) .WillOnce(InvokeEntryActionCallback2(google_apis::HTTP_SUCCESS)) .RetiresOnSaturation(); @@ -832,13 +832,13 @@ TEST_F(DriveFileSyncClientTest, DeleteFileInConflict) { scoped_ptr<base::Value> file_entry_data( google_apis::test_util::LoadJSONFile("gdata/file_entry.json").Pass()); - scoped_ptr<DocumentEntry> entry( - DocumentEntry::ExtractAndParse(*file_entry_data)); + scoped_ptr<ResourceEntry> entry( + ResourceEntry::ExtractAndParse(*file_entry_data)); testing::InSequence sequence; - // Expected to call GetDocumentEntry from DriveFileSyncClient::DeleteFile. - EXPECT_CALL(*mock_drive_service(), GetDocumentEntry(kResourceId, _)) + // Expected to call GetResourceEntry from DriveFileSyncClient::DeleteFile. + EXPECT_CALL(*mock_drive_service(), GetResourceEntry(kResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&file_entry_data))) .RetiresOnSaturation(); diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.cc b/chrome/browser/sync_file_system/drive_file_sync_service.cc index 8699154..35fb4d8 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_service.cc @@ -415,7 +415,7 @@ void DriveFileSyncService::GetRemoteFileMetadata( metadata_store_->ReadEntry(url, &metadata); if (status != fileapi::SYNC_STATUS_OK) callback.Run(status, fileapi::SyncFileMetadata()); - sync_client_->GetDocumentEntry( + sync_client_->GetResourceEntry( metadata.resource_id(), base::Bind(&DriveFileSyncService::DidGetRemoteFileMetadata, AsWeakPtr(), callback)); @@ -870,7 +870,7 @@ void DriveFileSyncService::DidGetDirectoryContentForBatchSync( return; } - typedef ScopedVector<google_apis::DocumentEntry>::const_iterator iterator; + typedef ScopedVector<google_apis::ResourceEntry>::const_iterator iterator; for (iterator itr = feed->entries().begin(); itr != feed->entries().end(); ++itr) { AppendRemoteChange(origin, **itr, largest_changestamp, @@ -901,7 +901,7 @@ void DriveFileSyncService::DidRemoveOriginOnMetadataStore( void DriveFileSyncService::DidGetRemoteFileMetadata( const fileapi::SyncFileMetadataCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> entry) { + scoped_ptr<google_apis::ResourceEntry> entry) { fileapi::SyncFileType file_type = fileapi::SYNC_FILE_TYPE_UNKNOWN; if (entry->is_file()) file_type = fileapi::SYNC_FILE_TYPE_FILE; @@ -1462,7 +1462,7 @@ void DriveFileSyncService::FinalizeRemoteSync( bool DriveFileSyncService::AppendRemoteChange( const GURL& origin, - const google_apis::DocumentEntry& entry, + const google_apis::ResourceEntry& entry, int64 changestamp, RemoteSyncType sync_type) { // TODO(tzik): Normalize the path here. @@ -1600,10 +1600,10 @@ void DriveFileSyncService::DidFetchChangesForIncrementalSync( return; } - typedef ScopedVector<google_apis::DocumentEntry>::const_iterator iterator; + typedef ScopedVector<google_apis::ResourceEntry>::const_iterator iterator; for (iterator itr = changes->entries().begin(); itr != changes->entries().end(); ++itr) { - const google_apis::DocumentEntry& entry = **itr; + const google_apis::ResourceEntry& entry = **itr; GURL origin; if (!GetOriginForEntry(entry, &origin)) continue; @@ -1641,7 +1641,7 @@ void DriveFileSyncService::DidFetchChangesForIncrementalSync( } bool DriveFileSyncService::GetOriginForEntry( - const google_apis::DocumentEntry& entry, + const google_apis::ResourceEntry& entry, GURL* origin_out) { typedef ScopedVector<google_apis::Link>::const_iterator iterator; for (iterator itr = entry.links().begin(); diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.h b/chrome/browser/sync_file_system/drive_file_sync_service.h index f0dce46..e731619 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service.h +++ b/chrome/browser/sync_file_system/drive_file_sync_service.h @@ -186,7 +186,7 @@ class DriveFileSyncService void DidGetRemoteFileMetadata( const fileapi::SyncFileMetadataCallback& callback, google_apis::GDataErrorCode error, - scoped_ptr<google_apis::DocumentEntry> entry); + scoped_ptr<google_apis::ResourceEntry> entry); LocalSyncOperationType ResolveLocalSyncOperationType( const fileapi::FileChange& local_file_change, @@ -299,7 +299,7 @@ class DriveFileSyncService // Returns true if |pending_changes_| was updated. bool AppendRemoteChange(const GURL& origin, - const google_apis::DocumentEntry& entry, + const google_apis::ResourceEntry& entry, int64 changestamp, RemoteSyncType sync_type); bool AppendFetchChange(const GURL& origin, @@ -331,7 +331,7 @@ class DriveFileSyncService bool has_new_changes, google_apis::GDataErrorCode error, scoped_ptr<google_apis::DocumentFeed> changes); - bool GetOriginForEntry(const google_apis::DocumentEntry& entry, GURL* origin); + bool GetOriginForEntry(const google_apis::ResourceEntry& entry, GURL* origin); void SchedulePolling(); scoped_ptr<DriveMetadataStore> metadata_store_; diff --git a/chrome/browser/sync_file_system/drive_file_sync_service_unittest.cc b/chrome/browser/sync_file_system/drive_file_sync_service_unittest.cc index c3e759b..bd13f7f 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service_unittest.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_service_unittest.cc @@ -32,7 +32,7 @@ using ::testing::InSequence; using ::testing::StrictMock; using ::testing::_; -using google_apis::DocumentEntry; +using google_apis::ResourceEntry; using google_apis::DriveServiceInterface; using google_apis::DriveUploaderInterface; using google_apis::test_util::LoadJSONFile; @@ -266,7 +266,7 @@ class DriveFileSyncServiceTest : public testing::Test { } void AppendIncrementalRemoteChange(const GURL& origin, - const google_apis::DocumentEntry& entry, + const google_apis::ResourceEntry& entry, int64 changestamp) { sync_service_->AppendRemoteChange( origin, entry, changestamp, @@ -375,7 +375,7 @@ TEST_F(DriveFileSyncServiceTest, GetSyncRoot) { "sync_file_system/sync_root_found.json")); std::string query = FormatTitleQuery(kSyncRootDirectoryName); EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), 0, query, false, std::string(), _)) + GetResourceList(GURL(), 0, query, false, std::string(), _)) .WillOnce(InvokeGetDataCallback5( google_apis::HTTP_SUCCESS, base::Passed(&sync_root_found))); @@ -427,8 +427,8 @@ TEST_F(DriveFileSyncServiceTest, BatchSyncOnInitialization) { scoped_ptr<Value> listing_files_in_directory(LoadJSONFile( "sync_file_system/listing_files_in_directory.json")); EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), 0, std::string(), false, - kDirectoryResourceId1, _)) + GetResourceList(GURL(), 0, std::string(), false, + kDirectoryResourceId1, _)) .WillOnce(InvokeGetDataCallback5( google_apis::HTTP_SUCCESS, base::Passed(&listing_files_in_directory))); @@ -471,7 +471,7 @@ TEST_F(DriveFileSyncServiceTest, RegisterNewOrigin) { DriveFileSyncClient::OriginToDirectoryTitle(kOrigin)); EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), 0, query, false, kSyncRootResourceId, _)) + GetResourceList(GURL(), 0, query, false, kSyncRootResourceId, _)) .WillOnce(InvokeGetDataCallback5( google_apis::HTTP_SUCCESS, base::Passed(&origin_directory_not_found))) @@ -486,7 +486,7 @@ TEST_F(DriveFileSyncServiceTest, RegisterNewOrigin) { scoped_ptr<Value> sync_root_entry(LoadJSONFile( "sync_file_system/sync_root_entry.json")); EXPECT_CALL(*mock_drive_service(), - GetDocumentEntry(kSyncRootResourceId, _)) + GetResourceEntry(kSyncRootResourceId, _)) .WillOnce(InvokeGetDataCallback1( google_apis::HTTP_SUCCESS, base::Passed(&sync_root_entry))); @@ -513,8 +513,8 @@ TEST_F(DriveFileSyncServiceTest, RegisterNewOrigin) { scoped_ptr<Value> listing_files_in_empty_directory(LoadJSONFile( "sync_file_system/listing_files_in_empty_directory.json")); EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), 0, std::string(), false, - kDirectoryResourceId, _)) + GetResourceList(GURL(), 0, std::string(), false, + kDirectoryResourceId, _)) .WillOnce(InvokeGetDataCallback5( google_apis::HTTP_SUCCESS, base::Passed(&listing_files_in_empty_directory))); @@ -551,7 +551,7 @@ TEST_F(DriveFileSyncServiceTest, RegisterExistingOrigin) { std::string query = FormatTitleQuery( DriveFileSyncClient::OriginToDirectoryTitle(kOrigin)); EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), 0, query, false, kSyncRootResourceId, _)) + GetResourceList(GURL(), 0, query, false, kSyncRootResourceId, _)) .WillOnce(InvokeGetDataCallback5( google_apis::HTTP_SUCCESS, base::Passed(&origin_directory_found))) @@ -569,8 +569,8 @@ TEST_F(DriveFileSyncServiceTest, RegisterExistingOrigin) { scoped_ptr<Value> listing_files_in_directory(LoadJSONFile( "sync_file_system/listing_files_in_directory.json")); EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), 0, std::string(), - false, kDirectoryResourceId, _)) + GetResourceList(GURL(), 0, std::string(), + false, kDirectoryResourceId, _)) .WillOnce(InvokeGetDataCallback5( google_apis::HTTP_SUCCESS, base::Passed(&listing_files_in_directory))); @@ -623,8 +623,8 @@ TEST_F(DriveFileSyncServiceTest, UnregisterOrigin) { scoped_ptr<Value> listing_files_in_directory(LoadJSONFile( "sync_file_system/listing_files_in_directory.json")); EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), 0, std::string(), false, - kDirectoryResourceId1, _)) + GetResourceList(GURL(), 0, std::string(), false, + kDirectoryResourceId1, _)) .WillOnce(InvokeGetDataCallback5( google_apis::HTTP_SUCCESS, base::Passed(&listing_files_in_directory))); @@ -659,7 +659,7 @@ TEST_F(DriveFileSyncServiceTest, ResolveLocalSyncOperationType) { "sync_file_system/sync_root_found.json")); std::string query = FormatTitleQuery(kSyncRootDirectoryName); EXPECT_CALL(*mock_drive_service(), - GetDocuments(GURL(), 0, query, false, std::string(), _)) + GetResourceList(GURL(), 0, query, false, std::string(), _)) .WillOnce(InvokeGetDataCallback5( google_apis::HTTP_SUCCESS, base::Passed(&sync_root_found))); @@ -782,7 +782,7 @@ TEST_F(DriveFileSyncServiceTest, RemoteChange_Busy) { SetUpDriveSyncService(); - scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse( + scoped_ptr<ResourceEntry> entry(ResourceEntry::ExtractAndParse( *LoadJSONFile("gdata/file_entry.json"))); AppendIncrementalRemoteChange(kOrigin, *entry, 12345); @@ -817,7 +817,7 @@ TEST_F(DriveFileSyncServiceTest, RemoteChange_NewFile) { scoped_ptr<Value> file_entry(LoadJSONFile("gdata/file_entry.json").Pass()); EXPECT_CALL(*mock_drive_service(), - GetDocumentEntry(kFileResourceId, _)) + GetResourceEntry(kFileResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&file_entry))); @@ -831,7 +831,7 @@ TEST_F(DriveFileSyncServiceTest, RemoteChange_NewFile) { SetUpDriveSyncService(); - scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse( + scoped_ptr<ResourceEntry> entry(ResourceEntry::ExtractAndParse( *LoadJSONFile("gdata/file_entry.json"))); AppendIncrementalRemoteChange(kOrigin, *entry, 12345); @@ -866,7 +866,7 @@ TEST_F(DriveFileSyncServiceTest, RemoteChange_UpdateFile) { scoped_ptr<Value> file_entry(LoadJSONFile("gdata/file_entry.json").Pass()); EXPECT_CALL(*mock_drive_service(), - GetDocumentEntry(kFileResourceId, _)) + GetResourceEntry(kFileResourceId, _)) .WillOnce(InvokeGetDataCallback1(google_apis::HTTP_SUCCESS, base::Passed(&file_entry))); @@ -880,7 +880,7 @@ TEST_F(DriveFileSyncServiceTest, RemoteChange_UpdateFile) { SetUpDriveSyncService(); - scoped_ptr<DocumentEntry> entry(DocumentEntry::ExtractAndParse( + scoped_ptr<ResourceEntry> entry(ResourceEntry::ExtractAndParse( *LoadJSONFile("gdata/file_entry.json"))); AppendIncrementalRemoteChange(kOrigin, *entry, 12345); ProcessRemoteChange(fileapi::SYNC_STATUS_OK, diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi index 4e584e2..042c898 100644 --- a/chrome/chrome_browser_chromeos.gypi +++ b/chrome/chrome_browser_chromeos.gypi @@ -198,8 +198,6 @@ 'browser/chromeos/dbus/proxy_resolution_service_provider.cc', 'browser/chromeos/dbus/proxy_resolution_service_provider.h', 'browser/chromeos/device_hierarchy_observer.h', - 'browser/chromeos/drive/document_entry_conversion.cc', - 'browser/chromeos/drive/document_entry_conversion.h', 'browser/chromeos/drive/drive_api_service.cc', 'browser/chromeos/drive/drive_api_service.h', 'browser/chromeos/drive/drive_cache.cc', @@ -262,6 +260,8 @@ 'browser/chromeos/drive/file_system/update_operation.h', 'browser/chromeos/drive/file_write_helper.cc', 'browser/chromeos/drive/file_write_helper.h', + 'browser/chromeos/drive/resource_entry_conversion.cc', + 'browser/chromeos/drive/resource_entry_conversion.h', 'browser/chromeos/drive/stale_cache_files_remover.cc', 'browser/chromeos/drive/stale_cache_files_remover.h', 'browser/chromeos/enrollment_dialog_view.cc', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 9b2270d..29df864 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -537,7 +537,6 @@ 'browser/chromeos/dbus/proxy_resolution_service_provider_unittest.cc', 'browser/chromeos/dbus/service_provider_test_helper.cc', 'browser/chromeos/dbus/service_provider_test_helper.h', - 'browser/chromeos/drive/document_entry_conversion_unittest.cc', 'browser/chromeos/drive/drive_cache_metadata_unittest.cc', 'browser/chromeos/drive/drive_cache_unittest.cc', 'browser/chromeos/drive/drive_file_system_unittest.cc', @@ -562,6 +561,7 @@ 'browser/chromeos/drive/mock_drive_web_apps_registry.h', 'browser/chromeos/drive/mock_free_disk_space_getter.cc', 'browser/chromeos/drive/mock_free_disk_space_getter.h', + 'browser/chromeos/drive/resource_entry_conversion_unittest.cc', 'browser/chromeos/drive/stale_cache_files_remover_unittest.cc', 'browser/chromeos/extensions/default_app_order_unittest.cc', 'browser/chromeos/extensions/file_browser_notifications_unittest.cc', |