diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-02 04:55:52 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-02 04:55:52 +0000 |
commit | 67241b83d4bd573d00f1fa6e6056cf25f74ddf49 (patch) | |
tree | 7613732325f898bcafbb7c9eac0f31e9ce9e5cd9 | |
parent | ce34e101af48b9b576b6cdee5fac7f88a956ec21 (diff) | |
download | chromium_src-67241b83d4bd573d00f1fa6e6056cf25f74ddf49.zip chromium_src-67241b83d4bd573d00f1fa6e6056cf25f74ddf49.tar.gz chromium_src-67241b83d4bd573d00f1fa6e6056cf25f74ddf49.tar.bz2 |
Rename drive::DriveEntryProto to drive::ResourceEntry
As part of an effort to remove 'drive' prefix from c/b/chromeos/drive.
BUG=233482
TEST=none
R=kinaba@chromium.org, thestig@chromium.org
Review URL: https://codereview.chromium.org/14616011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197808 0039d316-1c4b-4281-b951-d872f2087c98
61 files changed, 1060 insertions, 1053 deletions
diff --git a/chrome/browser/chromeos/drive/change_list_loader.cc b/chrome/browser/chromeos/drive/change_list_loader.cc index 1cca12b..340a189 100644 --- a/chrome/browser/chromeos/drive/change_list_loader.cc +++ b/chrome/browser/chromeos/drive/change_list_loader.cc @@ -592,7 +592,7 @@ ChangeListLoader::DoLoadGrandRootDirectoryFromServerAfterGetEntryInfoByPath( const DirectoryFetchInfo& directory_fetch_info, const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); DCHECK_EQ(directory_fetch_info.resource_id(), @@ -632,15 +632,15 @@ void ChangeListLoader::DoLoadGrandRootDirectoryFromServerAfterGetAboutResource( // Build entry proto map for grand root directory, which has two entries; // "/drive/root" and "/drive/other". - DriveEntryProtoMap grand_root_entry_proto_map; + ResourceEntryMap grand_root_entry_map; const std::string& root_resource_id = about_resource->root_folder_id(); - grand_root_entry_proto_map[root_resource_id] = + grand_root_entry_map[root_resource_id] = util::CreateMyDriveRootEntry(root_resource_id); - grand_root_entry_proto_map[util::kDriveOtherDirSpecialResourceId] = + grand_root_entry_map[util::kDriveOtherDirSpecialResourceId] = util::CreateOtherDirEntry(); resource_metadata_->RefreshDirectory( directory_fetch_info, - grand_root_entry_proto_map, + grand_root_entry_map, base::Bind(&ChangeListLoader::DoLoadDirectoryFromServerAfterRefresh, weak_ptr_factory_.GetWeakPtr(), directory_fetch_info, @@ -670,7 +670,7 @@ void ChangeListLoader::DoLoadDirectoryFromServerAfterLoad( change_list_processor.FeedToEntryProtoMap(change_lists.Pass(), NULL, NULL); resource_metadata_->RefreshDirectory( directory_fetch_info, - change_list_processor.entry_proto_map(), + change_list_processor.entry_map(), base::Bind(&ChangeListLoader::DoLoadDirectoryFromServerAfterRefresh, weak_ptr_factory_.GetWeakPtr(), directory_fetch_info, diff --git a/chrome/browser/chromeos/drive/change_list_loader.h b/chrome/browser/chromeos/drive/change_list_loader.h index fc98673..b29053f 100644 --- a/chrome/browser/chromeos/drive/change_list_loader.h +++ b/chrome/browser/chromeos/drive/change_list_loader.h @@ -224,7 +224,7 @@ class ChangeListLoader { const DirectoryFetchInfo& directory_fetch_info, const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Part of DoLoadDirectoryFromServer() for the grand root ("/drive"). void DoLoadGrandRootDirectoryFromServerAfterGetAboutResource( diff --git a/chrome/browser/chromeos/drive/change_list_processor.cc b/chrome/browser/chromeos/drive/change_list_processor.cc index 7be4437..c03608e 100644 --- a/chrome/browser/chromeos/drive/change_list_processor.cc +++ b/chrome/browser/chromeos/drive/change_list_processor.cc @@ -39,7 +39,7 @@ ChangeList::ChangeList(const google_apis::ResourceList& resource_list) entries_.resize(resource_list.entries().size()); for (size_t i = 0; i < resource_list.entries().size(); ++i) { - ConvertResourceEntryToDriveEntryProto(*resource_list.entries()[i]).Swap( + ConvertToResourceEntry(*resource_list.entries()[i]).Swap( &entries_[i]); } } @@ -171,8 +171,8 @@ void ChangeListProcessor::ApplyNextEntryProtoAsync() { void ChangeListProcessor::ApplyNextEntryProto() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!entry_proto_map_.empty()) { - ApplyNextByIterator(entry_proto_map_.begin()); // Continue. + if (!entry_map_.empty()) { + ApplyNextByIterator(entry_map_.begin()); // Continue. } else { // Update the root entry and finish. UpdateRootEntry(base::Bind(&ChangeListProcessor::OnComplete, @@ -180,23 +180,23 @@ void ChangeListProcessor::ApplyNextEntryProto() { } } -void ChangeListProcessor::ApplyNextByIterator(DriveEntryProtoMap::iterator it) { +void ChangeListProcessor::ApplyNextByIterator(ResourceEntryMap::iterator it) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveEntryProto entry_proto = it->second; - DCHECK_EQ(it->first, entry_proto.resource_id()); + ResourceEntry entry = it->second; + DCHECK_EQ(it->first, entry.resource_id()); // Add the largest changestamp if this entry is a directory. - if (entry_proto.file_info().is_directory()) { - entry_proto.mutable_directory_specific_info()->set_changestamp( + if (entry.file_info().is_directory()) { + entry.mutable_directory_specific_info()->set_changestamp( largest_changestamp_); } // The parent of this entry may not yet be processed. We need the parent // to be rooted in the metadata tree before we can add the child, so process // the parent first. - DriveEntryProtoMap::iterator parent_it = entry_proto_map_.find( - entry_proto.parent_resource_id()); - if (parent_it != entry_proto_map_.end()) { + ResourceEntryMap::iterator parent_it = entry_map_.find( + entry.parent_resource_id()); + if (parent_it != entry_map_.end()) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, base::Bind(&ChangeListProcessor::ApplyNextByIterator, @@ -204,54 +204,54 @@ void ChangeListProcessor::ApplyNextByIterator(DriveEntryProtoMap::iterator it) { parent_it)); } else { // Erase the entry so the deleted entry won't be referenced. - entry_proto_map_.erase(it); - ApplyEntryProto(entry_proto); + entry_map_.erase(it); + ApplyEntryProto(entry); } } -void ChangeListProcessor::ApplyEntryProto(const DriveEntryProto& entry_proto) { +void ChangeListProcessor::ApplyEntryProto(const ResourceEntry& entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // Lookup the entry. resource_metadata_->GetEntryInfoByResourceId( - entry_proto.resource_id(), + entry.resource_id(), base::Bind(&ChangeListProcessor::ContinueApplyEntryProto, weak_ptr_factory_.GetWeakPtr(), - entry_proto)); + entry)); } void ChangeListProcessor::ContinueApplyEntryProto( - const DriveEntryProto& entry_proto, + const ResourceEntry& entry, FileError error, const base::FilePath& file_path, - scoped_ptr<DriveEntryProto> old_entry_proto) { + scoped_ptr<ResourceEntry> old_entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (error == FILE_ERROR_OK) { - if (entry_proto.deleted()) { + if (entry.deleted()) { // Deleted file/directory. - RemoveEntryFromParent(entry_proto, file_path); + RemoveEntryFromParent(entry, file_path); } else { // Entry exists and needs to be refreshed. - RefreshEntry(entry_proto, file_path); + RefreshEntry(entry, file_path); } - } else if (error == FILE_ERROR_NOT_FOUND && !entry_proto.deleted()) { + } else if (error == FILE_ERROR_NOT_FOUND && !entry.deleted()) { // Adding a new entry. - AddEntry(entry_proto); + AddEntry(entry); } else { // Continue. ApplyNextEntryProtoAsync(); } } -void ChangeListProcessor::AddEntry(const DriveEntryProto& entry_proto) { +void ChangeListProcessor::AddEntry(const ResourceEntry& entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); resource_metadata_->AddEntry( - entry_proto, + entry, base::Bind(&ChangeListProcessor::NotifyForAddEntry, weak_ptr_factory_.GetWeakPtr(), - entry_proto.file_info().is_directory())); + entry.file_info().is_directory())); } void ChangeListProcessor::NotifyForAddEntry(bool is_directory, @@ -274,37 +274,37 @@ void ChangeListProcessor::NotifyForAddEntry(bool is_directory, } void ChangeListProcessor::RemoveEntryFromParent( - const DriveEntryProto& entry_proto, + const ResourceEntry& entry, const base::FilePath& file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!file_path.empty()); - if (!entry_proto.file_info().is_directory()) { + if (!entry.file_info().is_directory()) { // No children if entry is a file. - OnGetChildrenForRemove(entry_proto, file_path, std::set<base::FilePath>()); + OnGetChildrenForRemove(entry, file_path, std::set<base::FilePath>()); } else { // If entry is a directory, notify its children. resource_metadata_->GetChildDirectories( - entry_proto.resource_id(), + entry.resource_id(), base::Bind(&ChangeListProcessor::OnGetChildrenForRemove, weak_ptr_factory_.GetWeakPtr(), - entry_proto, + entry, file_path)); } } void ChangeListProcessor::OnGetChildrenForRemove( - const DriveEntryProto& entry_proto, + const ResourceEntry& entry, const base::FilePath& file_path, const std::set<base::FilePath>& child_directories) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!file_path.empty()); resource_metadata_->RemoveEntry( - entry_proto.resource_id(), + entry.resource_id(), base::Bind(&ChangeListProcessor::NotifyForRemoveEntryFromParent, weak_ptr_factory_.GetWeakPtr(), - entry_proto.file_info().is_directory(), + entry.file_info().is_directory(), file_path, child_directories)); } @@ -335,12 +335,12 @@ void ChangeListProcessor::NotifyForRemoveEntryFromParent( ApplyNextEntryProtoAsync(); } -void ChangeListProcessor::RefreshEntry(const DriveEntryProto& entry_proto, +void ChangeListProcessor::RefreshEntry(const ResourceEntry& entry, const base::FilePath& file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); resource_metadata_->RefreshEntry( - entry_proto, + entry, base::Bind(&ChangeListProcessor::NotifyForRefreshEntry, weak_ptr_factory_.GetWeakPtr(), file_path)); @@ -350,7 +350,7 @@ void ChangeListProcessor::NotifyForRefreshEntry( const base::FilePath& old_file_path, FileError error, const base::FilePath& file_path, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DVLOG(1) << "NotifyForRefreshEntry " << file_path.value(); @@ -362,7 +362,7 @@ void ChangeListProcessor::NotifyForRefreshEntry( changed_dirs_.insert(file_path.DirName()); // Notify self if entry is a directory. - if (entry_proto->file_info().is_directory()) { + if (entry->file_info().is_directory()) { // Notify new self. changed_dirs_.insert(file_path); // Notify old self. @@ -384,7 +384,7 @@ void ChangeListProcessor::FeedToEntryProtoMap( ChangeList* change_list = change_lists[i]; // Get upload url from the root feed. Links for all other collections will - // be handled in ConvertResourceEntryToDriveEntryProto. + // be handled in ConvertToResourceEntry. if (i == 0) { // The changestamp appears in the first page of the change list. // The changestamp does not appear in the full resource list. @@ -393,29 +393,29 @@ void ChangeListProcessor::FeedToEntryProtoMap( DCHECK_GE(change_list->largest_changestamp(), 0); } - std::vector<DriveEntryProto>* entries = change_list->mutable_entries(); + std::vector<ResourceEntry>* entries = change_list->mutable_entries(); for (size_t i = 0; i < entries->size(); ++i) { - DriveEntryProto* entry_proto = &(*entries)[i]; + ResourceEntry* entry = &(*entries)[i]; // Some document entries don't map into files (i.e. sites). - if (entry_proto->resource_id().empty()) + if (entry->resource_id().empty()) continue; // Count the number of files. if (uma_stats) { - if (!entry_proto->file_info().is_directory()) { + if (!entry->file_info().is_directory()) { uma_stats->IncrementNumFiles( - entry_proto->file_specific_info().is_hosted_document()); + entry->file_specific_info().is_hosted_document()); } - if (entry_proto->shared_with_me()) + if (entry->shared_with_me()) uma_stats->IncrementNumSharedWithMeEntries(); } - std::pair<DriveEntryProtoMap::iterator, bool> ret = entry_proto_map_. - insert(std::make_pair(entry_proto->resource_id(), DriveEntryProto())); + std::pair<ResourceEntryMap::iterator, bool> ret = entry_map_. + insert(std::make_pair(entry->resource_id(), ResourceEntry())); if (ret.second) - ret.first->second.Swap(entry_proto); + ret.first->second.Swap(entry); else - LOG(DFATAL) << "Found duplicate file " << entry_proto->base_name(); + LOG(DFATAL) << "Found duplicate file " << entry->base_name(); } } } @@ -434,13 +434,13 @@ void ChangeListProcessor::UpdateRootEntry(const base::Closure& closure) { void ChangeListProcessor::UpdateRootEntryAfterGetEntry( const base::Closure& closure, FileError error, - scoped_ptr<DriveEntryProto> root_proto) { + scoped_ptr<ResourceEntry> root_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!closure.is_null()); if (error != FILE_ERROR_OK) { // TODO(satorux): Need to trigger recovery if root is corrupt. - LOG(WARNING) << "Failed to get the proto for root directory"; + LOG(WARNING) << "Failed to get the entry for root directory"; closure.Run(); return; } @@ -461,7 +461,7 @@ void ChangeListProcessor::UpdateRootEntryAfterRefreshEntry( const base::Closure& closure, FileError error, const base::FilePath& /* root_path */, - scoped_ptr<DriveEntryProto> /* root_proto */) { + scoped_ptr<ResourceEntry> /* root_proto */) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!closure.is_null()); LOG_IF(WARNING, error != FILE_ERROR_OK) << "Failed to refresh root directory"; @@ -480,7 +480,7 @@ void ChangeListProcessor::OnComplete() { void ChangeListProcessor::Clear() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - entry_proto_map_.clear(); + entry_map_.clear(); changed_dirs_.clear(); largest_changestamp_ = 0; on_complete_callback_.Reset(); diff --git a/chrome/browser/chromeos/drive/change_list_processor.h b/chrome/browser/chromeos/drive/change_list_processor.h index eb3eb07..533518b0 100644 --- a/chrome/browser/chromeos/drive/change_list_processor.h +++ b/chrome/browser/chromeos/drive/change_list_processor.h @@ -24,7 +24,7 @@ class ResourceList; namespace drive { -class DriveEntryProto; +class ResourceEntry; namespace internal { class ResourceMetadata; @@ -36,13 +36,13 @@ class ChangeList { explicit ChangeList(const google_apis::ResourceList& resource_list); ~ChangeList(); - const std::vector<DriveEntryProto>& entries() const { return entries_; } - std::vector<DriveEntryProto>* mutable_entries() { return &entries_; } + const std::vector<ResourceEntry>& entries() const { return entries_; } + std::vector<ResourceEntry>* mutable_entries() { return &entries_; } const GURL& next_url() const { return next_url_; } int64 largest_changestamp() const { return largest_changestamp_; } private: - std::vector<DriveEntryProto> entries_; + std::vector<ResourceEntry> entries_; GURL next_url_; int64 largest_changestamp_; @@ -53,8 +53,8 @@ class ChangeList { // Documents List API) or Google Drive API. class ChangeListProcessor { public: - typedef std::map<std::string /* resource_id */, DriveEntryProto> - DriveEntryProtoMap; + typedef std::map<std::string /* resource_id */, ResourceEntry> + ResourceEntryMap; // Class used to record UMA stats with FeedToEntryProtoMap(). class ChangeListToEntryProtoMapUMAStats; @@ -80,20 +80,20 @@ class ChangeListProcessor { const base::Closure& on_complete_callback); // Converts list of document feeds from collected feeds into a - // DriveEntryProtoMap. |feed_changestamp| and/or |uma_stats| may be NULL. - // entry_proto_map_ is updated as side effects. + // ResourceEntryMap. |feed_changestamp| and/or |uma_stats| may be NULL. + // entry_map_ is updated as side effects. void FeedToEntryProtoMap(ScopedVector<ChangeList> change_lists, int64* feed_changestamp, ChangeListToEntryProtoMapUMAStats* uma_stats); - // A map of DriveEntryProto's representing a feed. - const DriveEntryProtoMap& entry_proto_map() const { return entry_proto_map_; } + // A map of ResourceEntry's representing a feed. + const ResourceEntryMap& entry_map() const { return entry_map_; } // The set of changed directories as a result of feed processing. const std::set<base::FilePath>& changed_dirs() const { return changed_dirs_; } private: - // Applies the pre-processed feed from entry_proto_map_ onto the filesystem. + // Applies the pre-processed feed from entry_map_ onto the filesystem. // If this is not delta feed update (i.e. |is_delta_feed| is false), // |about_resource| must not be null. void ApplyEntryProtoMap( @@ -103,28 +103,28 @@ class ChangeListProcessor { scoped_ptr<google_apis::AboutResource> about_resource, FileError error); - // Apply the next item from entry_proto_map_ to the file system. The async + // Apply the next item from entry_map_ to the file system. The async // version posts to the message loop to avoid recursive stack-overflow. void ApplyNextEntryProto(); void ApplyNextEntryProtoAsync(); - // Apply |entry_proto| to resource_metadata_. - void ApplyEntryProto(const DriveEntryProto& entry_proto); + // Apply |entry| to resource_metadata_. + void ApplyEntryProto(const ResourceEntry& entry); // Continue ApplyEntryProto. This is a callback for // ResourceMetadata::GetEntryInfoByResourceId. void ContinueApplyEntryProto( - const DriveEntryProto& entry_proto, + const ResourceEntry& entry, FileError error, const base::FilePath& file_path, - scoped_ptr<DriveEntryProto> old_entry_proto); + scoped_ptr<ResourceEntry> old_entry); - // Apply the DriveEntryProto pointed to by |it| to resource_metadata_. - void ApplyNextByIterator(DriveEntryProtoMap::iterator it); + // Apply the ResourceEntry pointed to by |it| to resource_metadata_. + void ApplyNextByIterator(ResourceEntryMap::iterator it); - // Helper function to add |entry_proto| to its parent. Updates changed_dirs_ + // Helper function to add |entry| to its parent. Updates changed_dirs_ // as a side effect. - void AddEntry(const DriveEntryProto& entry_proto); + void AddEntry(const ResourceEntry& entry); // Callback for ResourceMetadata::AddEntry. void NotifyForAddEntry(bool is_directory, @@ -134,13 +134,13 @@ class ChangeListProcessor { // Removes entry pointed to by |resource_id| from its parent. Updates // changed_dirs_ as a side effect. void RemoveEntryFromParent( - const DriveEntryProto& entry_proto, + const ResourceEntry& entry, const base::FilePath& file_path); // Continues RemoveEntryFromParent after // ResourceMetadata::GetChildDirectories. void OnGetChildrenForRemove( - const DriveEntryProto& entry_proto, + const ResourceEntry& entry, const base::FilePath& file_path, const std::set<base::FilePath>& child_directories); @@ -153,8 +153,8 @@ class ChangeListProcessor { const base::FilePath& parent_path); // Refreshes ResourceMetadata entry that has the same resource_id as - // |entry_proto| with |entry_proto|. Updates changed_dirs_ as a side effect. - void RefreshEntry(const DriveEntryProto& entry_proto, + // |entry| with |entry|. Updates changed_dirs_ as a side effect. + void RefreshEntry(const ResourceEntry& entry, const base::FilePath& file_path); // Callback for ResourceMetadata::RefreshEntry. @@ -162,7 +162,7 @@ class ChangeListProcessor { const base::FilePath& old_file_path, FileError error, const base::FilePath& file_path, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Updates the root directory entry. changestamp will be updated. Calls // |closure| upon completion regardless of whether the update was successful @@ -174,7 +174,7 @@ class ChangeListProcessor { // proto, and refreshes the root entry with the proto. void UpdateRootEntryAfterGetEntry(const base::Closure& closure, FileError error, - scoped_ptr<DriveEntryProto> root_proto); + scoped_ptr<ResourceEntry> root_proto); // Part of UpdateRootEntry(). Called after // ResourceMetadata::RefreshEntry() is complete. Calls OnComplete() to @@ -182,7 +182,7 @@ class ChangeListProcessor { void UpdateRootEntryAfterRefreshEntry(const base::Closure& closure, FileError error, const base::FilePath& root_path, - scoped_ptr<DriveEntryProto> root_proto); + scoped_ptr<ResourceEntry> root_proto); // Runs after all entries have been processed. void OnComplete(); @@ -192,7 +192,7 @@ class ChangeListProcessor { internal::ResourceMetadata* resource_metadata_; // Not owned. - DriveEntryProtoMap entry_proto_map_; + ResourceEntryMap entry_map_; std::set<base::FilePath> changed_dirs_; int64 largest_changestamp_; base::Closure on_complete_callback_; diff --git a/chrome/browser/chromeos/drive/download_handler.cc b/chrome/browser/chromeos/drive/download_handler.cc index 3a9f348..a8f879b 100644 --- a/chrome/browser/chromeos/drive/download_handler.cc +++ b/chrome/browser/chromeos/drive/download_handler.cc @@ -78,7 +78,7 @@ void MoveDownloadedFile(const base::FilePath& downloaded_file, void ContinueCheckingForFileExistence( const content::CheckForFileExistenceCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { callback.Run(error == FILE_ERROR_OK); } @@ -258,7 +258,7 @@ void DownloadHandler::OnEntryFound( const base::FilePath& drive_dir_path, const SubstituteDriveDownloadPathCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { if (error == FILE_ERROR_NOT_FOUND) { // Destination Drive directory doesn't exist, so create it. const bool is_exclusive = false, is_recursive = true; diff --git a/chrome/browser/chromeos/drive/download_handler.h b/chrome/browser/chromeos/drive/download_handler.h index ad6c8b6..f8d9670 100644 --- a/chrome/browser/chromeos/drive/download_handler.h +++ b/chrome/browser/chromeos/drive/download_handler.h @@ -20,9 +20,9 @@ class DownloadManager; namespace drive { -class DriveEntryProto; class FileSystemInterface; class FileWriteHelper; +class ResourceEntry; // Observes downloads to temporary local drive folder. Schedules these // downloads for upload to drive service. @@ -81,7 +81,7 @@ class DownloadHandler : public AllDownloadItemNotifier::Observer { void OnEntryFound(const base::FilePath& drive_dir_path, const SubstituteDriveDownloadPathCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Callback for FileSystem::CreateDirectory(). // Used to implement SubstituteDriveDownloadPath(). diff --git a/chrome/browser/chromeos/drive/download_handler_unittest.cc b/chrome/browser/chromeos/drive/download_handler_unittest.cc index c967b3c..42dfca2 100644 --- a/chrome/browser/chromeos/drive/download_handler_unittest.cc +++ b/chrome/browser/chromeos/drive/download_handler_unittest.cc @@ -111,7 +111,7 @@ TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPath) { google_apis::test_util::RunBlockingPoolTask(); // Return result of GetEntryInfoByPath(), destination directory found. - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); + scoped_ptr<ResourceEntry> entry(new ResourceEntry); ASSERT_FALSE(get_entry_info_callback_.is_null()); get_entry_info_callback_.Run(FILE_ERROR_OK, entry.Pass()); google_apis::test_util::RunBlockingPoolTask(); @@ -137,7 +137,7 @@ TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathGetEntryFailure) { // Return result of GetEntryInfoByPath(), failing for some reason. ASSERT_FALSE(get_entry_info_callback_.is_null()); get_entry_info_callback_.Run(FILE_ERROR_FAILED, - scoped_ptr<DriveEntryProto>()); + scoped_ptr<ResourceEntry>()); google_apis::test_util::RunBlockingPoolTask(); // Check the result. @@ -159,7 +159,7 @@ TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathCreateDirectory) { // Return result of GetEntryInfoByPath(), destination directory not found. ASSERT_FALSE(get_entry_info_callback_.is_null()); get_entry_info_callback_.Run(FILE_ERROR_NOT_FOUND, - scoped_ptr<DriveEntryProto>()); + scoped_ptr<ResourceEntry>()); google_apis::test_util::RunBlockingPoolTask(); // Return result of CreateDirecotry(). @@ -189,7 +189,7 @@ TEST_F(DownloadHandlerTest, // Return result of GetEntryInfoByPath(), destination directory not found. ASSERT_FALSE(get_entry_info_callback_.is_null()); get_entry_info_callback_.Run(FILE_ERROR_NOT_FOUND, - scoped_ptr<DriveEntryProto>()); + scoped_ptr<ResourceEntry>()); google_apis::test_util::RunBlockingPoolTask(); // Return result of CreateDirecotry(). @@ -216,7 +216,7 @@ TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathForSavePackage) { google_apis::test_util::RunBlockingPoolTask(); // Return result of GetEntryInfoByPath(), destination directory found. - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); + scoped_ptr<ResourceEntry> entry(new ResourceEntry); ASSERT_FALSE(get_entry_info_callback_.is_null()); get_entry_info_callback_.Run(FILE_ERROR_OK, entry.Pass()); google_apis::test_util::RunBlockingPoolTask(); @@ -253,7 +253,7 @@ TEST_F(DownloadHandlerTest, CheckForFileExistence) { // Return result of GetEntryInfoByPath(), file exists. { - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); + scoped_ptr<ResourceEntry> entry(new ResourceEntry); ASSERT_FALSE(get_entry_info_callback_.is_null()); get_entry_info_callback_.Run(FILE_ERROR_OK, entry.Pass()); } @@ -274,7 +274,7 @@ TEST_F(DownloadHandlerTest, CheckForFileExistence) { // Return result of GetEntryInfoByPath(), file does not exist. ASSERT_FALSE(get_entry_info_callback_.is_null()); get_entry_info_callback_.Run(FILE_ERROR_NOT_FOUND, - scoped_ptr<DriveEntryProto>()); + scoped_ptr<ResourceEntry>()); google_apis::test_util::RunBlockingPoolTask(); // Check the result. diff --git a/chrome/browser/chromeos/drive/drive.proto b/chrome/browser/chromeos/drive/drive.proto index 0ba66db..25ab80f 100644 --- a/chrome/browser/chromeos/drive/drive.proto +++ b/chrome/browser/chromeos/drive/drive.proto @@ -20,7 +20,7 @@ message PlatformFileInfoProto { optional int64 creation_time = 6; } -// File specific info, which is a part of DriveEntryProto. +// File specific info, which is a part of ResourceEntry. message DriveFileSpecificInfo { // This URL points to a thumbnail image. The thumbnail URL is not permanent // as it's not protected by authentication. See crbug.com/127697 for how @@ -57,7 +57,7 @@ message DriveDirectorySpecificInfo { } // Represents DriveEntry, DriveFile, and DriveDirectory without children. -message DriveEntryProto { +message ResourceEntry { optional PlatformFileInfoProto file_info = 1; optional string base_name = 2; optional string title = 3; diff --git a/chrome/browser/chromeos/drive/drive_file_stream_reader.cc b/chrome/browser/chromeos/drive/drive_file_stream_reader.cc index 2af15d4..4c2aa38 100644 --- a/chrome/browser/chromeos/drive/drive_file_stream_reader.cc +++ b/chrome/browser/chromeos/drive/drive_file_stream_reader.cc @@ -295,13 +295,13 @@ void DriveFileStreamReader::InitializeAfterGetFileContentByPathInitialized( const base::FilePath& drive_file_path, const InitializeCompletionCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry, + scoped_ptr<ResourceEntry> entry, const base::FilePath& local_cache_file_path, const base::Closure& ui_cancel_download_closure) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (error != FILE_ERROR_OK) { - callback.Run(error, scoped_ptr<DriveEntryProto>()); + callback.Run(error, scoped_ptr<ResourceEntry>()); return; } DCHECK(entry); @@ -344,13 +344,13 @@ void DriveFileStreamReader::InitializeAfterGetFileContentByPathInitialized( void DriveFileStreamReader::InitializeAfterLocalFileOpen( const InitializeCompletionCallback& callback, - scoped_ptr<DriveEntryProto> entry, + scoped_ptr<ResourceEntry> entry, scoped_ptr<net::FileStream> file_stream, int open_result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (open_result != net::OK) { - callback.Run(FILE_ERROR_FAILED, scoped_ptr<DriveEntryProto>()); + callback.Run(FILE_ERROR_FAILED, scoped_ptr<ResourceEntry>()); return; } @@ -384,7 +384,7 @@ void DriveFileStreamReader::OnGetFileContentByPathCompletion( // or may not be called. This is timing issue, and it is difficult to avoid // unfortunately. if (error != FILE_ERROR_OK) { - callback.Run(error, scoped_ptr<DriveEntryProto>()); + callback.Run(error, scoped_ptr<ResourceEntry>()); } } } diff --git a/chrome/browser/chromeos/drive/drive_file_stream_reader.h b/chrome/browser/chromeos/drive/drive_file_stream_reader.h index bfcfd8e..6520e2f 100644 --- a/chrome/browser/chromeos/drive/drive_file_stream_reader.h +++ b/chrome/browser/chromeos/drive/drive_file_stream_reader.h @@ -105,8 +105,8 @@ class NetworkReaderProxy : public ReaderProxy { } // namespace internal -class DriveEntryProto; class FileSystemInterface; +class ResourceEntry; // The stream reader for a file in FileSystem. Instances of this class // should live on IO thread. @@ -120,7 +120,7 @@ class DriveFileStreamReader { // Callback to return the result of Initialize(). typedef base::Callback<void(FileError error, - scoped_ptr<DriveEntryProto> entry)> + scoped_ptr<ResourceEntry> entry)> InitializeCompletionCallback; explicit DriveFileStreamReader( @@ -154,14 +154,14 @@ class DriveFileStreamReader { const base::FilePath& drive_file_path, const InitializeCompletionCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry, + scoped_ptr<ResourceEntry> entry, const base::FilePath& local_cache_file_path, const base::Closure& cancel_download_closure); // Part of Initialize. Called when the local file open process is done. void InitializeAfterLocalFileOpen( const InitializeCompletionCallback& callback, - scoped_ptr<DriveEntryProto> entry, + scoped_ptr<ResourceEntry> entry, scoped_ptr<net::FileStream> file_stream, int open_result); diff --git a/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc b/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc index 3a9744e..26a658b 100644 --- a/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc @@ -363,7 +363,7 @@ TEST_F(DriveFileStreamReaderTest, Read) { EXPECT_FALSE(reader->IsInitialized()); FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry; + scoped_ptr<ResourceEntry> entry; reader->Initialize( kDriveFile, google_apis::CreateComposedCallback( diff --git a/chrome/browser/chromeos/drive/drive_url_request_job.cc b/chrome/browser/chromeos/drive/drive_url_request_job.cc index b10bcf2..cfb1a7e 100644 --- a/chrome/browser/chromeos/drive/drive_url_request_job.cc +++ b/chrome/browser/chromeos/drive/drive_url_request_job.cc @@ -148,7 +148,7 @@ DriveURLRequestJob::~DriveURLRequestJob() { void DriveURLRequestJob::OnDriveFileStreamReaderInitialized( FileError error, - scoped_ptr<DriveEntryProto> entry) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(stream_reader_); diff --git a/chrome/browser/chromeos/drive/drive_url_request_job.h b/chrome/browser/chromeos/drive/drive_url_request_job.h index 4fb3c97..1c40c86 100644 --- a/chrome/browser/chromeos/drive/drive_url_request_job.h +++ b/chrome/browser/chromeos/drive/drive_url_request_job.h @@ -22,9 +22,9 @@ class URLRequest; namespace drive { -class DriveEntryProto; class DriveFileStreamReader; class FileSystemInterface; +class ResourceEntry; // DriveURLRequesetJob is the gateway between network-level drive:... // requests for drive resources and DriveFileSytem. It exposes content URLs @@ -59,7 +59,7 @@ class DriveURLRequestJob : public net::URLRequestJob { // Called when the initialization of DriveFileStreamReader is completed. void OnDriveFileStreamReaderInitialized( FileError error, - scoped_ptr<DriveEntryProto> entry); + scoped_ptr<ResourceEntry> entry); // Called when DriveFileStreamReader::Read is completed. void OnReadCompleted(int read_result); @@ -67,7 +67,7 @@ class DriveURLRequestJob : public net::URLRequestJob { const FileSystemGetter file_system_getter_; scoped_ptr<DriveFileStreamReader> stream_reader_; - scoped_ptr<DriveEntryProto> entry_; + scoped_ptr<ResourceEntry> entry_; // This should remain the last member so it'll be destroyed first and // invalidate its weak pointers before other members are destroyed. diff --git a/chrome/browser/chromeos/drive/drive_url_request_job_unittest.cc b/chrome/browser/chromeos/drive/drive_url_request_job_unittest.cc index 23fce0b..4f346a2 100644 --- a/chrome/browser/chromeos/drive/drive_url_request_job_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_url_request_job_unittest.cc @@ -159,7 +159,7 @@ class DriveURLRequestJobTest : public testing::Test { base::Unretained(this)))); FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry; + scoped_ptr<ResourceEntry> entry; reader->Initialize( file_path, google_apis::CreateComposedCallback( diff --git a/chrome/browser/chromeos/drive/fake_file_system.cc b/chrome/browser/chromeos/drive/fake_file_system.cc index 816b298..67c218a 100644 --- a/chrome/browser/chromeos/drive/fake_file_system.cc +++ b/chrome/browser/chromeos/drive/fake_file_system.cc @@ -321,13 +321,12 @@ void FakeFileSystem::GetFilePathAfterGetResourceEntry( DCHECK_EQ(util::GDataToFileError(error_in), FILE_ERROR_OK); DCHECK(resource_entry); - DriveEntryProto entry_proto = - ConvertResourceEntryToDriveEntryProto(*resource_entry); + ResourceEntry entry = ConvertToResourceEntry(*resource_entry); base::FilePath file_path = - base::FilePath::FromUTF8Unsafe(entry_proto.base_name()).Append( + base::FilePath::FromUTF8Unsafe(entry.base_name()).Append( remaining_file_path); - GetFilePathInternal(root_resource_id, entry_proto.parent_resource_id(), + GetFilePathInternal(root_resource_id, entry.parent_resource_id(), file_path, callback); } @@ -340,32 +339,32 @@ void FakeFileSystem::GetEntryInfoByResourceIdAfterGetResourceEntry( FileError error = util::GDataToFileError(error_in); if (error != FILE_ERROR_OK) { - callback.Run(error, base::FilePath(), scoped_ptr<DriveEntryProto>()); + callback.Run(error, base::FilePath(), scoped_ptr<ResourceEntry>()); return; } DCHECK(resource_entry); - scoped_ptr<DriveEntryProto> entry_proto(new DriveEntryProto( - ConvertResourceEntryToDriveEntryProto(*resource_entry))); + scoped_ptr<ResourceEntry> entry(new ResourceEntry( + ConvertToResourceEntry(*resource_entry))); - const std::string parent_resource_id = entry_proto->parent_resource_id(); + const std::string parent_resource_id = entry->parent_resource_id(); GetFilePath( parent_resource_id, base::Bind( &FakeFileSystem::GetEntryInfoByResourceIdAfterGetFilePath, weak_ptr_factory_.GetWeakPtr(), - callback, error, base::Passed(&entry_proto))); + callback, error, base::Passed(&entry))); } void FakeFileSystem::GetEntryInfoByResourceIdAfterGetFilePath( const GetEntryInfoWithFilePathCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const base::FilePath& parent_file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); base::FilePath file_path = parent_file_path.Append( - base::FilePath::FromUTF8Unsafe(entry_proto->base_name())); - callback.Run(error, file_path, entry_proto.Pass()); + base::FilePath::FromUTF8Unsafe(entry->base_name())); + callback.Run(error, file_path, entry.Pass()); } // Implementation of GetFileContentByPath. @@ -375,34 +374,34 @@ void FakeFileSystem::GetFileContentByPathAfterGetEntryInfo( const google_apis::GetContentCallback& get_content_callback, const FileOperationCallback& completion_callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (error != FILE_ERROR_OK) { completion_callback.Run(error); return; } - DCHECK(entry_proto); + DCHECK(entry); // We're only interested in a file. - if (entry_proto->file_info().is_directory()) { + if (entry->file_info().is_directory()) { completion_callback.Run(FILE_ERROR_NOT_A_FILE); return; } base::FilePath cache_path = - cache_dir_.path().AppendASCII(entry_proto->resource_id()); + cache_dir_.path().AppendASCII(entry->resource_id()); if (file_util::PathExists(cache_path)) { // Cache file is found. - initialized_callback.Run(FILE_ERROR_OK, entry_proto.Pass(), cache_path, + initialized_callback.Run(FILE_ERROR_OK, entry.Pass(), cache_path, base::Closure()); completion_callback.Run(FILE_ERROR_OK); return; } - // Copy the URL here before passing |entry_proto| to the callback. - const GURL download_url(entry_proto->download_url()); - initialized_callback.Run(FILE_ERROR_OK, entry_proto.Pass(), base::FilePath(), + // Copy the URL here before passing |entry| to the callback. + const GURL download_url(entry->download_url()); + initialized_callback.Run(FILE_ERROR_OK, entry.Pass(), base::FilePath(), base::Bind(&base::DoNothing)); drive_service_->DownloadFile( file_path, @@ -432,12 +431,12 @@ void FakeFileSystem::GetEntryInfoByPathAfterGetAboutResource( FileError error = util::GDataToFileError(gdata_error); if (error != FILE_ERROR_OK) { - callback.Run(error, scoped_ptr<DriveEntryProto>()); + callback.Run(error, scoped_ptr<ResourceEntry>()); return; } DCHECK(about_resource); - scoped_ptr<DriveEntryProto> root(new DriveEntryProto); + scoped_ptr<ResourceEntry> root(new ResourceEntry); root->mutable_file_info()->set_is_directory(true); root->set_resource_id(about_resource->root_folder_id()); root->set_title(util::kDriveMyDriveRootDirName); @@ -448,17 +447,17 @@ void FakeFileSystem::GetEntryInfoByPathAfterGetParentEntryInfo( const base::FilePath& base_name, const GetEntryInfoCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> parent_entry_proto) { + scoped_ptr<ResourceEntry> parent_entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (error != FILE_ERROR_OK) { - callback.Run(error, scoped_ptr<DriveEntryProto>()); + callback.Run(error, scoped_ptr<ResourceEntry>()); return; } - DCHECK(parent_entry_proto); + DCHECK(parent_entry); drive_service_->GetResourceListInDirectory( - parent_entry_proto->resource_id(), + parent_entry->resource_id(), base::Bind( &FakeFileSystem::GetEntryInfoByPathAfterGetResourceList, weak_ptr_factory_.GetWeakPtr(), base_name, callback)); @@ -473,7 +472,7 @@ void FakeFileSystem::GetEntryInfoByPathAfterGetResourceList( FileError error = util::GDataToFileError(gdata_error); if (error != FILE_ERROR_OK) { - callback.Run(error, scoped_ptr<DriveEntryProto>()); + callback.Run(error, scoped_ptr<ResourceEntry>()); return; } @@ -481,8 +480,8 @@ void FakeFileSystem::GetEntryInfoByPathAfterGetResourceList( const ScopedVector<google_apis::ResourceEntry>& entries = resource_list->entries(); for (size_t i = 0; i < entries.size(); ++i) { - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto( - ConvertResourceEntryToDriveEntryProto(*entries[i]))); + scoped_ptr<ResourceEntry> entry(new ResourceEntry( + ConvertToResourceEntry(*entries[i]))); if (entry->base_name() == base_name.AsUTF8Unsafe()) { // Found the target entry. callback.Run(FILE_ERROR_OK, entry.Pass()); @@ -490,7 +489,7 @@ void FakeFileSystem::GetEntryInfoByPathAfterGetResourceList( } } - callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); + callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>()); } } // namespace test_util diff --git a/chrome/browser/chromeos/drive/fake_file_system.h b/chrome/browser/chromeos/drive/fake_file_system.h index 4e5dc61..0475855 100644 --- a/chrome/browser/chromeos/drive/fake_file_system.h +++ b/chrome/browser/chromeos/drive/fake_file_system.h @@ -25,8 +25,8 @@ class ResourceEntry; namespace drive { -class DriveEntryProto; class FileSystemObserver; +class ResourceEntry; namespace test_util { @@ -181,12 +181,12 @@ class FakeFileSystem : public FileSystemInterface { void GetEntryInfoByResourceIdAfterGetFilePath( const GetEntryInfoWithFilePathCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const base::FilePath& parent_file_path); // Helpers of GetFileContentByPath. // How the method works: - // 1) Gets DriveEntryProto of the path. + // 1) Gets ResourceEntry of the path. // 2) Look at if there is a cache file or not. If found return it. // 3) Otherwise start DownloadFile. // 4) Runs the |completion_callback| upon the download completion. @@ -196,7 +196,7 @@ class FakeFileSystem : public FileSystemInterface { const google_apis::GetContentCallback& get_content_callback, const FileOperationCallback& completion_callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); void GetFileContentByPathAfterDownloadFile( const FileOperationCallback& completion_callback, google_apis::GDataErrorCode gdata_error, @@ -205,10 +205,10 @@ class FakeFileSystem : public FileSystemInterface { // Helpers of GetEntryInfoByPath. // How the method works: // 1) If the path is root, gets AboutResrouce from the drive service - // and create DriveEntryProto. - // 2-1) Otherwise, gets the parent's DriveEntryProto by recursive call. + // and create ResourceEntry. + // 2-1) Otherwise, gets the parent's ResourceEntry by recursive call. // 2-2) Then, gets the resource list by restricting the parent with its id. - // 2-3) Search the results based on title, and return the DriveEntryProto. + // 2-3) Search the results based on title, and return the ResourceEntry. // Note that adding suffix (e.g. " (2)") for files sharing a same name is // not supported in FakeFileSystem. Thus, even if the server has // files sharing the same name under a directory, the second (or later) @@ -221,7 +221,7 @@ class FakeFileSystem : public FileSystemInterface { const base::FilePath& base_name, const GetEntryInfoCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> parent_entry_proto); + scoped_ptr<ResourceEntry> parent_entry); void GetEntryInfoByPathAfterGetResourceList( const base::FilePath& base_name, const GetEntryInfoCallback& callback, diff --git a/chrome/browser/chromeos/drive/fake_file_system_unittest.cc b/chrome/browser/chromeos/drive/fake_file_system_unittest.cc index b0bbeff..44a0623 100644 --- a/chrome/browser/chromeos/drive/fake_file_system_unittest.cc +++ b/chrome/browser/chromeos/drive/fake_file_system_unittest.cc @@ -46,7 +46,7 @@ class FakeFileSystemTest : public ::testing::Test { TEST_F(FakeFileSystemTest, GetEntryInfoByResourceId) { FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry; + scoped_ptr<ResourceEntry> entry; base::FilePath file_path; fake_file_system_->GetEntryInfoByResourceId( @@ -68,7 +68,7 @@ TEST_F(FakeFileSystemTest, const std::string document_resource_id = "document:5_document_resource_id"; FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry; + scoped_ptr<ResourceEntry> entry; base::FilePath file_path; // Get entry info by resource id. @@ -97,7 +97,7 @@ TEST_F(FakeFileSystemTest, TEST_F(FakeFileSystemTest, GetFileContentByPath) { FileError initialize_error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; base::FilePath cache_file_path; base::Closure cancel_download; google_apis::test_util::TestGetContentCallback get_content_callback; @@ -110,13 +110,13 @@ TEST_F(FakeFileSystemTest, GetFileContentByPath) { fake_file_system_->GetFileContentByPath( kDriveFile, google_apis::test_util::CreateCopyResultCallback( - &initialize_error, &entry_proto, &cache_file_path, &cancel_download), + &initialize_error, &entry, &cache_file_path, &cancel_download), get_content_callback.callback(), google_apis::test_util::CreateCopyResultCallback(&completion_error)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, initialize_error); - EXPECT_TRUE(entry_proto); + EXPECT_TRUE(entry); // No cache file is available yet. EXPECT_TRUE(cache_file_path.empty()); @@ -128,7 +128,7 @@ TEST_F(FakeFileSystemTest, GetFileContentByPath) { EXPECT_EQ(FILE_ERROR_OK, completion_error); initialize_error = FILE_ERROR_FAILED; - entry_proto.reset(); + entry.reset(); get_content_callback.mutable_data()->clear(); completion_error = FILE_ERROR_FAILED; @@ -136,13 +136,13 @@ TEST_F(FakeFileSystemTest, GetFileContentByPath) { fake_file_system_->GetFileContentByPath( kDriveFile, google_apis::test_util::CreateCopyResultCallback( - &initialize_error, &entry_proto, &cache_file_path, &cancel_download), + &initialize_error, &entry, &cache_file_path, &cancel_download), get_content_callback.callback(), google_apis::test_util::CreateCopyResultCallback(&completion_error)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, initialize_error); - EXPECT_TRUE(entry_proto); + EXPECT_TRUE(entry); // Cache file should be available. ASSERT_FALSE(cache_file_path.empty()); @@ -160,7 +160,7 @@ TEST_F(FakeFileSystemTest, GetFileContentByPath) { TEST_F(FakeFileSystemTest, GetFileContentByPath_Directory) { FileError initialize_error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; base::FilePath cache_file_path; google_apis::test_util::TestGetContentCallback get_content_callback; FileError completion_error = FILE_ERROR_FAILED; @@ -169,7 +169,7 @@ TEST_F(FakeFileSystemTest, GetFileContentByPath_Directory) { fake_file_system_->GetFileContentByPath( util::GetDriveMyDriveRootPath(), google_apis::test_util::CreateCopyResultCallback( - &initialize_error, &entry_proto, &cache_file_path, &cancel_download), + &initialize_error, &entry, &cache_file_path, &cancel_download), get_content_callback.callback(), google_apis::test_util::CreateCopyResultCallback(&completion_error)); google_apis::test_util::RunBlockingPoolTask(); @@ -179,7 +179,7 @@ TEST_F(FakeFileSystemTest, GetFileContentByPath_Directory) { TEST_F(FakeFileSystemTest, GetEntryInfoByPath) { FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry; + scoped_ptr<ResourceEntry> entry; fake_file_system_->GetEntryInfoByPath( util::GetDriveMyDriveRootPath().AppendASCII( "Directory 1/Sub Directory Folder"), @@ -193,7 +193,7 @@ TEST_F(FakeFileSystemTest, GetEntryInfoByPath) { TEST_F(FakeFileSystemTest, GetEntryInfoByPath_Root) { FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry; + scoped_ptr<ResourceEntry> entry; fake_file_system_->GetEntryInfoByPath( util::GetDriveMyDriveRootPath(), google_apis::test_util::CreateCopyResultCallback(&error, &entry)); @@ -208,7 +208,7 @@ TEST_F(FakeFileSystemTest, GetEntryInfoByPath_Root) { TEST_F(FakeFileSystemTest, GetEntryInfoByPath_Invalid) { FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry; + scoped_ptr<ResourceEntry> entry; fake_file_system_->GetEntryInfoByPath( util::GetDriveMyDriveRootPath().AppendASCII("Invalid File Name"), google_apis::test_util::CreateCopyResultCallback(&error, &entry)); diff --git a/chrome/browser/chromeos/drive/file_system.cc b/chrome/browser/chromeos/drive/file_system.cc index 8dbcec9d..9739415 100644 --- a/chrome/browser/chromeos/drive/file_system.cc +++ b/chrome/browser/chromeos/drive/file_system.cc @@ -73,9 +73,9 @@ void RunGetEntryInfoWithFilePathCallback( const GetEntryInfoWithFilePathCallback& callback, const base::FilePath& path, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(!callback.is_null()); - callback.Run(error, path, entry_proto.Pass()); + callback.Run(error, path, entry.Pass()); } // Callback for ResourceMetadata::GetLargestChangestamp. @@ -133,18 +133,18 @@ struct FileSystem::GetResolvedFileParams { GetResolvedFileParams( const base::FilePath& drive_file_path, const DriveClientContext& context, - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const GetFileContentInitializedCallback& initialized_callback, const GetFileCallback& get_file_callback, const google_apis::GetContentCallback& get_content_callback) : drive_file_path(drive_file_path), context(context), - entry_proto(entry_proto.Pass()), + entry(entry.Pass()), initialized_callback(initialized_callback), get_file_callback(get_file_callback), get_content_callback(get_content_callback) { DCHECK(!get_file_callback.is_null()); - DCHECK(this->entry_proto); + DCHECK(this->entry); } void OnError(FileError error) { @@ -157,8 +157,10 @@ struct FileSystem::GetResolvedFileParams { return; } - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto(*entry_proto)); - initialized_callback.Run(FILE_ERROR_OK, entry.Pass(), local_file_path, + scoped_ptr<ResourceEntry> new_entry(new ResourceEntry(*entry)); + initialized_callback.Run(FILE_ERROR_OK, + new_entry.Pass(), + local_file_path, base::Closure()); } @@ -167,25 +169,27 @@ struct FileSystem::GetResolvedFileParams { return; } - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto(*entry_proto)); - initialized_callback.Run(FILE_ERROR_OK, entry.Pass(), base::FilePath(), + scoped_ptr<ResourceEntry> new_entry(new ResourceEntry(*entry)); + initialized_callback.Run(FILE_ERROR_OK, + new_entry.Pass(), + base::FilePath(), cancel_download_closure); } void OnComplete(const base::FilePath& local_file_path) { - if (entry_proto->file_specific_info().is_hosted_document()) { + if (entry->file_specific_info().is_hosted_document()) { get_file_callback.Run( FILE_ERROR_OK, local_file_path, kMimeTypeJson, HOSTED_DOCUMENT); } else { get_file_callback.Run( FILE_ERROR_OK, local_file_path, - entry_proto->file_specific_info().content_mime_type(), REGULAR_FILE); + entry->file_specific_info().content_mime_type(), REGULAR_FILE); } } const base::FilePath drive_file_path; const DriveClientContext context; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; const GetFileContentInitializedCallback initialized_callback; const GetFileCallback get_file_callback; const google_apis::GetContentCallback get_content_callback; @@ -333,18 +337,18 @@ void FileSystem::GetEntryInfoByResourceIdAfterGetEntry( const GetEntryInfoWithFilePathCallback& callback, FileError error, const base::FilePath& file_path, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { - callback.Run(error, base::FilePath(), scoped_ptr<DriveEntryProto>()); + callback.Run(error, base::FilePath(), scoped_ptr<ResourceEntry>()); return; } - DCHECK(entry_proto.get()); + DCHECK(entry.get()); CheckLocalModificationAndRun( - entry_proto.Pass(), + entry.Pass(), base::Bind(&RunGetEntryInfoWithFilePathCallback, callback, file_path)); @@ -450,7 +454,7 @@ void FileSystem::Pin(const base::FilePath& file_path, void FileSystem::PinAfterGetEntryInfoByPath( const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -482,7 +486,7 @@ void FileSystem::Unpin(const base::FilePath& file_path, void FileSystem::UnpinAfterGetEntryInfoByPath( const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -517,7 +521,7 @@ void FileSystem::OnGetEntryInfoCompleteForGetFileByPath( const base::FilePath& file_path, const GetFileCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -525,13 +529,13 @@ void FileSystem::OnGetEntryInfoCompleteForGetFileByPath( callback.Run(error, base::FilePath(), std::string(), REGULAR_FILE); return; } - DCHECK(entry_proto); + DCHECK(entry); GetResolvedFileByPath( make_scoped_ptr(new GetResolvedFileParams( file_path, DriveClientContext(USER_INITIATED), - entry_proto.Pass(), + entry.Pass(), GetFileContentInitializedCallback(), callback, google_apis::GetContentCallback()))); @@ -561,7 +565,7 @@ void FileSystem::GetFileByResourceIdAfterGetEntry( const google_apis::GetContentCallback& get_content_callback, FileError error, const base::FilePath& file_path, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!get_file_callback.is_null()); @@ -577,7 +581,7 @@ void FileSystem::GetFileByResourceIdAfterGetEntry( make_scoped_ptr(new GetResolvedFileParams( file_path, context, - entry_proto.Pass(), + entry.Pass(), GetFileContentInitializedCallback(), get_file_callback, get_content_callback))); @@ -609,7 +613,7 @@ void FileSystem::GetFileContentByPathAfterGetEntry( const google_apis::GetContentCallback& get_content_callback, const FileOperationCallback& completion_callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!initialized_callback.is_null()); DCHECK(!get_content_callback.is_null()); @@ -620,12 +624,12 @@ void FileSystem::GetFileContentByPathAfterGetEntry( return; } - DCHECK(entry_proto); + DCHECK(entry); GetResolvedFileByPath( make_scoped_ptr(new GetResolvedFileParams( file_path, DriveClientContext(USER_INITIATED), - entry_proto.Pass(), + entry.Pass(), initialized_callback, base::Bind(&GetFileCallbackToFileOperationCallbackAdapter, completion_callback), @@ -654,12 +658,12 @@ void FileSystem::GetEntryInfoByPathAfterGetEntry1( const base::FilePath& file_path, const GetEntryInfoCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); if (error == FILE_ERROR_OK) { - CheckLocalModificationAndRun(entry_proto.Pass(), callback); + CheckLocalModificationAndRun(entry.Pass(), callback); return; } @@ -682,7 +686,7 @@ void FileSystem::GetEntryInfoByPathAfterLoad( DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { - callback.Run(error, scoped_ptr<DriveEntryProto>()); + callback.Run(error, scoped_ptr<ResourceEntry>()); return; } @@ -696,17 +700,17 @@ void FileSystem::GetEntryInfoByPathAfterLoad( void FileSystem::GetEntryInfoByPathAfterGetEntry2( const GetEntryInfoCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { - callback.Run(error, scoped_ptr<DriveEntryProto>()); + callback.Run(error, scoped_ptr<ResourceEntry>()); return; } - DCHECK(entry_proto.get()); + DCHECK(entry.get()); - CheckLocalModificationAndRun(entry_proto.Pass(), callback); + CheckLocalModificationAndRun(entry.Pass(), callback); } void FileSystem::ReadDirectoryByPath( @@ -730,7 +734,7 @@ void FileSystem::ReadDirectoryByPathAfterGetEntry( const base::FilePath& directory_path, const ReadDirectoryWithSettingCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -745,18 +749,18 @@ void FileSystem::ReadDirectoryByPathAfterGetEntry( return; } - if (!entry_proto->file_info().is_directory()) { + if (!entry->file_info().is_directory()) { callback.Run(FILE_ERROR_NOT_A_DIRECTORY, hide_hosted_docs_, - scoped_ptr<DriveEntryProtoVector>()); + scoped_ptr<ResourceEntryVector>()); return; } // Pass the directory fetch info so we can fetch the contents of the // directory before loading change lists. DirectoryFetchInfo directory_fetch_info( - entry_proto->resource_id(), - entry_proto->directory_specific_info().changestamp()); + entry->resource_id(), + entry->directory_specific_info().changestamp()); change_list_loader_->LoadIfNeeded( directory_fetch_info, base::Bind(&FileSystem::ReadDirectoryByPathAfterLoad, @@ -775,7 +779,7 @@ void FileSystem::ReadDirectoryByPathAfterLoad( if (error != FILE_ERROR_OK) { callback.Run(error, hide_hosted_docs_, - scoped_ptr<DriveEntryProtoVector>()); + scoped_ptr<ResourceEntryVector>()); return; } @@ -789,14 +793,14 @@ void FileSystem::ReadDirectoryByPathAfterLoad( void FileSystem::ReadDirectoryByPathAfterRead( const ReadDirectoryWithSettingCallback& callback, FileError error, - scoped_ptr<DriveEntryProtoVector> entries) { + scoped_ptr<ResourceEntryVector> entries) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { callback.Run(error, hide_hosted_docs_, - scoped_ptr<DriveEntryProtoVector>()); + scoped_ptr<ResourceEntryVector>()); return; } DCHECK(entries.get()); // This is valid for empty directories too. @@ -809,29 +813,29 @@ void FileSystem::GetResolvedFileByPath( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(params); - if (params->entry_proto->file_info().is_directory()) { + if (params->entry->file_info().is_directory()) { params->OnError(FILE_ERROR_NOT_A_FILE); return; } // The file's entry should have its file specific info. - DCHECK(params->entry_proto->has_file_specific_info()); + DCHECK(params->entry->has_file_specific_info()); // For a hosted document, we create a special JSON file to represent the // document instead of fetching the document content in one of the exported // formats. The JSON file contains the edit URL and resource ID of the // document. - if (params->entry_proto->file_specific_info().is_hosted_document()) { + if (params->entry->file_specific_info().is_hosted_document()) { base::FilePath* temp_file_path = new base::FilePath; - DriveEntryProto* entry_proto_ptr = params->entry_proto.get(); + ResourceEntry* entry_ptr = params->entry.get(); base::PostTaskAndReplyWithResult( blocking_task_runner_, FROM_HERE, base::Bind(&CreateDocumentJsonFileOnBlockingPool, cache_->GetCacheDirectoryPath( FileCache::CACHE_TYPE_TMP_DOCUMENTS), - GURL(entry_proto_ptr->file_specific_info().alternate_url()), - entry_proto_ptr->resource_id(), + GURL(entry_ptr->file_specific_info().alternate_url()), + entry_ptr->resource_id(), temp_file_path), base::Bind( &FileSystem::GetResolvedFileByPathAfterCreateDocumentJsonFile, @@ -842,10 +846,10 @@ void FileSystem::GetResolvedFileByPath( } // Returns absolute path of the file if it were cached or to be cached. - DriveEntryProto* entry_proto_ptr = params->entry_proto.get(); + ResourceEntry* entry_ptr = params->entry.get(); cache_->GetFile( - entry_proto_ptr->resource_id(), - entry_proto_ptr->file_specific_info().file_md5(), + entry_ptr->resource_id(), + entry_ptr->file_specific_info().file_md5(), base::Bind( &FileSystem::GetResolvedFileByPathAfterGetFileFromCache, weak_ptr_factory_.GetWeakPtr(), @@ -895,7 +899,7 @@ void FileSystem::GetResolvedFileByPathAfterGetFileFromCache( // - if we have enough space, start downloading the file from the server GetResolvedFileParams* params_ptr = params.get(); scheduler_->GetResourceEntry( - params_ptr->entry_proto->resource_id(), + params_ptr->entry->resource_id(), params_ptr->context, base::Bind(&FileSystem::GetResolvedFileByPathAfterGetResourceEntry, weak_ptr_factory_.GetWeakPtr(), @@ -928,9 +932,9 @@ void FileSystem::GetResolvedFileByPathAfterGetResourceEntry( return; } - DCHECK_EQ(params->entry_proto->resource_id(), entry->resource_id()); + DCHECK_EQ(params->entry->resource_id(), entry->resource_id()); resource_metadata_->RefreshEntry( - ConvertResourceEntryToDriveEntryProto(*entry), + ConvertToResourceEntry(*entry), base::Bind(&FileSystem::GetResolvedFileByPathAfterRefreshEntry, weak_ptr_factory_.GetWeakPtr(), base::Passed(¶ms), @@ -942,7 +946,7 @@ void FileSystem::GetResolvedFileByPathAfterRefreshEntry( const GURL& download_url, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(params); @@ -951,8 +955,8 @@ void FileSystem::GetResolvedFileByPathAfterRefreshEntry( return; } - int64 file_size = entry_proto->file_info().size(); - params->entry_proto = entry_proto.Pass(); // Update the entry in |params|. + int64 file_size = entry->file_info().size(); + params->entry = entry.Pass(); // Update the entry in |params|. cache_->FreeDiskSpaceIfNeededFor( file_size, base::Bind(&FileSystem::GetResolvedFileByPathAfterFreeDiskSpace, @@ -1031,13 +1035,13 @@ void FileSystem::GetResolvedFileByPathAfterDownloadFile( // unpinned so that we do not sync the file again. if (status == google_apis::GDATA_CANCELLED) { cache_->GetCacheEntry( - params->entry_proto->resource_id(), - params->entry_proto->file_specific_info().file_md5(), + params->entry->resource_id(), + params->entry->file_specific_info().file_md5(), base::Bind( &FileSystem::GetResolvedFileByPathAfterGetCacheEntryForCancel, weak_ptr_factory_.GetWeakPtr(), - params->entry_proto->resource_id(), - params->entry_proto->file_specific_info().file_md5())); + params->entry->resource_id(), + params->entry->file_specific_info().file_md5())); } FileError error = util::GDataToFileError(status); @@ -1046,7 +1050,7 @@ void FileSystem::GetResolvedFileByPathAfterDownloadFile( return; } - DriveEntryProto* entry = params->entry_proto.get(); + ResourceEntry* entry = params->entry.get(); cache_->Store(entry->resource_id(), entry->file_specific_info().file_md5(), downloaded_file_path, @@ -1091,7 +1095,7 @@ void FileSystem::GetResolvedFileByPathAfterStore( // Storing to cache changes the "offline available" status, hence notify. OnDirectoryChanged(params->drive_file_path.DirName()); - DriveEntryProto* entry = params->entry_proto.get(); + ResourceEntry* entry = params->entry.get(); cache_->GetFile( entry->resource_id(), entry->file_specific_info().file_md5(), @@ -1133,7 +1137,7 @@ void FileSystem::RefreshDirectoryAfterGetEntryInfo( const base::FilePath& directory_path, const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -1141,18 +1145,18 @@ void FileSystem::RefreshDirectoryAfterGetEntryInfo( callback.Run(error); return; } - if (!entry_proto->file_info().is_directory()) { + if (!entry->file_info().is_directory()) { callback.Run(FILE_ERROR_NOT_A_DIRECTORY); return; } - if (util::IsSpecialResourceId(entry_proto->resource_id())) { + if (util::IsSpecialResourceId(entry->resource_id())) { // Do not load special directories. Just return. callback.Run(FILE_ERROR_OK); return; } change_list_loader_->LoadDirectoryFromServer( - entry_proto->resource_id(), + entry->resource_id(), callback); } @@ -1224,7 +1228,7 @@ void FileSystem::OnSearch(const SearchCallback& search_callback, const base::Closure callback = base::Bind( search_callback, FILE_ERROR_OK, next_feed, base::Passed(&result_vec)); - const std::vector<DriveEntryProto>& entries = change_list->entries(); + const std::vector<ResourceEntry>& entries = change_list->entries(); if (entries.empty()) { callback.Run(); return; @@ -1236,7 +1240,7 @@ void FileSystem::OnSearch(const SearchCallback& search_callback, for (size_t i = 0; i < entries.size(); ++i) { // Run the callback if this is the last iteration of the loop. const bool should_run_callback = (i + 1 == entries.size()); - const DriveEntryProto& entry_proto = entries[i]; + const ResourceEntry& entry = entries[i]; const GetEntryInfoWithFilePathCallback entry_info_callback = base::Bind(&FileSystem::AddToSearchResults, @@ -1245,7 +1249,7 @@ void FileSystem::OnSearch(const SearchCallback& search_callback, should_run_callback, callback); - resource_metadata_->RefreshEntry(entry_proto, entry_info_callback); + resource_metadata_->RefreshEntry(entry, entry_info_callback); } } @@ -1255,7 +1259,7 @@ void FileSystem::AddToSearchResults( const base::Closure& callback, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // If a result is not present in our local file system snapshot, call @@ -1263,8 +1267,8 @@ void FileSystem::AddToSearchResults( // if the entry has recently been added to the drive (and we still haven't // received its delta feed). if (error == FILE_ERROR_OK) { - DCHECK(entry_proto.get()); - results->push_back(SearchResultInfo(drive_file_path, *entry_proto.get())); + DCHECK(entry.get()); + results->push_back(SearchResultInfo(drive_file_path, *entry.get())); DVLOG(1) << "AddToSearchResults " << drive_file_path.value(); } else if (error == FILE_ERROR_NOT_FOUND) { CheckForUpdates(); @@ -1349,7 +1353,7 @@ void FileSystem::AddUploadedFile( entry->file_md5()); resource_metadata_->AddEntry( - ConvertResourceEntryToDriveEntryProto(*entry), + ConvertToResourceEntry(*entry), base::Bind(&FileSystem::AddUploadedFileToCache, weak_ptr_factory_.GetWeakPtr(), params)); } @@ -1413,7 +1417,7 @@ void FileSystem::MarkCacheFileAsMounted( void FileSystem::MarkCacheFileAsMountedAfterGetEntryInfo( const OpenFileCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -1422,9 +1426,9 @@ void FileSystem::MarkCacheFileAsMountedAfterGetEntryInfo( return; } - DCHECK(entry_proto); - cache_->MarkAsMounted(entry_proto->resource_id(), - entry_proto->file_specific_info().file_md5(), + DCHECK(entry); + cache_->MarkAsMounted(entry->resource_id(), + entry->file_specific_info().file_md5(), callback); } @@ -1528,17 +1532,17 @@ void FileSystem::OnGetEntryInfoCompleteForOpenFile( const base::FilePath& file_path, const OpenFileCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - DCHECK(entry_proto.get() || error != FILE_ERROR_OK); + DCHECK(entry.get() || error != FILE_ERROR_OK); - if (entry_proto.get() && !entry_proto->has_file_specific_info()) + if (entry.get() && !entry->has_file_specific_info()) error = FILE_ERROR_NOT_FOUND; if (error == FILE_ERROR_OK) { - if (entry_proto->file_specific_info().file_md5().empty() || - entry_proto->file_specific_info().is_hosted_document()) { + if (entry->file_specific_info().file_md5().empty() || + entry->file_specific_info().is_hosted_document()) { // No support for opening a directory or hosted document. error = FILE_ERROR_INVALID_OPERATION; } @@ -1549,21 +1553,21 @@ void FileSystem::OnGetEntryInfoCompleteForOpenFile( return; } - DCHECK(!entry_proto->resource_id().empty()); + DCHECK(!entry->resource_id().empty()); // Extract a pointer before we call Pass() so we can use it below. - DriveEntryProto* entry_proto_ptr = entry_proto.get(); + ResourceEntry* entry_ptr = entry.get(); GetResolvedFileByPath( make_scoped_ptr(new GetResolvedFileParams( file_path, DriveClientContext(USER_INITIATED), - entry_proto.Pass(), + entry.Pass(), GetFileContentInitializedCallback(), base::Bind(&FileSystem::OnGetFileCompleteForOpenFile, weak_ptr_factory_.GetWeakPtr(), GetFileCompleteForOpenParams( callback, - entry_proto_ptr->resource_id(), - entry_proto_ptr->file_specific_info().file_md5())), + entry_ptr->resource_id(), + entry_ptr->file_specific_info().file_md5())), google_apis::GetContentCallback()))); } @@ -1652,11 +1656,11 @@ void FileSystem::CloseFileAfterGetEntryInfo( const base::FilePath& file_path, const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (entry_proto.get() && !entry_proto->has_file_specific_info()) + if (entry.get() && !entry->has_file_specific_info()) error = FILE_ERROR_NOT_FOUND; if (error != FILE_ERROR_OK) { @@ -1670,8 +1674,8 @@ void FileSystem::CloseFileAfterGetEntryInfo( // if the file has not been modified. Come up with a way to detect the // intactness effectively, or provide a method for user to declare it when // calling CloseFile(). - cache_->CommitDirty(entry_proto->resource_id(), - entry_proto->file_specific_info().file_md5(), + cache_->CommitDirty(entry->resource_id(), + entry->file_specific_info().file_md5(), callback); } @@ -1692,34 +1696,34 @@ void FileSystem::CloseFileFinalize(const base::FilePath& file_path, } void FileSystem::CheckLocalModificationAndRun( - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const GetEntryInfoCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(entry_proto.get()); + DCHECK(entry.get()); DCHECK(!callback.is_null()); // For entries that will never be cached, use the original entry info as is. - if (!entry_proto->has_file_specific_info() || - entry_proto->file_specific_info().is_hosted_document()) { - callback.Run(FILE_ERROR_OK, entry_proto.Pass()); + if (!entry->has_file_specific_info() || + entry->file_specific_info().is_hosted_document()) { + callback.Run(FILE_ERROR_OK, entry.Pass()); return; } // Checks if the file is cached and modified locally. - const std::string resource_id = entry_proto->resource_id(); - const std::string md5 = entry_proto->file_specific_info().file_md5(); + const std::string resource_id = entry->resource_id(); + const std::string md5 = entry->file_specific_info().file_md5(); cache_->GetCacheEntry( resource_id, md5, base::Bind( &FileSystem::CheckLocalModificationAndRunAfterGetCacheEntry, weak_ptr_factory_.GetWeakPtr(), - base::Passed(&entry_proto), + base::Passed(&entry), callback)); } void FileSystem::CheckLocalModificationAndRunAfterGetCacheEntry( - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const GetEntryInfoCallback& callback, bool success, const FileCacheEntry& cache_entry) { @@ -1728,25 +1732,25 @@ void FileSystem::CheckLocalModificationAndRunAfterGetCacheEntry( // When no dirty cache is found, use the original entry info as is. if (!success || !cache_entry.is_dirty()) { - callback.Run(FILE_ERROR_OK, entry_proto.Pass()); + callback.Run(FILE_ERROR_OK, entry.Pass()); return; } // Gets the cache file path. - const std::string& resource_id = entry_proto->resource_id(); - const std::string& md5 = entry_proto->file_specific_info().file_md5(); + const std::string& resource_id = entry->resource_id(); + const std::string& md5 = entry->file_specific_info().file_md5(); cache_->GetFile( resource_id, md5, base::Bind( &FileSystem::CheckLocalModificationAndRunAfterGetCacheFile, weak_ptr_factory_.GetWeakPtr(), - base::Passed(&entry_proto), + base::Passed(&entry), callback)); } void FileSystem::CheckLocalModificationAndRunAfterGetCacheFile( - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const GetEntryInfoCallback& callback, FileError error, const base::FilePath& local_cache_path) { @@ -1755,7 +1759,7 @@ void FileSystem::CheckLocalModificationAndRunAfterGetCacheFile( // When no dirty cache is found, use the original entry info as is. if (error != FILE_ERROR_OK) { - callback.Run(FILE_ERROR_OK, entry_proto.Pass()); + callback.Run(FILE_ERROR_OK, entry.Pass()); return; } @@ -1769,13 +1773,13 @@ void FileSystem::CheckLocalModificationAndRunAfterGetCacheFile( base::Unretained(file_info)), base::Bind(&FileSystem::CheckLocalModificationAndRunAfterGetFileInfo, weak_ptr_factory_.GetWeakPtr(), - base::Passed(&entry_proto), + base::Passed(&entry), callback, base::Owned(file_info))); } void FileSystem::CheckLocalModificationAndRunAfterGetFileInfo( - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const GetEntryInfoCallback& callback, base::PlatformFileInfo* file_info, bool get_file_info_result) { @@ -1783,14 +1787,14 @@ void FileSystem::CheckLocalModificationAndRunAfterGetFileInfo( DCHECK(!callback.is_null()); if (!get_file_info_result) { - callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); + callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>()); return; } PlatformFileInfoProto entry_file_info; - util::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); - *entry_proto->mutable_file_info() = entry_file_info; - callback.Run(FILE_ERROR_OK, entry_proto.Pass()); + util::ConvertPlatformFileInfoToResourceEntry(*file_info, &entry_file_info); + *entry->mutable_file_info() = entry_file_info; + callback.Run(FILE_ERROR_OK, entry.Pass()); } void FileSystem::CancelJobInScheduler(JobID id) { diff --git a/chrome/browser/chromeos/drive/file_system.h b/chrome/browser/chromeos/drive/file_system.h index 6fb6519..e5dd662 100644 --- a/chrome/browser/chromeos/drive/file_system.h +++ b/chrome/browser/chromeos/drive/file_system.h @@ -199,7 +199,7 @@ class FileSystem : public FileSystemInterface, FileError error); // Callback for ResourceMetadata::RefreshEntry, from OnSearch. - // Adds |drive_file_path| to |results|. When |entry_proto| is not present in + // Adds |drive_file_path| to |results|. When |entry| is not present in // the local file system snapshot, it is not added to |results|. Instead, // CheckForUpdates is called. Runs |callback| with |results| if // |should_run_callback| is true. @@ -208,7 +208,7 @@ class FileSystem : public FileSystemInterface, const base::Closure& callback, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Part of CreateDirectory(). Called after ChangeListLoader::LoadIfNeeded() // is called and made sure that the resource metadata is loaded. @@ -221,12 +221,12 @@ class FileSystem : public FileSystemInterface, // Used to implement Pin(). void PinAfterGetEntryInfoByPath(const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry); + scoped_ptr<ResourceEntry> entry); // Used to implement Unpin(). void UnpinAfterGetEntryInfoByPath(const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry); + scoped_ptr<ResourceEntry> entry); // Invoked upon completion of GetEntryInfoByPath initiated by // GetFileByPath. It then continues to invoke GetResolvedFileByPath. @@ -235,7 +235,7 @@ class FileSystem : public FileSystemInterface, const base::FilePath& file_path, const GetFileCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> file_info); + scoped_ptr<ResourceEntry> file_info); // Invoked upon completion of GetEntryInfoByPath initiated by OpenFile. // It then continues to invoke GetResolvedFileByPath and proceeds to @@ -244,7 +244,7 @@ class FileSystem : public FileSystemInterface, const base::FilePath& file_path, const OpenFileCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> file_info); + scoped_ptr<ResourceEntry> file_info); // Invoked at the last step of OpenFile. It removes |file_path| from the // current set of opened files if |result| is an error, and then invokes the @@ -263,7 +263,7 @@ class FileSystem : public FileSystemInterface, void CloseFileAfterGetEntryInfo(const base::FilePath& file_path, const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); void CloseFileFinalize(const base::FilePath& file_path, const FileOperationCallback& callback, FileError result); @@ -314,14 +314,14 @@ class FileSystem : public FileSystemInterface, const base::FilePath& file_path, const GetEntryInfoCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); void GetEntryInfoByPathAfterLoad(const base::FilePath& file_path, const GetEntryInfoCallback& callback, FileError error); void GetEntryInfoByPathAfterGetEntry2( const GetEntryInfoCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Part of ReadDirectoryByPath() // 1) Called when ResourceMetadata::GetEntryInfoByPath() is complete. @@ -332,7 +332,7 @@ class FileSystem : public FileSystemInterface, const base::FilePath& directory_path, const ReadDirectoryWithSettingCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); void ReadDirectoryByPathAfterLoad( const base::FilePath& directory_path, const ReadDirectoryWithSettingCallback& callback, @@ -340,7 +340,7 @@ class FileSystem : public FileSystemInterface, void ReadDirectoryByPathAfterRead( const ReadDirectoryWithSettingCallback& callback, FileError error, - scoped_ptr<DriveEntryProtoVector> entries); + scoped_ptr<ResourceEntryVector> entries); // Gets the file at |file_path| from the cache (if found in the cache), // or the server (if not found in the cache) after the file info is @@ -363,7 +363,7 @@ class FileSystem : public FileSystemInterface, const GURL& download_url, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); void GetResolvedFileByPathAfterFreeDiskSpace( scoped_ptr<GetResolvedFileParams> params, const GURL& download_url, @@ -398,7 +398,7 @@ class FileSystem : public FileSystemInterface, const GetEntryInfoWithFilePathCallback& callback, FileError error, const base::FilePath& file_path, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Part of GetFileByResourceId(). Called after // ResourceMetadata::GetEntryInfoByResourceId() is complete. @@ -410,7 +410,7 @@ class FileSystem : public FileSystemInterface, const google_apis::GetContentCallback& get_content_callback, FileError error, const base::FilePath& file_path, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Part of GetFileContentByPath(). Called after // ResourceMetadata::GetEntryInfoByPath() is complete. @@ -422,7 +422,7 @@ class FileSystem : public FileSystemInterface, const google_apis::GetContentCallback& get_content_callback, const FileOperationCallback& completion_callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Part of RefreshDirectory(). Called after // GetEntryInfoByPath() is complete. @@ -430,26 +430,26 @@ class FileSystem : public FileSystemInterface, const base::FilePath& directory_path, const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Part of GetEntryByResourceId and GetEntryByPath. Checks whether there is a // local dirty cache for the entry, and if there is, replace the - // PlatformFileInfo part of the |entry_proto| with the locally modified info. + // PlatformFileInfo part of the |entry| with the locally modified info. // |callback| must not be null. - void CheckLocalModificationAndRun(scoped_ptr<DriveEntryProto> entry_proto, + void CheckLocalModificationAndRun(scoped_ptr<ResourceEntry> entry, const GetEntryInfoCallback& callback); void CheckLocalModificationAndRunAfterGetCacheEntry( - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const GetEntryInfoCallback& callback, bool success, const FileCacheEntry& cache_entry); void CheckLocalModificationAndRunAfterGetCacheFile( - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const GetEntryInfoCallback& callback, FileError error, const base::FilePath& local_cache_path); void CheckLocalModificationAndRunAfterGetFileInfo( - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const GetEntryInfoCallback& callback, base::PlatformFileInfo* file_info, bool get_file_info_result); @@ -459,7 +459,7 @@ class FileSystem : public FileSystemInterface, void MarkCacheFileAsMountedAfterGetEntryInfo( const OpenFileCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Cancels the job with |id| in the scheduler. void CancelJobInScheduler(JobID id); diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc b/chrome/browser/chromeos/drive/file_system/copy_operation.cc index 3ce9cda..fea479b 100644 --- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc @@ -20,8 +20,6 @@ #include "net/base/mime_util.h" using content::BrowserThread; -using google_apis::ResourceEntry; -using google_apis::GDataErrorCode; namespace drive { namespace file_system { @@ -46,7 +44,8 @@ FileError CopyLocalFileOnBlockingPool( std::string GetDocumentResourceIdOnBlockingPool( const base::FilePath& local_file_path) { std::string result; - if (ResourceEntry::HasHostedDocumentExtension(local_file_path)) { + if (google_apis::ResourceEntry::HasHostedDocumentExtension( + local_file_path)) { std::string error; DictionaryValue* dict_value = NULL; JSONFileValueSerializer serializer(local_file_path); @@ -212,7 +211,7 @@ void CopyOperation::CopyHostedDocumentToDirectory( void CopyOperation::OnCopyHostedDocumentCompleted( const base::FilePath& dir_path, const FileOperationCallback& callback, - GDataErrorCode status, + google_apis::GDataErrorCode status, scoped_ptr<google_apis::ResourceEntry> resource_entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -227,7 +226,7 @@ void CopyOperation::OnCopyHostedDocumentCompleted( // The entry was added in the root directory on the server, so we should // first add it to the root to mirror the state and then move it to the // destination directory by MoveEntryFromRootDirectory(). - metadata_->AddEntry(ConvertResourceEntryToDriveEntryProto(*resource_entry), + metadata_->AddEntry(ConvertToResourceEntry(*resource_entry), base::Bind(&CopyOperation::MoveEntryFromRootDirectory, weak_ptr_factory_.GetWeakPtr(), dir_path, @@ -271,8 +270,8 @@ void CopyOperation::CopyAfterGetEntryInfoPair( return; } - scoped_ptr<DriveEntryProto> src_file_proto = result->first.proto.Pass(); - scoped_ptr<DriveEntryProto> dest_parent_proto = result->second.proto.Pass(); + scoped_ptr<ResourceEntry> src_file_proto = result->first.entry.Pass(); + scoped_ptr<ResourceEntry> dest_parent_proto = result->second.entry.Pass(); if (!dest_parent_proto->file_info().is_directory()) { callback.Run(FILE_ERROR_NOT_A_DIRECTORY); @@ -345,21 +344,21 @@ void CopyOperation::StartFileUploadAfterGetEntryInfo( const StartFileUploadParams& params, const std::string& content_type, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!params.callback.is_null()); - if (entry_proto.get() && !entry_proto->file_info().is_directory()) + if (entry.get() && !entry->file_info().is_directory()) error = FILE_ERROR_NOT_A_DIRECTORY; if (error != FILE_ERROR_OK) { params.callback.Run(error); return; } - DCHECK(entry_proto.get()); + DCHECK(entry.get()); job_scheduler_->UploadNewFile( - entry_proto->resource_id(), + entry->resource_id(), params.remote_file_path, params.local_file_path, params.remote_file_path.BaseName().value(), @@ -375,7 +374,7 @@ void CopyOperation::OnTransferCompleted( google_apis::GDataErrorCode error, const base::FilePath& drive_path, const base::FilePath& file_path, - scoped_ptr<ResourceEntry> resource_entry) { + scoped_ptr<google_apis::ResourceEntry> resource_entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -393,7 +392,7 @@ void CopyOperation::TransferFileFromLocalToRemoteAfterGetEntryInfo( const base::FilePath& remote_dest_file_path, const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -402,8 +401,8 @@ void CopyOperation::TransferFileFromLocalToRemoteAfterGetEntryInfo( return; } - DCHECK(entry_proto.get()); - if (!entry_proto->file_info().is_directory()) { + DCHECK(entry.get()); + if (!entry->file_info().is_directory()) { // The parent of |remote_dest_file_path| is not a directory. callback.Run(FILE_ERROR_NOT_A_DIRECTORY); return; diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.h b/chrome/browser/chromeos/drive/file_system/copy_operation.h index 4972e2c..04d3ea5 100644 --- a/chrome/browser/chromeos/drive/file_system/copy_operation.h +++ b/chrome/browser/chromeos/drive/file_system/copy_operation.h @@ -24,9 +24,9 @@ class ResourceEntry; namespace drive { -class DriveEntryProto; class FileSystemInterface; class JobScheduler; +class ResourceEntry; namespace file_system { @@ -163,7 +163,7 @@ class CopyOperation { const StartFileUploadParams& params, const std::string& content_type, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Helper function that completes bookkeeping tasks related to // completed file transfer. @@ -181,7 +181,7 @@ class CopyOperation { const base::FilePath& remote_dest_file_path, const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Initiates transfer of |local_file_path| with |resource_id| to // |remote_dest_file_path|. |local_file_path| must be a file from the local diff --git a/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc b/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc index 1b11269..ce915d9 100644 --- a/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc @@ -166,7 +166,7 @@ void CreateDirectoryOperation::AddNewDirectory( } metadata_->AddEntry( - ConvertResourceEntryToDriveEntryProto(*entry), + ConvertToResourceEntry(*entry), base::Bind(&CreateDirectoryOperation::ContinueCreateDirectory, weak_ptr_factory_.GetWeakPtr(), base::Passed(¶ms), @@ -251,7 +251,7 @@ void CreateDirectoryOperation::FindFirstMissingParentDirectoryInternal( void CreateDirectoryOperation::ContinueFindFirstMissingParentDirectory( scoped_ptr<FindFirstMissingParentDirectoryParams> params, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(params.get()); @@ -263,13 +263,13 @@ void CreateDirectoryOperation::ContinueFindFirstMissingParentDirectory( params->last_dir_resource_id); params->callback.Run(result); } else if (error != FILE_ERROR_OK || - !entry_proto->file_info().is_directory()) { + !entry->file_info().is_directory()) { // Unexpected error, or found a file when we were expecting a directory. result.Init(FIND_FIRST_FOUND_INVALID, base::FilePath(), ""); params->callback.Run(result); } else { // This parent exists, so recursively look at the next element. - params->last_dir_resource_id = entry_proto->resource_id(); + params->last_dir_resource_id = entry->resource_id(); params->index++; FindFirstMissingParentDirectoryInternal(params.Pass()); } diff --git a/chrome/browser/chromeos/drive/file_system/create_directory_operation.h b/chrome/browser/chromeos/drive/file_system/create_directory_operation.h index a125e76..5d536165 100644 --- a/chrome/browser/chromeos/drive/file_system/create_directory_operation.h +++ b/chrome/browser/chromeos/drive/file_system/create_directory_operation.h @@ -22,8 +22,8 @@ class ResourceEntry; namespace drive { -class DriveEntryProto; class JobScheduler; +class ResourceEntry; namespace internal { class ResourceMetadata; @@ -142,7 +142,7 @@ class CreateDirectoryOperation { void ContinueFindFirstMissingParentDirectory( scoped_ptr<FindFirstMissingParentDirectoryParams> params, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); JobScheduler* job_scheduler_; internal::ResourceMetadata* metadata_; diff --git a/chrome/browser/chromeos/drive/file_system/create_file_operation.cc b/chrome/browser/chromeos/drive/file_system/create_file_operation.cc index 17f147d..95f7b37 100644 --- a/chrome/browser/chromeos/drive/file_system/create_file_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/create_file_operation.cc @@ -66,7 +66,7 @@ void CreateFileOperation::CreateFileAfterGetEntryInfo( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); FileError error = pair_result->second.error; - scoped_ptr<DriveEntryProto> parent(pair_result->first.proto.Pass()); + scoped_ptr<ResourceEntry> parent(pair_result->first.entry.Pass()); // If parent path is not a directory, it is an error. if (!parent || !parent->file_info().is_directory()) { @@ -76,7 +76,7 @@ void CreateFileOperation::CreateFileAfterGetEntryInfo( // If an entry already exists at |path|: if (error == FILE_ERROR_OK) { - scoped_ptr<DriveEntryProto> entry(pair_result->second.proto.Pass()); + scoped_ptr<ResourceEntry> entry(pair_result->second.entry.Pass()); // Error if an exclusive mode is requested, or the entry is not a file. if (is_exclusive || entry->file_info().is_directory() || diff --git a/chrome/browser/chromeos/drive/file_system/create_file_operation.h b/chrome/browser/chromeos/drive/file_system/create_file_operation.h index 07164be..795f7ba 100644 --- a/chrome/browser/chromeos/drive/file_system/create_file_operation.h +++ b/chrome/browser/chromeos/drive/file_system/create_file_operation.h @@ -21,9 +21,9 @@ class ResourceEntry; namespace drive { -class DriveEntryProto; class FileSystemInterface; class JobScheduler; +class ResourceEntry; namespace file_system { diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.cc b/chrome/browser/chromeos/drive/file_system/move_operation.cc index de536fb..5959468 100644 --- a/chrome/browser/chromeos/drive/file_system/move_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/move_operation.cc @@ -61,19 +61,19 @@ void MoveOperation::MoveAfterGetEntryInfoPair( callback.Run(src_dest_info->second.error); return; } - if (!src_dest_info->second.proto->file_info().is_directory()) { + if (!src_dest_info->second.entry->file_info().is_directory()) { callback.Run(FILE_ERROR_NOT_A_DIRECTORY); return; } - const std::string& src_id = src_dest_info->first.proto->resource_id(); + const std::string& src_id = src_dest_info->first.entry->resource_id(); const base::FilePath& src_path = src_dest_info->first.path; const base::FilePath new_name = dest_file_path.BaseName(); const bool new_name_has_hosted_extension = - src_dest_info->first.proto->has_file_specific_info() && - src_dest_info->first.proto->file_specific_info().is_hosted_document() && + src_dest_info->first.entry->has_file_specific_info() && + src_dest_info->first.entry->file_specific_info().is_hosted_document() && new_name.Extension() == - src_dest_info->first.proto->file_specific_info().document_extension(); + src_dest_info->first.entry->file_specific_info().document_extension(); Rename(src_id, src_path, new_name, new_name_has_hosted_extension, base::Bind(&MoveOperation::MoveAfterRename, @@ -94,8 +94,8 @@ void MoveOperation::MoveAfterRename( return; } - const std::string& src_id = src_dest_info->first.proto->resource_id(); - const std::string& dest_dir_id = src_dest_info->second.proto->resource_id(); + const std::string& src_id = src_dest_info->first.entry->resource_id(); + const std::string& dest_dir_id = src_dest_info->second.entry->resource_id(); const base::FilePath& dest_dir_path = src_dest_info->second.path; // The source and the destination directory are the same. Nothing more to do. @@ -128,8 +128,8 @@ void MoveOperation::MoveAfterAddToDirectory( observer_->OnDirectoryChangedByOperation(src_path.DirName()); observer_->OnDirectoryChangedByOperation(new_path.DirName()); - RemoveFromDirectory(src_dest_info->first.proto->resource_id(), - src_dest_info->first.proto->parent_resource_id(), + RemoveFromDirectory(src_dest_info->first.entry->resource_id(), + src_dest_info->first.entry->parent_resource_id(), callback); } diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.h b/chrome/browser/chromeos/drive/file_system/move_operation.h index f4b0fb9..43a2e4a 100644 --- a/chrome/browser/chromeos/drive/file_system/move_operation.h +++ b/chrome/browser/chromeos/drive/file_system/move_operation.h @@ -19,9 +19,9 @@ class FilePath; namespace drive { -class DriveEntryProto; class FileCache; class JobScheduler; +class ResourceEntry; namespace internal { class ResourceMetadata; diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.cc b/chrome/browser/chromeos/drive/file_system/remove_operation.cc index 149d7aa..f50406e 100644 --- a/chrome/browser/chromeos/drive/file_system/remove_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.cc @@ -58,7 +58,7 @@ void RemoveOperation::Remove( void RemoveOperation::RemoveAfterGetEntryInfo( const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -66,14 +66,14 @@ void RemoveOperation::RemoveAfterGetEntryInfo( callback.Run(error); return; } - DCHECK(entry_proto.get()); + DCHECK(entry.get()); job_scheduler_->DeleteResource( - entry_proto->resource_id(), + entry->resource_id(), base::Bind(&RemoveOperation::RemoveResourceLocally, weak_ptr_factory_.GetWeakPtr(), callback, - entry_proto->resource_id())); + entry->resource_id())); } void RemoveOperation::RemoveResourceLocally( diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.h b/chrome/browser/chromeos/drive/file_system/remove_operation.h index b4a5ccf..bcaa82e 100644 --- a/chrome/browser/chromeos/drive/file_system/remove_operation.h +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.h @@ -22,10 +22,10 @@ namespace google_apis { namespace drive { -class DriveEntryProto; -class FileSystem; class FileCache; +class FileSystem; class JobScheduler; +class ResourceEntry; namespace file_system { @@ -55,7 +55,7 @@ class RemoveOperation { void RemoveAfterGetEntryInfo( const FileOperationCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Callback for DriveServiceInterface::DeleteResource. Removes the entry with // |resource_id| from the local snapshot of the filesystem and the cache. diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.cc b/chrome/browser/chromeos/drive/file_system/update_operation.cc index d6947b4..cbd82c5 100644 --- a/chrome/browser/chromeos/drive/file_system/update_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/update_operation.cc @@ -59,7 +59,7 @@ void UpdateOperation::UpdateFileByEntryInfo( const FileOperationCallback& callback, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -68,29 +68,29 @@ void UpdateOperation::UpdateFileByEntryInfo( return; } - DCHECK(entry_proto.get()); - if (entry_proto->file_info().is_directory()) { + DCHECK(entry.get()); + if (entry->file_info().is_directory()) { callback.Run(FILE_ERROR_NOT_FOUND); return; } // Extract a pointer before we call Pass() so we can use it below. - DriveEntryProto* entry_proto_ptr = entry_proto.get(); - cache_->GetFile(entry_proto_ptr->resource_id(), - entry_proto_ptr->file_specific_info().file_md5(), + ResourceEntry* entry_ptr = entry.get(); + cache_->GetFile(entry_ptr->resource_id(), + entry_ptr->file_specific_info().file_md5(), base::Bind(&UpdateOperation::OnGetFileCompleteForUpdateFile, weak_ptr_factory_.GetWeakPtr(), context, callback, drive_file_path, - base::Passed(&entry_proto))); + base::Passed(&entry))); } void UpdateOperation::OnGetFileCompleteForUpdateFile( DriveClientContext context, const FileOperationCallback& callback, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, FileError error, const base::FilePath& cache_file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -102,10 +102,10 @@ void UpdateOperation::OnGetFileCompleteForUpdateFile( } scheduler_->UploadExistingFile( - entry_proto->resource_id(), + entry->resource_id(), drive_file_path, cache_file_path, - entry_proto->file_specific_info().content_mime_type(), + entry->file_specific_info().content_mime_type(), "", // etag context, base::Bind(&UpdateOperation::OnUpdatedFileUploaded, @@ -129,7 +129,7 @@ void UpdateOperation::OnUpdatedFileUploaded( } metadata_->RefreshEntry( - ConvertResourceEntryToDriveEntryProto(*resource_entry), + ConvertToResourceEntry(*resource_entry), base::Bind(&UpdateOperation::OnUpdatedFileRefreshed, weak_ptr_factory_.GetWeakPtr(), callback)); } @@ -138,7 +138,7 @@ void UpdateOperation::OnUpdatedFileRefreshed( const FileOperationCallback& callback, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -147,16 +147,16 @@ void UpdateOperation::OnUpdatedFileRefreshed( return; } - DCHECK(entry_proto.get()); - DCHECK(entry_proto->has_resource_id()); - DCHECK(entry_proto->has_file_specific_info()); - DCHECK(entry_proto->file_specific_info().has_file_md5()); + DCHECK(entry.get()); + DCHECK(entry->has_resource_id()); + DCHECK(entry->has_file_specific_info()); + DCHECK(entry->file_specific_info().has_file_md5()); observer_->OnDirectoryChangedByOperation(drive_file_path.DirName()); // Clear the dirty bit if we have updated an existing file. - cache_->ClearDirty(entry_proto->resource_id(), - entry_proto->file_specific_info().file_md5(), + cache_->ClearDirty(entry->resource_id(), + entry->file_specific_info().file_md5(), callback); } diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.h b/chrome/browser/chromeos/drive/file_system/update_operation.h index 4e8f704..e6a68da 100644 --- a/chrome/browser/chromeos/drive/file_system/update_operation.h +++ b/chrome/browser/chromeos/drive/file_system/update_operation.h @@ -20,9 +20,9 @@ class FilePath; namespace drive { -class DriveEntryProto; class FileCache; class JobScheduler; +class ResourceEntry; namespace file_system { @@ -62,7 +62,7 @@ class UpdateOperation { const FileOperationCallback& callback, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Part of UpdateFileByResourceId(). // Called when FileCache::GetFileOnUIThread() is completed for @@ -72,7 +72,7 @@ class UpdateOperation { DriveClientContext context, const FileOperationCallback& callback, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, FileError error, const base::FilePath& cache_file_path); @@ -92,7 +92,7 @@ class UpdateOperation { void OnUpdatedFileRefreshed(const FileOperationCallback& callback, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); FileCache* cache_; internal::ResourceMetadata* metadata_; diff --git a/chrome/browser/chromeos/drive/file_system_interface.h b/chrome/browser/chromeos/drive/file_system_interface.h index a25b878..6803f4b 100644 --- a/chrome/browser/chromeos/drive/file_system_interface.h +++ b/chrome/browser/chromeos/drive/file_system_interface.h @@ -23,7 +23,7 @@ namespace drive { class FileSystemObserver; -typedef std::vector<DriveEntryProto> DriveEntryProtoVector; +typedef std::vector<ResourceEntry> ResourceEntryVector; // File type on the drive file system can be either a regular file or // a hosted document. @@ -37,28 +37,28 @@ enum DriveFileType { // browser. struct SearchResultInfo { SearchResultInfo(const base::FilePath& path, - const DriveEntryProto& entry_proto) + const ResourceEntry& entry) : path(path), - entry_proto(entry_proto) { + entry(entry) { } base::FilePath path; - DriveEntryProto entry_proto; + ResourceEntry entry; }; // Struct to represent a search result for SearchMetadata(). struct MetadataSearchResult { MetadataSearchResult(const base::FilePath& in_path, - const DriveEntryProto& in_entry_proto, + const ResourceEntry& in_entry, const std::string& in_highlighted_base_name) : path(in_path), - entry_proto(in_entry_proto), + entry(in_entry), highlighted_base_name(in_highlighted_base_name) { } // The two members are used to create FileEntry object. base::FilePath path; - DriveEntryProto entry_proto; + ResourceEntry entry; // The base name to be displayed in the UI. The parts matched the search // query are highlighted with <b> tag. Meta characters are escaped like < @@ -88,7 +88,7 @@ typedef base::Callback<void(FileError error, // download job can be cancelled. // |cancel_download_closure| must be called on the UI thread. typedef base::Callback<void(FileError error, - scoped_ptr<DriveEntryProto> entry_proto, + scoped_ptr<ResourceEntry> entry, const base::FilePath& local_file, const base::Closure& cancel_download_closure)> GetFileContentInitializedCallback; @@ -100,7 +100,7 @@ typedef base::Callback<void(FileError error, // |entries| are contents, both files and directories, of the directory. typedef base::Callback<void(FileError error, bool hide_hosted_documents, - scoped_ptr<DriveEntryProtoVector> entries)> + scoped_ptr<ResourceEntryVector> entries)> ReadDirectoryWithSettingCallback; // Used to get drive content search results. diff --git a/chrome/browser/chromeos/drive/file_system_proxy.cc b/chrome/browser/chromeos/drive/file_system_proxy.cc index 6b609cf..1ca7e88 100644 --- a/chrome/browser/chromeos/drive/file_system_proxy.cc +++ b/chrome/browser/chromeos/drive/file_system_proxy.cc @@ -152,13 +152,14 @@ void DidCloseFileForTruncate( } // namespace -base::FileUtilProxy::Entry DriveEntryProtoToFileUtilProxyEntry( - const DriveEntryProto& proto) { +base::FileUtilProxy::Entry ResourceEntryToFileUtilProxyEntry( + const ResourceEntry& resource_entry) { base::PlatformFileInfo file_info; - util::ConvertProtoToPlatformFileInfo(proto.file_info(), &file_info); + util::ConvertResourceEntryToPlatformFileInfo( + resource_entry.file_info(), &file_info); base::FileUtilProxy::Entry entry; - entry.name = proto.base_name(); + entry.name = resource_entry.base_name(); entry.is_directory = file_info.is_directory; entry.size = file_info.size; entry.last_modified_time = file_info.last_modified; @@ -656,10 +657,10 @@ void FileSystemProxy::OnGetEntryInfoByPath( const base::FilePath& entry_path, const FileSystemOperation::SnapshotFileCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (error != FILE_ERROR_OK || !entry_proto.get()) { + if (error != FILE_ERROR_OK || !entry.get()) { callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, base::PlatformFileInfo(), base::FilePath(), @@ -668,7 +669,7 @@ void FileSystemProxy::OnGetEntryInfoByPath( } base::PlatformFileInfo file_info; - util::ConvertProtoToPlatformFileInfo(entry_proto->file_info(), &file_info); + util::ConvertResourceEntryToPlatformFileInfo(entry->file_info(), &file_info); CallFileSystemMethodOnUIThread( base::Bind(&FileSystemInterface::GetFileByPath, @@ -750,7 +751,7 @@ void FileSystemProxy::OnGetMetadata( const base::FilePath& file_path, const FileSystemOperation::GetMetadataCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (error != FILE_ERROR_OK) { @@ -759,10 +760,10 @@ void FileSystemProxy::OnGetMetadata( base::FilePath()); return; } - DCHECK(entry_proto.get()); + DCHECK(entry.get()); base::PlatformFileInfo file_info; - util::ConvertProtoToPlatformFileInfo(entry_proto->file_info(), &file_info); + util::ConvertResourceEntryToPlatformFileInfo(entry->file_info(), &file_info); callback.Run(base::PLATFORM_FILE_OK, file_info, file_path); } @@ -772,7 +773,7 @@ void FileSystemProxy::OnReadDirectory( callback, FileError error, bool hide_hosted_documents, - scoped_ptr<DriveEntryProtoVector> proto_entries) { + scoped_ptr<ResourceEntryVector> resource_entries) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (error != FILE_ERROR_OK) { @@ -781,18 +782,18 @@ void FileSystemProxy::OnReadDirectory( false); return; } - DCHECK(proto_entries.get()); + DCHECK(resource_entries.get()); std::vector<base::FileUtilProxy::Entry> entries; // Convert Drive files to something File API stack can understand. - for (size_t i = 0; i < proto_entries->size(); ++i) { - const DriveEntryProto& proto = (*proto_entries)[i]; - if (proto.has_file_specific_info() && - proto.file_specific_info().is_hosted_document() && + for (size_t i = 0; i < resource_entries->size(); ++i) { + const ResourceEntry& resource_entry = (*resource_entries)[i]; + if (resource_entry.has_file_specific_info() && + resource_entry.file_specific_info().is_hosted_document() && hide_hosted_documents) { continue; } - entries.push_back(DriveEntryProtoToFileUtilProxyEntry(proto)); + entries.push_back(ResourceEntryToFileUtilProxyEntry(resource_entry)); } callback.Run(base::PLATFORM_FILE_OK, entries, false); diff --git a/chrome/browser/chromeos/drive/file_system_proxy.h b/chrome/browser/chromeos/drive/file_system_proxy.h index 96ac917..3669dd8 100644 --- a/chrome/browser/chromeos/drive/file_system_proxy.h +++ b/chrome/browser/chromeos/drive/file_system_proxy.h @@ -14,10 +14,10 @@ class FileSystemURL; namespace drive { -class DriveEntryProto; class FileSystemInterface; +class ResourceEntry; -typedef std::vector<DriveEntryProto> DriveEntryProtoVector; +typedef std::vector<ResourceEntry> ResourceEntryVector; // Implementation of File API's remote file system proxy for Drive file system. class FileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { @@ -120,7 +120,7 @@ class FileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { const fileapi::FileSystemOperation::GetMetadataCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Helper callback for relaying reply for GetEntryInfoByPath() to the // calling thread. @@ -129,7 +129,7 @@ class FileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { const fileapi::FileSystemOperation::SnapshotFileCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Helper callback for relaying reply for ReadDirectory() to the calling // thread. @@ -138,7 +138,7 @@ class FileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { callback, FileError error, bool hide_hosted_documents, - scoped_ptr<DriveEntryProtoVector> proto_entries); + scoped_ptr<ResourceEntryVector> resource_entries); // Helper callback for relaying reply for CreateWritableSnapshotFile() to // the calling thread. diff --git a/chrome/browser/chromeos/drive/file_system_unittest.cc b/chrome/browser/chromeos/drive/file_system_unittest.cc index c1bec5c..98acb26 100644 --- a/chrome/browser/chromeos/drive/file_system_unittest.cc +++ b/chrome/browser/chromeos/drive/file_system_unittest.cc @@ -67,7 +67,7 @@ void DriveSearchCallback( EXPECT_EQ(base::FilePath(expected_results[i].path), results->at(i).path); EXPECT_EQ(expected_results[i].is_directory, - results->at(i).entry_proto.file_info().is_directory()); + results->at(i).entry.file_info().is_directory()); } EXPECT_EQ(expected_next_feed, next_feed); @@ -76,7 +76,7 @@ void DriveSearchCallback( } // Counts the number of files (not directories) in |entries|. -int CountFiles(const DriveEntryProtoVector& entries) { +int CountFiles(const ResourceEntryVector& entries) { int num_files = 0; for (size_t i = 0; i < entries.size(); ++i) { if (!entries[i].file_info().is_directory()) @@ -89,7 +89,7 @@ int CountFiles(const DriveEntryProtoVector& entries) { // quits the current message loop. void AsyncInitializationCallback( int* counter, int expected_counter, MessageLoop* message_loop, - FileError error, scoped_ptr<DriveEntryProto> entry) { + FileError error, scoped_ptr<ResourceEntry> entry) { if (error != FILE_ERROR_OK || !entry) { // If we hit an error case, quit the message loop immediately. // Then the expectation in the test case can find it because the actual @@ -234,24 +234,24 @@ class DriveFileSystemTest : public testing::Test { } // Gets entry info by path synchronously. - scoped_ptr<DriveEntryProto> GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> GetEntryInfoByPathSync( const base::FilePath& file_path) { FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; file_system_->GetEntryInfoByPath( file_path, - google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); + google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); - return entry_proto.Pass(); + return entry.Pass(); } // Gets directory info by path synchronously. - scoped_ptr<DriveEntryProtoVector> ReadDirectoryByPathSync( + scoped_ptr<ResourceEntryVector> ReadDirectoryByPathSync( const base::FilePath& file_path) { FileError error = FILE_ERROR_FAILED; bool unused_hide_hosted_documents; - scoped_ptr<DriveEntryProtoVector> entries; + scoped_ptr<ResourceEntryVector> entries; file_system_->ReadDirectoryByPath( file_path, google_apis::test_util::CreateCopyResultCallback( @@ -268,10 +268,10 @@ class DriveFileSystemTest : public testing::Test { // Gets the resource ID of |file_path|. Returns an empty string if not found. std::string GetResourceIdByPath(const base::FilePath& file_path) { - scoped_ptr<DriveEntryProto> entry_proto = + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(file_path); - if (entry_proto) - return entry_proto->resource_id(); + if (entry) + return entry->resource_id(); else return ""; } @@ -345,7 +345,7 @@ class DriveFileSystemTest : public testing::Test { return false; // drive/root/File1 - DriveEntryProto file1; + ResourceEntry file1; file1.set_title("File1"); file1.set_resource_id("resource_id:File1"); file1.set_parent_resource_id(root_resource_id); @@ -360,7 +360,7 @@ class DriveFileSystemTest : public testing::Test { return false; // drive/root/Dir1 - DriveEntryProto dir1; + ResourceEntry dir1; dir1.set_title("Dir1"); dir1.set_resource_id("resource_id:Dir1"); dir1.set_parent_resource_id(root_resource_id); @@ -373,7 +373,7 @@ class DriveFileSystemTest : public testing::Test { return false; // drive/root/Dir1/File2 - DriveEntryProto file2; + ResourceEntry file2; file2.set_title("File2"); file2.set_resource_id("resource_id:File2"); file2.set_parent_resource_id(dir1.resource_id()); @@ -388,7 +388,7 @@ class DriveFileSystemTest : public testing::Test { return false; // drive/root/Dir1/SubDir2 - DriveEntryProto dir2; + ResourceEntry dir2; dir2.set_title("SubDir2"); dir2.set_resource_id("resource_id:SubDir2"); dir2.set_parent_resource_id(dir1.resource_id()); @@ -401,7 +401,7 @@ class DriveFileSystemTest : public testing::Test { return false; // drive/root/Dir1/SubDir2/File3 - DriveEntryProto file3; + ResourceEntry file3; file3.set_title("File3"); file3.set_resource_id("resource_id:File3"); file3.set_parent_resource_id(dir2.resource_id()); @@ -423,7 +423,7 @@ class DriveFileSystemTest : public testing::Test { // Verifies that |file_path| is a valid JSON file for the hosted document // associated with |entry| (i.e. |url| and |resource_id| match). - void VerifyHostedDocumentJSONFile(const DriveEntryProto& entry_proto, + void VerifyHostedDocumentJSONFile(const ResourceEntry& entry, const base::FilePath& file_path) { std::string error; JSONFileValueSerializer serializer(file_path); @@ -436,9 +436,9 @@ class DriveFileSystemTest : public testing::Test { EXPECT_TRUE(dict_value->GetString("url", &edit_url)); EXPECT_TRUE(dict_value->GetString("resource_id", &resource_id)); - EXPECT_EQ(entry_proto.file_specific_info().alternate_url(), + EXPECT_EQ(entry.file_specific_info().alternate_url(), edit_url); - EXPECT_EQ(entry_proto.resource_id(), resource_id); + EXPECT_EQ(entry.resource_id(), resource_id); } MessageLoopForUI message_loop_; @@ -481,7 +481,7 @@ TEST_F(DriveFileSystemTest, DuplicatedAsyncInitialization) { TEST_F(DriveFileSystemTest, GetGrandRootEntry) { const base::FilePath kFilePath(FILE_PATH_LITERAL("drive")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath); ASSERT_TRUE(entry); EXPECT_EQ(util::kDriveGrandRootSpecialResourceId, entry->resource_id()); @@ -492,7 +492,7 @@ TEST_F(DriveFileSystemTest, GetGrandRootEntry) { TEST_F(DriveFileSystemTest, GetOtherDirEntry) { const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/other")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath); ASSERT_TRUE(entry); EXPECT_EQ(util::kDriveOtherDirSpecialResourceId, entry->resource_id()); @@ -504,7 +504,7 @@ TEST_F(DriveFileSystemTest, GetOtherDirEntry) { TEST_F(DriveFileSystemTest, GetMyDriveRoot) { const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath); ASSERT_TRUE(entry); EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); @@ -520,7 +520,7 @@ TEST_F(DriveFileSystemTest, GetMyDriveRoot) { TEST_F(DriveFileSystemTest, GetExistingFile) { const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath); ASSERT_TRUE(entry); EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); @@ -531,7 +531,7 @@ TEST_F(DriveFileSystemTest, GetExistingFile) { TEST_F(DriveFileSystemTest, GetExistingDocument) { const base::FilePath kFilePath( FILE_PATH_LITERAL("drive/root/Document 1 excludeDir-test.gdoc")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath); ASSERT_TRUE(entry); EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); } @@ -539,14 +539,14 @@ TEST_F(DriveFileSystemTest, GetExistingDocument) { TEST_F(DriveFileSystemTest, GetNonExistingFile) { const base::FilePath kFilePath( FILE_PATH_LITERAL("drive/root/nonexisting.file")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath); EXPECT_FALSE(entry); } TEST_F(DriveFileSystemTest, GetEncodedFileNames) { const base::FilePath kFilePath1( FILE_PATH_LITERAL("drive/root/Slash / in file 1.txt")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath1); ASSERT_FALSE(entry); const base::FilePath kFilePath2 = base::FilePath::FromUTF8Unsafe( @@ -565,7 +565,7 @@ TEST_F(DriveFileSystemTest, GetEncodedFileNames) { TEST_F(DriveFileSystemTest, GetDuplicateNames) { const base::FilePath kFilePath1( FILE_PATH_LITERAL("drive/root/Duplicate Name.txt")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath1); ASSERT_TRUE(entry); const std::string resource_id1 = entry->resource_id(); @@ -587,7 +587,7 @@ TEST_F(DriveFileSystemTest, GetDuplicateNames) { TEST_F(DriveFileSystemTest, GetExistingDirectory) { const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root/Directory 1")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath); ASSERT_TRUE(entry); ASSERT_EQ("folder:1_folder_resource_id", entry->resource_id()); @@ -600,7 +600,7 @@ TEST_F(DriveFileSystemTest, GetInSubSubdir) { const base::FilePath kFilePath( FILE_PATH_LITERAL("drive/root/Directory 1/Sub Directory Folder/" "Sub Sub Directory Folder")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath); ASSERT_TRUE(entry); ASSERT_EQ("folder:sub_sub_directory_folder_id", entry->resource_id()); } @@ -608,7 +608,7 @@ TEST_F(DriveFileSystemTest, GetInSubSubdir) { TEST_F(DriveFileSystemTest, GetOrphanFile) { const base::FilePath kFilePath( FILE_PATH_LITERAL("drive/other/Orphan File 1.txt")); - scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync(kFilePath); ASSERT_TRUE(entry); EXPECT_EQ("file:1_orphanfile_resource_id", entry->resource_id()); } @@ -618,7 +618,7 @@ TEST_F(DriveFileSystemTest, ReadDirectoryByPath_Root) { Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); // ReadDirectoryByPath() should kick off the resource list loading. - scoped_ptr<DriveEntryProtoVector> entries( + scoped_ptr<ResourceEntryVector> entries( ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive"))); // The root directory should be read correctly. ASSERT_TRUE(entries); @@ -643,7 +643,7 @@ TEST_F(DriveFileSystemTest, ReadDirectoryByPath_Root) { TEST_F(DriveFileSystemTest, ReadDirectoryByPath_NonRootDirectory) { // ReadDirectoryByPath() should kick off the resource list loading. - scoped_ptr<DriveEntryProtoVector> entries( + scoped_ptr<ResourceEntryVector> entries( ReadDirectoryByPathSync( base::FilePath::FromUTF8Unsafe("drive/root/Directory 1"))); // The non root directory should also be read correctly. @@ -985,7 +985,7 @@ TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_RegularFile) { base::FilePath remote_src_file_path( FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> file = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> file = GetEntryInfoByPathSync( remote_src_file_path); const int64 file_size = file->file_info().size(); @@ -1040,10 +1040,10 @@ TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_HostedDocument) { EXPECT_EQ(FILE_ERROR_OK, error); - scoped_ptr<DriveEntryProto> entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> entry = GetEntryInfoByPathSync( remote_src_file_path); - ASSERT_TRUE(entry_proto); - VerifyHostedDocumentJSONFile(*entry_proto, local_dest_file_path); + ASSERT_TRUE(entry); + VerifyHostedDocumentJSONFile(*entry, local_dest_file_path); } TEST_F(DriveFileSystemTest, CopyNotExistingFile) { @@ -1074,12 +1074,12 @@ TEST_F(DriveFileSystemTest, CopyFileToNonExistingDirectory) { ASSERT_TRUE(LoadRootFeedDocument()); ASSERT_TRUE(EntryExists(src_file_path)); - scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_entry = GetEntryInfoByPathSync( src_file_path); - ASSERT_TRUE(src_entry_proto); + ASSERT_TRUE(src_entry); std::string src_file_path_resource_id = - src_entry_proto->resource_id(); - EXPECT_FALSE(src_entry_proto->edit_url().empty()); + src_entry->resource_id(); + EXPECT_FALSE(src_entry->edit_url().empty()); EXPECT_FALSE(EntryExists(dest_parent_path)); @@ -1109,17 +1109,17 @@ TEST_F(DriveFileSystemTest, CopyFileToInvalidPath) { ASSERT_TRUE(LoadRootFeedDocument()); ASSERT_TRUE(EntryExists(src_file_path)); - scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_entry = GetEntryInfoByPathSync( src_file_path); - ASSERT_TRUE(src_entry_proto); + ASSERT_TRUE(src_entry); std::string src_file_resource_id = - src_entry_proto->resource_id(); - EXPECT_FALSE(src_entry_proto->edit_url().empty()); + src_entry->resource_id(); + EXPECT_FALSE(src_entry->edit_url().empty()); ASSERT_TRUE(EntryExists(dest_parent_path)); - scoped_ptr<DriveEntryProto> dest_entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> dest_entry = GetEntryInfoByPathSync( dest_parent_path); - ASSERT_TRUE(dest_entry_proto); + ASSERT_TRUE(dest_entry); FileError error = FILE_ERROR_OK; file_system_->Copy( @@ -1147,11 +1147,11 @@ TEST_F(DriveFileSystemTest, RenameFile) { ASSERT_TRUE(LoadRootFeedDocument()); ASSERT_TRUE(EntryExists(src_file_path)); - scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_entry = GetEntryInfoByPathSync( src_file_path); - ASSERT_TRUE(src_entry_proto); + ASSERT_TRUE(src_entry); std::string src_file_resource_id = - src_entry_proto->resource_id(); + src_entry->resource_id(); EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) @@ -1179,15 +1179,15 @@ TEST_F(DriveFileSystemTest, MoveFileFromRootToSubDirectory) { ASSERT_TRUE(LoadRootFeedDocument()); ASSERT_TRUE(EntryExists(src_file_path)); - scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_entry = GetEntryInfoByPathSync( src_file_path); - ASSERT_TRUE(src_entry_proto); + ASSERT_TRUE(src_entry); std::string src_file_resource_id = - src_entry_proto->resource_id(); - EXPECT_FALSE(src_entry_proto->edit_url().empty()); + src_entry->resource_id(); + EXPECT_FALSE(src_entry->edit_url().empty()); ASSERT_TRUE(EntryExists(dest_parent_path)); - scoped_ptr<DriveEntryProto> dest_parent_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> dest_parent_proto = GetEntryInfoByPathSync( dest_parent_path); ASSERT_TRUE(dest_parent_proto); ASSERT_TRUE(dest_parent_proto->file_info().is_directory()); @@ -1222,15 +1222,15 @@ TEST_F(DriveFileSystemTest, MoveFileFromSubDirectoryToRoot) { ASSERT_TRUE(LoadRootFeedDocument()); ASSERT_TRUE(EntryExists(src_file_path)); - scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_entry = GetEntryInfoByPathSync( src_file_path); - ASSERT_TRUE(src_entry_proto); + ASSERT_TRUE(src_entry); std::string src_file_resource_id = - src_entry_proto->resource_id(); - EXPECT_FALSE(src_entry_proto->edit_url().empty()); + src_entry->resource_id(); + EXPECT_FALSE(src_entry->edit_url().empty()); ASSERT_TRUE(EntryExists(src_parent_path)); - scoped_ptr<DriveEntryProto> src_parent_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_parent_proto = GetEntryInfoByPathSync( src_parent_path); ASSERT_TRUE(src_parent_proto); ASSERT_TRUE(src_parent_proto->file_info().is_directory()); @@ -1273,22 +1273,22 @@ TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) { EXPECT_EQ(FILE_ERROR_OK, AddDirectory(dest_parent_path)); ASSERT_TRUE(EntryExists(src_file_path)); - scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_entry = GetEntryInfoByPathSync( src_file_path); - ASSERT_TRUE(src_entry_proto); + ASSERT_TRUE(src_entry); std::string src_file_resource_id = - src_entry_proto->resource_id(); - EXPECT_FALSE(src_entry_proto->edit_url().empty()); + src_entry->resource_id(); + EXPECT_FALSE(src_entry->edit_url().empty()); ASSERT_TRUE(EntryExists(src_parent_path)); - scoped_ptr<DriveEntryProto> src_parent_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_parent_proto = GetEntryInfoByPathSync( src_parent_path); ASSERT_TRUE(src_parent_proto); ASSERT_TRUE(src_parent_proto->file_info().is_directory()); EXPECT_FALSE(src_parent_proto->download_url().empty()); ASSERT_TRUE(EntryExists(dest_parent_path)); - scoped_ptr<DriveEntryProto> dest_parent_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> dest_parent_proto = GetEntryInfoByPathSync( dest_parent_path); ASSERT_TRUE(dest_parent_proto); ASSERT_TRUE(dest_parent_proto->file_info().is_directory()); @@ -1348,12 +1348,12 @@ TEST_F(DriveFileSystemTest, MoveFileToNonExistingDirectory) { ASSERT_TRUE(LoadRootFeedDocument()); ASSERT_TRUE(EntryExists(src_file_path)); - scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_entry = GetEntryInfoByPathSync( src_file_path); - ASSERT_TRUE(src_entry_proto); + ASSERT_TRUE(src_entry); std::string src_file_resource_id = - src_entry_proto->resource_id(); - EXPECT_FALSE(src_entry_proto->edit_url().empty()); + src_entry->resource_id(); + EXPECT_FALSE(src_entry->edit_url().empty()); EXPECT_FALSE(EntryExists(dest_parent_path)); @@ -1381,15 +1381,15 @@ TEST_F(DriveFileSystemTest, MoveFileToInvalidPath) { ASSERT_TRUE(LoadRootFeedDocument()); ASSERT_TRUE(EntryExists(src_file_path)); - scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> src_entry = GetEntryInfoByPathSync( src_file_path); - ASSERT_TRUE(src_entry_proto); + ASSERT_TRUE(src_entry); std::string src_file_resource_id = - src_entry_proto->resource_id(); - EXPECT_FALSE(src_entry_proto->edit_url().empty()); + src_entry->resource_id(); + EXPECT_FALSE(src_entry->edit_url().empty()); ASSERT_TRUE(EntryExists(dest_parent_path)); - scoped_ptr<DriveEntryProto> dest_parent_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> dest_parent_proto = GetEntryInfoByPathSync( dest_parent_path); ASSERT_TRUE(dest_parent_proto); @@ -1417,18 +1417,18 @@ TEST_F(DriveFileSystemTest, RemoveEntries) { FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); ASSERT_TRUE(EntryExists(file_in_root)); - scoped_ptr<DriveEntryProto> file_in_root_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> file_in_root_proto = GetEntryInfoByPathSync( file_in_root); ASSERT_TRUE(file_in_root_proto); ASSERT_TRUE(EntryExists(dir_in_root)); - scoped_ptr<DriveEntryProto> dir_in_root_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> dir_in_root_proto = GetEntryInfoByPathSync( dir_in_root); ASSERT_TRUE(dir_in_root_proto); ASSERT_TRUE(dir_in_root_proto->file_info().is_directory()); ASSERT_TRUE(EntryExists(file_in_subdir)); - scoped_ptr<DriveEntryProto> file_in_subdir_proto = GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> file_in_subdir_proto = GetEntryInfoByPathSync( file_in_subdir); ASSERT_TRUE(file_in_subdir_proto); @@ -1509,7 +1509,7 @@ TEST_F(DriveFileSystemTest, PinAndUnpin) { base::FilePath file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); // Get the file info. - scoped_ptr<DriveEntryProto> entry(GetEntryInfoByPathSync(file_path)); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(file_path)); ASSERT_TRUE(entry); // Pin the file. @@ -1542,8 +1542,8 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); - const int64 file_size = entry_proto->file_info().size(); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(file_in_root)); + const int64 file_size = entry->file_info().size(); // Pretend we have enough space. fake_free_disk_space_getter_->set_fake_free_disk_space( @@ -1566,7 +1566,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { ASSERT_TRUE(LoadRootFeedDocument()); base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(file_in_root)); // Pretend we have no space at all. fake_free_disk_space_getter_->set_fake_free_disk_space(0); @@ -1592,8 +1592,8 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); - const int64 file_size = entry_proto->file_info().size(); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(file_in_root)); + const int64 file_size = entry->file_info().size(); // Pretend we have no space first (checked before downloading a file), // but then start reporting we have space. This is to emulate that @@ -1641,8 +1641,8 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpaceButBecomeFull) { ASSERT_TRUE(LoadRootFeedDocument()); base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); - const int64 file_size = entry_proto->file_info().size(); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(file_in_root)); + const int64 file_size = entry->file_info().size(); // Pretend we have enough space first (checked before downloading a file), // but then start reporting we have not enough space. This is to emulate that @@ -1671,12 +1671,12 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { ASSERT_TRUE(LoadRootFeedDocument()); base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(file_in_root)); // Store something as cached version of this file. FileError error = FILE_ERROR_OK; - cache_->Store(entry_proto->resource_id(), - entry_proto->file_specific_info().file_md5(), + cache_->Store(entry->resource_id(), + entry->file_specific_info().file_md5(), google_apis::test_util::GetTestFilePath( "chromeos/gdata/root_feed.json"), FileCache::FILE_OPERATION_COPY, @@ -1701,9 +1701,9 @@ TEST_F(DriveFileSystemTest, GetFileByPath_HostedDocument) { base::FilePath file_in_root(FILE_PATH_LITERAL( "drive/root/Document 1 excludeDir-test.gdoc")); - scoped_ptr<DriveEntryProto> src_entry_proto = + scoped_ptr<ResourceEntry> src_entry = GetEntryInfoByPathSync(file_in_root); - ASSERT_TRUE(src_entry_proto); + ASSERT_TRUE(src_entry); FileError error = FILE_ERROR_FAILED; base::FilePath file_path; @@ -1717,8 +1717,8 @@ TEST_F(DriveFileSystemTest, GetFileByPath_HostedDocument) { EXPECT_EQ(HOSTED_DOCUMENT, file_type); EXPECT_FALSE(file_path.empty()); - ASSERT_TRUE(src_entry_proto); - VerifyHostedDocumentJSONFile(*src_entry_proto, file_path); + ASSERT_TRUE(src_entry); + VerifyHostedDocumentJSONFile(*src_entry, file_path); } TEST_F(DriveFileSystemTest, GetFileByResourceId) { @@ -1732,14 +1732,14 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId) { ASSERT_TRUE(LoadRootFeedDocument()); base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(file_in_root)); FileError error = FILE_ERROR_OK; base::FilePath file_path; std::string mime_type; DriveFileType file_type; file_system_->GetFileByResourceId( - entry_proto->resource_id(), + entry->resource_id(), DriveClientContext(USER_INITIATED), google_apis::test_util::CreateCopyResultCallback( &error, &file_path, &mime_type, &file_type), @@ -1764,7 +1764,7 @@ TEST_F(DriveFileSystemTest, GetFileContentByPath) { { FileError initialized_error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; base::FilePath local_path; base::Closure cancel_download; @@ -1775,7 +1775,7 @@ TEST_F(DriveFileSystemTest, GetFileContentByPath) { file_system_->GetFileContentByPath( file_in_root, google_apis::test_util::CreateCopyResultCallback( - &initialized_error, &entry_proto, &local_path, &cancel_download), + &initialized_error, &entry, &local_path, &cancel_download), base::Bind(&AppendContent, &content_buffer), google_apis::test_util::CreateCopyResultCallback(&completion_error)); google_apis::test_util::RunBlockingPoolTask(); @@ -1783,7 +1783,7 @@ TEST_F(DriveFileSystemTest, GetFileContentByPath) { // For the first time, file is downloaded from the remote server. // In this case, |local_path| is empty while |cancel_download| is not. EXPECT_EQ(FILE_ERROR_OK, initialized_error); - ASSERT_TRUE(entry_proto); + ASSERT_TRUE(entry); ASSERT_TRUE(local_path.empty()); EXPECT_TRUE(!cancel_download.is_null()); // Content is available through the second callback arguemnt. @@ -1791,14 +1791,14 @@ TEST_F(DriveFileSystemTest, GetFileContentByPath) { for (size_t i = 0; i < content_buffer.size(); ++i) { content_size += content_buffer[i].size(); } - EXPECT_EQ(static_cast<size_t>(entry_proto->file_info().size()), + EXPECT_EQ(static_cast<size_t>(entry->file_info().size()), content_size); EXPECT_EQ(FILE_ERROR_OK, completion_error); } { FileError initialized_error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; base::FilePath local_path; base::Closure cancel_download; @@ -1809,7 +1809,7 @@ TEST_F(DriveFileSystemTest, GetFileContentByPath) { file_system_->GetFileContentByPath( file_in_root, google_apis::test_util::CreateCopyResultCallback( - &initialized_error, &entry_proto, &local_path, &cancel_download), + &initialized_error, &entry, &local_path, &cancel_download), base::Bind(&AppendContent, &content_buffer), google_apis::test_util::CreateCopyResultCallback(&completion_error)); google_apis::test_util::RunBlockingPoolTask(); @@ -1817,14 +1817,14 @@ TEST_F(DriveFileSystemTest, GetFileContentByPath) { // Try second download. In this case, the file should be cached, so // |local_path| should not be empty while |cancel_download| is empty. EXPECT_EQ(FILE_ERROR_OK, initialized_error); - ASSERT_TRUE(entry_proto); + ASSERT_TRUE(entry); ASSERT_TRUE(!local_path.empty()); EXPECT_TRUE(cancel_download.is_null()); // The content is available from the cache file. EXPECT_TRUE(content_buffer.empty()); int64 local_file_size = 0; file_util::GetFileSize(local_path, &local_file_size); - EXPECT_EQ(entry_proto->file_info().size(), local_file_size); + EXPECT_EQ(entry->file_info().size(), local_file_size); EXPECT_EQ(FILE_ERROR_OK, completion_error); } } @@ -1835,12 +1835,12 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId_FromCache) { ASSERT_TRUE(LoadRootFeedDocument()); base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(file_in_root)); // Store something as cached version of this file. FileError error = FILE_ERROR_FAILED; - cache_->Store(entry_proto->resource_id(), - entry_proto->file_specific_info().file_md5(), + cache_->Store(entry->resource_id(), + entry->file_specific_info().file_md5(), google_apis::test_util::GetTestFilePath( "chromeos/gdata/root_feed.json"), FileCache::FILE_OPERATION_COPY, @@ -1856,7 +1856,7 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId_FromCache) { std::string mime_type; DriveFileType file_type; file_system_->GetFileByResourceId( - entry_proto->resource_id(), + entry->resource_id(), DriveClientContext(USER_INITIATED), google_apis::test_util::CreateCopyResultCallback( &error, &file_path, &mime_type, &file_type), @@ -1916,7 +1916,7 @@ TEST_F(DriveFileSystemTest, UpdateFileByResourceId_PersistentFile) { // Check the number of files in the root directory. We'll compare the // number after updating a file. - scoped_ptr<DriveEntryProtoVector> root_directory_entries( + scoped_ptr<ResourceEntryVector> root_directory_entries( ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive/root"))); ASSERT_TRUE(root_directory_entries); const int num_files_in_root = CountFiles(*root_directory_entries); @@ -2069,11 +2069,11 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); const base::FilePath kFileInRoot(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(kFileInRoot)); - const int64 file_size = entry_proto->file_info().size(); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(kFileInRoot)); + const int64 file_size = entry->file_info().size(); const std::string& file_resource_id = - entry_proto->resource_id(); - const std::string& file_md5 = entry_proto->file_specific_info().file_md5(); + entry->resource_id(); + const std::string& file_md5 = entry->file_specific_info().file_md5(); // A dirty file is created on close. EXPECT_CALL(*mock_cache_observer_, OnCacheCommitted(file_resource_id)) @@ -2183,7 +2183,7 @@ TEST_F(DriveFileSystemTest, MarkCacheFileAsMountedAndUnmounted) { ASSERT_TRUE(LoadRootFeedDocument()); base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); - scoped_ptr<DriveEntryProto> entry(GetEntryInfoByPathSync(file_in_root)); + scoped_ptr<ResourceEntry> entry(GetEntryInfoByPathSync(file_in_root)); ASSERT_TRUE(entry); // Write to cache. diff --git a/chrome/browser/chromeos/drive/file_system_util.cc b/chrome/browser/chromeos/drive/file_system_util.cc index 921ac5a..ab85e4b 100644 --- a/chrome/browser/chromeos/drive/file_system_util.cc +++ b/chrome/browser/chromeos/drive/file_system_util.cc @@ -93,8 +93,8 @@ bool IsSpecialResourceId(const std::string& resource_id) { resource_id == kDriveOtherDirSpecialResourceId; } -DriveEntryProto CreateMyDriveRootEntry(const std::string& root_resource_id) { - DriveEntryProto mydrive_root; +ResourceEntry CreateMyDriveRootEntry(const std::string& root_resource_id) { + ResourceEntry mydrive_root; mydrive_root.mutable_file_info()->set_is_directory(true); mydrive_root.set_resource_id(root_resource_id); mydrive_root.set_parent_resource_id(util::kDriveGrandRootSpecialResourceId); @@ -102,8 +102,8 @@ DriveEntryProto CreateMyDriveRootEntry(const std::string& root_resource_id) { return mydrive_root; } -DriveEntryProto CreateOtherDirEntry() { - DriveEntryProto other_dir; +ResourceEntry CreateOtherDirEntry() { + ResourceEntry other_dir; other_dir.mutable_file_info()->set_is_directory(true); other_dir.set_resource_id(util::kDriveOtherDirSpecialResourceId); other_dir.set_parent_resource_id(util::kDriveGrandRootSpecialResourceId); @@ -349,27 +349,29 @@ FileError GDataToFileError(google_apis::GDataErrorCode status) { } } -void ConvertProtoToPlatformFileInfo(const PlatformFileInfoProto& proto, - base::PlatformFileInfo* file_info) { - file_info->size = proto.size(); - file_info->is_directory = proto.is_directory(); - file_info->is_symbolic_link = proto.is_symbolic_link(); +void ConvertResourceEntryToPlatformFileInfo( + const PlatformFileInfoProto& entry, + base::PlatformFileInfo* file_info) { + file_info->size = entry.size(); + file_info->is_directory = entry.is_directory(); + file_info->is_symbolic_link = entry.is_symbolic_link(); file_info->last_modified = base::Time::FromInternalValue( - proto.last_modified()); + entry.last_modified()); file_info->last_accessed = base::Time::FromInternalValue( - proto.last_accessed()); + entry.last_accessed()); file_info->creation_time = base::Time::FromInternalValue( - proto.creation_time()); + entry.creation_time()); } -void ConvertPlatformFileInfoToProto(const base::PlatformFileInfo& file_info, - PlatformFileInfoProto* proto) { - proto->set_size(file_info.size); - proto->set_is_directory(file_info.is_directory); - proto->set_is_symbolic_link(file_info.is_symbolic_link); - proto->set_last_modified(file_info.last_modified.ToInternalValue()); - proto->set_last_accessed(file_info.last_accessed.ToInternalValue()); - proto->set_creation_time(file_info.creation_time.ToInternalValue()); +void ConvertPlatformFileInfoToResourceEntry( + const base::PlatformFileInfo& file_info, + PlatformFileInfoProto* entry) { + entry->set_size(file_info.size); + entry->set_is_directory(file_info.is_directory); + entry->set_is_symbolic_link(file_info.is_symbolic_link); + entry->set_last_modified(file_info.last_modified.ToInternalValue()); + entry->set_last_accessed(file_info.last_accessed.ToInternalValue()); + entry->set_creation_time(file_info.creation_time.ToInternalValue()); } void EmptyFileOperationCallback(FileError error) { diff --git a/chrome/browser/chromeos/drive/file_system_util.h b/chrome/browser/chromeos/drive/file_system_util.h index d4f4719..d2a3f85 100644 --- a/chrome/browser/chromeos/drive/file_system_util.h +++ b/chrome/browser/chromeos/drive/file_system_util.h @@ -90,11 +90,11 @@ const base::FilePath& GetDriveMountPointPath(); // implementation and is not supposed to be sent to the server. bool IsSpecialResourceId(const std::string& resource_id); -// Returns a DriveEntryProto for "/drive/root" directory. -DriveEntryProto CreateMyDriveRootEntry(const std::string& root_resource_id); +// Returns a ResourceEntry for "/drive/root" directory. +ResourceEntry CreateMyDriveRootEntry(const std::string& root_resource_id); -// Returns a DriveEntryProto for "/drive/other" directory. -DriveEntryProto CreateOtherDirEntry(); +// Returns a ResourceEntry for "/drive/other" directory. +ResourceEntry CreateOtherDirEntry(); // Returns the Drive mount path as string. const std::string& GetDriveMountPointPathAsString(); @@ -196,13 +196,15 @@ void EnsureDirectoryExists(Profile* profile, // Converts GData error code into file platform error code. FileError GDataToFileError(google_apis::GDataErrorCode status); -// Converts the proto representation to the platform file. -void ConvertProtoToPlatformFileInfo(const PlatformFileInfoProto& proto, - base::PlatformFileInfo* file_info); +// Converts the resource entry to the platform file. +void ConvertResourceEntryToPlatformFileInfo( + const PlatformFileInfoProto& entry, + base::PlatformFileInfo* file_info); -// Converts the platform file info to the proto representation. -void ConvertPlatformFileInfoToProto(const base::PlatformFileInfo& file_info, - PlatformFileInfoProto* proto); +// Converts the platform file info to the resource entry. +void ConvertPlatformFileInfoToResourceEntry( + const base::PlatformFileInfo& file_info, + PlatformFileInfoProto* entry); // Does nothing with |error|. Used with functions taking FileOperationCallback. void EmptyFileOperationCallback(FileError error); diff --git a/chrome/browser/chromeos/drive/file_task_executor.cc b/chrome/browser/chromeos/drive/file_task_executor.cc index ced3ecc..0dd8b26 100644 --- a/chrome/browser/chromeos/drive/file_task_executor.cc +++ b/chrome/browser/chromeos/drive/file_task_executor.cc @@ -76,7 +76,7 @@ bool FileTaskExecutor::ExecuteAndNotify( void FileTaskExecutor::OnFileEntryFetched( FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { // If we aborted, then this will be zero. if (!current_index_) return; @@ -85,7 +85,7 @@ void FileTaskExecutor::OnFileEntryFetched( DriveSystemServiceFactory::GetForProfile(profile()); // Here, we are only interested in files. - if (entry_proto.get() && !entry_proto->has_file_specific_info()) + if (entry.get() && !entry->has_file_specific_info()) error = FILE_ERROR_NOT_FOUND; if (!system_service || error != FILE_ERROR_OK) { @@ -95,7 +95,7 @@ void FileTaskExecutor::OnFileEntryFetched( // The edit URL can be empty for non-editable files (such as files shared with // read-only privilege). - if (entry_proto->edit_url().empty()) { + if (entry->edit_url().empty()) { Done(false); return; } @@ -107,11 +107,11 @@ void FileTaskExecutor::OnFileEntryFetched( // current document entry for this document so we can get the // open-with-<app_id> urls from the document entry. drive_service->AuthorizeApp( - entry_proto->resource_id(), + entry->resource_id(), extension_id(), // really app_id base::Bind(&FileTaskExecutor::OnAppAuthorized, this, - entry_proto->resource_id())); + entry->resource_id())); } void FileTaskExecutor::OnAppAuthorized( diff --git a/chrome/browser/chromeos/drive/file_task_executor.h b/chrome/browser/chromeos/drive/file_task_executor.h index ee05a72..d1700ef9 100644 --- a/chrome/browser/chromeos/drive/file_task_executor.h +++ b/chrome/browser/chromeos/drive/file_task_executor.h @@ -14,7 +14,7 @@ namespace drive { -class DriveEntryProto; +class ResourceEntry; // This class implements an "executor" class that will execute tasks for // third party Drive apps that store data in Drive itself. To do that, it @@ -38,7 +38,7 @@ class FileTaskExecutor : public file_handler_util::FileTaskExecutor { virtual ~FileTaskExecutor(); void OnFileEntryFetched(FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); void OnAppAuthorized(const std::string& resource_id, google_apis::GDataErrorCode error, const GURL& open_link); diff --git a/chrome/browser/chromeos/drive/resource_entry_conversion.cc b/chrome/browser/chromeos/drive/resource_entry_conversion.cc index 0e19fe7..0cb0e74 100644 --- a/chrome/browser/chromeos/drive/resource_entry_conversion.cc +++ b/chrome/browser/chromeos/drive/resource_entry_conversion.cc @@ -33,24 +33,24 @@ bool HasSharedWithMeLabel(const google_apis::ResourceEntry& entry) { } // namespace -DriveEntryProto ConvertResourceEntryToDriveEntryProto( - const google_apis::ResourceEntry& entry) { - DriveEntryProto entry_proto; +ResourceEntry ConvertToResourceEntry( + const google_apis::ResourceEntry& input) { + ResourceEntry output; // For regular files, the 'filename' and 'title' attribute in the metadata // may be different (e.g. due to rename). To be consistent with the web // interface and other client to use the 'title' attribute, instead of // 'filename', as the file name in the local snapshot. - entry_proto.set_title(entry.title()); - entry_proto.set_base_name(util::EscapeUtf8FileName(entry_proto.title())); + output.set_title(input.title()); + output.set_base_name(util::EscapeUtf8FileName(output.title())); - entry_proto.set_resource_id(entry.resource_id()); - entry_proto.set_download_url(entry.download_url().spec()); + output.set_resource_id(input.resource_id()); + output.set_download_url(input.download_url().spec()); const google_apis::Link* edit_link = - entry.GetLinkByType(google_apis::Link::LINK_EDIT); + input.GetLinkByType(google_apis::Link::LINK_EDIT); if (edit_link) - entry_proto.set_edit_url(edit_link->href().spec()); + output.set_edit_url(edit_link->href().spec()); // Sets parent Resource ID. On drive.google.com, a file can have multiple // parents or no parent, but we are forcing a tree-shaped structure (i.e. no @@ -58,75 +58,75 @@ DriveEntryProto ConvertResourceEntryToDriveEntryProto( // used for the entry and if the entry has no parent, we assign a special ID // which represents no-parent entries. Tracked in http://crbug.com/158904. const google_apis::Link* parent_link = - entry.GetLinkByType(google_apis::Link::LINK_PARENT); + input.GetLinkByType(google_apis::Link::LINK_PARENT); if (parent_link) { - entry_proto.set_parent_resource_id( + output.set_parent_resource_id( util::ExtractResourceIdFromUrl(parent_link->href())); } // Apply mapping from an empty parent to the special dummy directory. - if (entry_proto.parent_resource_id().empty()) - entry_proto.set_parent_resource_id(util::kDriveOtherDirSpecialResourceId); + if (output.parent_resource_id().empty()) + output.set_parent_resource_id(util::kDriveOtherDirSpecialResourceId); - entry_proto.set_deleted(entry.deleted()); - entry_proto.set_shared_with_me(HasSharedWithMeLabel(entry)); + output.set_deleted(input.deleted()); + output.set_shared_with_me(HasSharedWithMeLabel(input)); - PlatformFileInfoProto* file_info = entry_proto.mutable_file_info(); + PlatformFileInfoProto* file_info = output.mutable_file_info(); - file_info->set_last_modified(entry.updated_time().ToInternalValue()); + file_info->set_last_modified(input.updated_time().ToInternalValue()); // If the file has never been viewed (last_viewed_time().is_null() == true), // then we will set the last_accessed field in the protocol buffer to 0. - file_info->set_last_accessed(entry.last_viewed_time().ToInternalValue()); - file_info->set_creation_time(entry.published_time().ToInternalValue()); + file_info->set_last_accessed(input.last_viewed_time().ToInternalValue()); + file_info->set_creation_time(input.published_time().ToInternalValue()); - if (entry.is_file() || entry.is_hosted_document()) { + if (input.is_file() || input.is_hosted_document()) { DriveFileSpecificInfo* file_specific_info = - entry_proto.mutable_file_specific_info(); - if (entry.is_file()) { - file_info->set_size(entry.file_size()); - file_specific_info->set_file_md5(entry.file_md5()); + output.mutable_file_specific_info(); + if (input.is_file()) { + file_info->set_size(input.file_size()); + file_specific_info->set_file_md5(input.file_md5()); // The resumable-edit-media link should only be present for regular // files as hosted documents are not uploadable. - } else if (entry.is_hosted_document()) { + } else if (input.is_hosted_document()) { // Attach .g<something> extension to hosted documents so we can special // case their handling in UI. - // TODO(satorux): Figure out better way how to pass entry info like kind + // TODO(satorux): Figure out better way how to pass input info like kind // to UI through the File API stack. - const std::string document_extension = entry.GetHostedDocumentExtension(); + const std::string document_extension = input.GetHostedDocumentExtension(); file_specific_info->set_document_extension(document_extension); - entry_proto.set_base_name( - util::EscapeUtf8FileName(entry_proto.title() + document_extension)); + output.set_base_name( + util::EscapeUtf8FileName(output.title() + document_extension)); // We don't know the size of hosted docs and it does not matter since // is has no effect on the quota. file_info->set_size(0); } file_info->set_is_directory(false); - file_specific_info->set_content_mime_type(entry.content_mime_type()); - file_specific_info->set_is_hosted_document(entry.is_hosted_document()); + file_specific_info->set_content_mime_type(input.content_mime_type()); + file_specific_info->set_is_hosted_document(input.is_hosted_document()); - const google_apis::Link* thumbnail_link = entry.GetLinkByType( + const google_apis::Link* thumbnail_link = input.GetLinkByType( google_apis::Link::LINK_THUMBNAIL); if (thumbnail_link) file_specific_info->set_thumbnail_url(thumbnail_link->href().spec()); - const google_apis::Link* alternate_link = entry.GetLinkByType( + const google_apis::Link* alternate_link = input.GetLinkByType( google_apis::Link::LINK_ALTERNATE); if (alternate_link) file_specific_info->set_alternate_url(alternate_link->href().spec()); - const google_apis::Link* share_link = entry.GetLinkByType( + const google_apis::Link* share_link = input.GetLinkByType( google_apis::Link::LINK_SHARE); if (share_link) file_specific_info->set_share_url(share_link->href().spec()); - } else if (entry.is_folder()) { + } else if (input.is_folder()) { file_info->set_is_directory(true); } else { // Some resource entries don't map into files (i.e. sites). - return DriveEntryProto(); + return ResourceEntry(); } - return entry_proto; + return output; } } // namespace drive diff --git a/chrome/browser/chromeos/drive/resource_entry_conversion.h b/chrome/browser/chromeos/drive/resource_entry_conversion.h index eb51f22..a0f9234 100644 --- a/chrome/browser/chromeos/drive/resource_entry_conversion.h +++ b/chrome/browser/chromeos/drive/resource_entry_conversion.h @@ -11,10 +11,10 @@ class ResourceEntry; namespace drive { -class DriveEntryProto; +class ResourceEntry; -// Converts a google_apis::ResourceEntry into a DriveEntryProto. -DriveEntryProto ConvertResourceEntryToDriveEntryProto( +// Converts a google_apis::ResourceEntry into a drive::ResourceEntry. +ResourceEntry ConvertToResourceEntry( const google_apis::ResourceEntry& resource_entry); } // namespace drive diff --git a/chrome/browser/chromeos/drive/resource_entry_conversion_unittest.cc b/chrome/browser/chromeos/drive/resource_entry_conversion_unittest.cc index c7e391e..62b44ce 100644 --- a/chrome/browser/chromeos/drive/resource_entry_conversion_unittest.cc +++ b/chrome/browser/chromeos/drive/resource_entry_conversion_unittest.cc @@ -15,29 +15,29 @@ namespace drive { -TEST(ResourceEntryConversionTest, ConvertResourceEntryToDriveEntryProto_File) { +TEST(ResourceEntryConversionTest, ConvertToResourceEntry_File) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile("chromeos/gdata/file_entry.json"); ASSERT_TRUE(value.get()); - scoped_ptr<google_apis::ResourceEntry> resource_entry( + scoped_ptr<google_apis::ResourceEntry> gdata_resource_entry( google_apis::ResourceEntry::ExtractAndParse(*value)); - ASSERT_TRUE(resource_entry.get()); + ASSERT_TRUE(gdata_resource_entry.get()); - DriveEntryProto entry_proto = - ConvertResourceEntryToDriveEntryProto(*resource_entry); + ResourceEntry entry = + ConvertToResourceEntry(*gdata_resource_entry); - EXPECT_EQ("File 1.mp3", entry_proto.title()); - EXPECT_EQ("File 1.mp3", entry_proto.base_name()); - EXPECT_EQ("file:2_file_resource_id", entry_proto.resource_id()); - EXPECT_EQ("https://file_content_url/", entry_proto.download_url()); + EXPECT_EQ("File 1.mp3", entry.title()); + EXPECT_EQ("File 1.mp3", entry.base_name()); + EXPECT_EQ("file:2_file_resource_id", entry.resource_id()); + EXPECT_EQ("https://file_content_url/", entry.download_url()); EXPECT_EQ("https://file1_link_self/file:2_file_resource_id", - entry_proto.edit_url()); + entry.edit_url()); EXPECT_EQ(util::kDriveOtherDirSpecialResourceId, - entry_proto.parent_resource_id()); + entry.parent_resource_id()); - EXPECT_FALSE(entry_proto.deleted()); - EXPECT_FALSE(entry_proto.shared_with_me()); + EXPECT_FALSE(entry.deleted()); + EXPECT_FALSE(entry.shared_with_me()); base::Time expected_creation_time; base::Time expected_modified_time; @@ -71,55 +71,55 @@ TEST(ResourceEntryConversionTest, ConvertResourceEntryToDriveEntryProto_File) { } EXPECT_EQ(expected_modified_time.ToInternalValue(), - entry_proto.file_info().last_modified()); + entry.file_info().last_modified()); // Last accessed value equal to 0 means that the file has never been viewed. - EXPECT_EQ(0, entry_proto.file_info().last_accessed()); + EXPECT_EQ(0, entry.file_info().last_accessed()); EXPECT_EQ(expected_creation_time.ToInternalValue(), - entry_proto.file_info().creation_time()); + entry.file_info().creation_time()); EXPECT_EQ("audio/mpeg", - entry_proto.file_specific_info().content_mime_type()); - EXPECT_FALSE(entry_proto.file_specific_info().is_hosted_document()); + entry.file_specific_info().content_mime_type()); + EXPECT_FALSE(entry.file_specific_info().is_hosted_document()); EXPECT_EQ("", - entry_proto.file_specific_info().thumbnail_url()); + entry.file_specific_info().thumbnail_url()); EXPECT_EQ("https://file_link_alternate/", - entry_proto.file_specific_info().alternate_url()); + entry.file_specific_info().alternate_url()); EXPECT_EQ("https://file_link_share/", - entry_proto.file_specific_info().share_url()); + entry.file_specific_info().share_url()); // Regular file specific fields. - EXPECT_EQ(892721, entry_proto.file_info().size()); + EXPECT_EQ(892721, entry.file_info().size()); EXPECT_EQ("3b4382ebefec6e743578c76bbd0575ce", - entry_proto.file_specific_info().file_md5()); - EXPECT_FALSE(entry_proto.file_info().is_directory()); + entry.file_specific_info().file_md5()); + EXPECT_FALSE(entry.file_info().is_directory()); } TEST(ResourceEntryConversionTest, - ConvertResourceEntryToDriveEntryProto_HostedDocument) { + ConvertToResourceEntry_HostedDocument) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile( "chromeos/gdata/hosted_document_entry.json"); ASSERT_TRUE(value.get()); - scoped_ptr<google_apis::ResourceEntry> resource_entry( + scoped_ptr<google_apis::ResourceEntry> gdata_resource_entry( google_apis::ResourceEntry::ExtractAndParse(*value)); - ASSERT_TRUE(resource_entry.get()); + ASSERT_TRUE(gdata_resource_entry.get()); - DriveEntryProto entry_proto = - ConvertResourceEntryToDriveEntryProto(*resource_entry); + ResourceEntry entry = + ConvertToResourceEntry(*gdata_resource_entry); - EXPECT_EQ("Document 1", entry_proto.title()); - EXPECT_EQ("Document 1.gdoc", entry_proto.base_name()); // The suffix added. - EXPECT_EQ(".gdoc", entry_proto.file_specific_info().document_extension()); - EXPECT_EQ("document:5_document_resource_id", entry_proto.resource_id()); - EXPECT_EQ("https://3_document_content/", entry_proto.download_url()); + EXPECT_EQ("Document 1", entry.title()); + EXPECT_EQ("Document 1.gdoc", entry.base_name()); // The suffix added. + EXPECT_EQ(".gdoc", entry.file_specific_info().document_extension()); + EXPECT_EQ("document:5_document_resource_id", entry.resource_id()); + EXPECT_EQ("https://3_document_content/", entry.download_url()); EXPECT_EQ("https://3_document_self_link/document:5_document_resource_id", - entry_proto.edit_url()); + entry.edit_url()); EXPECT_EQ(util::kDriveOtherDirSpecialResourceId, - entry_proto.parent_resource_id()); + entry.parent_resource_id()); - EXPECT_FALSE(entry_proto.deleted()); - EXPECT_FALSE(entry_proto.shared_with_me()); + EXPECT_FALSE(entry.deleted()); + EXPECT_FALSE(entry.shared_with_me()); // 2011-12-12T23:28:52.783Z base::Time::Exploded exploded; @@ -159,53 +159,53 @@ TEST(ResourceEntryConversionTest, base::Time::FromUTCExploded(exploded); EXPECT_EQ(expected_last_modified_time.ToInternalValue(), - entry_proto.file_info().last_modified()); + entry.file_info().last_modified()); EXPECT_EQ(expected_last_accessed_time.ToInternalValue(), - entry_proto.file_info().last_accessed()); + entry.file_info().last_accessed()); EXPECT_EQ(expected_creation_time.ToInternalValue(), - entry_proto.file_info().creation_time()); + entry.file_info().creation_time()); EXPECT_EQ("text/html", - entry_proto.file_specific_info().content_mime_type()); - EXPECT_TRUE(entry_proto.file_specific_info().is_hosted_document()); + entry.file_specific_info().content_mime_type()); + EXPECT_TRUE(entry.file_specific_info().is_hosted_document()); EXPECT_EQ("https://3_document_thumbnail_link/", - entry_proto.file_specific_info().thumbnail_url()); + entry.file_specific_info().thumbnail_url()); EXPECT_EQ("https://3_document_alternate_link/", - entry_proto.file_specific_info().alternate_url()); + entry.file_specific_info().alternate_url()); EXPECT_EQ("https://3_document_share_link/", - entry_proto.file_specific_info().share_url()); + entry.file_specific_info().share_url()); // The size should be 0 for a hosted document. - EXPECT_EQ(0, entry_proto.file_info().size()); - EXPECT_FALSE(entry_proto.file_info().is_directory()); + EXPECT_EQ(0, entry.file_info().size()); + EXPECT_FALSE(entry.file_info().is_directory()); } TEST(ResourceEntryConversionTest, - ConvertResourceEntryToDriveEntryProto_Directory) { + ConvertToResourceEntry_Directory) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile( "chromeos/gdata/directory_entry.json"); ASSERT_TRUE(value.get()); - scoped_ptr<google_apis::ResourceEntry> resource_entry( + scoped_ptr<google_apis::ResourceEntry> gdata_resource_entry( google_apis::ResourceEntry::ExtractAndParse(*value)); - ASSERT_TRUE(resource_entry.get()); + ASSERT_TRUE(gdata_resource_entry.get()); - DriveEntryProto entry_proto = - ConvertResourceEntryToDriveEntryProto(*resource_entry); + ResourceEntry entry = + ConvertToResourceEntry(*gdata_resource_entry); - EXPECT_EQ("Sub Directory Folder", entry_proto.title()); - EXPECT_EQ("Sub Directory Folder", entry_proto.base_name()); - EXPECT_EQ("folder:sub_dir_folder_resource_id", entry_proto.resource_id()); - EXPECT_EQ("https://1_folder_content_url/", entry_proto.download_url()); + EXPECT_EQ("Sub Directory Folder", entry.title()); + EXPECT_EQ("Sub Directory Folder", entry.base_name()); + EXPECT_EQ("folder:sub_dir_folder_resource_id", entry.resource_id()); + EXPECT_EQ("https://1_folder_content_url/", entry.download_url()); EXPECT_EQ("https://dir2_sub_self_link/folder:sub_dir_folder_resource_id", - entry_proto.edit_url()); + entry.edit_url()); // The parent resource ID should be obtained as this is a sub directory // under a non-root directory. - EXPECT_EQ("folder:1_folder_resource_id", entry_proto.parent_resource_id()); + EXPECT_EQ("folder:1_folder_resource_id", entry.parent_resource_id()); - EXPECT_FALSE(entry_proto.deleted()); - EXPECT_FALSE(entry_proto.shared_with_me()); + EXPECT_FALSE(entry.deleted()); + EXPECT_FALSE(entry.shared_with_me()); // 2011-04-01T18:34:08.234Z base::Time::Exploded exploded; @@ -245,40 +245,40 @@ TEST(ResourceEntryConversionTest, base::Time::FromUTCExploded(exploded); EXPECT_EQ(expected_last_modified_time.ToInternalValue(), - entry_proto.file_info().last_modified()); + entry.file_info().last_modified()); EXPECT_EQ(expected_last_accessed_time.ToInternalValue(), - entry_proto.file_info().last_accessed()); + entry.file_info().last_accessed()); EXPECT_EQ(expected_creation_time.ToInternalValue(), - entry_proto.file_info().creation_time()); + entry.file_info().creation_time()); - EXPECT_TRUE(entry_proto.file_info().is_directory()); + EXPECT_TRUE(entry.file_info().is_directory()); } TEST(ResourceEntryConversionTest, - ConvertResourceEntryToDriveEntryProto_DeletedHostedDocument) { + ConvertToResourceEntry_DeletedHostedDocument) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile( "chromeos/gdata/deleted_hosted_document_entry.json"); ASSERT_TRUE(value.get()); - scoped_ptr<google_apis::ResourceEntry> resource_entry( + scoped_ptr<google_apis::ResourceEntry> gdata_resource_entry( google_apis::ResourceEntry::ExtractAndParse(*value)); - ASSERT_TRUE(resource_entry.get()); + ASSERT_TRUE(gdata_resource_entry.get()); - DriveEntryProto entry_proto = - ConvertResourceEntryToDriveEntryProto(*resource_entry); + ResourceEntry entry = + ConvertToResourceEntry(*gdata_resource_entry); - EXPECT_EQ("Deleted document", entry_proto.title()); - EXPECT_EQ("Deleted document.gdoc", entry_proto.base_name()); - EXPECT_EQ("document:deleted_in_root_id", entry_proto.resource_id()); - EXPECT_EQ("https://content_url/", entry_proto.download_url()); + EXPECT_EQ("Deleted document", entry.title()); + EXPECT_EQ("Deleted document.gdoc", entry.base_name()); + EXPECT_EQ("document:deleted_in_root_id", entry.resource_id()); + EXPECT_EQ("https://content_url/", entry.download_url()); EXPECT_EQ("https://edit_url/document%3Adeleted_in_root_id", - entry_proto.edit_url()); + entry.edit_url()); EXPECT_EQ(util::kDriveOtherDirSpecialResourceId, - entry_proto.parent_resource_id()); + entry.parent_resource_id()); - EXPECT_TRUE(entry_proto.deleted()); // The document was deleted. - EXPECT_FALSE(entry_proto.shared_with_me()); + EXPECT_TRUE(entry.deleted()); // The document was deleted. + EXPECT_FALSE(entry.shared_with_me()); // 2012-04-10T22:50:55.797Z base::Time::Exploded exploded; @@ -318,40 +318,40 @@ TEST(ResourceEntryConversionTest, base::Time::FromUTCExploded(exploded); EXPECT_EQ(expected_last_modified_time.ToInternalValue(), - entry_proto.file_info().last_modified()); + entry.file_info().last_modified()); EXPECT_EQ(expected_last_accessed_time.ToInternalValue(), - entry_proto.file_info().last_accessed()); + entry.file_info().last_accessed()); EXPECT_EQ(expected_creation_time.ToInternalValue(), - entry_proto.file_info().creation_time()); + entry.file_info().creation_time()); EXPECT_EQ("text/html", - entry_proto.file_specific_info().content_mime_type()); - EXPECT_TRUE(entry_proto.file_specific_info().is_hosted_document()); + entry.file_specific_info().content_mime_type()); + EXPECT_TRUE(entry.file_specific_info().is_hosted_document()); EXPECT_EQ("", - entry_proto.file_specific_info().thumbnail_url()); + entry.file_specific_info().thumbnail_url()); EXPECT_EQ("https://alternate/document%3Adeleted_in_root_id/edit", - entry_proto.file_specific_info().alternate_url()); + entry.file_specific_info().alternate_url()); EXPECT_EQ("", - entry_proto.file_specific_info().share_url()); + entry.file_specific_info().share_url()); // The size should be 0 for a hosted document. - EXPECT_EQ(0, entry_proto.file_info().size()); + EXPECT_EQ(0, entry.file_info().size()); } TEST(ResourceEntryConversionTest, - ConvertResourceEntryToDriveEntryProto_SharedWithMeEntry) { + ConvertToResourceEntry_SharedWithMeEntry) { scoped_ptr<base::Value> value = google_apis::test_util::LoadJSONFile( "chromeos/gdata/shared_with_me_entry.json"); ASSERT_TRUE(value.get()); - scoped_ptr<google_apis::ResourceEntry> resource_entry( + scoped_ptr<google_apis::ResourceEntry> gdata_resource_entry( google_apis::ResourceEntry::ExtractAndParse(*value)); - ASSERT_TRUE(resource_entry.get()); + ASSERT_TRUE(gdata_resource_entry.get()); - DriveEntryProto entry_proto = - ConvertResourceEntryToDriveEntryProto(*resource_entry); + ResourceEntry entry = + ConvertToResourceEntry(*gdata_resource_entry); - EXPECT_TRUE(entry_proto.shared_with_me()); + EXPECT_TRUE(entry.shared_with_me()); } } // namespace drive diff --git a/chrome/browser/chromeos/drive/resource_metadata.cc b/chrome/browser/chromeos/drive/resource_metadata.cc index 853f717..937e073 100644 --- a/chrome/browser/chromeos/drive/resource_metadata.cc +++ b/chrome/browser/chromeos/drive/resource_metadata.cc @@ -19,7 +19,7 @@ namespace drive { namespace { // Sets entry's base name from its title and other attributes. -void SetBaseNameFromTitle(DriveEntryProto* entry) { +void SetBaseNameFromTitle(ResourceEntry* entry) { std::string base_name = entry->title(); if (entry->has_file_specific_info() && entry->file_specific_info().is_hosted_document()) { @@ -29,8 +29,8 @@ void SetBaseNameFromTitle(DriveEntryProto* entry) { } // Creates an entry by copying |source|, and setting the base name properly. -DriveEntryProto CreateEntryWithProperBaseName(const DriveEntryProto& source) { - DriveEntryProto entry(source); +ResourceEntry CreateEntryWithProperBaseName(const ResourceEntry& source) { + ResourceEntry entry(source); SetBaseNameFromTitle(&entry); return entry; } @@ -53,7 +53,7 @@ bool EnoughDiskSpaceIsAvailableForDBOperation(const base::FilePath& path) { // Runs |callback| with arguments. void RunGetEntryInfoCallback(const GetEntryInfoCallback& callback, - scoped_ptr<DriveEntryProto> entry, + scoped_ptr<ResourceEntry> entry, FileError error) { DCHECK(!callback.is_null()); @@ -66,7 +66,7 @@ void RunGetEntryInfoCallback(const GetEntryInfoCallback& callback, void RunGetEntryInfoWithFilePathCallback( const GetEntryInfoWithFilePathCallback& callback, base::FilePath* path, - scoped_ptr<DriveEntryProto> entry, + scoped_ptr<ResourceEntry> entry, FileError error) { DCHECK(!callback.is_null()); DCHECK(path); @@ -78,7 +78,7 @@ void RunGetEntryInfoWithFilePathCallback( // Runs |callback| with arguments. void RunReadDirectoryCallback(const ReadDirectoryCallback& callback, - scoped_ptr<DriveEntryProtoVector> entries, + scoped_ptr<ResourceEntryVector> entries, FileError error) { DCHECK(!callback.is_null()); @@ -206,7 +206,7 @@ bool ResourceMetadata::SetUpDefaultEntries() { // Initialize the grand root and "other" entries. "/drive" and "/drive/other". // As an intermediate change, "/drive/root" is also added here. if (!storage_->GetEntry(util::kDriveGrandRootSpecialResourceId)) { - DriveEntryProto root; + ResourceEntry root; root.mutable_file_info()->set_is_directory(true); root.set_resource_id(util::kDriveGrandRootSpecialResourceId); root.set_title(util::kDriveGrandRootDirName); @@ -265,7 +265,7 @@ void ResourceMetadata::SetLargestChangestamp( callback); } -void ResourceMetadata::AddEntry(const DriveEntryProto& entry_proto, +void ResourceMetadata::AddEntry(const ResourceEntry& entry, const FileMoveCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -273,7 +273,7 @@ void ResourceMetadata::AddEntry(const DriveEntryProto& entry_proto, PostFileMoveTask(blocking_task_runner_, base::Bind(&ResourceMetadata::AddEntryOnBlockingPool, base::Unretained(this), - entry_proto), + entry), callback); } @@ -326,8 +326,8 @@ void ResourceMetadata::GetEntryInfoByResourceId( DCHECK(!callback.is_null()); base::FilePath* file_path = new base::FilePath; - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); - DriveEntryProto* entry_ptr = entry.get(); + scoped_ptr<ResourceEntry> entry(new ResourceEntry); + ResourceEntry* entry_ptr = entry.get(); base::PostTaskAndReplyWithResult( blocking_task_runner_, FROM_HERE, @@ -348,8 +348,8 @@ void ResourceMetadata::GetEntryInfoByPath( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); - DriveEntryProto* entry_ptr = entry.get(); + scoped_ptr<ResourceEntry> entry(new ResourceEntry); + ResourceEntry* entry_ptr = entry.get(); base::PostTaskAndReplyWithResult( blocking_task_runner_, FROM_HERE, @@ -368,8 +368,8 @@ void ResourceMetadata::ReadDirectoryByPath( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - scoped_ptr<DriveEntryProtoVector> entries(new DriveEntryProtoVector); - DriveEntryProtoVector* entries_ptr = entries.get(); + scoped_ptr<ResourceEntryVector> entries(new ResourceEntryVector); + ResourceEntryVector* entries_ptr = entries.get(); base::PostTaskAndReplyWithResult( blocking_task_runner_, FROM_HERE, @@ -383,20 +383,20 @@ void ResourceMetadata::ReadDirectoryByPath( } void ResourceMetadata::RefreshEntry( - const DriveEntryProto& entry_proto, + const ResourceEntry& in_entry, const GetEntryInfoWithFilePathCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); base::FilePath* file_path = new base::FilePath; - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); - DriveEntryProto* entry_ptr = entry.get(); + scoped_ptr<ResourceEntry> entry(new ResourceEntry); + ResourceEntry* entry_ptr = entry.get(); base::PostTaskAndReplyWithResult( blocking_task_runner_, FROM_HERE, base::Bind(&ResourceMetadata::RefreshEntryOnBlockingPool, base::Unretained(this), - entry_proto, + in_entry, file_path, entry_ptr), base::Bind(&RunGetEntryInfoWithFilePathCallback, @@ -407,7 +407,7 @@ void ResourceMetadata::RefreshEntry( void ResourceMetadata::RefreshDirectory( const DirectoryFetchInfo& directory_fetch_info, - const DriveEntryProtoMap& entry_proto_map, + const ResourceEntryMap& entry_map, const FileMoveCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -417,7 +417,7 @@ void ResourceMetadata::RefreshDirectory( base::Bind(&ResourceMetadata::RefreshDirectoryOnBlockingPool, base::Unretained(this), directory_fetch_info, - entry_proto_map), + entry_map), callback); } @@ -478,8 +478,8 @@ FileError ResourceMetadata::MoveEntryToDirectoryOnBlockingPool( if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) return FILE_ERROR_NO_SPACE; - scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(file_path); - scoped_ptr<DriveEntryProto> destination = FindEntryByPathSync(directory_path); + scoped_ptr<ResourceEntry> entry = FindEntryByPathSync(file_path); + scoped_ptr<ResourceEntry> destination = FindEntryByPathSync(directory_path); if (!entry || !destination) return FILE_ERROR_NOT_FOUND; if (!destination->file_info().is_directory()) @@ -503,7 +503,7 @@ FileError ResourceMetadata::RenameEntryOnBlockingPool( if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) return FILE_ERROR_NO_SPACE; - scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(file_path); + scoped_ptr<ResourceEntry> entry = FindEntryByPathSync(file_path); if (!entry) return FILE_ERROR_NOT_FOUND; @@ -526,7 +526,7 @@ FileError ResourceMetadata::RemoveEntryOnBlockingPool( if (util::IsSpecialResourceId(resource_id)) return FILE_ERROR_ACCESS_DENIED; - scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); + scoped_ptr<ResourceEntry> entry = storage_->GetEntry(resource_id); if (!entry) return FILE_ERROR_NOT_FOUND; @@ -538,12 +538,12 @@ FileError ResourceMetadata::RemoveEntryOnBlockingPool( return FILE_ERROR_OK; } -scoped_ptr<DriveEntryProto> ResourceMetadata::FindEntryByPathSync( +scoped_ptr<ResourceEntry> ResourceMetadata::FindEntryByPathSync( const base::FilePath& file_path) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); // Start from the root. - scoped_ptr<DriveEntryProto> entry = + scoped_ptr<ResourceEntry> entry = storage_->GetEntry(util::kDriveGrandRootSpecialResourceId); DCHECK(entry); DCHECK(entry->parent_resource_id().empty()); @@ -553,7 +553,7 @@ scoped_ptr<DriveEntryProto> ResourceMetadata::FindEntryByPathSync( file_path.GetComponents(&components); if (components.empty() || base::FilePath(components[0]).AsUTF8Unsafe() != entry->base_name()) - return scoped_ptr<DriveEntryProto>(); + return scoped_ptr<ResourceEntry>(); // Iterate over the remaining components. for (size_t i = 1; i < components.size(); ++i) { @@ -561,7 +561,7 @@ scoped_ptr<DriveEntryProto> ResourceMetadata::FindEntryByPathSync( const std::string resource_id = storage_->GetChild(entry->resource_id(), component); if (resource_id.empty()) - return scoped_ptr<DriveEntryProto>(); + return scoped_ptr<ResourceEntry>(); entry = storage_->GetEntry(resource_id); DCHECK(entry); @@ -573,11 +573,11 @@ scoped_ptr<DriveEntryProto> ResourceMetadata::FindEntryByPathSync( FileError ResourceMetadata::GetEntryInfoByResourceIdOnBlockingPool( const std::string& resource_id, base::FilePath* out_file_path, - DriveEntryProto* out_entry) { + ResourceEntry* out_entry) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); DCHECK(!resource_id.empty()); - scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); + scoped_ptr<ResourceEntry> entry = storage_->GetEntry(resource_id); if (!entry) return FILE_ERROR_NOT_FOUND; @@ -591,11 +591,11 @@ FileError ResourceMetadata::GetEntryInfoByResourceIdOnBlockingPool( FileError ResourceMetadata::GetEntryInfoByPathOnBlockingPool( const base::FilePath& path, - DriveEntryProto* out_entry) { + ResourceEntry* out_entry) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); DCHECK(out_entry); - scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(path); + scoped_ptr<ResourceEntry> entry = FindEntryByPathSync(path); if (!entry) return FILE_ERROR_NOT_FOUND; @@ -605,11 +605,11 @@ FileError ResourceMetadata::GetEntryInfoByPathOnBlockingPool( FileError ResourceMetadata::ReadDirectoryByPathOnBlockingPool( const base::FilePath& path, - DriveEntryProtoVector* out_entries) { + ResourceEntryVector* out_entries) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); DCHECK(out_entries); - scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(path); + scoped_ptr<ResourceEntry> entry = FindEntryByPathSync(path); if (!entry) return FILE_ERROR_NOT_FOUND; @@ -638,15 +638,15 @@ void ResourceMetadata::GetEntryInfoPairByPaths( } FileError ResourceMetadata::RefreshEntryOnBlockingPool( - const DriveEntryProto& entry, + const ResourceEntry& entry, base::FilePath* out_file_path, - DriveEntryProto* out_entry) { + ResourceEntry* out_entry) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) return FILE_ERROR_NO_SPACE; - scoped_ptr<DriveEntryProto> old_entry = + scoped_ptr<ResourceEntry> old_entry = storage_->GetEntry(entry.resource_id()); if (!old_entry) return FILE_ERROR_NOT_FOUND; @@ -657,7 +657,7 @@ FileError ResourceMetadata::RefreshEntryOnBlockingPool( return FILE_ERROR_INVALID_OPERATION; // Update data. - scoped_ptr<DriveEntryProto> new_parent = + scoped_ptr<ResourceEntry> new_parent = GetDirectory(entry.parent_resource_id()); if (!new_parent) @@ -671,18 +671,18 @@ FileError ResourceMetadata::RefreshEntryOnBlockingPool( *out_file_path = GetFilePath(entry.resource_id()); if (out_entry) { - // Note that base_name is not the same for the new entry and entry_proto. - scoped_ptr<DriveEntryProto> result_entry_proto = + // Note that base_name is not the same for the new entry and entry. + scoped_ptr<ResourceEntry> result_entry = storage_->GetEntry(entry.resource_id()); - DCHECK(result_entry_proto); - *out_entry = *result_entry_proto; + DCHECK(result_entry); + *out_entry = *result_entry; } return FILE_ERROR_OK; } FileError ResourceMetadata::RefreshDirectoryOnBlockingPool( const DirectoryFetchInfo& directory_fetch_info, - const DriveEntryProtoMap& entry_proto_map, + const ResourceEntryMap& entry_map, base::FilePath* out_file_path) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); DCHECK(!directory_fetch_info.empty()); @@ -690,7 +690,7 @@ FileError ResourceMetadata::RefreshDirectoryOnBlockingPool( if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) return FILE_ERROR_NO_SPACE; - scoped_ptr<DriveEntryProto> directory = storage_->GetEntry( + scoped_ptr<ResourceEntry> directory = storage_->GetEntry( directory_fetch_info.resource_id()); if (!directory) @@ -705,12 +705,12 @@ FileError ResourceMetadata::RefreshDirectoryOnBlockingPool( // First, go through the entry map. We'll handle existing entries and new // entries in the loop. We'll process deleted entries afterwards. - for (DriveEntryProtoMap::const_iterator it = entry_proto_map.begin(); - it != entry_proto_map.end(); ++it) { + for (ResourceEntryMap::const_iterator it = entry_map.begin(); + it != entry_map.end(); ++it) { if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) return FILE_ERROR_NO_SPACE; - const DriveEntryProto& entry_proto = it->second; + const ResourceEntry& entry = it->second; // Skip if the parent resource ID does not match. This is needed to // handle entries with multiple parents. For such entries, the first // parent is picked and other parents are ignored, hence some entries may @@ -718,26 +718,26 @@ FileError ResourceMetadata::RefreshDirectoryOnBlockingPool( // // TODO(satorux): Move the filtering logic to somewhere more appropriate. // crbug.com/193525. - if (entry_proto.parent_resource_id() != + if (entry.parent_resource_id() != directory_fetch_info.resource_id()) { - DVLOG(1) << "Wrong-parent entry rejected: " << entry_proto.resource_id(); + DVLOG(1) << "Wrong-parent entry rejected: " << entry.resource_id(); continue; } - if (!PutEntryUnderDirectory(CreateEntryWithProperBaseName(entry_proto))) + if (!PutEntryUnderDirectory(CreateEntryWithProperBaseName(entry))) return FILE_ERROR_FAILED; } // Go through the existing entries and remove deleted entries. - scoped_ptr<DriveEntryProtoVector> entries = + scoped_ptr<ResourceEntryVector> entries = DirectoryChildrenToProtoVector(directory->resource_id()); for (size_t i = 0; i < entries->size(); ++i) { if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) return FILE_ERROR_NO_SPACE; - const DriveEntryProto& entry_proto = entries->at(i); - if (entry_proto_map.count(entry_proto.resource_id()) == 0) { - if (!RemoveEntryRecursively(entry_proto.resource_id())) + const ResourceEntry& entry = entries->at(i); + if (entry_map.count(entry.resource_id()) == 0) { + if (!RemoveEntryRecursively(entry.resource_id())) return FILE_ERROR_FAILED; } } @@ -749,47 +749,47 @@ FileError ResourceMetadata::RefreshDirectoryOnBlockingPool( } FileError ResourceMetadata::AddEntryOnBlockingPool( - const DriveEntryProto& entry_proto, + const ResourceEntry& entry, base::FilePath* out_file_path) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) return FILE_ERROR_NO_SPACE; - scoped_ptr<DriveEntryProto> existing_entry = - storage_->GetEntry(entry_proto.resource_id()); + scoped_ptr<ResourceEntry> existing_entry = + storage_->GetEntry(entry.resource_id()); if (existing_entry) return FILE_ERROR_EXISTS; - scoped_ptr<DriveEntryProto> parent = - GetDirectory(entry_proto.parent_resource_id()); + scoped_ptr<ResourceEntry> parent = + GetDirectory(entry.parent_resource_id()); if (!parent) return FILE_ERROR_NOT_FOUND; - if (!PutEntryUnderDirectory(entry_proto)) + if (!PutEntryUnderDirectory(entry)) return FILE_ERROR_FAILED; if (out_file_path) - *out_file_path = GetFilePath(entry_proto.resource_id()); + *out_file_path = GetFilePath(entry.resource_id()); return FILE_ERROR_OK; } -scoped_ptr<DriveEntryProto> ResourceMetadata::GetDirectory( +scoped_ptr<ResourceEntry> ResourceMetadata::GetDirectory( const std::string& resource_id) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); DCHECK(!resource_id.empty()); - scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); + scoped_ptr<ResourceEntry> entry = storage_->GetEntry(resource_id); return entry && entry->file_info().is_directory() ? - entry.Pass() : scoped_ptr<DriveEntryProto>(); + entry.Pass() : scoped_ptr<ResourceEntry>(); } base::FilePath ResourceMetadata::GetFilePath( const std::string& resource_id) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); - scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); + scoped_ptr<ResourceEntry> entry = storage_->GetEntry(resource_id); DCHECK(entry); base::FilePath path; if (!entry->parent_resource_id().empty()) @@ -805,7 +805,7 @@ ResourceMetadata::GetChildDirectoriesOnBlockingPool( scoped_ptr<std::set<base::FilePath> > changed_directories( new std::set<base::FilePath>); - scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); + scoped_ptr<ResourceEntry> entry = storage_->GetEntry(resource_id); if (entry && entry->file_info().is_directory()) GetDescendantDirectoryPaths(resource_id, changed_directories.get()); @@ -820,7 +820,7 @@ void ResourceMetadata::GetDescendantDirectoryPaths( std::vector<std::string> children; storage_->GetChildren(directory_resource_id, &children); for (size_t i = 0; i < children.size(); ++i) { - scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(children[i]); + scoped_ptr<ResourceEntry> entry = storage_->GetEntry(children[i]); DCHECK(entry); if (entry->file_info().is_directory()) { child_directories->insert(GetFilePath(entry->resource_id())); @@ -842,14 +842,14 @@ void ResourceMetadata::GetEntryInfoPairByPathsAfterGetFirst( const base::FilePath& second_path, const GetEntryInfoPairCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); scoped_ptr<EntryInfoPairResult> result(new EntryInfoPairResult); result->first.path = first_path; result->first.error = error; - result->first.proto = entry_proto.Pass(); + result->first.entry = entry.Pass(); // If the first one is not found, don't continue. if (error != FILE_ERROR_OK) { @@ -872,23 +872,23 @@ void ResourceMetadata::GetEntryInfoPairByPathsAfterGetSecond( const GetEntryInfoPairCallback& callback, scoped_ptr<EntryInfoPairResult> result, FileError error, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); DCHECK(result.get()); result->second.path = second_path; result->second.error = error; - result->second.proto = entry_proto.Pass(); + result->second.entry = entry.Pass(); callback.Run(result.Pass()); } bool ResourceMetadata::PutEntryUnderDirectory( - const DriveEntryProto& entry) { + const ResourceEntry& entry) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); - DriveEntryProto updated_entry(entry); + ResourceEntry updated_entry(entry); // The entry name may have been changed due to prior name de-duplication. // We need to first restore the file name based on the title before going @@ -921,7 +921,7 @@ bool ResourceMetadata::RemoveEntryRecursively( const std::string& resource_id) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); - scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); + scoped_ptr<ResourceEntry> entry = storage_->GetEntry(resource_id); DCHECK(entry); if (entry->file_info().is_directory()) { @@ -935,16 +935,16 @@ bool ResourceMetadata::RemoveEntryRecursively( return storage_->RemoveEntry(resource_id); } -scoped_ptr<DriveEntryProtoVector> +scoped_ptr<ResourceEntryVector> ResourceMetadata::DirectoryChildrenToProtoVector( const std::string& directory_resource_id) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); - scoped_ptr<DriveEntryProtoVector> entries(new DriveEntryProtoVector); + scoped_ptr<ResourceEntryVector> entries(new ResourceEntryVector); std::vector<std::string> children; storage_->GetChildren(directory_resource_id, &children); for (size_t i = 0; i < children.size(); ++i) { - scoped_ptr<DriveEntryProto> child = storage_->GetEntry(children[i]); + scoped_ptr<ResourceEntry> child = storage_->GetEntry(children[i]); DCHECK(child); entries->push_back(*child); } diff --git a/chrome/browser/chromeos/drive/resource_metadata.h b/chrome/browser/chromeos/drive/resource_metadata.h index dcec8c7b..30d7a38 100644 --- a/chrome/browser/chromeos/drive/resource_metadata.h +++ b/chrome/browser/chromeos/drive/resource_metadata.h @@ -24,12 +24,12 @@ class SequencedTaskRunner; namespace drive { -class DriveEntryProto; +class ResourceEntry; class ResourceMetadataStorage; -typedef std::vector<DriveEntryProto> DriveEntryProtoVector; -typedef std::map<std::string /* resource_id */, DriveEntryProto> - DriveEntryProtoMap; +typedef std::vector<ResourceEntry> ResourceEntryVector; +typedef std::map<std::string /* resource_id */, ResourceEntry> + ResourceEntryMap; // Holds information needed to fetch contents of a directory. // This object is copyable. @@ -69,22 +69,22 @@ typedef base::Callback<void(FileError error, // Used to get entry info from the file system. // If |error| is not FILE_ERROR_OK, |entry_info| is set to NULL. typedef base::Callback<void(FileError error, - scoped_ptr<DriveEntryProto> entry_proto)> + scoped_ptr<ResourceEntry> entry)> GetEntryInfoCallback; typedef base::Callback<void(FileError error, - scoped_ptr<DriveEntryProtoVector> entries)> + scoped_ptr<ResourceEntryVector> entries)> ReadDirectoryCallback; // Used to get entry info from the file system, with the Drive file path. -// If |error| is not FILE_ERROR_OK, |entry_proto| is set to NULL. +// If |error| is not FILE_ERROR_OK, |entry| is set to NULL. // -// |drive_file_path| parameter is provided as DriveEntryProto does not contain +// |drive_file_path| parameter is provided as ResourceEntry does not contain // the Drive file path (i.e. only contains the base name without parent // directory names). typedef base::Callback<void(FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto)> + scoped_ptr<ResourceEntry> entry)> GetEntryInfoWithFilePathCallback; // Used to get a set of changed directories for feed processing. @@ -100,7 +100,7 @@ struct EntryInfoResult { base::FilePath path; FileError error; - scoped_ptr<DriveEntryProto> proto; + scoped_ptr<ResourceEntry> entry; }; // The result of GetEntryInfoPairCallback(). Used to get a pair of entries @@ -144,9 +144,9 @@ class ResourceMetadata { void SetLargestChangestamp(int64 value, const FileOperationCallback& callback); - // Adds |entry_proto| to the metadata tree, based on its parent_resource_id. + // Adds |entry| to the metadata tree, based on its parent_resource_id. // |callback| must not be null. - void AddEntry(const DriveEntryProto& entry_proto, + void AddEntry(const ResourceEntry& entry, const FileMoveCallback& callback); // Moves entry specified by |file_path| to the directory specified by @@ -191,15 +191,15 @@ class ResourceMetadata { const base::FilePath& second_path, const GetEntryInfoPairCallback& callback); - // Refreshes a drive entry with the same resource id as |entry_proto|. - // |callback| is run with the error, file path and proto of the entry. + // Refreshes a drive entry with the same resource id as |entry|. + // |callback| is run with the error, file path and the new entry. // |callback| must not be null. - void RefreshEntry(const DriveEntryProto& entry_proto, + void RefreshEntry(const ResourceEntry& entry, const GetEntryInfoWithFilePathCallback& callback); // Removes all child files of the directory pointed by // |directory_fetch_info| and replaces them with - // |entry_proto_map|. The changestamp of the directory will be updated per + // |entry_map|. The changestamp of the directory will be updated per // |directory_fetch_info|. |callback| is called with the directory path. // |callback| must not be null. // @@ -208,7 +208,7 @@ class ResourceMetadata { // remain as-is, but the new directories should be added with changestamp // set to zero, which will be fast fetched. void RefreshDirectory(const DirectoryFetchInfo& directory_fetch_info, - const DriveEntryProtoMap& entry_proto_map, + const ResourceEntryMap& entry_map, const FileMoveCallback& callback); // Recursively get child directories of entry pointed to by |resource_id|. @@ -245,7 +245,7 @@ class ResourceMetadata { FileError SetLargestChangestampOnBlockingPool(int64 value); // Used to implement AddEntry(). - FileError AddEntryOnBlockingPool(const DriveEntryProto& entry_proto, + FileError AddEntryOnBlockingPool(const ResourceEntry& entry, base::FilePath* out_file_path); // Used to implement MoveEntryToDirectory(). @@ -267,26 +267,26 @@ class ResourceMetadata { FileError GetEntryInfoByResourceIdOnBlockingPool( const std::string& resource_id, base::FilePath* out_file_path, - DriveEntryProto* out_entry); + ResourceEntry* out_entry); // Used to implement GetEntryInfoByPath(). FileError GetEntryInfoByPathOnBlockingPool(const base::FilePath& file_path, - DriveEntryProto* out_entry); + ResourceEntry* out_entry); // Used to implement ReadDirectoryByPath(). FileError ReadDirectoryByPathOnBlockingPool( const base::FilePath& file_path, - DriveEntryProtoVector* out_entries); + ResourceEntryVector* out_entries); // Used to implement RefreshEntry(). - FileError RefreshEntryOnBlockingPool(const DriveEntryProto& entry_proto, + FileError RefreshEntryOnBlockingPool(const ResourceEntry& entry, base::FilePath* out_file_path, - DriveEntryProto* out_entry); + ResourceEntry* out_entry); // Used to implement RefreshDirectory(). FileError RefreshDirectoryOnBlockingPool( const DirectoryFetchInfo& directory_fetch_info, - const DriveEntryProtoMap& entry_proto_map, + const ResourceEntryMap& entry_map, base::FilePath* out_file_path); // Used to implement GetChildDirectories(). @@ -304,7 +304,7 @@ class ResourceMetadata { const base::FilePath& second_path, const GetEntryInfoPairCallback& callback, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Continues with GetIntroInfoPairByPaths after the second DriveEntry has been // asynchronously fetched. @@ -313,16 +313,16 @@ class ResourceMetadata { const GetEntryInfoPairCallback& callback, scoped_ptr<EntryInfoPairResult> result, FileError error, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Searches for |file_path| synchronously. - scoped_ptr<DriveEntryProto> FindEntryByPathSync( + scoped_ptr<ResourceEntry> FindEntryByPathSync( const base::FilePath& file_path); // Helper function to get a directory given |resource_id|. |resource_id| can // not be empty. Returns NULL if it finds no corresponding entry, or the // corresponding entry is not a directory. - scoped_ptr<DriveEntryProto> GetDirectory(const std::string& resource_id); + scoped_ptr<ResourceEntry> GetDirectory(const std::string& resource_id); // Returns virtual file path of the entry. base::FilePath GetFilePath(const std::string& resource_id); @@ -335,13 +335,13 @@ class ResourceMetadata { // parent if there is. This method will also do name de-duplication to ensure // that the exposed presentation path does not have naming conflicts. Two // files with the same name "Foo" will be renames to "Foo (1)" and "Foo (2)". - bool PutEntryUnderDirectory(const DriveEntryProto& entry); + bool PutEntryUnderDirectory(const ResourceEntry& entry); // Removes the entry and its descendants. bool RemoveEntryRecursively(const std::string& resource_id); - // Converts the children as a vector of DriveEntryProto. - scoped_ptr<DriveEntryProtoVector> DirectoryChildrenToProtoVector( + // Converts the children as a vector of ResourceEntry. + scoped_ptr<ResourceEntryVector> DirectoryChildrenToProtoVector( const std::string& directory_resource_id); const base::FilePath data_directory_path_; diff --git a/chrome/browser/chromeos/drive/resource_metadata_storage.cc b/chrome/browser/chromeos/drive/resource_metadata_storage.cc index ae9fa6c..d322f52 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_storage.cc +++ b/chrome/browser/chromeos/drive/resource_metadata_storage.cc @@ -175,7 +175,7 @@ int64 ResourceMetadataStorage::GetLargestChangestamp() { return header->largest_changestamp(); } -bool ResourceMetadataStorage::PutEntry(const DriveEntryProto& entry) { +bool ResourceMetadataStorage::PutEntry(const ResourceEntry& entry) { base::ThreadRestrictions::AssertIOAllowed(); DCHECK(!entry.resource_id().empty()); @@ -188,7 +188,7 @@ bool ResourceMetadataStorage::PutEntry(const DriveEntryProto& entry) { leveldb::WriteBatch batch; // Remove from the old parent. - scoped_ptr<DriveEntryProto> old_entry = GetEntry(entry.resource_id()); + scoped_ptr<ResourceEntry> old_entry = GetEntry(entry.resource_id()); if (old_entry && !old_entry->parent_resource_id().empty()) { batch.Delete(GetChildEntryKey(old_entry->parent_resource_id(), old_entry->base_name())); @@ -208,7 +208,7 @@ bool ResourceMetadataStorage::PutEntry(const DriveEntryProto& entry) { return status.ok(); } -scoped_ptr<DriveEntryProto> ResourceMetadataStorage::GetEntry( +scoped_ptr<ResourceEntry> ResourceMetadataStorage::GetEntry( const std::string& resource_id) { base::ThreadRestrictions::AssertIOAllowed(); DCHECK(!resource_id.empty()); @@ -218,11 +218,11 @@ scoped_ptr<DriveEntryProto> ResourceMetadataStorage::GetEntry( leveldb::Slice(resource_id), &serialized_entry); if (!status.ok()) - return scoped_ptr<DriveEntryProto>(); + return scoped_ptr<ResourceEntry>(); - scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); + scoped_ptr<ResourceEntry> entry(new ResourceEntry); if (!entry->ParseFromString(serialized_entry)) - return scoped_ptr<DriveEntryProto>(); + return scoped_ptr<ResourceEntry>(); return entry.Pass(); } @@ -230,7 +230,7 @@ bool ResourceMetadataStorage::RemoveEntry(const std::string& resource_id) { base::ThreadRestrictions::AssertIOAllowed(); DCHECK(!resource_id.empty()); - scoped_ptr<DriveEntryProto> entry = GetEntry(resource_id); + scoped_ptr<ResourceEntry> entry = GetEntry(resource_id); if (!entry) return false; @@ -262,7 +262,7 @@ void ResourceMetadataStorage::Iterate(const IterateCallback& callback) { it->Seek(leveldb::Slice(GetHeaderDBKey())); it->Next(); - DriveEntryProto entry; + ResourceEntry entry; for (; it->Valid(); it->Next()) { if (!IsChildEntryKey(it->key()) && entry.ParseFromArray(it->value().data(), it->value().size())) @@ -370,7 +370,7 @@ bool ResourceMetadataStorage::CheckValidity() { // Check all entires. size_t num_entries_with_parent = 0; size_t num_child_entries = 0; - DriveEntryProto entry; + ResourceEntry entry; std::string serialized_parent_entry; std::string child_resource_id; for (it->Next(); it->Valid(); it->Next()) { diff --git a/chrome/browser/chromeos/drive/resource_metadata_storage.h b/chrome/browser/chromeos/drive/resource_metadata_storage.h index 66cc295..1be55d9 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_storage.h +++ b/chrome/browser/chromeos/drive/resource_metadata_storage.h @@ -19,10 +19,10 @@ class DB; namespace drive { -class DriveEntryProto; +class ResourceEntry; class ResourceMetadataHeader; -typedef base::Callback<void(const DriveEntryProto& entry)> IterateCallback; +typedef base::Callback<void(const ResourceEntry& entry)> IterateCallback; // Storage for ResourceMetadata which is responsible to manage entry info // and child-parent relationships between entries. @@ -45,10 +45,10 @@ class ResourceMetadataStorage { int64 GetLargestChangestamp(); // Puts the entry to this storage. - bool PutEntry(const DriveEntryProto& entry); + bool PutEntry(const ResourceEntry& entry); // Returns an entry stored in this storage. - scoped_ptr<DriveEntryProto> GetEntry(const std::string& resource_id); + scoped_ptr<ResourceEntry> GetEntry(const std::string& resource_id); // Removes an entry from this storage. bool RemoveEntry(const std::string& resource_id); diff --git a/chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc b/chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc index 07bba8b..a53b5b9 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc +++ b/chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc @@ -18,8 +18,8 @@ namespace drive { namespace { // Stores the entry to the map. -void StoreEntryToMap(std::map<std::string,DriveEntryProto>* out, - const DriveEntryProto& entry) { +void StoreEntryToMap(std::map<std::string,ResourceEntry>* out, + const ResourceEntry& entry) { (*out)[entry.resource_id()] = entry; } @@ -86,7 +86,7 @@ TEST_F(ResourceMetadataStorageTest, PutEntry) { const std::string name2 = "ABCD"; const std::string name3 = "EFGH"; - DriveEntryProto entry1; + ResourceEntry entry1; entry1.set_resource_id(key1); // key1 not found. @@ -96,7 +96,7 @@ TEST_F(ResourceMetadataStorageTest, PutEntry) { EXPECT_TRUE(storage_->PutEntry(entry1)); // key1 found. - scoped_ptr<DriveEntryProto> result; + scoped_ptr<ResourceEntry> result; result = storage_->GetEntry(key1); ASSERT_TRUE(result); EXPECT_EQ(key1, result->resource_id()); @@ -105,7 +105,7 @@ TEST_F(ResourceMetadataStorageTest, PutEntry) { EXPECT_FALSE(storage_->GetEntry(key2)); // Put entry2 as a child of entry1. - DriveEntryProto entry2; + ResourceEntry entry2; entry2.set_parent_resource_id(key1); entry2.set_resource_id(key2); entry2.set_base_name(name2); @@ -116,7 +116,7 @@ TEST_F(ResourceMetadataStorageTest, PutEntry) { EXPECT_EQ(key2, storage_->GetChild(key1, name2)); // Put entry3 as a child of entry2. - DriveEntryProto entry3; + ResourceEntry entry3; entry3.set_parent_resource_id(key2); entry3.set_resource_id(key3); entry3.set_base_name(name3); @@ -145,8 +145,8 @@ TEST_F(ResourceMetadataStorageTest, PutEntry) { TEST_F(ResourceMetadataStorageTest, Iterate) { // Prepare data. - std::vector<DriveEntryProto> entries; - DriveEntryProto entry; + std::vector<ResourceEntry> entries; + ResourceEntry entry; entry.set_resource_id("entry1"); entries.push_back(entry); @@ -161,7 +161,7 @@ TEST_F(ResourceMetadataStorageTest, Iterate) { EXPECT_TRUE(storage_->PutEntry(entries[i])); // Call Iterate and check the result. - std::map<std::string, DriveEntryProto> result; + std::map<std::string, ResourceEntry> result; storage_->Iterate(base::Bind(&StoreEntryToMap, base::Unretained(&result))); EXPECT_EQ(entries.size(), result.size()); @@ -191,7 +191,7 @@ TEST_F(ResourceMetadataStorageTest, GetChildren) { // Put parents. for (size_t i = 0; i < arraysize(parents_id); ++i) { - DriveEntryProto entry; + ResourceEntry entry; entry.set_resource_id(parents_id[i]); EXPECT_TRUE(storage_->PutEntry(entry)); } @@ -199,7 +199,7 @@ TEST_F(ResourceMetadataStorageTest, GetChildren) { // Put some data. for (size_t i = 0; i < children_name_id.size(); ++i) { for (size_t j = 0; j < children_name_id[i].size(); ++j) { - DriveEntryProto entry; + ResourceEntry entry; entry.set_parent_resource_id(parents_id[i]); entry.set_base_name(children_name_id[i][j].first); entry.set_resource_id(children_name_id[i][j].second); @@ -225,9 +225,9 @@ TEST_F(ResourceMetadataStorageTest, OpenExistingDB) { const std::string child_name1 = "WXYZABC"; const std::string child_id1 = "qwerty"; - DriveEntryProto entry1; + ResourceEntry entry1; entry1.set_resource_id(parent_id1); - DriveEntryProto entry2; + ResourceEntry entry2; entry2.set_resource_id(child_id1); entry2.set_parent_resource_id(parent_id1); entry2.set_base_name(child_name1); @@ -241,7 +241,7 @@ TEST_F(ResourceMetadataStorageTest, OpenExistingDB) { ASSERT_TRUE(storage_->Initialize()); // Can read data. - scoped_ptr<DriveEntryProto> result; + scoped_ptr<ResourceEntry> result; result = storage_->GetEntry(parent_id1); ASSERT_TRUE(result); EXPECT_EQ(parent_id1, result->resource_id()); @@ -259,7 +259,7 @@ TEST_F(ResourceMetadataStorageTest, IncompatibleDB) { const int64 kLargestChangestamp = 1234567890; const std::string key1 = "abcd"; - DriveEntryProto entry; + ResourceEntry entry; entry.set_resource_id(key1); // Put some data. @@ -299,7 +299,7 @@ TEST_F(ResourceMetadataStorageTest, CheckValidity) { EXPECT_TRUE(CheckValidity()); // Put entry with key1. - DriveEntryProto entry; + ResourceEntry entry; entry.set_resource_id(key1); entry.set_base_name(name1); EXPECT_TRUE(storage_->PutEntry(entry)); diff --git a/chrome/browser/chromeos/drive/resource_metadata_unittest.cc b/chrome/browser/chromeos/drive/resource_metadata_unittest.cc index fba5c58..8e3c45a 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_unittest.cc +++ b/chrome/browser/chromeos/drive/resource_metadata_unittest.cc @@ -36,7 +36,7 @@ const int64 kTestChangestamp = 100; // Returns the sorted base names from |entries|. std::vector<std::string> GetSortedBaseNames( - const DriveEntryProtoVector& entries) { + const ResourceEntryVector& entries) { std::vector<std::string> base_names; for (size_t i = 0; i < entries.size(); ++i) base_names.push_back(entries[i].base_name()); @@ -46,7 +46,7 @@ std::vector<std::string> GetSortedBaseNames( } // Increments |count| if |entry| is a file. -void CountFile(int* count, const DriveEntryProto& entry) { +void CountFile(int* count, const ResourceEntry& entry) { if (!entry.file_info().is_directory()) ++*count; } @@ -72,14 +72,14 @@ class ResourceMetadataTest : public testing::Test { // drive/root/dir1/dir3/file10 static void Init(ResourceMetadata* resource_metadata); - // Creates a DriveEntryProto. - static DriveEntryProto CreateDriveEntryProto( + // Creates a ResourceEntry. + static ResourceEntry CreateResourceEntry( int sequence_id, bool is_directory, const std::string& parent_resource_id); - // Adds a DriveEntryProto to the metadata tree. Returns true on success. - static bool AddDriveEntryProto(ResourceMetadata* resource_metadata, + // Adds a ResourceEntry to the metadata tree. Returns true on success. + static bool AddResourceEntry(ResourceMetadata* resource_metadata, int sequence_id, bool is_directory, const std::string& parent_resource_id); @@ -103,24 +103,24 @@ class ResourceMetadataTest : public testing::Test { } // Gets the entry info by path synchronously. Returns NULL on failure. - scoped_ptr<DriveEntryProto> GetEntryInfoByPathSync( + scoped_ptr<ResourceEntry> GetEntryInfoByPathSync( const base::FilePath& file_path) { FileError error = FILE_ERROR_OK; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; resource_metadata_->GetEntryInfoByPath( file_path, - google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); + google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_TRUE(error == FILE_ERROR_OK || !entry_proto); - return entry_proto.Pass(); + EXPECT_TRUE(error == FILE_ERROR_OK || !entry); + return entry.Pass(); } // Reads the directory contents by path synchronously. Returns NULL on // failure. - scoped_ptr<DriveEntryProtoVector> ReadDirectoryByPathSync( + scoped_ptr<ResourceEntryVector> ReadDirectoryByPathSync( const base::FilePath& directory_path) { FileError error = FILE_ERROR_OK; - scoped_ptr<DriveEntryProtoVector> entries; + scoped_ptr<ResourceEntryVector> entries; resource_metadata_->ReadDirectoryByPath( directory_path, google_apis::test_util::CreateCopyResultCallback(&error, &entries)); @@ -159,28 +159,28 @@ void ResourceMetadataTest::Init(ResourceMetadata* resource_metadata) { } int sequence_id = 1; - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, true, kTestRootResourceId)); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, true, kTestRootResourceId)); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, true, "resource_id:dir1")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, false, "resource_id:dir1")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, false, "resource_id:dir1")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, false, "resource_id:dir2")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, false, "resource_id:dir2")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, false, "resource_id:dir2")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, false, "resource_id:dir3")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata, sequence_id++, false, "resource_id:dir3")); resource_metadata->SetLargestChangestamp( @@ -191,47 +191,47 @@ void ResourceMetadataTest::Init(ResourceMetadata* resource_metadata) { } // static -DriveEntryProto ResourceMetadataTest::CreateDriveEntryProto( +ResourceEntry ResourceMetadataTest::CreateResourceEntry( int sequence_id, bool is_directory, const std::string& parent_resource_id) { - DriveEntryProto entry_proto; + ResourceEntry entry; const std::string sequence_id_str = base::IntToString(sequence_id); const std::string title = (is_directory ? "dir" : "file") + sequence_id_str; const std::string resource_id = "resource_id:" + title; - entry_proto.set_title(title); - entry_proto.set_resource_id(resource_id); - entry_proto.set_parent_resource_id(parent_resource_id); + entry.set_title(title); + entry.set_resource_id(resource_id); + entry.set_parent_resource_id(parent_resource_id); - PlatformFileInfoProto* file_info = entry_proto.mutable_file_info(); + PlatformFileInfoProto* file_info = entry.mutable_file_info(); file_info->set_is_directory(is_directory); if (!is_directory) { DriveFileSpecificInfo* file_specific_info = - entry_proto.mutable_file_specific_info(); + entry.mutable_file_specific_info(); file_info->set_size(sequence_id * 1024); file_specific_info->set_file_md5(std::string("md5:") + title); } else { DriveDirectorySpecificInfo* directory_specific_info = - entry_proto.mutable_directory_specific_info(); + entry.mutable_directory_specific_info(); directory_specific_info->set_changestamp(kTestChangestamp); } - return entry_proto; + return entry; } -bool ResourceMetadataTest::AddDriveEntryProto( +bool ResourceMetadataTest::AddResourceEntry( ResourceMetadata* resource_metadata, int sequence_id, bool is_directory, const std::string& parent_resource_id) { - DriveEntryProto entry_proto = CreateDriveEntryProto(sequence_id, + ResourceEntry entry = CreateResourceEntry(sequence_id, is_directory, parent_resource_id); FileError error = FILE_ERROR_FAILED; base::FilePath drive_path; resource_metadata->AddEntry( - entry_proto, + entry, google_apis::test_util::CreateCopyResultCallback(&error, &drive_path)); google_apis::test_util::RunBlockingPoolTask(); return FILE_ERROR_OK == error; @@ -272,105 +272,105 @@ TEST_F(ResourceMetadataTest, GetEntryInfoByResourceId_RootDirectory) { ASSERT_EQ(FILE_ERROR_OK, error); base::FilePath drive_file_path; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; // Look up the root directory by its resource ID. resource_metadata->GetEntryInfoByResourceId( util::kDriveGrandRootSpecialResourceId, google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive"), drive_file_path); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("drive", entry_proto->base_name()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("drive", entry->base_name()); } TEST_F(ResourceMetadataTest, GetEntryInfoByResourceId) { // Confirm that an existing file is found. FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; resource_metadata_->GetEntryInfoByResourceId( "resource_id:file4", google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), drive_file_path); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("file4", entry_proto->base_name()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("file4", entry->base_name()); // Confirm that a non existing file is not found. error = FILE_ERROR_FAILED; - entry_proto.reset(); + entry.reset(); resource_metadata_->GetEntryInfoByResourceId( "file:non_existing", google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); - EXPECT_FALSE(entry_proto.get()); + EXPECT_FALSE(entry.get()); } TEST_F(ResourceMetadataTest, GetEntryInfoByPath) { // Confirm that an existing file is found. FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), - google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); + google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("file4", entry_proto->base_name()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("file4", entry->base_name()); // Confirm that a non existing file is not found. error = FILE_ERROR_FAILED; - entry_proto.reset(); + entry.reset(); resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existing"), - google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); + google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); - EXPECT_FALSE(entry_proto.get()); + EXPECT_FALSE(entry.get()); // Confirm that the root is found. error = FILE_ERROR_FAILED; - entry_proto.reset(); + entry.reset(); resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("drive"), - google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); + google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); - EXPECT_TRUE(entry_proto.get()); + EXPECT_TRUE(entry.get()); // Confirm that a non existing file is not found at the root level. error = FILE_ERROR_FAILED; - entry_proto.reset(); + entry.reset(); resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("non_existing"), - google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); + google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); - EXPECT_FALSE(entry_proto.get()); + EXPECT_FALSE(entry.get()); // Confirm that an entry is not found with a wrong root. error = FILE_ERROR_FAILED; - entry_proto.reset(); + entry.reset(); resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("non_existing/root"), - google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); + google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); - EXPECT_FALSE(entry_proto.get()); + EXPECT_FALSE(entry.get()); } TEST_F(ResourceMetadataTest, ReadDirectoryByPath) { // Confirm that an existing directory is found. FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProtoVector> entries; + scoped_ptr<ResourceEntryVector> entries; resource_metadata_->ReadDirectoryByPath( base::FilePath::FromUTF8Unsafe("drive/root/dir1"), google_apis::test_util::CreateCopyResultCallback(&error, &entries)); @@ -417,14 +417,14 @@ TEST_F(ResourceMetadataTest, GetEntryInfoPairByPaths) { EXPECT_EQ(FILE_ERROR_OK, pair_result->first.error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), pair_result->first.path); - ASSERT_TRUE(pair_result->first.proto.get()); - EXPECT_EQ("file4", pair_result->first.proto->base_name()); + ASSERT_TRUE(pair_result->first.entry.get()); + EXPECT_EQ("file4", pair_result->first.entry->base_name()); // The second entry should be found. EXPECT_EQ(FILE_ERROR_OK, pair_result->second.error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file5"), pair_result->second.path); - ASSERT_TRUE(pair_result->second.proto.get()); - EXPECT_EQ("file5", pair_result->second.proto->base_name()); + ASSERT_TRUE(pair_result->second.entry.get()); + EXPECT_EQ("file5", pair_result->second.entry->base_name()); // Confirm that the first non existent file is not found. pair_result.reset(); @@ -437,11 +437,11 @@ TEST_F(ResourceMetadataTest, GetEntryInfoPairByPaths) { EXPECT_EQ(FILE_ERROR_NOT_FOUND, pair_result->first.error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"), pair_result->first.path); - ASSERT_FALSE(pair_result->first.proto.get()); + ASSERT_FALSE(pair_result->first.entry.get()); // The second entry should not be found, because the first one failed. EXPECT_EQ(FILE_ERROR_FAILED, pair_result->second.error); EXPECT_EQ(base::FilePath(), pair_result->second.path); - ASSERT_FALSE(pair_result->second.proto.get()); + ASSERT_FALSE(pair_result->second.entry.get()); // Confirm that the second non existent file is not found. pair_result.reset(); @@ -454,13 +454,13 @@ TEST_F(ResourceMetadataTest, GetEntryInfoPairByPaths) { EXPECT_EQ(FILE_ERROR_OK, pair_result->first.error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), pair_result->first.path); - ASSERT_TRUE(pair_result->first.proto.get()); - EXPECT_EQ("file4", pair_result->first.proto->base_name()); + ASSERT_TRUE(pair_result->first.entry.get()); + EXPECT_EQ("file4", pair_result->first.entry->base_name()); // The second entry should not be found. EXPECT_EQ(FILE_ERROR_NOT_FOUND, pair_result->second.error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existent"), pair_result->second.path); - ASSERT_FALSE(pair_result->second.proto.get()); + ASSERT_FALSE(pair_result->second.entry.get()); } TEST_F(ResourceMetadataTest, RemoveEntry) { @@ -468,17 +468,17 @@ TEST_F(ResourceMetadataTest, RemoveEntry) { FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; const std::string file9_resource_id = "resource_id:file9"; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; resource_metadata_->GetEntryInfoByResourceId( file9_resource_id, google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file9"), drive_file_path); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("file9", entry_proto->base_name()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("file9", entry->base_name()); // Remove file9 using RemoveEntry. resource_metadata_->RemoveEntry( @@ -494,23 +494,23 @@ TEST_F(ResourceMetadataTest, RemoveEntry) { resource_metadata_->GetEntryInfoByResourceId( file9_resource_id, google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); - EXPECT_FALSE(entry_proto.get()); + EXPECT_FALSE(entry.get()); // Look for dir3. const std::string dir3_resource_id = "resource_id:dir3"; resource_metadata_->GetEntryInfoByResourceId( dir3_resource_id, google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3"), drive_file_path); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("dir3", entry_proto->base_name()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("dir3", entry->base_name()); // Remove dir3 using RemoveEntry. resource_metadata_->RemoveEntry( @@ -525,10 +525,10 @@ TEST_F(ResourceMetadataTest, RemoveEntry) { resource_metadata_->GetEntryInfoByResourceId( dir3_resource_id, google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); - EXPECT_FALSE(entry_proto.get()); + EXPECT_FALSE(entry.get()); // Remove unknown resource_id using RemoveEntry. resource_metadata_->RemoveEntry( @@ -550,7 +550,7 @@ TEST_F(ResourceMetadataTest, RemoveEntry) { TEST_F(ResourceMetadataTest, MoveEntryToDirectory) { FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; // Move file8 to drive/dir1. resource_metadata_->MoveEntryToDirectory( @@ -567,7 +567,7 @@ TEST_F(ResourceMetadataTest, MoveEntryToDirectory) { resource_metadata_->GetEntryInfoByResourceId( "resource_id:file8", google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file8"), @@ -629,7 +629,7 @@ TEST_F(ResourceMetadataTest, MoveEntryToDirectory) { resource_metadata_->GetEntryInfoByResourceId( "resource_id:file8", google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir2/file8"), @@ -639,7 +639,7 @@ TEST_F(ResourceMetadataTest, MoveEntryToDirectory) { TEST_F(ResourceMetadataTest, RenameEntry) { FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; // Rename file8 to file11. resource_metadata_->RenameEntry( @@ -656,7 +656,7 @@ TEST_F(ResourceMetadataTest, RenameEntry) { resource_metadata_->GetEntryInfoByResourceId( "resource_id:file8", google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir2/file11"), @@ -697,105 +697,105 @@ TEST_F(ResourceMetadataTest, RenameEntry) { TEST_F(ResourceMetadataTest, RefreshEntry) { FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; // Get file9. - entry_proto = GetEntryInfoByPathSync( + entry = GetEntryInfoByPathSync( base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file9")); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("file9", entry_proto->base_name()); - ASSERT_TRUE(!entry_proto->file_info().is_directory()); - EXPECT_EQ("md5:file9", entry_proto->file_specific_info().file_md5()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("file9", entry->base_name()); + ASSERT_TRUE(!entry->file_info().is_directory()); + EXPECT_EQ("md5:file9", entry->file_specific_info().file_md5()); // Rename it. - DriveEntryProto file_entry_proto(*entry_proto); - file_entry_proto.set_title("file100"); - entry_proto.reset(); + ResourceEntry file_entry(*entry); + file_entry.set_title("file100"); + entry.reset(); resource_metadata_->RefreshEntry( - file_entry_proto, + file_entry, google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file100"), drive_file_path); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("file100", entry_proto->base_name()); - ASSERT_TRUE(!entry_proto->file_info().is_directory()); - EXPECT_EQ("md5:file9", entry_proto->file_specific_info().file_md5()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("file100", entry->base_name()); + ASSERT_TRUE(!entry->file_info().is_directory()); + EXPECT_EQ("md5:file9", entry->file_specific_info().file_md5()); // Update the file md5. const std::string updated_md5("md5:updated"); - file_entry_proto = *entry_proto; - file_entry_proto.mutable_file_specific_info()->set_file_md5(updated_md5); - entry_proto.reset(); + file_entry = *entry; + file_entry.mutable_file_specific_info()->set_file_md5(updated_md5); + entry.reset(); resource_metadata_->RefreshEntry( - file_entry_proto, + file_entry, google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file100"), drive_file_path); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("file100", entry_proto->base_name()); - ASSERT_TRUE(!entry_proto->file_info().is_directory()); - EXPECT_EQ(updated_md5, entry_proto->file_specific_info().file_md5()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("file100", entry->base_name()); + ASSERT_TRUE(!entry->file_info().is_directory()); + EXPECT_EQ(updated_md5, entry->file_specific_info().file_md5()); // Make sure we get the same thing from GetEntryInfoByPath. - entry_proto = GetEntryInfoByPathSync( + entry = GetEntryInfoByPathSync( base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file100")); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("file100", entry_proto->base_name()); - ASSERT_TRUE(!entry_proto->file_info().is_directory()); - EXPECT_EQ(updated_md5, entry_proto->file_specific_info().file_md5()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("file100", entry->base_name()); + ASSERT_TRUE(!entry->file_info().is_directory()); + EXPECT_EQ(updated_md5, entry->file_specific_info().file_md5()); // Get dir2. - entry_proto = GetEntryInfoByPathSync( + entry = GetEntryInfoByPathSync( base::FilePath::FromUTF8Unsafe("drive/root/dir2")); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("dir2", entry_proto->base_name()); - ASSERT_TRUE(entry_proto->file_info().is_directory()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("dir2", entry->base_name()); + ASSERT_TRUE(entry->file_info().is_directory()); // Change the name to dir100 and change the parent to drive/dir1/dir3. - DriveEntryProto dir_entry_proto(*entry_proto); - dir_entry_proto.set_title("dir100"); - dir_entry_proto.set_parent_resource_id("resource_id:dir3"); - entry_proto.reset(); + ResourceEntry dir_entry(*entry); + dir_entry.set_title("dir100"); + dir_entry.set_parent_resource_id("resource_id:dir3"); + entry.reset(); resource_metadata_->RefreshEntry( - dir_entry_proto, + dir_entry, google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/dir100"), drive_file_path); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("dir100", entry_proto->base_name()); - EXPECT_TRUE(entry_proto->file_info().is_directory()); - EXPECT_EQ("resource_id:dir2", entry_proto->resource_id()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("dir100", entry->base_name()); + EXPECT_TRUE(entry->file_info().is_directory()); + EXPECT_EQ("resource_id:dir2", entry->resource_id()); // Make sure the children have moved over. Test file6. - entry_proto = GetEntryInfoByPathSync( + entry = GetEntryInfoByPathSync( base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/dir100/file6")); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("file6", entry_proto->base_name()); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("file6", entry->base_name()); // Make sure dir2 no longer exists. - entry_proto = GetEntryInfoByPathSync( + entry = GetEntryInfoByPathSync( base::FilePath::FromUTF8Unsafe("drive/root/dir2")); - EXPECT_FALSE(entry_proto.get()); + EXPECT_FALSE(entry.get()); // Cannot refresh root. - dir_entry_proto.Clear(); - dir_entry_proto.set_resource_id(util::kDriveGrandRootSpecialResourceId); - dir_entry_proto.set_title("new-root-name"); - dir_entry_proto.set_parent_resource_id("resource_id:dir1"); - entry_proto.reset(); + dir_entry.Clear(); + dir_entry.set_resource_id(util::kDriveGrandRootSpecialResourceId); + dir_entry.set_title("new-root-name"); + dir_entry.set_parent_resource_id("resource_id:dir1"); + entry.reset(); resource_metadata_->RefreshEntry( - dir_entry_proto, + dir_entry, google_apis::test_util::CreateCopyResultCallback( - &error, &drive_file_path, &entry_proto)); + &error, &drive_file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_INVALID_OPERATION, error); } @@ -806,7 +806,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_EmtpyMap) { // Read the directory. FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProtoVector> entries; + scoped_ptr<ResourceEntryVector> entries; entries = ReadDirectoryByPathSync(base::FilePath(kDirectoryPath)); ASSERT_TRUE(entries.get()); // "file4", "file5", "dir3" should exist in drive/dir1. @@ -817,7 +817,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_EmtpyMap) { EXPECT_EQ("file5", base_names[2]); // Get the directory. - scoped_ptr<DriveEntryProto> dir1_proto; + scoped_ptr<ResourceEntry> dir1_proto; dir1_proto = GetEntryInfoByPathSync(kDirectoryPath); ASSERT_TRUE(dir1_proto.get()); // The changestamp should be initially kTestChangestamp. @@ -826,7 +826,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_EmtpyMap) { // Update the directory with an empty map. base::FilePath file_path; - DriveEntryProtoMap entry_map; + ResourceEntryMap entry_map; resource_metadata_->RefreshDirectory( DirectoryFetchInfo(dir1_proto->resource_id(), kNewChangestamp), entry_map, @@ -856,7 +856,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_NonEmptyMap) { // Read the directory. FileError error = FILE_ERROR_FAILED; - scoped_ptr<DriveEntryProtoVector> entries; + scoped_ptr<ResourceEntryVector> entries; entries = ReadDirectoryByPathSync(kDirectoryPath); ASSERT_TRUE(entries.get()); // "file4", "file5", "dir3" should exist in drive/dir1. @@ -867,7 +867,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_NonEmptyMap) { EXPECT_EQ("file5", base_names[2]); // Get the directory dir1. - scoped_ptr<DriveEntryProto> dir1_proto; + scoped_ptr<ResourceEntry> dir1_proto; dir1_proto = GetEntryInfoByPathSync(kDirectoryPath); ASSERT_TRUE(dir1_proto.get()); // The changestamp should be initially kTestChangestamp. @@ -876,7 +876,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_NonEmptyMap) { // Get the directory dir2 (existing non-child directory). // This directory will be moved to "drive/dir1/dir2". - scoped_ptr<DriveEntryProto> dir2_proto; + scoped_ptr<ResourceEntry> dir2_proto; dir2_proto = GetEntryInfoByPathSync( base::FilePath::FromUTF8Unsafe("drive/root/dir2")); ASSERT_TRUE(dir2_proto.get()); @@ -887,7 +887,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_NonEmptyMap) { // Get the directory dir3 (existing child directory). // This directory will remain as "drive/dir1/dir3". - scoped_ptr<DriveEntryProto> dir3_proto; + scoped_ptr<ResourceEntry> dir3_proto; dir3_proto = GetEntryInfoByPathSync( base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3")); ASSERT_TRUE(dir3_proto.get()); @@ -895,17 +895,17 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_NonEmptyMap) { dir3_proto->directory_specific_info().changestamp()); // Create a map. - DriveEntryProtoMap entry_map; + ResourceEntryMap entry_map; // Add a new file to the map. - DriveEntryProto new_file; + ResourceEntry new_file; new_file.set_title("new_file"); new_file.set_resource_id("new_file_id"); new_file.set_parent_resource_id(dir1_proto->resource_id()); entry_map["new_file_id"] = new_file; // Add a new directory to the map. - DriveEntryProto new_directory; + ResourceEntry new_directory; new_directory.set_title("new_directory"); new_directory.set_resource_id("new_directory_id"); new_directory.set_parent_resource_id(dir1_proto->resource_id()); @@ -946,7 +946,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_NonEmptyMap) { EXPECT_EQ("new_file", base_names[3]); // Get the new directory. - scoped_ptr<DriveEntryProto> new_directory_proto; + scoped_ptr<ResourceEntry> new_directory_proto; new_directory_proto = GetEntryInfoByPathSync( base::FilePath::FromUTF8Unsafe("drive/root/dir1/new_directory")); ASSERT_TRUE(new_directory_proto.get()); @@ -996,13 +996,13 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_WrongParentResourceId) { const int64 kNewChangestamp = kTestChangestamp + 1; // Get the directory dir1. - scoped_ptr<DriveEntryProto> dir1_proto; + scoped_ptr<ResourceEntry> dir1_proto; dir1_proto = GetEntryInfoByPathSync(kDirectoryPath); ASSERT_TRUE(dir1_proto.get()); // Create a map and add a new file to it. - DriveEntryProtoMap entry_map; - DriveEntryProto new_file; + ResourceEntryMap entry_map; + ResourceEntry new_file; new_file.set_title("new_file"); new_file.set_resource_id("new_file_id"); // Set a random parent resource ID. This entry should not be added because @@ -1022,7 +1022,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_WrongParentResourceId) { EXPECT_EQ(kDirectoryPath, file_path); // Read the directory. Confirm that the new file is not added. - scoped_ptr<DriveEntryProtoVector> entries; + scoped_ptr<ResourceEntryVector> entries; entries = ReadDirectoryByPathSync(kDirectoryPath); ASSERT_TRUE(entries.get()); ASSERT_TRUE(entries->empty()); @@ -1030,7 +1030,7 @@ TEST_F(ResourceMetadataTest, RefreshDirectory_WrongParentResourceId) { TEST_F(ResourceMetadataTest, AddEntry) { int sequence_id = 100; - DriveEntryProto file_entry_proto = CreateDriveEntryProto( + ResourceEntry file_entry = CreateResourceEntry( sequence_id++, false, "resource_id:dir3"); FileError error = FILE_ERROR_FAILED; @@ -1038,7 +1038,7 @@ TEST_F(ResourceMetadataTest, AddEntry) { // Add to dir3. resource_metadata_->AddEntry( - file_entry_proto, + file_entry, google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); @@ -1047,11 +1047,11 @@ TEST_F(ResourceMetadataTest, AddEntry) { drive_file_path); // Add a directory. - DriveEntryProto dir_entry_proto = CreateDriveEntryProto( + ResourceEntry dir_entry = CreateResourceEntry( sequence_id++, true, "resource_id:dir1"); resource_metadata_->AddEntry( - dir_entry_proto, + dir_entry, google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); @@ -1060,11 +1060,11 @@ TEST_F(ResourceMetadataTest, AddEntry) { drive_file_path); // Add to an invalid parent. - DriveEntryProto file_entry_proto3 = CreateDriveEntryProto( + ResourceEntry file_entry3 = CreateResourceEntry( sequence_id++, false, "resource_id:invalid"); resource_metadata_->AddEntry( - file_entry_proto3, + file_entry3, google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); @@ -1072,7 +1072,7 @@ TEST_F(ResourceMetadataTest, AddEntry) { // Add an existing file. resource_metadata_->AddEntry( - file_entry_proto, + file_entry, google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); @@ -1115,21 +1115,21 @@ TEST_F(ResourceMetadataTest, GetChildDirectories) { // dir2/dir101/dir102/dir105/dir106 // dir2/dir101/dir102/dir105/dir106/dir107 int sequence_id = 100; - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata_.get(), sequence_id++, true, "resource_id:dir2")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata_.get(), sequence_id++, true, "resource_id:dir2")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata_.get(), sequence_id++, true, "resource_id:dir101")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata_.get(), sequence_id++, true, "resource_id:dir101")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata_.get(), sequence_id++, true, "resource_id:dir101")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata_.get(), sequence_id++, true, "resource_id:dir102")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata_.get(), sequence_id++, true, "resource_id:dir105")); - ASSERT_TRUE(AddDriveEntryProto( + ASSERT_TRUE(AddResourceEntry( resource_metadata_.get(), sequence_id++, true, "resource_id:dir106")); resource_metadata_->GetChildDirectories( @@ -1147,7 +1147,7 @@ TEST_F(ResourceMetadataTest, GetChildDirectories) { TEST_F(ResourceMetadataTest, Reset) { // The grand root has "root" which is not empty. - scoped_ptr<DriveEntryProtoVector> entries; + scoped_ptr<ResourceEntryVector> entries; entries = ReadDirectoryByPathSync( base::FilePath::FromUTF8Unsafe("drive/root")); ASSERT_TRUE(entries.get()); @@ -1161,7 +1161,7 @@ TEST_F(ResourceMetadataTest, Reset) { EXPECT_EQ(FILE_ERROR_OK, error); base::FilePath drive_file_path; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; // change stamp should be reset. int64 changestamp = -1; @@ -1171,18 +1171,18 @@ TEST_F(ResourceMetadataTest, Reset) { EXPECT_EQ(0, changestamp); // root should continue to exist. - entry_proto = GetEntryInfoByPathSync(base::FilePath::FromUTF8Unsafe("drive")); - ASSERT_TRUE(entry_proto.get()); - EXPECT_EQ("drive", entry_proto->base_name()); - ASSERT_TRUE(entry_proto->file_info().is_directory()); - EXPECT_EQ(util::kDriveGrandRootSpecialResourceId, entry_proto->resource_id()); + entry = GetEntryInfoByPathSync(base::FilePath::FromUTF8Unsafe("drive")); + ASSERT_TRUE(entry.get()); + EXPECT_EQ("drive", entry->base_name()); + ASSERT_TRUE(entry->file_info().is_directory()); + EXPECT_EQ(util::kDriveGrandRootSpecialResourceId, entry->resource_id()); // There is "other", which are both empty. entries = ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive")); ASSERT_TRUE(entries.get()); EXPECT_EQ(1U, entries->size()); - scoped_ptr<DriveEntryProtoVector> entries_in_other = + scoped_ptr<ResourceEntryVector> entries_in_other = ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive/other")); ASSERT_TRUE(entries_in_other.get()); EXPECT_TRUE(entries_in_other->empty()); diff --git a/chrome/browser/chromeos/drive/search_metadata.cc b/chrome/browser/chromeos/drive/search_metadata.cc index 6f31711..3377e58 100644 --- a/chrome/browser/chromeos/drive/search_metadata.cc +++ b/chrome/browser/chromeos/drive/search_metadata.cc @@ -21,7 +21,7 @@ namespace { // Used to sort the result canididates per the last accessed/modified time. The // recently accessed/modified files come first. -bool CompareByTimestamp(const DriveEntryProto& a, const DriveEntryProto& b) { +bool CompareByTimestamp(const ResourceEntry& a, const ResourceEntry& b) { const PlatformFileInfoProto& a_file_info = a.file_info(); const PlatformFileInfoProto& b_file_info = b.file_info(); @@ -37,7 +37,7 @@ bool CompareByTimestamp(const DriveEntryProto& a, const DriveEntryProto& b) { struct MetadataSearchResultComparator { bool operator()(const MetadataSearchResult* a, const MetadataSearchResult* b) const { - return CompareByTimestamp(a->entry_proto, b->entry_proto); + return CompareByTimestamp(a->entry, b->entry); } }; @@ -77,7 +77,7 @@ class ScopedPriorityQueue { // documents are skipped. If SEARCH_METADATA_EXCLUDE_DIRECTORIES is requested, // the directories are skipped. If SEARCH_METADATA_SHARED_WITH_ME is requested, // only the entries with shared-with-me label will be tested. -bool IsEligibleEntry(const DriveEntryProto& entry, int options) { +bool IsEligibleEntry(const ResourceEntry& entry, int options) { if ((options & SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS) && entry.file_specific_info().is_hosted_document()) return false; @@ -130,7 +130,7 @@ class SearchMetadataHelper { private: // Adds entry to the result when appropriate. - void MaybeAddEntryToResult(const DriveEntryProto& entry) { + void MaybeAddEntryToResult(const ResourceEntry& entry) { DCHECK_GE(at_most_num_matches_, static_cast<int>(result_candidates_.size())); @@ -144,7 +144,7 @@ class SearchMetadataHelper { // Make space for |entry| when appropriate. if (static_cast<int>(result_candidates_.size()) == at_most_num_matches_ && - CompareByTimestamp(entry, result_candidates_.top()->entry_proto)) + CompareByTimestamp(entry, result_candidates_.top()->entry)) result_candidates_.pop(); // Add |entry| to the result when appropriate. @@ -161,7 +161,7 @@ class SearchMetadataHelper { return; } resource_metadata_->GetEntryInfoByResourceId( - result_candidates_.top()->entry_proto.resource_id(), + result_candidates_.top()->entry.resource_id(), base::Bind(&SearchMetadataHelper::ContinuePrepareResults, weak_ptr_factory_.GetWeakPtr())); } @@ -169,7 +169,7 @@ class SearchMetadataHelper { // Implements PrepareResults(). void ContinuePrepareResults(FileError error, const base::FilePath& path, - scoped_ptr<DriveEntryProto> unused_entry) { + scoped_ptr<ResourceEntry> unused_entry) { if (error != FILE_ERROR_OK) { Finish(error); return; diff --git a/chrome/browser/chromeos/drive/search_metadata_unittest.cc b/chrome/browser/chromeos/drive/search_metadata_unittest.cc index e482921..d221804 100644 --- a/chrome/browser/chromeos/drive/search_metadata_unittest.cc +++ b/chrome/browser/chromeos/drive/search_metadata_unittest.cc @@ -48,7 +48,7 @@ class SearchMetadataTest : public testing::Test { } void AddEntriesToMetadata() { - DriveEntryProto entry; + ResourceEntry entry; AddEntryToMetadata(GetDirectoryEntry( util::kDriveMyDriveRootDirName, "root", 100, @@ -79,11 +79,11 @@ class SearchMetadataTest : public testing::Test { AddEntryToMetadata(entry); } - DriveEntryProto GetFileEntry(const std::string& name, + ResourceEntry GetFileEntry(const std::string& name, const std::string& resource_id, int64 last_accessed, const std::string& parent_resource_id) { - DriveEntryProto entry; + ResourceEntry entry; entry.set_title(name); entry.set_resource_id(resource_id); entry.set_parent_resource_id(parent_resource_id); @@ -91,11 +91,11 @@ class SearchMetadataTest : public testing::Test { return entry; } - DriveEntryProto GetDirectoryEntry(const std::string& name, + ResourceEntry GetDirectoryEntry(const std::string& name, const std::string& resource_id, int64 last_accessed, const std::string& parent_resource_id) { - DriveEntryProto entry; + ResourceEntry entry; entry.set_title(name); entry.set_resource_id(resource_id); entry.set_parent_resource_id(parent_resource_id); @@ -104,7 +104,7 @@ class SearchMetadataTest : public testing::Test { return entry; } - void AddEntryToMetadata(const DriveEntryProto& entry) { + void AddEntryToMetadata(const ResourceEntry& entry) { FileError error = FILE_ERROR_FAILED; base::FilePath drive_path; @@ -190,8 +190,8 @@ TEST_F(SearchMetadataTest, SearchMetadata_RegularFiles) { ASSERT_EQ(2U, result->size()); // The results should be sorted by the last accessed time in descending order. - EXPECT_EQ(6, result->at(0).entry_proto.file_info().last_accessed()); - EXPECT_EQ(2, result->at(1).entry_proto.file_info().last_accessed()); + EXPECT_EQ(6, result->at(0).entry.file_info().last_accessed()); + EXPECT_EQ(2, result->at(1).entry.file_info().last_accessed()); // All base names should contain "File". EXPECT_EQ("drive/root/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt", diff --git a/chrome/browser/chromeos/drive/stale_cache_files_remover.cc b/chrome/browser/chromeos/drive/stale_cache_files_remover.cc index 9bcb2918..8d9b145 100644 --- a/chrome/browser/chromeos/drive/stale_cache_files_remover.cc +++ b/chrome/browser/chromeos/drive/stale_cache_files_remover.cc @@ -68,7 +68,7 @@ void StaleCacheFilesRemover::RemoveCacheIfNecessary( const std::string& cache_md5, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // The entry is not found in the file system. @@ -78,9 +78,9 @@ void StaleCacheFilesRemover::RemoveCacheIfNecessary( } // The entry is found but the MD5 does not match. - DCHECK(entry_proto.get()); - if (!entry_proto->has_file_specific_info() || - cache_md5 != entry_proto->file_specific_info().file_md5()) { + DCHECK(entry.get()); + if (!entry->has_file_specific_info() || + cache_md5 != entry->file_specific_info().file_md5()) { cache_->Remove(resource_id, base::Bind(&EmitErrorLog, resource_id)); return; } diff --git a/chrome/browser/chromeos/drive/stale_cache_files_remover.h b/chrome/browser/chromeos/drive/stale_cache_files_remover.h index c69d87d..751cf80 100644 --- a/chrome/browser/chromeos/drive/stale_cache_files_remover.h +++ b/chrome/browser/chromeos/drive/stale_cache_files_remover.h @@ -47,7 +47,7 @@ class StaleCacheFilesRemover : public FileSystemObserver { const std::string& cache_md5, FileError error, const base::FilePath& drive_file_path, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); FileCache* cache_; // Not owned. FileSystemInterface* file_system_; // Not owned. 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 9a35c23..fd89da9 100644 --- a/chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc +++ b/chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc @@ -136,14 +136,14 @@ TEST_F(StaleCacheFilesRemoverTest, RemoveStaleCacheFiles) { EXPECT_TRUE(success); base::FilePath unused; - scoped_ptr<DriveEntryProto> entry_proto; + scoped_ptr<ResourceEntry> entry; file_system_->GetEntryInfoByResourceId( resource_id, google_apis::test_util::CreateCopyResultCallback( - &error, &unused, &entry_proto)); + &error, &unused, &entry)); google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); - EXPECT_FALSE(entry_proto.get()); + EXPECT_FALSE(entry.get()); // Load a root feed again to kick the StaleCacheFilesRemover. file_system_->Reload(); diff --git a/chrome/browser/chromeos/drive/sync_client.cc b/chrome/browser/chromeos/drive/sync_client.cc index 8701deb..9be0cb4 100644 --- a/chrome/browser/chromeos/drive/sync_client.cc +++ b/chrome/browser/chromeos/drive/sync_client.cc @@ -246,10 +246,10 @@ void SyncClient::OnGetEntryInfoByResourceId( const FileCacheEntry& cache_entry, FileError error, const base::FilePath& /* drive_file_path */, - scoped_ptr<DriveEntryProto> entry_proto) { + scoped_ptr<ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (entry_proto.get() && !entry_proto->has_file_specific_info()) + if (entry.get() && !entry->has_file_specific_info()) error = FILE_ERROR_NOT_FOUND; if (error != FILE_ERROR_OK) { @@ -260,7 +260,7 @@ void SyncClient::OnGetEntryInfoByResourceId( // If MD5s don't match, it indicates the local cache file is stale, unless // the file is dirty (the MD5 is "local"). We should never re-fetch the // file when we have a locally modified version. - if (entry_proto->file_specific_info().file_md5() != cache_entry.md5() && + if (entry->file_specific_info().file_md5() != cache_entry.md5() && !cache_entry.is_dirty()) { cache_->Remove(resource_id, base::Bind(&SyncClient::OnRemove, diff --git a/chrome/browser/chromeos/drive/sync_client.h b/chrome/browser/chromeos/drive/sync_client.h index dae1d43..8382cf0 100644 --- a/chrome/browser/chromeos/drive/sync_client.h +++ b/chrome/browser/chromeos/drive/sync_client.h @@ -17,10 +17,10 @@ namespace drive { +class FileCache; class FileCacheEntry; -class DriveEntryProto; class FileSystemInterface; -class FileCache; +class ResourceEntry; // The SyncClient is used to synchronize pinned files on Drive and the // cache on the local drive. The sync client works as follows. @@ -109,7 +109,7 @@ class SyncClient : public FileSystemObserver, const FileCacheEntry& cache_entry, FileError error, const base::FilePath& file_path, - scoped_ptr<DriveEntryProto> entry_proto); + scoped_ptr<ResourceEntry> entry); // Called when a cache entry is obtained. void OnGetCacheEntry(const std::string& resource_id, diff --git a/chrome/browser/chromeos/drive/sync_client_unittest.cc b/chrome/browser/chromeos/drive/sync_client_unittest.cc index 78bba3b..1395a11 100644 --- a/chrome/browser/chromeos/drive/sync_client_unittest.cc +++ b/chrome/browser/chromeos/drive/sync_client_unittest.cc @@ -42,9 +42,9 @@ ACTION_P(MockUpdateFileByResourceId, error) { // Action used to set mock expectations for GetFileInfoByResourceId(). ACTION_P2(MockUpdateFileByResourceId, error, md5) { - scoped_ptr<DriveEntryProto> entry_proto(new DriveEntryProto); - entry_proto->mutable_file_specific_info()->set_file_md5(md5); - arg1.Run(error, base::FilePath(), entry_proto.Pass()); + scoped_ptr<ResourceEntry> entry(new ResourceEntry); + entry->mutable_file_specific_info()->set_file_md5(md5); + arg1.Run(error, base::FilePath(), entry.Pass()); } } // namespace @@ -177,7 +177,7 @@ class SyncClientTest : public testing::Test { // ID. // // This is used for testing StartCheckingExistingPinnedFiles(), hence we - // are only interested in the MD5 value in DriveEntryProto. + // are only interested in the MD5 value in ResourceEntry. void SetExpectationForGetFileInfoByResourceId( const std::string& resource_id, const std::string& new_md5) { diff --git a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc index 9bafdd2..9a0175d 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc @@ -364,7 +364,7 @@ void DoNothingWithBool(bool /* success */) { } void FillDriveEntryPropertiesValue( - const drive::DriveEntryProto& entry_proto, + const drive::ResourceEntry& entry_proto, DictionaryValue* property_dict) { property_dict->SetBoolean("sharedWithMe", entry_proto.shared_with_me()); @@ -2346,7 +2346,7 @@ bool GetDriveEntryPropertiesFunction::RunImpl() { void GetDriveEntryPropertiesFunction::OnGetFileInfo( drive::FileError error, - scoped_ptr<drive::DriveEntryProto> entry) { + scoped_ptr<drive::ResourceEntry> entry) { DCHECK(properties_); if (error != drive::FILE_ERROR_OK) { @@ -2834,7 +2834,7 @@ void SearchDriveFunction::OnSearch( entry->SetString("fileSystemRoot", file_system_url_.spec()); entry->SetString("fileFullPath", "/" + results->at(i).path.value()); entry->SetBoolean("fileIsDirectory", - results->at(i).entry_proto.file_info().is_directory()); + results->at(i).entry.file_info().is_directory()); entries->Append(entry); } @@ -2933,7 +2933,7 @@ void SearchDriveMetadataFunction::OnSearchMetadata( entry->SetString("fileSystemRoot", file_system_url_.spec()); entry->SetString("fileFullPath", "/" + results->at(i).path.value()); entry->SetBoolean("fileIsDirectory", - results->at(i).entry_proto.file_info().is_directory()); + results->at(i).entry.file_info().is_directory()); result_dict->Set("entry", entry); result_dict->SetString("highlightedBaseName", diff --git a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h index 47586e6..8b86caf 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h +++ b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h @@ -515,7 +515,7 @@ class GetDriveEntryPropertiesFunction : public FileBrowserFunction { private: void OnGetFileInfo(drive::FileError error, - scoped_ptr<drive::DriveEntryProto> entry); + scoped_ptr<drive::ResourceEntry> entry); void CacheStateReceived(bool success, const drive::FileCacheEntry& cache_entry); diff --git a/chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc b/chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc index b51228c..73023c3 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc @@ -471,7 +471,7 @@ class DriveTestVolume : public TestVolume, DCHECK(system_service_->file_system()); drive::FileError error = drive::FILE_ERROR_FAILED; - scoped_ptr<drive::DriveEntryProto> entry_proto; + scoped_ptr<drive::ResourceEntry> entry_proto; system_service_->file_system()->GetEntryInfoByPath( file_path, google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); @@ -532,7 +532,7 @@ class DriveTestVolume : public TestVolume, DCHECK(system_service_->file_system()); drive::FileError error = drive::FILE_ERROR_FAILED; - scoped_ptr<drive::DriveEntryProto> entry_proto; + scoped_ptr<drive::ResourceEntry> entry_proto; system_service_->file_system()->GetEntryInfoByPath( file_path, google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); @@ -549,7 +549,7 @@ class DriveTestVolume : public TestVolume, DCHECK(system_service_->file_system()); drive::FileError error = drive::FILE_ERROR_FAILED; - scoped_ptr<drive::DriveEntryProto> entry_proto; + scoped_ptr<drive::ResourceEntry> entry_proto; system_service_->file_system()->GetEntryInfoByPath( file_path, google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc index 2d14faf..e849fab1 100644 --- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc +++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc @@ -117,7 +117,7 @@ void GetFreeDiskSpace(const base::FilePath& home_path, // Formats |entry| into text. std::string FormatEntry(const base::FilePath& path, - const drive::DriveEntryProto& entry) { + const drive::ResourceEntry& entry) { using base::StringAppendF; using google_apis::util::FormatTimeAsString; @@ -227,13 +227,13 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { // Called when GetEntryInfoByPath() is complete. void OnGetEntryInfoByPath(const base::FilePath& path, drive::FileError error, - scoped_ptr<drive::DriveEntryProto> entry); + scoped_ptr<drive::ResourceEntry> entry); // Called when ReadDirectoryByPath() is complete. void OnReadDirectoryByPath(const base::FilePath& parent_path, drive::FileError error, bool hide_hosted_documents, - scoped_ptr<drive::DriveEntryProtoVector> entries); + scoped_ptr<drive::ResourceEntryVector> entries); // Called as the iterator for DebugInfoCollector::IterateFileCache(). void UpdateCacheEntry(const std::string& resource_id, @@ -656,7 +656,7 @@ void DriveInternalsWebUIHandler::OnGetGCacheContents( void DriveInternalsWebUIHandler::OnGetEntryInfoByPath( const base::FilePath& path, drive::FileError error, - scoped_ptr<drive::DriveEntryProto> entry) { + scoped_ptr<drive::ResourceEntry> entry) { if (error == drive::FILE_ERROR_OK) { DCHECK(entry.get()); const base::StringValue value(FormatEntry(path, *entry) + "\n"); @@ -668,13 +668,13 @@ void DriveInternalsWebUIHandler::OnReadDirectoryByPath( const base::FilePath& parent_path, drive::FileError error, bool hide_hosted_documents, - scoped_ptr<drive::DriveEntryProtoVector> entries) { + scoped_ptr<drive::ResourceEntryVector> entries) { if (error == drive::FILE_ERROR_OK) { DCHECK(entries.get()); std::string file_system_as_text; for (size_t i = 0; i < entries->size(); ++i) { - const drive::DriveEntryProto& entry = (*entries)[i]; + const drive::ResourceEntry& entry = (*entries)[i]; const base::FilePath current_path = parent_path.Append( base::FilePath::FromUTF8Unsafe(entry.base_name())); diff --git a/chrome/browser/ui/webui/feedback_ui.cc b/chrome/browser/ui/webui/feedback_ui.cc index 77689ca..1d09ab9 100644 --- a/chrome/browser/ui/webui/feedback_ui.cc +++ b/chrome/browser/ui/webui/feedback_ui.cc @@ -106,8 +106,8 @@ std::string GetUserEmail() { return manager->GetLoggedInUser()->display_email(); } -bool ScreenshotDriveTimestampComp(const drive::DriveEntryProto& entry1, - const drive::DriveEntryProto& entry2) { +bool ScreenshotDriveTimestampComp(const drive::ResourceEntry& entry1, + const drive::ResourceEntry& entry2) { return entry1.file_info().last_modified() > entry2.file_info().last_modified(); } @@ -117,16 +117,16 @@ void ReadDirectoryCallback(size_t max_saved, base::Closure callback, drive::FileError error, bool hide_hosted_documents, - scoped_ptr<drive::DriveEntryProtoVector> entries) { + scoped_ptr<drive::ResourceEntryVector> entries) { if (error != drive::FILE_ERROR_OK) { callback.Run(); return; } size_t max_scan = std::min(kMaxNumScanFiles, entries->size()); - std::vector<drive::DriveEntryProto> screenshot_entries; + std::vector<drive::ResourceEntry> screenshot_entries; for (size_t i = 0; i < max_scan; ++i) { - const drive::DriveEntryProto& entry = (*entries)[i]; + const drive::ResourceEntry& entry = (*entries)[i]; if (StartsWithASCII(entry.base_name(), ScreenshotSource::kScreenshotPrefix, true) && EndsWith(entry.base_name(), @@ -141,7 +141,7 @@ void ReadDirectoryCallback(size_t max_saved, screenshot_entries.end(), ScreenshotDriveTimestampComp); for (size_t i = 0; i < sort_size; ++i) { - const drive::DriveEntryProto& entry = screenshot_entries[i]; + const drive::ResourceEntry& entry = screenshot_entries[i]; saved_screenshots->push_back( std::string(ScreenshotSource::kScreenshotUrlRoot) + std::string(ScreenshotSource::kScreenshotSaved) + |