diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-23 06:57:49 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-23 06:57:49 +0000 |
commit | 78a158bedcd8d5d91995e1e4fe4a0b7b9e7f6b9d (patch) | |
tree | f67332b2b1499bc27d63a1d11cb86ec5b692037c | |
parent | e4326b7dc0d72a5a12d806191693181442e22dbf (diff) | |
download | chromium_src-78a158bedcd8d5d91995e1e4fe4a0b7b9e7f6b9d.zip chromium_src-78a158bedcd8d5d91995e1e4fe4a0b7b9e7f6b9d.tar.gz chromium_src-78a158bedcd8d5d91995e1e4fe4a0b7b9e7f6b9d.tar.bz2 |
drive: Rename DriveFileError to FileError
This looked like drive::DriveFileError outside of 'c/b/chromeos/drive'
which was redundant. Inside 'c/b/chromeos/drive', FileError is sufficient.
This is a very mechanical change as shown below:
cd chrome/browser/chromeos/drive
git mv drive_file_error.h file_errors.h
git mv drive_file_error.cc file_errors.cc
cd -
tools/git/mass-rename.sh
tools/git/for-all-touched-files.py -c "tools/sort-headers.py -f [[FILENAME]]"
cd chrome
perl -i -pe 's/DRIVE_FILE_ERROR_/FILE_ERROR_/g' **/*.{cc,h}
perl -i -pe 's/DRIVE_FILE_OK/FILE_ERROR_OK/g' **/*.{cc,h}
perl -i -pe 's/DriveFileError/FileError/g' **/*.{cc,h}
also edit chrome_browser_chromeos.gypi manually to sort file names
BUG=231807
TEST=none; just global renames
Review URL: https://codereview.chromium.org/14420002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195744 0039d316-1c4b-4281-b951-d872f2087c98
84 files changed, 1338 insertions, 1338 deletions
diff --git a/chrome/browser/chromeos/drive/change_list_loader.cc b/chrome/browser/chromeos/drive/change_list_loader.cc index 7d931bf..1b53d69 100644 --- a/chrome/browser/chromeos/drive/change_list_loader.cc +++ b/chrome/browser/chromeos/drive/change_list_loader.cc @@ -73,7 +73,7 @@ void ChangeListLoader::LoadIfNeeded( if (loaded_ && (directory_fetch_info.empty() || !IsRefreshing())) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, - base::Bind(callback, DRIVE_FILE_OK)); + base::Bind(callback, FILE_ERROR_OK)); return; } Load(directory_fetch_info, callback); @@ -179,7 +179,7 @@ void ChangeListLoader::DoInitialLoad( if (local_changestamp > 0) { // The local data is usable. Flush callbacks to tell loading was successful. - OnChangeListLoadComplete(DRIVE_FILE_OK); + OnChangeListLoadComplete(FILE_ERROR_OK); // Continues to load from server in background. // Put dummy callbacks to indicate that fetching is still continuing. @@ -220,10 +220,10 @@ void ChangeListLoader::DoUpdateLoad( } } -void ChangeListLoader::OnChangeListLoadComplete(DriveFileError error) { +void ChangeListLoader::OnChangeListLoadComplete(FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!loaded_ && error == DRIVE_FILE_OK) { + if (!loaded_ && error == FILE_ERROR_OK) { loaded_ = true; FOR_EACH_OBSERVER(ChangeListLoaderObserver, observers_, @@ -244,10 +244,10 @@ void ChangeListLoader::OnChangeListLoadComplete(DriveFileError error) { void ChangeListLoader::OnDirectoryLoadComplete( const DirectoryFetchInfo& directory_fetch_info, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DVLOG_IF(1, error == DRIVE_FILE_OK) << "Fast-fetch was successful: " + DVLOG_IF(1, error == FILE_ERROR_OK) << "Fast-fetch was successful: " << directory_fetch_info.ToString(); const std::string& resource_id = directory_fetch_info.resource_id(); @@ -301,10 +301,10 @@ void ChangeListLoader::LoadFromServerIfNeededAfterGetAbout( google_apis::GDataErrorCode status, scoped_ptr<google_apis::AboutResource> about_resource) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK_EQ(util::GDataToDriveFileError(status) == DRIVE_FILE_OK, + DCHECK_EQ(util::GDataToFileError(status) == FILE_ERROR_OK, about_resource.get() != NULL); - if (util::GDataToDriveFileError(status) == DRIVE_FILE_OK) { + if (util::GDataToFileError(status) == FILE_ERROR_OK) { DCHECK(about_resource); last_known_remote_changestamp_ = about_resource->largest_change_id(); } @@ -320,7 +320,7 @@ void ChangeListLoader::LoadFromServerIfNeededAfterGetAbout( } // No changes detected, tell the client that the loading was successful. - OnChangeListLoadComplete(DRIVE_FILE_OK); + OnChangeListLoadComplete(FILE_ERROR_OK); return; } @@ -329,7 +329,7 @@ void ChangeListLoader::LoadFromServerIfNeededAfterGetAbout( // Full update needs AboutResource. If this is a full update, we should just // give up. Note that to exit from the feed loading, we always have to flush // the pending callback tasks via OnChangeListLoadComplete. - OnChangeListLoadComplete(DRIVE_FILE_ERROR_FAILED); + OnChangeListLoadComplete(FILE_ERROR_FAILED); return; } @@ -356,14 +356,14 @@ void ChangeListLoader::LoadChangeListFromServerAfterLoadDirectory( const DirectoryFetchInfo& directory_fetch_info, scoped_ptr<google_apis::AboutResource> about_resource, int64 start_changestamp, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { // The directory fast-fetch succeeded. Runs the callbacks waiting for the // directory loading. If failed, do not flush so they're run after the // change list loading is complete. - OnDirectoryLoadComplete(directory_fetch_info, DRIVE_FILE_OK); + OnDirectoryLoadComplete(directory_fetch_info, FILE_ERROR_OK); } LoadChangeListFromServer(about_resource.Pass(), start_changestamp); } @@ -415,8 +415,8 @@ void ChangeListLoader::OnGetResourceList( base::TimeTicks::Now() - start_time); } - DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { callback.Run(ScopedVector<ChangeList>(), error); return; } @@ -444,17 +444,17 @@ void ChangeListLoader::OnGetResourceList( base::TimeTicks::Now() - start_time); // Run the callback so the client can process the retrieved feeds. - callback.Run(change_lists.Pass(), DRIVE_FILE_OK); + callback.Run(change_lists.Pass(), FILE_ERROR_OK); } void ChangeListLoader::UpdateMetadataFromFeedAfterLoadFromServer( scoped_ptr<google_apis::AboutResource> about_resource, bool is_delta_feed, ScopedVector<ChangeList> change_lists, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { OnChangeListLoadComplete(error); return; } @@ -469,7 +469,7 @@ void ChangeListLoader::UpdateMetadataFromFeedAfterLoadFromServer( void ChangeListLoader::OnUpdateFromFeed() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - OnChangeListLoadComplete(DRIVE_FILE_OK); + OnChangeListLoadComplete(FILE_ERROR_OK); FOR_EACH_OBSERVER(ChangeListLoaderObserver, observers_, @@ -484,7 +484,7 @@ void ChangeListLoader::LoadDirectoryFromServerAfterGetAbout( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (util::GDataToDriveFileError(status) == DRIVE_FILE_OK) { + if (util::GDataToFileError(status) == FILE_ERROR_OK) { DCHECK(about_resource); last_known_remote_changestamp_ = about_resource->largest_change_id(); } @@ -511,7 +511,7 @@ void ChangeListLoader::CheckChangestampAndLoadDirectoryIfNeeed( // yet. In that case we conservatively assume that we need to fetch. if (last_known_remote_changestamp_ > 0 && directory_changestamp >= last_known_remote_changestamp_) { - callback.Run(DRIVE_FILE_OK); + callback.Run(FILE_ERROR_OK); return; } @@ -538,7 +538,7 @@ void ChangeListLoader::DoLoadDirectoryFromServer( util::kDriveOtherDirSpecialResourceId) { // Load for a <other> directory is meaningless in the server. // Let it succeed and use what we have locally. - callback.Run(DRIVE_FILE_OK); + callback.Run(FILE_ERROR_OK); return; } @@ -579,16 +579,16 @@ void ChangeListLoader::DoLoadGrandRootDirectoryFromServerAfterGetEntryInfoByPath( const DirectoryFetchInfo& directory_fetch_info, const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); DCHECK_EQ(directory_fetch_info.resource_id(), util::kDriveGrandRootSpecialResourceId); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { // MyDrive root already exists. Just return success. - callback.Run(DRIVE_FILE_OK); + callback.Run(FILE_ERROR_OK); return; } @@ -612,8 +612,8 @@ void ChangeListLoader::DoLoadGrandRootDirectoryFromServerAfterGetAboutResource( DCHECK_EQ(directory_fetch_info.resource_id(), util::kDriveGrandRootSpecialResourceId); - DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -639,15 +639,15 @@ void ChangeListLoader::DoLoadDirectoryFromServerAfterLoad( const DirectoryFetchInfo& directory_fetch_info, const FileOperationCallback& callback, ScopedVector<ChangeList> change_lists, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); DCHECK(!directory_fetch_info.empty()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { LOG(ERROR) << "Failed to load directory: " << directory_fetch_info.resource_id() - << ": " << DriveFileErrorToString(error); + << ": " << FileErrorToString(error); callback.Run(error); return; } @@ -668,7 +668,7 @@ void ChangeListLoader::DoLoadDirectoryFromServerAfterLoad( void ChangeListLoader::DoLoadDirectoryFromServerAfterRefresh( const DirectoryFetchInfo& directory_fetch_info, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& directory_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -676,7 +676,7 @@ void ChangeListLoader::DoLoadDirectoryFromServerAfterRefresh( DVLOG(1) << "Directory loaded: " << directory_fetch_info.ToString(); callback.Run(error); // Also notify the observers. - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { FOR_EACH_OBSERVER(ChangeListLoaderObserver, observers_, OnDirectoryChanged(directory_path)); } @@ -686,8 +686,8 @@ void ChangeListLoader::OnGetAppList(google_apis::GDataErrorCode status, scoped_ptr<google_apis::AppList> app_list) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) + FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) return; if (app_list.get()) @@ -701,8 +701,8 @@ void ChangeListLoader::SearchFromServerAfterGetResourceList( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { callback.Run(ScopedVector<ChangeList>(), error); return; } @@ -711,7 +711,7 @@ void ChangeListLoader::SearchFromServerAfterGetResourceList( ScopedVector<ChangeList> change_lists; change_lists.push_back(new ChangeList(*resource_list)); - callback.Run(change_lists.Pass(), DRIVE_FILE_OK); + callback.Run(change_lists.Pass(), FILE_ERROR_OK); } void ChangeListLoader::NotifyDirectoryChangedAfterApplyFeed( diff --git a/chrome/browser/chromeos/drive/change_list_loader.h b/chrome/browser/chromeos/drive/change_list_loader.h index b018eb5..803e1ab 100644 --- a/chrome/browser/chromeos/drive/change_list_loader.h +++ b/chrome/browser/chromeos/drive/change_list_loader.h @@ -33,7 +33,7 @@ class DriveWebAppsRegistry; // Callback run as a response to SearchFromServer. typedef base::Callback<void(ScopedVector<ChangeList> change_lists, - DriveFileError error)> LoadFeedListCallback; + FileError error)> LoadFeedListCallback; // ChangeListLoader is used to load feeds from WAPI (codename for // Documents List API) or Google Drive API and load the cached metadata. @@ -127,13 +127,13 @@ class ChangeListLoader { // Part of Load(). // This function should be called when the change list load is complete. // Flushes the callbacks for change list loading and all directory loading. - void OnChangeListLoadComplete(DriveFileError error); + void OnChangeListLoadComplete(FileError error); // Part of Load(). // This function should be called when the directory load is complete. // Flushes the callbacks waiting for the directory to be loaded. void OnDirectoryLoadComplete(const DirectoryFetchInfo& directory_fetch_info, - DriveFileError error); + FileError error); // ================= Implementation for change list loading ================= @@ -160,7 +160,7 @@ class ChangeListLoader { const DirectoryFetchInfo& directory_fetch_info, scoped_ptr<google_apis::AboutResource> about_resource, int64 start_changestamp, - DriveFileError error); + FileError error); // Part of LoadFromServerIfNeeded(). // Starts loading the change list since |start_changestamp|, or the full @@ -186,7 +186,7 @@ class ChangeListLoader { scoped_ptr<google_apis::AboutResource> about_resource, bool is_delta_feed, ScopedVector<ChangeList> change_lists, - DriveFileError error); + FileError error); // Part of LoadFromServerIfNeeded(). // Called when UpdateMetadataFromFeedAfterLoadFromServer is finished. @@ -222,7 +222,7 @@ class ChangeListLoader { void DoLoadGrandRootDirectoryFromServerAfterGetEntryInfoByPath( const DirectoryFetchInfo& directory_fetch_info, const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Part of DoLoadDirectoryFromServer() for the grand root ("/drive"). @@ -237,13 +237,13 @@ class ChangeListLoader { const DirectoryFetchInfo& directory_fetch_info, const FileOperationCallback& callback, ScopedVector<ChangeList> change_lists, - DriveFileError error); + FileError error); // Part of DoLoadDirectoryFromServer(). void DoLoadDirectoryFromServerAfterRefresh( const DirectoryFetchInfo& directory_fetch_info, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& directory_path); // ================= Implementation for other stuff ================= diff --git a/chrome/browser/chromeos/drive/change_list_processor.cc b/chrome/browser/chromeos/drive/change_list_processor.cc index 9b357b4..8b564e9 100644 --- a/chrome/browser/chromeos/drive/change_list_processor.cc +++ b/chrome/browser/chromeos/drive/change_list_processor.cc @@ -23,11 +23,11 @@ namespace { // Callback for DriveResourceMetadata::SetLargestChangestamp. // Runs |on_complete_callback|. |on_complete_callback| must not be null. void RunOnCompleteCallback(const base::Closure& on_complete_callback, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!on_complete_callback.is_null()); - DLOG_IF(ERROR, error != DRIVE_FILE_OK) << "SetLargestChangeStamp failed: " - << DriveFileErrorToString(error); + DLOG_IF(ERROR, error != FILE_ERROR_OK) << "SetLargestChangeStamp failed: " + << FileErrorToString(error); on_complete_callback.Run(); } @@ -210,12 +210,12 @@ void ChangeListProcessor::ApplyEntryProto(const DriveEntryProto& entry_proto) { void ChangeListProcessor::ContinueApplyEntryProto( const DriveEntryProto& entry_proto, - DriveFileError error, + FileError error, const base::FilePath& file_path, scoped_ptr<DriveEntryProto> old_entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { if (entry_proto.deleted()) { // Deleted file/directory. RemoveEntryFromParent(entry_proto, file_path); @@ -223,7 +223,7 @@ void ChangeListProcessor::ContinueApplyEntryProto( // Entry exists and needs to be refreshed. RefreshEntry(entry_proto, file_path); } - } else if (error == DRIVE_FILE_ERROR_NOT_FOUND && !entry_proto.deleted()) { + } else if (error == FILE_ERROR_NOT_FOUND && !entry_proto.deleted()) { // Adding a new entry. AddEntry(entry_proto); } else { @@ -243,13 +243,13 @@ void ChangeListProcessor::AddEntry(const DriveEntryProto& entry_proto) { } void ChangeListProcessor::NotifyForAddEntry(bool is_directory, - DriveFileError error, + FileError error, const base::FilePath& file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DVLOG(1) << "NotifyForAddEntry " << file_path.value() << ", error = " - << DriveFileErrorToString(error); - if (error == DRIVE_FILE_OK) { + << FileErrorToString(error); + if (error == FILE_ERROR_OK) { // Notify if a directory has been created. if (is_directory) changed_dirs_.insert(file_path); @@ -301,12 +301,12 @@ void ChangeListProcessor::NotifyForRemoveEntryFromParent( bool is_directory, const base::FilePath& file_path, const std::set<base::FilePath>& child_directories, - DriveFileError error, + FileError error, const base::FilePath& parent_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DVLOG(1) << "NotifyForRemoveEntryFromParent " << file_path.value(); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { // Notify parent. changed_dirs_.insert(parent_path); @@ -336,13 +336,13 @@ void ChangeListProcessor::RefreshEntry(const DriveEntryProto& entry_proto, void ChangeListProcessor::NotifyForRefreshEntry( const base::FilePath& old_file_path, - DriveFileError error, + FileError error, const base::FilePath& file_path, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DVLOG(1) << "NotifyForRefreshEntry " << file_path.value(); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { // Notify old parent. changed_dirs_.insert(old_file_path.DirName()); @@ -421,12 +421,12 @@ void ChangeListProcessor::UpdateRootEntry(const base::Closure& closure) { void ChangeListProcessor::UpdateRootEntryAfterGetEntry( const base::Closure& closure, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> root_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!closure.is_null()); - if (error != DRIVE_FILE_OK) { + 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"; closure.Run(); @@ -447,12 +447,12 @@ void ChangeListProcessor::UpdateRootEntryAfterGetEntry( void ChangeListProcessor::UpdateRootEntryAfterRefreshEntry( const base::Closure& closure, - DriveFileError error, + FileError error, const base::FilePath& /* root_path */, scoped_ptr<DriveEntryProto> /* root_proto */) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!closure.is_null()); - LOG_IF(WARNING, error != DRIVE_FILE_OK) << "Failed to refresh root directory"; + LOG_IF(WARNING, error != FILE_ERROR_OK) << "Failed to refresh root directory"; closure.Run(); } diff --git a/chrome/browser/chromeos/drive/change_list_processor.h b/chrome/browser/chromeos/drive/change_list_processor.h index 03b8313..353cfa3 100644 --- a/chrome/browser/chromeos/drive/change_list_processor.h +++ b/chrome/browser/chromeos/drive/change_list_processor.h @@ -14,7 +14,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/google_apis/drive_api_parser.h" #include "googleurl/src/gurl.h" @@ -109,7 +109,7 @@ class ChangeListProcessor { // DriveResourceMetadata::GetEntryInfoByResourceId. void ContinueApplyEntryProto( const DriveEntryProto& entry_proto, - DriveFileError error, + FileError error, const base::FilePath& file_path, scoped_ptr<DriveEntryProto> old_entry_proto); @@ -122,7 +122,7 @@ class ChangeListProcessor { // Callback for DriveResourceMetadata::AddEntry. void NotifyForAddEntry(bool is_directory, - DriveFileError error, + FileError error, const base::FilePath& file_path); // Removes entry pointed to by |resource_id| from its parent. Updates @@ -143,7 +143,7 @@ class ChangeListProcessor { bool is_directory, const base::FilePath& file_path, const std::set<base::FilePath>& child_directories, - DriveFileError error, + FileError error, const base::FilePath& parent_path); // Refreshes DriveResourceMetadata entry that has the same resource_id as @@ -154,7 +154,7 @@ class ChangeListProcessor { // Callback for DriveResourceMetadata::RefreshEntry. void NotifyForRefreshEntry( const base::FilePath& old_file_path, - DriveFileError error, + FileError error, const base::FilePath& file_path, scoped_ptr<DriveEntryProto> entry_proto); @@ -167,14 +167,14 @@ class ChangeListProcessor { // DriveResourceMetadata::GetEntryInfoByPath is complete. Updates the root // proto, and refreshes the root entry with the proto. void UpdateRootEntryAfterGetEntry(const base::Closure& closure, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> root_proto); // Part of UpdateRootEntry(). Called after // DriveResourceMetadata::RefreshEntry() is complete. Calls OnComplete() to // finish the change list processing. void UpdateRootEntryAfterRefreshEntry(const base::Closure& closure, - DriveFileError error, + FileError error, const base::FilePath& root_path, scoped_ptr<DriveEntryProto> root_proto); diff --git a/chrome/browser/chromeos/drive/drive_cache.cc b/chrome/browser/chromeos/drive/drive_cache.cc index 489bdf9..d072f47 100644 --- a/chrome/browser/chromeos/drive/drive_cache.cc +++ b/chrome/browser/chromeos/drive/drive_cache.cc @@ -158,7 +158,7 @@ void DeleteFilesSelectively(const base::FilePath& path_to_delete_pattern, // Used to implement GetFile, MarkAsMounted. void RunGetFileFromCacheCallback( const GetFileFromCacheCallback& callback, - scoped_ptr<std::pair<DriveFileError, base::FilePath> > result) { + scoped_ptr<std::pair<FileError, base::FilePath> > result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); DCHECK(result.get()); @@ -554,7 +554,7 @@ scoped_ptr<DriveCache::GetFileResult> DriveCache::GetFileOnBlockingPool( DriveCacheEntry cache_entry; if (!GetCacheEntryOnBlockingPool(resource_id, md5, &cache_entry) || !cache_entry.is_present()) { - result->first = DRIVE_FILE_ERROR_NOT_FOUND; + result->first = FILE_ERROR_NOT_FOUND; return result.Pass(); } @@ -566,7 +566,7 @@ scoped_ptr<DriveCache::GetFileResult> DriveCache::GetFileOnBlockingPool( } else { file_origin = CACHED_FILE_FROM_SERVER; } - result->first = DRIVE_FILE_OK; + result->first = FILE_ERROR_OK; result->second = GetCacheFilePath(resource_id, md5, GetSubDirectoryType(cache_entry), @@ -574,7 +574,7 @@ scoped_ptr<DriveCache::GetFileResult> DriveCache::GetFileOnBlockingPool( return result.Pass(); } -DriveFileError DriveCache::StoreOnBlockingPool( +FileError DriveCache::StoreOnBlockingPool( const std::string& resource_id, const std::string& md5, const base::FilePath& source_path, @@ -585,11 +585,11 @@ DriveFileError DriveCache::StoreOnBlockingPool( if (file_operation_type == FILE_OPERATION_COPY) { if (!file_util::GetFileSize(source_path, &file_size)) { LOG(WARNING) << "Couldn't get file size for: " << source_path.value(); - return DRIVE_FILE_ERROR_FAILED; + return FILE_ERROR_FAILED; } } if (!FreeDiskSpaceOnBlockingPoolIfNeededFor(file_size)) - return DRIVE_FILE_ERROR_NO_SPACE; + return FILE_ERROR_NO_SPACE; base::FilePath symlink_path; CacheSubDirectoryType sub_dir_type = CACHE_TYPE_TMP; @@ -604,7 +604,7 @@ DriveFileError DriveCache::StoreOnBlockingPool( << (cache_entry.is_dirty() ? "dirty" : "mounted") << " file: res_id=" << resource_id << ", md5=" << md5; - return DRIVE_FILE_ERROR_IN_USE; + return FILE_ERROR_IN_USE; } if (cache_entry.is_pinned()) @@ -655,11 +655,11 @@ DriveFileError DriveCache::StoreOnBlockingPool( metadata_->AddOrUpdateCacheEntry(resource_id, cache_entry); } - return success ? DRIVE_FILE_OK : DRIVE_FILE_ERROR_FAILED; + return success ? FILE_ERROR_OK : FILE_ERROR_FAILED; } -DriveFileError DriveCache::PinOnBlockingPool(const std::string& resource_id, - const std::string& md5) { +FileError DriveCache::PinOnBlockingPool(const std::string& resource_id, + const std::string& md5) { AssertOnSequencedWorkerPool(); bool is_persistent = true; @@ -676,7 +676,7 @@ DriveFileError DriveCache::PinOnBlockingPool(const std::string& resource_id, // - don't need to move the file. if (!cache_entry.is_present()) { DCHECK(cache_entry.is_pinned()); - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } // File exists, move it to persistent dir. // Gets the current path of the file in cache. @@ -689,7 +689,7 @@ DriveFileError DriveCache::PinOnBlockingPool(const std::string& resource_id, CACHE_TYPE_PERSISTENT, CACHED_FILE_FROM_SERVER); if (!MoveFile(source_path, dest_path)) - return DRIVE_FILE_ERROR_FAILED; + return FILE_ERROR_FAILED; } } @@ -698,11 +698,11 @@ DriveFileError DriveCache::PinOnBlockingPool(const std::string& resource_id, cache_entry.set_is_pinned(true); cache_entry.set_is_persistent(is_persistent); metadata_->AddOrUpdateCacheEntry(resource_id, cache_entry); - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } -DriveFileError DriveCache::UnpinOnBlockingPool(const std::string& resource_id, - const std::string& md5) { +FileError DriveCache::UnpinOnBlockingPool(const std::string& resource_id, + const std::string& md5) { AssertOnSequencedWorkerPool(); // Unpinning a file means its entry must exist in cache. @@ -711,7 +711,7 @@ DriveFileError DriveCache::UnpinOnBlockingPool(const std::string& resource_id, LOG(WARNING) << "Can't unpin a file that wasn't pinned or cached: res_id=" << resource_id << ", md5=" << md5; - return DRIVE_FILE_ERROR_NOT_FOUND; + return FILE_ERROR_NOT_FOUND; } CacheSubDirectoryType sub_dir_type = CACHE_TYPE_TMP; @@ -735,7 +735,7 @@ DriveFileError DriveCache::UnpinOnBlockingPool(const std::string& resource_id, CACHE_TYPE_TMP, CACHED_FILE_FROM_SERVER); if (!MoveFile(source_path, dest_path)) - return DRIVE_FILE_ERROR_FAILED; + return FILE_ERROR_FAILED; } } @@ -749,7 +749,7 @@ DriveFileError DriveCache::UnpinOnBlockingPool(const std::string& resource_id, // Remove the existing entry if we are unpinning a non-present file. metadata_->RemoveCacheEntry(resource_id); } - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } scoped_ptr<DriveCache::GetFileResult> DriveCache::MarkAsMountedOnBlockingPool( @@ -762,12 +762,12 @@ scoped_ptr<DriveCache::GetFileResult> DriveCache::MarkAsMountedOnBlockingPool( // Get cache entry associated with the resource_id and md5 DriveCacheEntry cache_entry; if (!GetCacheEntryOnBlockingPool(resource_id, md5, &cache_entry)) { - result->first = DRIVE_FILE_ERROR_NOT_FOUND; + result->first = FILE_ERROR_NOT_FOUND; return result.Pass(); } if (cache_entry.is_mounted()) { - result->first = DRIVE_FILE_ERROR_INVALID_OPERATION; + result->first = FILE_ERROR_INVALID_OPERATION; return result.Pass(); } @@ -792,12 +792,12 @@ scoped_ptr<DriveCache::GetFileResult> DriveCache::MarkAsMountedOnBlockingPool( cache_entry.set_is_persistent(true); metadata_->AddOrUpdateCacheEntry(resource_id, cache_entry); } - result->first = success ? DRIVE_FILE_OK : DRIVE_FILE_ERROR_FAILED; + result->first = success ? FILE_ERROR_OK : FILE_ERROR_FAILED; result->second = mounted_path; return result.Pass(); } -DriveFileError DriveCache::MarkAsUnmountedOnBlockingPool( +FileError DriveCache::MarkAsUnmountedOnBlockingPool( const base::FilePath& file_path) { AssertOnSequencedWorkerPool(); DCHECK(IsUnderDriveCacheDirectory(file_path)); @@ -813,10 +813,10 @@ DriveFileError DriveCache::MarkAsUnmountedOnBlockingPool( // Get cache entry associated with the resource_id and md5 DriveCacheEntry cache_entry; if (!GetCacheEntryOnBlockingPool(resource_id, md5, &cache_entry)) - return DRIVE_FILE_ERROR_NOT_FOUND; + return FILE_ERROR_NOT_FOUND; if (!cache_entry.is_mounted()) - return DRIVE_FILE_ERROR_INVALID_OPERATION; + return FILE_ERROR_INVALID_OPERATION; // Get the subdir type and path for the unmounted state. CacheSubDirectoryType unmounted_subdir = @@ -831,17 +831,17 @@ DriveFileError DriveCache::MarkAsUnmountedOnBlockingPool( // Move cache file. if (!MoveFile(mounted_path, unmounted_path)) - return DRIVE_FILE_ERROR_FAILED; + return FILE_ERROR_FAILED; // Now that cache operation is complete, update metadata. cache_entry.set_md5(md5); cache_entry.set_is_mounted(false); cache_entry.set_is_persistent(unmounted_subdir == CACHE_TYPE_PERSISTENT); metadata_->AddOrUpdateCacheEntry(resource_id, cache_entry); - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } -DriveFileError DriveCache::MarkDirtyOnBlockingPool( +FileError DriveCache::MarkDirtyOnBlockingPool( const std::string& resource_id, const std::string& md5) { AssertOnSequencedWorkerPool(); @@ -859,7 +859,7 @@ DriveFileError DriveCache::MarkDirtyOnBlockingPool( LOG(WARNING) << "Can't mark dirty a file that wasn't cached: res_id=" << resource_id << ", md5=" << md5; - return DRIVE_FILE_ERROR_NOT_FOUND; + return FILE_ERROR_NOT_FOUND; } // If a file is already dirty (i.e. MarkDirtyInCache was called before), @@ -879,7 +879,7 @@ DriveFileError DriveCache::MarkDirtyOnBlockingPool( CACHED_FILE_FROM_SERVER); DeleteSymlink(symlink_path); - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } // Move file to persistent dir with new .local extension. @@ -897,17 +897,17 @@ DriveFileError DriveCache::MarkDirtyOnBlockingPool( CACHED_FILE_LOCALLY_MODIFIED); if (!MoveFile(source_path, cache_file_path)) - return DRIVE_FILE_ERROR_FAILED; + return FILE_ERROR_FAILED; // Now that file operations have completed, update metadata. cache_entry.set_md5(md5); cache_entry.set_is_dirty(true); cache_entry.set_is_persistent(sub_dir_type == CACHE_TYPE_PERSISTENT); metadata_->AddOrUpdateCacheEntry(resource_id, cache_entry); - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } -DriveFileError DriveCache::CommitDirtyOnBlockingPool( +FileError DriveCache::CommitDirtyOnBlockingPool( const std::string& resource_id, const std::string& md5) { AssertOnSequencedWorkerPool(); @@ -925,7 +925,7 @@ DriveFileError DriveCache::CommitDirtyOnBlockingPool( LOG(WARNING) << "Can't commit dirty a file that wasn't cached: res_id=" << resource_id << ", md5=" << md5; - return DRIVE_FILE_ERROR_NOT_FOUND; + return FILE_ERROR_NOT_FOUND; } // If a file is not dirty (it should have been marked dirty via @@ -934,7 +934,7 @@ DriveFileError DriveCache::CommitDirtyOnBlockingPool( LOG(WARNING) << "Can't commit a non-dirty file: res_id=" << resource_id << ", md5=" << md5; - return DRIVE_FILE_ERROR_INVALID_OPERATION; + return FILE_ERROR_INVALID_OPERATION; } // Dirty files must be in persistent dir. @@ -953,10 +953,10 @@ DriveFileError DriveCache::CommitDirtyOnBlockingPool( CACHED_FILE_LOCALLY_MODIFIED); return CreateSymlink(target_path, symlink_path) ? - DRIVE_FILE_OK : DRIVE_FILE_ERROR_FAILED; + FILE_ERROR_OK : FILE_ERROR_FAILED; } -DriveFileError DriveCache::ClearDirtyOnBlockingPool( +FileError DriveCache::ClearDirtyOnBlockingPool( const std::string& resource_id, const std::string& md5) { AssertOnSequencedWorkerPool(); @@ -972,7 +972,7 @@ DriveFileError DriveCache::ClearDirtyOnBlockingPool( LOG(WARNING) << "Can't clear dirty state of a file that wasn't cached: " << "res_id=" << resource_id << ", md5=" << md5; - return DRIVE_FILE_ERROR_NOT_FOUND; + return FILE_ERROR_NOT_FOUND; } // If a file is not dirty (it should have been marked dirty via @@ -981,7 +981,7 @@ DriveFileError DriveCache::ClearDirtyOnBlockingPool( LOG(WARNING) << "Can't clear dirty state of a non-dirty file: res_id=" << resource_id << ", md5=" << md5; - return DRIVE_FILE_ERROR_INVALID_OPERATION; + return FILE_ERROR_INVALID_OPERATION; } // File must be dirty and hence in persistent dir. @@ -1005,7 +1005,7 @@ DriveFileError DriveCache::ClearDirtyOnBlockingPool( CACHED_FILE_FROM_SERVER); if (!MoveFile(source_path, dest_path)) - return DRIVE_FILE_ERROR_FAILED; + return FILE_ERROR_FAILED; // Delete symlink in outgoing dir. base::FilePath symlink_path = GetCacheFilePath(resource_id, @@ -1019,10 +1019,10 @@ DriveFileError DriveCache::ClearDirtyOnBlockingPool( cache_entry.set_is_dirty(false); cache_entry.set_is_persistent(sub_dir_type == CACHE_TYPE_PERSISTENT); metadata_->AddOrUpdateCacheEntry(resource_id, cache_entry); - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } -DriveFileError DriveCache::RemoveOnBlockingPool( +FileError DriveCache::RemoveOnBlockingPool( const std::string& resource_id) { AssertOnSequencedWorkerPool(); @@ -1040,7 +1040,7 @@ DriveFileError DriveCache::RemoveOnBlockingPool( (cache_entry.is_dirty() ? "dirty" : "mounted") : "non-existent") << " in cache, not removing"; - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } // Determine paths to delete all cache versions of |resource_id| in @@ -1073,7 +1073,7 @@ DriveFileError DriveCache::RemoveOnBlockingPool( // Now that all file operations have completed, remove from metadata. metadata_->RemoveCacheEntry(resource_id); - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } bool DriveCache::ClearAllOnBlockingPool() { @@ -1094,13 +1094,13 @@ bool DriveCache::ClearAllOnBlockingPool() { void DriveCache::OnPinned(const std::string& resource_id, const std::string& md5, const FileOperationCallback& callback, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); callback.Run(error); - if (error == DRIVE_FILE_OK) + if (error == FILE_ERROR_OK) FOR_EACH_OBSERVER(DriveCacheObserver, observers_, OnCachePinned(resource_id, md5)); @@ -1109,13 +1109,13 @@ void DriveCache::OnPinned(const std::string& resource_id, void DriveCache::OnUnpinned(const std::string& resource_id, const std::string& md5, const FileOperationCallback& callback, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); callback.Run(error); - if (error == DRIVE_FILE_OK) + if (error == FILE_ERROR_OK) FOR_EACH_OBSERVER(DriveCacheObserver, observers_, OnCacheUnpinned(resource_id, md5)); @@ -1132,13 +1132,13 @@ void DriveCache::OnUnpinned(const std::string& resource_id, void DriveCache::OnCommitDirty(const std::string& resource_id, const FileOperationCallback& callback, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); callback.Run(error); - if (error == DRIVE_FILE_OK) + if (error == FILE_ERROR_OK) FOR_EACH_OBSERVER(DriveCacheObserver, observers_, OnCacheCommitted(resource_id)); diff --git a/chrome/browser/chromeos/drive/drive_cache.h b/chrome/browser/chromeos/drive/drive_cache.h index d089917..9178a72 100644 --- a/chrome/browser/chromeos/drive/drive_cache.h +++ b/chrome/browser/chromeos/drive/drive_cache.h @@ -14,7 +14,7 @@ #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "chrome/browser/chromeos/drive/drive_cache_metadata.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" class Profile; @@ -31,7 +31,7 @@ class DriveCacheMetadata; class DriveCacheObserver; // Callback for GetFileFromCache. -typedef base::Callback<void(DriveFileError error, +typedef base::Callback<void(FileError error, const base::FilePath& cache_file_path)> GetFileFromCacheCallback; @@ -44,7 +44,7 @@ typedef base::Callback<void(bool success, const DriveCacheEntry& cache_entry)> // Callback for RequestInitialize. // |success| indicates if the operation was successful. -// TODO(satorux): Change this to DriveFileError when it becomes necessary. +// TODO(satorux): Change this to FileError when it becomes necessary. typedef base::Callback<void(bool success)> InitializeCacheCallback; @@ -263,7 +263,7 @@ class DriveCache { private: friend class DriveCacheTest; - typedef std::pair<DriveFileError, base::FilePath> GetFileResult; + typedef std::pair<FileError, base::FilePath> GetFileResult; // Enum defining origin of a cached file. enum CachedFileOrigin { @@ -315,18 +315,18 @@ class DriveCache { const std::string& md5); // Used to implement Store. - DriveFileError StoreOnBlockingPool(const std::string& resource_id, - const std::string& md5, - const base::FilePath& source_path, - FileOperationType file_operation_type); + FileError StoreOnBlockingPool(const std::string& resource_id, + const std::string& md5, + const base::FilePath& source_path, + FileOperationType file_operation_type); // Used to implement Pin. - DriveFileError PinOnBlockingPool(const std::string& resource_id, - const std::string& md5); + FileError PinOnBlockingPool(const std::string& resource_id, + const std::string& md5); // Used to implement Unpin. - DriveFileError UnpinOnBlockingPool(const std::string& resource_id, - const std::string& md5); + FileError UnpinOnBlockingPool(const std::string& resource_id, + const std::string& md5); // Used to implement MarkAsMounted. scoped_ptr<GetFileResult> MarkAsMountedOnBlockingPool( @@ -334,22 +334,22 @@ class DriveCache { const std::string& md5); // Used to implement MarkAsUnmounted. - DriveFileError MarkAsUnmountedOnBlockingPool(const base::FilePath& file_path); + FileError MarkAsUnmountedOnBlockingPool(const base::FilePath& file_path); // Used to implement MarkDirty. - DriveFileError MarkDirtyOnBlockingPool(const std::string& resource_id, - const std::string& md5); + FileError MarkDirtyOnBlockingPool(const std::string& resource_id, + const std::string& md5); // Used to implement CommitDirty. - DriveFileError CommitDirtyOnBlockingPool(const std::string& resource_id, - const std::string& md5); + FileError CommitDirtyOnBlockingPool(const std::string& resource_id, + const std::string& md5); // Used to implement ClearDirty. - DriveFileError ClearDirtyOnBlockingPool(const std::string& resource_id, - const std::string& md5); + FileError ClearDirtyOnBlockingPool(const std::string& resource_id, + const std::string& md5); // Used to implement Remove. - DriveFileError RemoveOnBlockingPool(const std::string& resource_id); + FileError RemoveOnBlockingPool(const std::string& resource_id); // Used to implement ClearAll. bool ClearAllOnBlockingPool(); @@ -358,18 +358,18 @@ class DriveCache { void OnPinned(const std::string& resource_id, const std::string& md5, const FileOperationCallback& callback, - DriveFileError error); + FileError error); // Runs callback and notifies the observers when file is unpinned. void OnUnpinned(const std::string& resource_id, const std::string& md5, const FileOperationCallback& callback, - DriveFileError error); + FileError error); // Runs callback and notifies the observers when file is committed. void OnCommitDirty(const std::string& resource_id, const FileOperationCallback& callback, - DriveFileError error); + FileError error); // Returns true if we have sufficient space to store the given number of // bytes, while keeping kMinFreeSpace bytes on the disk. diff --git a/chrome/browser/chromeos/drive/drive_cache_unittest.cc b/chrome/browser/chromeos/drive/drive_cache_unittest.cc index 5e5b366..f3e6b91 100644 --- a/chrome/browser/chromeos/drive/drive_cache_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_cache_unittest.cc @@ -94,7 +94,7 @@ class DriveCacheTest : public testing::Test { DriveCacheTest() : ui_thread_(content::BrowserThread::UI, &message_loop_), cache_(NULL), - expected_error_(DRIVE_FILE_OK), + expected_error_(FILE_ERROR_OK), expected_cache_state_(0), expected_sub_dir_type_(DriveCache::CACHE_TYPE_META), expected_success_(true), @@ -141,7 +141,7 @@ class DriveCacheTest : public testing::Test { google_apis::test_util::GetTestFilePath( std::string("chromeos/") + resource.source_file); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->Store( resource.resource_id, resource.md5, @@ -149,11 +149,11 @@ class DriveCacheTest : public testing::Test { DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); } // Pin. if (resource.is_pinned) { - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; EXPECT_CALL(*mock_cache_observer_, OnCachePinned(resource.resource_id, resource.md5)).Times(1); cache_->Pin( @@ -161,17 +161,17 @@ class DriveCacheTest : public testing::Test { resource.md5, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); } // Mark dirty. if (resource.is_dirty) { - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->MarkDirty( resource.resource_id, resource.md5, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_CALL(*mock_cache_observer_, OnCacheCommitted(resource.resource_id)).Times(1); @@ -180,7 +180,7 @@ class DriveCacheTest : public testing::Test { resource.md5, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); } } } @@ -188,9 +188,9 @@ class DriveCacheTest : public testing::Test { void TestGetFileFromCacheByResourceIdAndMd5( const std::string& resource_id, const std::string& md5, - DriveFileError expected_error, + FileError expected_error, const std::string& expected_file_extension) { - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; base::FilePath cache_file_path; cache_->GetFile(resource_id, md5, google_apis::test_util::CreateCopyResultCallback( @@ -198,7 +198,7 @@ class DriveCacheTest : public testing::Test { google_apis::test_util::RunBlockingPoolTask(); EXPECT_EQ(expected_error, error); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { // Verify filename of |cache_file_path|. base::FilePath base_name = cache_file_path.BaseName(); EXPECT_EQ(util::EscapeCacheFileName(resource_id) + @@ -216,14 +216,14 @@ class DriveCacheTest : public testing::Test { const std::string& resource_id, const std::string& md5, const base::FilePath& source_path, - DriveFileError expected_error, + FileError expected_error, int expected_cache_state, DriveCache::CacheSubDirectoryType expected_sub_dir_type) { expected_error_ = expected_error; expected_cache_state_ = expected_cache_state; expected_sub_dir_type_ = expected_sub_dir_type; - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->Store(resource_id, md5, source_path, DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); @@ -232,10 +232,10 @@ class DriveCacheTest : public testing::Test { } void TestRemoveFromCache(const std::string& resource_id, - DriveFileError expected_error) { + FileError expected_error) { expected_error_ = expected_error; - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->Remove( resource_id, google_apis::test_util::CreateCopyResultCallback(&error)); @@ -243,7 +243,7 @@ class DriveCacheTest : public testing::Test { VerifyRemoveFromCache(error, resource_id, ""); } - void VerifyRemoveFromCache(DriveFileError error, + void VerifyRemoveFromCache(FileError error, const std::string& resource_id, const std::string& md5) { EXPECT_EQ(expected_error_, error); @@ -325,14 +325,14 @@ class DriveCacheTest : public testing::Test { void TestPin( const std::string& resource_id, const std::string& md5, - DriveFileError expected_error, + FileError expected_error, int expected_cache_state, DriveCache::CacheSubDirectoryType expected_sub_dir_type) { expected_error_ = expected_error; expected_cache_state_ = expected_cache_state; expected_sub_dir_type_ = expected_sub_dir_type; - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->Pin(resource_id, md5, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); @@ -342,14 +342,14 @@ class DriveCacheTest : public testing::Test { void TestUnpin( const std::string& resource_id, const std::string& md5, - DriveFileError expected_error, + FileError expected_error, int expected_cache_state, DriveCache::CacheSubDirectoryType expected_sub_dir_type) { expected_error_ = expected_error; expected_cache_state_ = expected_cache_state; expected_sub_dir_type_ = expected_sub_dir_type; - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->Unpin(resource_id, md5, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); @@ -358,7 +358,7 @@ class DriveCacheTest : public testing::Test { void TestMarkDirty(const std::string& resource_id, const std::string& md5, - DriveFileError expected_error, + FileError expected_error, int expected_cache_state, DriveCache::CacheSubDirectoryType expected_sub_dir_type) { expected_error_ = expected_error; @@ -366,7 +366,7 @@ class DriveCacheTest : public testing::Test { expected_sub_dir_type_ = expected_sub_dir_type; expect_outgoing_symlink_ = false; - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->MarkDirty( resource_id, md5, google_apis::test_util::CreateCopyResultCallback(&error)); @@ -375,14 +375,14 @@ class DriveCacheTest : public testing::Test { VerifyCacheFileState(error, resource_id, md5); // Verify filename. - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { base::FilePath cache_file_path; cache_->GetFile(resource_id, md5, google_apis::test_util::CreateCopyResultCallback( &error, &cache_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); base::FilePath base_name = cache_file_path.BaseName(); EXPECT_EQ(util::EscapeCacheFileName(resource_id) + base::FilePath::kExtensionSeparator + @@ -394,7 +394,7 @@ class DriveCacheTest : public testing::Test { void TestCommitDirty( const std::string& resource_id, const std::string& md5, - DriveFileError expected_error, + FileError expected_error, int expected_cache_state, DriveCache::CacheSubDirectoryType expected_sub_dir_type) { expected_error_ = expected_error; @@ -402,7 +402,7 @@ class DriveCacheTest : public testing::Test { expected_sub_dir_type_ = expected_sub_dir_type; expect_outgoing_symlink_ = true; - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->CommitDirty( resource_id, md5, google_apis::test_util::CreateCopyResultCallback(&error)); @@ -413,7 +413,7 @@ class DriveCacheTest : public testing::Test { void TestClearDirty( const std::string& resource_id, const std::string& md5, - DriveFileError expected_error, + FileError expected_error, int expected_cache_state, DriveCache::CacheSubDirectoryType expected_sub_dir_type) { expected_error_ = expected_error; @@ -421,7 +421,7 @@ class DriveCacheTest : public testing::Test { expected_sub_dir_type_ = expected_sub_dir_type; expect_outgoing_symlink_ = false; - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->ClearDirty( resource_id, md5, google_apis::test_util::CreateCopyResultCallback(&error)); @@ -432,7 +432,7 @@ class DriveCacheTest : public testing::Test { void TestMarkAsMounted( const std::string& resource_id, const std::string& md5, - DriveFileError expected_error, + FileError expected_error, int expected_cache_state, DriveCache::CacheSubDirectoryType expected_sub_dir_type) { expected_error_ = expected_error; @@ -440,7 +440,7 @@ class DriveCacheTest : public testing::Test { expected_sub_dir_type_ = expected_sub_dir_type; expect_outgoing_symlink_ = false; - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; base::FilePath cache_file_path; cache_->MarkAsMounted(resource_id, md5, google_apis::test_util::CreateCopyResultCallback( @@ -459,7 +459,7 @@ class DriveCacheTest : public testing::Test { const std::string& resource_id, const std::string& md5, const base::FilePath& file_path, - DriveFileError expected_error, + FileError expected_error, int expected_cache_state, DriveCache::CacheSubDirectoryType expected_sub_dir_type) { expected_error_ = expected_error; @@ -467,7 +467,7 @@ class DriveCacheTest : public testing::Test { expected_sub_dir_type_ = expected_sub_dir_type; expect_outgoing_symlink_ = false; - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->MarkAsUnmounted( file_path, google_apis::test_util::CreateCopyResultCallback(&error)); @@ -478,7 +478,7 @@ class DriveCacheTest : public testing::Test { google_apis::test_util::CreateCopyResultCallback( &error, &cache_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_TRUE(file_util::PathExists(cache_file_path)); EXPECT_EQ(cache_file_path, @@ -488,7 +488,7 @@ class DriveCacheTest : public testing::Test { DriveCache::CACHED_FILE_FROM_SERVER)); } - void VerifyCacheFileState(DriveFileError error, + void VerifyCacheFileState(FileError error, const std::string& resource_id, const std::string& md5) { EXPECT_EQ(expected_error_, error); @@ -633,7 +633,7 @@ class DriveCacheTest : public testing::Test { scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; - DriveFileError expected_error_; + FileError expected_error_; int expected_cache_state_; DriveCache::CacheSubDirectoryType expected_sub_dir_type_; bool expected_success_; @@ -670,12 +670,12 @@ TEST_F(DriveCacheTest, StoreToCacheSimple) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Store a non-existent file to the same |resource_id| and |md5|. TestStoreToCache(resource_id, md5, base::FilePath("./non_existent.json"), - DRIVE_FILE_ERROR_FAILED, + FILE_ERROR_FAILED, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); @@ -686,7 +686,7 @@ TEST_F(DriveCacheTest, StoreToCacheSimple) { resource_id, md5, google_apis::test_util::GetTestFilePath( "chromeos/gdata/empty_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Verify that there's only one file with name <resource_id>, i.e. previously @@ -703,23 +703,23 @@ TEST_F(DriveCacheTest, GetFromCacheSimple) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Then try to get the existing file from cache. TestGetFileFromCacheByResourceIdAndMd5( - resource_id, md5, DRIVE_FILE_OK, md5); + resource_id, md5, FILE_ERROR_OK, md5); // Get file from cache with same resource id as existing file but different // md5. TestGetFileFromCacheByResourceIdAndMd5( - resource_id, "9999", DRIVE_FILE_ERROR_NOT_FOUND, md5); + resource_id, "9999", FILE_ERROR_NOT_FOUND, md5); // Get file from cache with different resource id from existing file but same // md5. resource_id = "document:1a2b"; TestGetFileFromCacheByResourceIdAndMd5( - resource_id, md5, DRIVE_FILE_ERROR_NOT_FOUND, md5); + resource_id, md5, FILE_ERROR_NOT_FOUND, md5); } TEST_F(DriveCacheTest, RemoveFromCacheSimple) { @@ -732,11 +732,11 @@ TEST_F(DriveCacheTest, RemoveFromCacheSimple) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Then try to remove existing file from cache. - TestRemoveFromCache(resource_id, DRIVE_FILE_OK); + TestRemoveFromCache(resource_id, FILE_ERROR_OK); // Repeat using non-alphanumeric characters for resource id, including '.' // which is an extension separator. @@ -744,10 +744,10 @@ TEST_F(DriveCacheTest, RemoveFromCacheSimple) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); - TestRemoveFromCache(resource_id, DRIVE_FILE_OK); + TestRemoveFromCache(resource_id, FILE_ERROR_OK); } TEST_F(DriveCacheTest, PinAndUnpin) { @@ -763,23 +763,23 @@ TEST_F(DriveCacheTest, PinAndUnpin) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Pin the existing file in cache. - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Unpin the existing file in cache. - TestUnpin(resource_id, md5, DRIVE_FILE_OK, + TestUnpin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Pin back the same existing file in cache. - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -791,12 +791,12 @@ TEST_F(DriveCacheTest, PinAndUnpin) { EXPECT_CALL(*mock_cache_observer_, OnCacheUnpinned(resource_id, md5)) .Times(1); - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PINNED, DriveCache::CACHE_TYPE_TMP); // Unpin the previously pinned non-existent file in cache. - TestUnpin(resource_id, md5, DRIVE_FILE_OK, + TestUnpin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_NONE, DriveCache::CACHE_TYPE_TMP); @@ -807,7 +807,7 @@ TEST_F(DriveCacheTest, PinAndUnpin) { EXPECT_CALL(*mock_cache_observer_, OnCacheUnpinned(resource_id, md5)) .Times(0); - TestUnpin(resource_id, md5, DRIVE_FILE_ERROR_NOT_FOUND, + TestUnpin(resource_id, md5, FILE_ERROR_NOT_FOUND, test_util::TEST_CACHE_STATE_NONE, DriveCache::CACHE_TYPE_TMP /* non-applicable */); } @@ -820,7 +820,7 @@ TEST_F(DriveCacheTest, StoreToCachePinned) { EXPECT_CALL(*mock_cache_observer_, OnCachePinned(resource_id, md5)).Times(1); // Pin a non-existent file. - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PINNED, DriveCache::CACHE_TYPE_TMP); @@ -828,7 +828,7 @@ TEST_F(DriveCacheTest, StoreToCachePinned) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -836,7 +836,7 @@ TEST_F(DriveCacheTest, StoreToCachePinned) { // Store a non-existent file to a previously pinned and stored file. TestStoreToCache(resource_id, md5, base::FilePath("./non_existent.json"), - DRIVE_FILE_ERROR_FAILED, + FILE_ERROR_FAILED, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -851,19 +851,19 @@ TEST_F(DriveCacheTest, GetFromCachePinned) { EXPECT_CALL(*mock_cache_observer_, OnCachePinned(resource_id, md5)).Times(1); // Pin a non-existent file. - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PINNED, DriveCache::CACHE_TYPE_TMP); // Get the non-existent pinned file from cache. TestGetFileFromCacheByResourceIdAndMd5( - resource_id, md5, DRIVE_FILE_ERROR_NOT_FOUND, md5); + resource_id, md5, FILE_ERROR_NOT_FOUND, md5); // Store an existing file to the previously pinned non-existent file. TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -871,7 +871,7 @@ TEST_F(DriveCacheTest, GetFromCachePinned) { // Get the previously pinned and stored file from cache. TestGetFileFromCacheByResourceIdAndMd5( - resource_id, md5, DRIVE_FILE_OK, md5); + resource_id, md5, FILE_ERROR_OK, md5); } TEST_F(DriveCacheTest, RemoveFromCachePinned) { @@ -886,16 +886,16 @@ TEST_F(DriveCacheTest, RemoveFromCachePinned) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Remove |resource_id| from cache. - TestRemoveFromCache(resource_id, DRIVE_FILE_OK); + TestRemoveFromCache(resource_id, FILE_ERROR_OK); // Repeat using non-alphanumeric characters for resource id, including '.' // which is an extension separator. @@ -905,15 +905,15 @@ TEST_F(DriveCacheTest, RemoveFromCachePinned) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); - TestRemoveFromCache(resource_id, DRIVE_FILE_OK); + TestRemoveFromCache(resource_id, FILE_ERROR_OK); } TEST_F(DriveCacheTest, DirtyCacheSimple) { @@ -927,25 +927,25 @@ TEST_F(DriveCacheTest, DirtyCacheSimple) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Mark the file dirty. - TestMarkDirty(resource_id, md5, DRIVE_FILE_OK, + TestMarkDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Commit the file dirty. - TestCommitDirty(resource_id, md5, DRIVE_FILE_OK, + TestCommitDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Clear dirty state of the file. - TestClearDirty(resource_id, md5, DRIVE_FILE_OK, + TestClearDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); } @@ -962,16 +962,16 @@ TEST_F(DriveCacheTest, DirtyCachePinned) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Mark the file dirty. - TestMarkDirty(resource_id, md5, DRIVE_FILE_OK, + TestMarkDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PINNED | @@ -979,7 +979,7 @@ TEST_F(DriveCacheTest, DirtyCachePinned) { DriveCache::CACHE_TYPE_PERSISTENT); // Commit the file dirty. - TestCommitDirty(resource_id, md5, DRIVE_FILE_OK, + TestCommitDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PINNED | @@ -987,7 +987,7 @@ TEST_F(DriveCacheTest, DirtyCachePinned) { DriveCache::CACHE_TYPE_PERSISTENT); // Clear dirty state of the file. - TestClearDirty(resource_id, md5, DRIVE_FILE_OK, + TestClearDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -1008,9 +1008,9 @@ TEST_F(DriveCacheTest, PinAndUnpinDirtyCache) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); - TestMarkDirty(resource_id, md5, DRIVE_FILE_OK, + TestMarkDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -1018,16 +1018,16 @@ TEST_F(DriveCacheTest, PinAndUnpinDirtyCache) { // Verifies dirty file exists. base::FilePath dirty_path; - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; cache_->GetFile( resource_id, md5, google_apis::test_util::CreateCopyResultCallback(&error, &dirty_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_TRUE(file_util::PathExists(dirty_path)); // Pin the dirty file. - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PINNED | @@ -1038,7 +1038,7 @@ TEST_F(DriveCacheTest, PinAndUnpinDirtyCache) { EXPECT_TRUE(file_util::PathExists(dirty_path)); // Unpin the dirty file. - TestUnpin(resource_id, md5, DRIVE_FILE_OK, + TestUnpin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -1059,32 +1059,32 @@ TEST_F(DriveCacheTest, DirtyCacheRepetitive) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Mark the file dirty. - TestMarkDirty(resource_id, md5, DRIVE_FILE_OK, + TestMarkDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Again, mark the file dirty. Nothing should change. - TestMarkDirty(resource_id, md5, DRIVE_FILE_OK, + TestMarkDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Commit the file dirty. Outgoing symlink should be created. - TestCommitDirty(resource_id, md5, DRIVE_FILE_OK, + TestCommitDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Again, commit the file dirty. Nothing should change. - TestCommitDirty(resource_id, md5, DRIVE_FILE_OK, + TestCommitDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -1092,26 +1092,26 @@ TEST_F(DriveCacheTest, DirtyCacheRepetitive) { // Mark the file dirty again after it's being committed. Outgoing symlink // should be deleted. - TestMarkDirty(resource_id, md5, DRIVE_FILE_OK, + TestMarkDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Commit the file dirty. Outgoing symlink should be created again. - TestCommitDirty(resource_id, md5, DRIVE_FILE_OK, + TestCommitDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); // Clear dirty state of the file. - TestClearDirty(resource_id, md5, DRIVE_FILE_OK, + TestClearDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Again, clear dirty state of the file, which is no longer dirty. - TestClearDirty(resource_id, md5, DRIVE_FILE_ERROR_INVALID_OPERATION, + TestClearDirty(resource_id, md5, FILE_ERROR_INVALID_OPERATION, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); } @@ -1123,17 +1123,17 @@ TEST_F(DriveCacheTest, DirtyCacheInvalid) { std::string md5("abcdef0123456789"); // Mark a non-existent file dirty. - TestMarkDirty(resource_id, md5, DRIVE_FILE_ERROR_NOT_FOUND, + TestMarkDirty(resource_id, md5, FILE_ERROR_NOT_FOUND, test_util::TEST_CACHE_STATE_NONE, DriveCache::CACHE_TYPE_TMP); // Commit a non-existent file dirty. - TestCommitDirty(resource_id, md5, DRIVE_FILE_ERROR_NOT_FOUND, + TestCommitDirty(resource_id, md5, FILE_ERROR_NOT_FOUND, test_util::TEST_CACHE_STATE_NONE, DriveCache::CACHE_TYPE_TMP); // Clear dirty state of a non-existent file. - TestClearDirty(resource_id, md5, DRIVE_FILE_ERROR_NOT_FOUND, + TestClearDirty(resource_id, md5, FILE_ERROR_NOT_FOUND, test_util::TEST_CACHE_STATE_NONE, DriveCache::CACHE_TYPE_TMP); @@ -1141,22 +1141,22 @@ TEST_F(DriveCacheTest, DirtyCacheInvalid) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Commit a non-dirty existing file dirty. - TestCommitDirty(resource_id, md5, DRIVE_FILE_ERROR_INVALID_OPERATION, + TestCommitDirty(resource_id, md5, FILE_ERROR_INVALID_OPERATION, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Clear dirty state of a non-dirty existing file. - TestClearDirty(resource_id, md5, DRIVE_FILE_ERROR_INVALID_OPERATION, + TestClearDirty(resource_id, md5, FILE_ERROR_INVALID_OPERATION, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Mark an existing file dirty, then store a new file to the same resource id // but different md5, which should fail. - TestMarkDirty(resource_id, md5, DRIVE_FILE_OK, + TestMarkDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -1166,7 +1166,7 @@ TEST_F(DriveCacheTest, DirtyCacheInvalid) { resource_id, md5, google_apis::test_util::GetTestFilePath( "chromeos/gdata/empty_feed.json"), - DRIVE_FILE_ERROR_IN_USE, + FILE_ERROR_IN_USE, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -1185,20 +1185,20 @@ TEST_F(DriveCacheTest, RemoveFromDirtyCache) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); - TestPin(resource_id, md5, DRIVE_FILE_OK, + TestPin(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); - TestMarkDirty(resource_id, md5, DRIVE_FILE_OK, + TestMarkDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_DIRTY | test_util::TEST_CACHE_STATE_PERSISTENT, DriveCache::CACHE_TYPE_PERSISTENT); - TestCommitDirty(resource_id, md5, DRIVE_FILE_OK, + TestCommitDirty(resource_id, md5, FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_PINNED | test_util::TEST_CACHE_STATE_DIRTY | @@ -1207,7 +1207,7 @@ TEST_F(DriveCacheTest, RemoveFromDirtyCache) { // Try to remove the file. Since file is dirty, it and the corresponding // pinned and outgoing symlinks should not be removed. - TestRemoveFromCache(resource_id, DRIVE_FILE_OK); + TestRemoveFromCache(resource_id, FILE_ERROR_OK); } TEST_F(DriveCacheTest, MountUnmount) { @@ -1220,13 +1220,13 @@ TEST_F(DriveCacheTest, MountUnmount) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Mark the file mounted. TestMarkAsMounted(resource_id, md5, - DRIVE_FILE_OK, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT | test_util::TEST_CACHE_STATE_MOUNTED | test_util::TEST_CACHE_STATE_PERSISTENT, @@ -1235,21 +1235,21 @@ TEST_F(DriveCacheTest, MountUnmount) { // Clear mounted state of the file. base::FilePath file_path; - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; cache_->GetFile( resource_id, md5, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); TestMarkAsUnmounted(resource_id, md5, file_path, - DRIVE_FILE_OK, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); EXPECT_TRUE(CacheEntryExists(resource_id, md5)); // Try to remove the file. - TestRemoveFromCache(resource_id, DRIVE_FILE_OK); + TestRemoveFromCache(resource_id, FILE_ERROR_OK); } TEST_F(DriveCacheTest, Iterate) { @@ -1288,7 +1288,7 @@ TEST_F(DriveCacheTest, ClearAll) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_OK, test_util::TEST_CACHE_STATE_PRESENT, + FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT, DriveCache::CACHE_TYPE_TMP); // Verify that there's only one cached file. @@ -1301,8 +1301,8 @@ TEST_F(DriveCacheTest, ClearAll) { EXPECT_TRUE(success); // Verify that all the cache is removed. - expected_error_ = DRIVE_FILE_OK; - VerifyRemoveFromCache(DRIVE_FILE_OK, resource_id, md5); + expected_error_ = FILE_ERROR_OK; + VerifyRemoveFromCache(FILE_ERROR_OK, resource_id, md5); EXPECT_EQ(0U, CountCacheFiles(resource_id, md5)); } @@ -1316,7 +1316,7 @@ TEST_F(DriveCacheTest, StoreToCacheNoSpace) { TestStoreToCache( resource_id, md5, google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), - DRIVE_FILE_ERROR_NO_SPACE, + FILE_ERROR_NO_SPACE, test_util::TEST_CACHE_STATE_NONE, DriveCache::CACHE_TYPE_TMP); diff --git a/chrome/browser/chromeos/drive/drive_download_handler.cc b/chrome/browser/chromeos/drive/drive_download_handler.cc index 621f373..badf6ed 100644 --- a/chrome/browser/chromeos/drive/drive_download_handler.cc +++ b/chrome/browser/chromeos/drive/drive_download_handler.cc @@ -67,9 +67,9 @@ base::FilePath GetDriveTempDownloadPath( // Moves downloaded file to Drive. void MoveDownloadedFile(const base::FilePath& downloaded_file, - DriveFileError error, + FileError error, const base::FilePath& dest_path) { - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) return; file_util::Move(downloaded_file, dest_path); } @@ -77,9 +77,9 @@ void MoveDownloadedFile(const base::FilePath& downloaded_file, // Used to implement CheckForFileExistence(). void ContinueCheckingForFileExistence( const content::CheckForFileExistenceCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { - callback.Run(error == DRIVE_FILE_OK); + callback.Run(error == FILE_ERROR_OK); } // Returns true if |download| is a Drive download created from data persisted @@ -257,9 +257,9 @@ void DriveDownloadHandler::OnDownloadUpdated( void DriveDownloadHandler::OnEntryFound( const base::FilePath& drive_dir_path, const SubstituteDriveDownloadPathCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { - if (error == DRIVE_FILE_ERROR_NOT_FOUND) { + if (error == FILE_ERROR_NOT_FOUND) { // Destination Drive directory doesn't exist, so create it. const bool is_exclusive = false, is_recursive = true; file_system_->CreateDirectory( @@ -267,22 +267,22 @@ void DriveDownloadHandler::OnEntryFound( base::Bind(&DriveDownloadHandler::OnCreateDirectory, weak_ptr_factory_.GetWeakPtr(), callback)); - } else if (error == DRIVE_FILE_OK) { + } else if (error == FILE_ERROR_OK) { // Directory is already ready. - OnCreateDirectory(callback, DRIVE_FILE_OK); + OnCreateDirectory(callback, FILE_ERROR_OK); } else { LOG(WARNING) << "Failed to get entry info for path: " << drive_dir_path.value() << ", error = " - << DriveFileErrorToString(error); + << FileErrorToString(error); callback.Run(base::FilePath()); } } void DriveDownloadHandler::OnCreateDirectory( const SubstituteDriveDownloadPathCallback& callback, - DriveFileError error) { - DVLOG(1) << "OnCreateDirectory " << DriveFileErrorToString(error); - if (error == DRIVE_FILE_OK) { + FileError error) { + DVLOG(1) << "OnCreateDirectory " << FileErrorToString(error); + if (error == FILE_ERROR_OK) { base::PostTaskAndReplyWithResult( BrowserThread::GetBlockingPool(), FROM_HERE, @@ -290,7 +290,7 @@ void DriveDownloadHandler::OnCreateDirectory( callback); } else { LOG(WARNING) << "Failed to create directory, error = " - << DriveFileErrorToString(error); + << FileErrorToString(error); callback.Run(base::FilePath()); } } diff --git a/chrome/browser/chromeos/drive/drive_download_handler.h b/chrome/browser/chromeos/drive/drive_download_handler.h index c80d8e0..6023730 100644 --- a/chrome/browser/chromeos/drive/drive_download_handler.h +++ b/chrome/browser/chromeos/drive/drive_download_handler.h @@ -7,7 +7,7 @@ #include "base/callback_forward.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/download/all_download_item_notifier.h" #include "content/public/browser/download_manager_delegate.h" @@ -40,7 +40,7 @@ class DriveDownloadHandler : public AllDownloadItemNotifier::Observer { const base::FilePath& drive_tmp_download_path); // Callback used to return results from SubstituteDriveDownloadPath. - // TODO(hashimoto): Report error with a DriveFileError. crbug.com/171345 + // TODO(hashimoto): Report error with a FileError. crbug.com/171345 typedef base::Callback<void(const base::FilePath&)> SubstituteDriveDownloadPathCallback; @@ -80,13 +80,13 @@ class DriveDownloadHandler : public AllDownloadItemNotifier::Observer { // Used to implement SubstituteDriveDownloadPath(). void OnEntryFound(const base::FilePath& drive_dir_path, const SubstituteDriveDownloadPathCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Callback for DriveFileSystem::CreateDirectory(). // Used to implement SubstituteDriveDownloadPath(). void OnCreateDirectory(const SubstituteDriveDownloadPathCallback& callback, - DriveFileError error); + FileError error); // Starts the upload of a downloaded/downloading file. void UploadDownloadItem(content::DownloadItem* download); diff --git a/chrome/browser/chromeos/drive/drive_download_handler_unittest.cc b/chrome/browser/chromeos/drive/drive_download_handler_unittest.cc index fccd202..708713d 100644 --- a/chrome/browser/chromeos/drive/drive_download_handler_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_download_handler_unittest.cc @@ -113,7 +113,7 @@ TEST_F(DriveDownloadHandlerTest, SubstituteDriveDownloadPath) { // Return result of GetEntryInfoByPath(), destination directory found. scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); ASSERT_FALSE(get_entry_info_callback_.is_null()); - get_entry_info_callback_.Run(DRIVE_FILE_OK, entry.Pass()); + get_entry_info_callback_.Run(FILE_ERROR_OK, entry.Pass()); google_apis::test_util::RunBlockingPoolTask(); // Check the result. @@ -136,7 +136,7 @@ TEST_F(DriveDownloadHandlerTest, SubstituteDriveDownloadPathGetEntryFailure) { // Return result of GetEntryInfoByPath(), failing for some reason. ASSERT_FALSE(get_entry_info_callback_.is_null()); - get_entry_info_callback_.Run(DRIVE_FILE_ERROR_FAILED, + get_entry_info_callback_.Run(FILE_ERROR_FAILED, scoped_ptr<DriveEntryProto>()); google_apis::test_util::RunBlockingPoolTask(); @@ -158,13 +158,13 @@ TEST_F(DriveDownloadHandlerTest, SubstituteDriveDownloadPathCreateDirectory) { // Return result of GetEntryInfoByPath(), destination directory not found. ASSERT_FALSE(get_entry_info_callback_.is_null()); - get_entry_info_callback_.Run(DRIVE_FILE_ERROR_NOT_FOUND, + get_entry_info_callback_.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); google_apis::test_util::RunBlockingPoolTask(); // Return result of CreateDirecotry(). ASSERT_FALSE(create_directory_callback_.is_null()); - create_directory_callback_.Run(DRIVE_FILE_OK); + create_directory_callback_.Run(FILE_ERROR_OK); google_apis::test_util::RunBlockingPoolTask(); // Check the result. @@ -188,13 +188,13 @@ TEST_F(DriveDownloadHandlerTest, // Return result of GetEntryInfoByPath(), destination directory not found. ASSERT_FALSE(get_entry_info_callback_.is_null()); - get_entry_info_callback_.Run(DRIVE_FILE_ERROR_NOT_FOUND, + get_entry_info_callback_.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); google_apis::test_util::RunBlockingPoolTask(); // Return result of CreateDirecotry(). ASSERT_FALSE(create_directory_callback_.is_null()); - create_directory_callback_.Run(DRIVE_FILE_ERROR_FAILED); + create_directory_callback_.Run(FILE_ERROR_FAILED); google_apis::test_util::RunBlockingPoolTask(); // Check the result. @@ -218,7 +218,7 @@ TEST_F(DriveDownloadHandlerTest, SubstituteDriveDownloadPathForSavePackage) { // Return result of GetEntryInfoByPath(), destination directory found. scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); ASSERT_FALSE(get_entry_info_callback_.is_null()); - get_entry_info_callback_.Run(DRIVE_FILE_OK, entry.Pass()); + get_entry_info_callback_.Run(FILE_ERROR_OK, entry.Pass()); google_apis::test_util::RunBlockingPoolTask(); // Check the result of SubstituteDriveDownloadPath(). @@ -255,7 +255,7 @@ TEST_F(DriveDownloadHandlerTest, CheckForFileExistence) { { scoped_ptr<DriveEntryProto> entry(new DriveEntryProto); ASSERT_FALSE(get_entry_info_callback_.is_null()); - get_entry_info_callback_.Run(DRIVE_FILE_OK, entry.Pass()); + get_entry_info_callback_.Run(FILE_ERROR_OK, entry.Pass()); } google_apis::test_util::RunBlockingPoolTask(); @@ -273,7 +273,7 @@ TEST_F(DriveDownloadHandlerTest, CheckForFileExistence) { // Return result of GetEntryInfoByPath(), file does not exist. ASSERT_FALSE(get_entry_info_callback_.is_null()); - get_entry_info_callback_.Run(DRIVE_FILE_ERROR_NOT_FOUND, + get_entry_info_callback_.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); google_apis::test_util::RunBlockingPoolTask(); diff --git a/chrome/browser/chromeos/drive/drive_file_error.cc b/chrome/browser/chromeos/drive/drive_file_error.cc deleted file mode 100644 index e6146ae..0000000 --- a/chrome/browser/chromeos/drive/drive_file_error.cc +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/drive/drive_file_error.h" - -#include "base/logging.h" - -namespace drive { - -std::string DriveFileErrorToString(DriveFileError error) { - switch (error) { - case DRIVE_FILE_OK: - return "DRIVE_FILE_OK"; - - case DRIVE_FILE_ERROR_FAILED: - return "DRIVE_FILE_ERROR_FAILED"; - - case DRIVE_FILE_ERROR_IN_USE: - return "DRIVE_FILE_ERROR_IN_USE"; - - case DRIVE_FILE_ERROR_EXISTS: - return "DRIVE_FILE_ERROR_EXISTS"; - - case DRIVE_FILE_ERROR_NOT_FOUND: - return "DRIVE_FILE_ERROR_NOT_FOUND"; - - case DRIVE_FILE_ERROR_ACCESS_DENIED: - return "DRIVE_FILE_ERROR_ACCESS_DENIED"; - - case DRIVE_FILE_ERROR_TOO_MANY_OPENED: - return "DRIVE_FILE_ERROR_TOO_MANY_OPENED"; - - case DRIVE_FILE_ERROR_NO_MEMORY: - return "DRIVE_FILE_ERROR_NO_MEMORY"; - - case DRIVE_FILE_ERROR_NO_SPACE: - return "DRIVE_FILE_ERROR_NO_SPACE"; - - case DRIVE_FILE_ERROR_NOT_A_DIRECTORY: - return "DRIVE_FILE_ERROR_NOT_A_DIRECTORY"; - - case DRIVE_FILE_ERROR_INVALID_OPERATION: - return "DRIVE_FILE_ERROR_INVALID_OPERATION"; - - case DRIVE_FILE_ERROR_SECURITY: - return "DRIVE_FILE_ERROR_SECURITY"; - - case DRIVE_FILE_ERROR_ABORT: - return "DRIVE_FILE_ERROR_ABORT"; - - case DRIVE_FILE_ERROR_NOT_A_FILE: - return "DRIVE_FILE_ERROR_NOT_A_FILE"; - - case DRIVE_FILE_ERROR_NOT_EMPTY: - return "DRIVE_FILE_ERROR_NOT_EMPTY"; - - case DRIVE_FILE_ERROR_INVALID_URL: - return "DRIVE_FILE_ERROR_INVALID_URL"; - - case DRIVE_FILE_ERROR_NO_CONNECTION: - return "DRIVE_FILE_ERROR_NO_CONNECTION"; - - case DRIVE_FILE_ERROR_THROTTLED: - return "DRIVE_FILE_ERROR_THROTTLED"; - } - - NOTREACHED(); - return ""; -} - -base::PlatformFileError DriveFileErrorToPlatformError(DriveFileError error) { - switch (error) { - case DRIVE_FILE_OK: - return base::PLATFORM_FILE_OK; - - case DRIVE_FILE_ERROR_FAILED: - return base::PLATFORM_FILE_ERROR_FAILED; - - case DRIVE_FILE_ERROR_IN_USE: - return base::PLATFORM_FILE_ERROR_IN_USE; - - case DRIVE_FILE_ERROR_EXISTS: - return base::PLATFORM_FILE_ERROR_EXISTS; - - case DRIVE_FILE_ERROR_NOT_FOUND: - return base::PLATFORM_FILE_ERROR_NOT_FOUND; - - case DRIVE_FILE_ERROR_ACCESS_DENIED: - return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; - - case DRIVE_FILE_ERROR_TOO_MANY_OPENED: - return base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED; - - case DRIVE_FILE_ERROR_NO_MEMORY: - return base::PLATFORM_FILE_ERROR_NO_MEMORY; - - case DRIVE_FILE_ERROR_NO_SPACE: - return base::PLATFORM_FILE_ERROR_NO_SPACE; - - case DRIVE_FILE_ERROR_NOT_A_DIRECTORY: - return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; - - case DRIVE_FILE_ERROR_INVALID_OPERATION: - return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; - - case DRIVE_FILE_ERROR_SECURITY: - return base::PLATFORM_FILE_ERROR_SECURITY; - - case DRIVE_FILE_ERROR_ABORT: - return base::PLATFORM_FILE_ERROR_ABORT; - - case DRIVE_FILE_ERROR_NOT_A_FILE: - return base::PLATFORM_FILE_ERROR_NOT_A_FILE; - - case DRIVE_FILE_ERROR_NOT_EMPTY: - return base::PLATFORM_FILE_ERROR_NOT_EMPTY; - - case DRIVE_FILE_ERROR_INVALID_URL: - return base::PLATFORM_FILE_ERROR_INVALID_URL; - - case DRIVE_FILE_ERROR_NO_CONNECTION: - return base::PLATFORM_FILE_ERROR_FAILED; - - case DRIVE_FILE_ERROR_THROTTLED: - return base::PLATFORM_FILE_ERROR_FAILED; - } - - NOTREACHED(); - return base::PLATFORM_FILE_ERROR_FAILED; -} - -DriveFileError DriveUploadErrorToDriveFileError( - google_apis::DriveUploadError error) { - switch (error) { - case google_apis::DRIVE_UPLOAD_OK: - return DRIVE_FILE_OK; - - case google_apis::DRIVE_UPLOAD_ERROR_NOT_FOUND: - return DRIVE_FILE_ERROR_NOT_FOUND; - - case google_apis::DRIVE_UPLOAD_ERROR_NO_SPACE: - return DRIVE_FILE_ERROR_NO_SPACE; - - case google_apis::DRIVE_UPLOAD_ERROR_CONFLICT: - return DRIVE_FILE_ERROR_THROTTLED; - - case google_apis::DRIVE_UPLOAD_ERROR_ABORT: - return DRIVE_FILE_ERROR_ABORT; - } - - NOTREACHED(); - return DRIVE_FILE_ERROR_FAILED; -} - -} // namespace drive diff --git a/chrome/browser/chromeos/drive/drive_file_error.h b/chrome/browser/chromeos/drive/drive_file_error.h deleted file mode 100644 index dea04c2..0000000 --- a/chrome/browser/chromeos/drive/drive_file_error.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_ERROR_H_ -#define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_ERROR_H_ - -#include "base/callback_forward.h" -#include "base/platform_file.h" -#include "chrome/browser/google_apis/drive_upload_error.h" - -namespace drive { - -enum DriveFileError { - DRIVE_FILE_OK = 0, - DRIVE_FILE_ERROR_FAILED = -1, - DRIVE_FILE_ERROR_IN_USE = -2, - DRIVE_FILE_ERROR_EXISTS = -3, - DRIVE_FILE_ERROR_NOT_FOUND = -4, - DRIVE_FILE_ERROR_ACCESS_DENIED = -5, - DRIVE_FILE_ERROR_TOO_MANY_OPENED = -6, - DRIVE_FILE_ERROR_NO_MEMORY = -7, - DRIVE_FILE_ERROR_NO_SPACE = -8, - DRIVE_FILE_ERROR_NOT_A_DIRECTORY = -9, - DRIVE_FILE_ERROR_INVALID_OPERATION = -10, - DRIVE_FILE_ERROR_SECURITY = -11, - DRIVE_FILE_ERROR_ABORT = -12, - DRIVE_FILE_ERROR_NOT_A_FILE = -13, - DRIVE_FILE_ERROR_NOT_EMPTY = -14, - DRIVE_FILE_ERROR_INVALID_URL = -15, - DRIVE_FILE_ERROR_NO_CONNECTION = -16, - DRIVE_FILE_ERROR_THROTTLED = -17, -}; - -// Used as callbacks for file operations. -typedef base::Callback<void(DriveFileError error)> FileOperationCallback; - -// Returns a string representation of DriveFileError. -std::string DriveFileErrorToString(DriveFileError error); - -// Returns a PlatformFileError that corresponds to the DriveFileError provided. -base::PlatformFileError DriveFileErrorToPlatformError(DriveFileError error); - -// Returns a DriveFileError that corresponds to the DriveUploadError provided. -DriveFileError DriveUploadErrorToDriveFileError( - google_apis::DriveUploadError error); - -} // namespace drive - -#endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_ERROR_H_ diff --git a/chrome/browser/chromeos/drive/drive_file_stream_reader.cc b/chrome/browser/chromeos/drive/drive_file_stream_reader.cc index 2a20415..9282ed7 100644 --- a/chrome/browser/chromeos/drive/drive_file_stream_reader.cc +++ b/chrome/browser/chromeos/drive/drive_file_stream_reader.cc @@ -77,7 +77,7 @@ void LocalReaderProxy::OnGetContent(scoped_ptr<std::string> data) { NOTREACHED(); } -void LocalReaderProxy::OnError(DriveFileError error) { +void LocalReaderProxy::OnError(FileError error) { // This method should never be called, because we don't access to the server // during the reading of local-cache file. NOTREACHED(); @@ -149,12 +149,12 @@ void NetworkReaderProxy::OnGetContent(scoped_ptr<std::string> data) { base::ResetAndReturn(&callback_).Run(result); } -void NetworkReaderProxy::OnError(DriveFileError error) { +void NetworkReaderProxy::OnError(FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DCHECK_NE(error, DRIVE_FILE_OK); + DCHECK_NE(error, FILE_ERROR_OK); error_code_ = - net::PlatformFileErrorToNetError(DriveFileErrorToPlatformError(error)); + net::PlatformFileErrorToNetError(FileErrorToPlatformError(error)); pending_data_.clear(); if (callback_.is_null()) { @@ -173,7 +173,7 @@ namespace { // Calls DriveFileSystemInterface::GetFileContentByPath if the file system // is available. If not, the |completion_callback| is invoked with -// DRIVE_FILE_ERROR_FAILED. +// FILE_ERROR_FAILED. void GetFileContentByPathOnUIThread( const DriveFileStreamReader::DriveFileSystemGetter& file_system_getter, const base::FilePath& drive_file_path, @@ -184,7 +184,7 @@ void GetFileContentByPathOnUIThread( DriveFileSystemInterface* file_system = file_system_getter.Run(); if (!file_system) { - completion_callback.Run(DRIVE_FILE_ERROR_FAILED); + completion_callback.Run(FILE_ERROR_FAILED); return; } @@ -257,12 +257,12 @@ int DriveFileStreamReader::Read(net::IOBuffer* buffer, int buffer_length, void DriveFileStreamReader::InitializeAfterGetFileContentByPathInitialized( const InitializeCompletionCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry, const base::FilePath& drive_file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, scoped_ptr<DriveEntryProto>()); return; } @@ -272,7 +272,7 @@ void DriveFileStreamReader::InitializeAfterGetFileContentByPathInitialized( // The file is not cached, and being downloaded. reader_proxy_.reset( new internal::NetworkReaderProxy(entry->file_info().size())); - callback.Run(DRIVE_FILE_OK, entry.Pass()); + callback.Run(FILE_ERROR_OK, entry.Pass()); return; } @@ -308,12 +308,12 @@ void DriveFileStreamReader::InitializeAfterLocalFileOpen( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (open_result != net::OK) { - callback.Run(DRIVE_FILE_ERROR_FAILED, scoped_ptr<DriveEntryProto>()); + callback.Run(FILE_ERROR_FAILED, scoped_ptr<DriveEntryProto>()); return; } reader_proxy_.reset(new internal::LocalReaderProxy(file_stream.Pass())); - callback.Run(DRIVE_FILE_OK, entry.Pass()); + callback.Run(FILE_ERROR_OK, entry.Pass()); } void DriveFileStreamReader::OnGetContent(google_apis::GDataErrorCode error_code, @@ -325,10 +325,10 @@ void DriveFileStreamReader::OnGetContent(google_apis::GDataErrorCode error_code, void DriveFileStreamReader::OnGetFileContentByPathCompletion( const InitializeCompletionCallback& callback, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { // We are interested in only errors. return; } diff --git a/chrome/browser/chromeos/drive/drive_file_stream_reader.h b/chrome/browser/chromeos/drive/drive_file_stream_reader.h index f69fdaf..5d31338 100644 --- a/chrome/browser/chromeos/drive/drive_file_stream_reader.h +++ b/chrome/browser/chromeos/drive/drive_file_stream_reader.h @@ -11,7 +11,7 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/google_apis/gdata_errorcode.h" #include "net/base/completion_callback.h" @@ -38,7 +38,7 @@ class ReaderProxy { virtual void OnGetContent(scoped_ptr<std::string> data) = 0; // Called when an error is found, during the network downloading. - virtual void OnError(DriveFileError error) = 0; + virtual void OnError(FileError error) = 0; }; // The read operation implementation for the locally cached files. @@ -53,7 +53,7 @@ class LocalReaderProxy : public ReaderProxy { virtual int Read(net::IOBuffer* buffer, int buffer_length, const net::CompletionCallback& callback) OVERRIDE; virtual void OnGetContent(scoped_ptr<std::string> data) OVERRIDE; - virtual void OnError(DriveFileError error) OVERRIDE; + virtual void OnError(FileError error) OVERRIDE; private: scoped_ptr<net::FileStream> file_stream_; @@ -71,7 +71,7 @@ class NetworkReaderProxy : public ReaderProxy { virtual int Read(net::IOBuffer* buffer, int buffer_length, const net::CompletionCallback& callback) OVERRIDE; virtual void OnGetContent(scoped_ptr<std::string> data) OVERRIDE; - virtual void OnError(DriveFileError error) OVERRIDE; + virtual void OnError(FileError error) OVERRIDE; private: // The data received from the server, but not yet read. @@ -107,7 +107,7 @@ class DriveFileStreamReader { typedef base::Callback<DriveFileSystemInterface*()> DriveFileSystemGetter; // Callback to return the result of Initialize(). - typedef base::Callback<void(DriveFileError error, + typedef base::Callback<void(FileError error, scoped_ptr<DriveEntryProto> entry)> InitializeCompletionCallback; @@ -137,7 +137,7 @@ class DriveFileStreamReader { // is done. void InitializeAfterGetFileContentByPathInitialized( const InitializeCompletionCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry, const base::FilePath& drive_file_path); @@ -155,7 +155,7 @@ class DriveFileStreamReader { // Called when GetFileContentByPath is completed. void OnGetFileContentByPathCompletion( const InitializeCompletionCallback& callback, - DriveFileError error); + FileError error); const DriveFileSystemGetter drive_file_system_getter_; scoped_ptr<internal::ReaderProxy> reader_proxy_; 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 c24de06..1951a01 100644 --- a/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_file_stream_reader_unittest.cc @@ -153,7 +153,7 @@ TEST(NetworkReaderProxyTest, ErrorWithPendingCallback) { EXPECT_EQ(net::ERR_IO_PENDING, result); // Emulate that an error is found. The callback should be called internally. - proxy.OnError(DRIVE_FILE_ERROR_FAILED); + proxy.OnError(FILE_ERROR_FAILED); result = callback.GetResult(result); EXPECT_EQ(net::ERR_FAILED, result); @@ -178,7 +178,7 @@ TEST(NetworkReaderProxyTest, ErrorWithPendingData) { proxy.OnGetContent(data.Pass()); // Emulate that an error is found. - proxy.OnError(DRIVE_FILE_ERROR_FAILED); + proxy.OnError(FILE_ERROR_FAILED); // The next Read call should return the error code, even if there is // pending data (the pending data should be released in OnError. @@ -266,7 +266,7 @@ TEST_F(DriveFileStreamReaderTest, Read) { scoped_ptr<DriveFileStreamReader> reader( new DriveFileStreamReader(GetDriveFileSystemGetter())); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry; reader->Initialize( kDriveFile, @@ -275,7 +275,7 @@ TEST_F(DriveFileStreamReaderTest, Read) { google_apis::test_util::CreateCopyResultCallback( &error, &entry))); message_loop_.Run(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(entry); // Read data from the reader. @@ -295,7 +295,7 @@ TEST_F(DriveFileStreamReaderTest, Read) { reader.reset( new DriveFileStreamReader(GetDriveFileSystemGetter())); - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; entry.reset(); reader->Initialize( kDriveFile, @@ -304,7 +304,7 @@ TEST_F(DriveFileStreamReaderTest, Read) { google_apis::test_util::CreateCopyResultCallback( &error, &entry))); message_loop_.Run(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(entry); // The size should be same. diff --git a/chrome/browser/chromeos/drive/drive_file_system.cc b/chrome/browser/chromeos/drive/drive_file_system.cc index e899eda..b5a2c2a 100644 --- a/chrome/browser/chromeos/drive/drive_file_system.cc +++ b/chrome/browser/chromeos/drive/drive_file_system.cc @@ -43,14 +43,14 @@ const char kEmptyFilePath[] = "/dev/null"; // Creates a temporary JSON file representing a document with |edit_url| // and |resource_id| under |document_dir| on blocking pool. -DriveFileError CreateDocumentJsonFileOnBlockingPool( +FileError CreateDocumentJsonFileOnBlockingPool( const base::FilePath& document_dir, const GURL& edit_url, const std::string& resource_id, base::FilePath* temp_file_path) { DCHECK(temp_file_path); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; if (file_util::CreateTemporaryFileInDir(document_dir, temp_file_path)) { std::string document_content = base::StringPrintf( @@ -59,11 +59,11 @@ DriveFileError CreateDocumentJsonFileOnBlockingPool( int document_size = static_cast<int>(document_content.size()); if (file_util::WriteFile(*temp_file_path, document_content.data(), document_size) == document_size) { - error = DRIVE_FILE_OK; + error = FILE_ERROR_OK; } } - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) temp_file_path->clear(); return error; } @@ -73,7 +73,7 @@ DriveFileError CreateDocumentJsonFileOnBlockingPool( void RunGetEntryInfoWithFilePathCallback( const GetEntryInfoWithFilePathCallback& callback, const base::FilePath& path, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(!callback.is_null()); callback.Run(error, path, entry_proto.Pass()); @@ -95,7 +95,7 @@ void OnGetLargestChangestamp( // Thin adapter to map GetFileCallback to FileOperationCallback. void GetFileCallbackToFileOperationCallbackAdapter( const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& unused_file_path, const std::string& unused_mime_type, DriveFileType unused_file_type) { @@ -142,7 +142,7 @@ struct DriveFileSystem::GetResolvedFileParams { DCHECK(this->entry_proto); } - void OnError(DriveFileError error) { + void OnError(FileError error) { get_file_callback.Run( error, base::FilePath(), std::string(), REGULAR_FILE); } @@ -153,7 +153,7 @@ struct DriveFileSystem::GetResolvedFileParams { } scoped_ptr<DriveEntryProto> entry(new DriveEntryProto(*entry_proto)); - initialized_callback.Run(DRIVE_FILE_OK, entry.Pass(), local_file_path); + initialized_callback.Run(FILE_ERROR_OK, entry.Pass(), local_file_path); } void OnStartDownloading() { @@ -162,16 +162,16 @@ struct DriveFileSystem::GetResolvedFileParams { } scoped_ptr<DriveEntryProto> entry(new DriveEntryProto(*entry_proto)); - initialized_callback.Run(DRIVE_FILE_OK, entry.Pass(), base::FilePath()); + initialized_callback.Run(FILE_ERROR_OK, entry.Pass(), base::FilePath()); } void OnComplete(const base::FilePath& local_file_path) { if (entry_proto->file_specific_info().is_hosted_document()) { get_file_callback.Run( - DRIVE_FILE_OK, local_file_path, kMimeTypeJson, HOSTED_DOCUMENT); + FILE_ERROR_OK, local_file_path, kMimeTypeJson, HOSTED_DOCUMENT); } else { get_file_callback.Run( - DRIVE_FILE_OK, local_file_path, + FILE_ERROR_OK, local_file_path, entry_proto->file_specific_info().content_mime_type(), REGULAR_FILE); } } @@ -219,7 +219,7 @@ DriveFileSystem::DriveFileSystem( scheduler_(scheduler), webapps_registry_(webapps_registry), resource_metadata_(resource_metadata), - last_update_check_error_(DRIVE_FILE_OK), + last_update_check_error_(FILE_ERROR_OK), hide_hosted_docs_(false), blocking_task_runner_(blocking_task_runner), ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { @@ -278,9 +278,9 @@ void DriveFileSystem::CheckForUpdates() { } } -void DriveFileSystem::OnUpdateChecked(DriveFileError error) { +void DriveFileSystem::OnUpdateChecked(FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DVLOG(1) << "CheckForUpdates finished: " << DriveFileErrorToString(error); + DVLOG(1) << "CheckForUpdates finished: " << FileErrorToString(error); last_update_check_time_ = base::Time::Now(); last_update_check_error_ = error; } @@ -318,13 +318,13 @@ void DriveFileSystem::GetEntryInfoByResourceId( void DriveFileSystem::GetEntryInfoByResourceIdAfterGetEntry( const GetEntryInfoWithFilePathCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& file_path, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, base::FilePath(), scoped_ptr<DriveEntryProto>()); return; } @@ -413,32 +413,32 @@ void DriveFileSystem::OnGetEntryInfoForCreateFile( const base::FilePath& file_path, bool is_exclusive, const FileOperationCallback& callback, - DriveFileError result, + FileError result, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); // The |file_path| is invalid. It is an error. - if (result != DRIVE_FILE_ERROR_NOT_FOUND && - result != DRIVE_FILE_OK) { + if (result != FILE_ERROR_NOT_FOUND && + result != FILE_ERROR_OK) { callback.Run(result); return; } // An entry already exists at |file_path|. - if (result == DRIVE_FILE_OK) { + if (result == FILE_ERROR_OK) { DCHECK(entry_proto.get()); // If an exclusive mode is requested, or the entry is not a regular file, // it is an error. if (is_exclusive || entry_proto->file_info().is_directory() || entry_proto->file_specific_info().is_hosted_document()) { - callback.Run(DRIVE_FILE_ERROR_EXISTS); + callback.Run(FILE_ERROR_EXISTS); return; } // Otherwise nothing more to do. Succeeded. - callback.Run(DRIVE_FILE_OK); + callback.Run(FILE_ERROR_OK); return; } @@ -463,16 +463,16 @@ void DriveFileSystem::Pin(const base::FilePath& file_path, void DriveFileSystem::PinAfterGetEntryInfoByPath( const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); // TODO(hashimoto): Support pinning directories. crbug.com/127831 if (entry && entry->file_info().is_directory()) - error = DRIVE_FILE_ERROR_NOT_A_FILE; + error = FILE_ERROR_NOT_A_FILE; - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -495,16 +495,16 @@ void DriveFileSystem::Unpin(const base::FilePath& file_path, void DriveFileSystem::UnpinAfterGetEntryInfoByPath( const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); // TODO(hashimoto): Support pinning directories. crbug.com/127831 if (entry && entry->file_info().is_directory()) - error = DRIVE_FILE_ERROR_NOT_A_FILE; + error = FILE_ERROR_NOT_A_FILE; - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -530,12 +530,12 @@ void DriveFileSystem::GetFileByPath(const base::FilePath& file_path, void DriveFileSystem::OnGetEntryInfoCompleteForGetFileByPath( const base::FilePath& file_path, const GetFileCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, base::FilePath(), std::string(), REGULAR_FILE); return; } @@ -573,14 +573,14 @@ void DriveFileSystem::GetFileByResourceIdAfterGetEntry( const DriveClientContext& context, const GetFileCallback& get_file_callback, const google_apis::GetContentCallback& get_content_callback, - DriveFileError error, + FileError error, const base::FilePath& file_path, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!get_file_callback.is_null()); - if (error != DRIVE_FILE_OK) { - get_file_callback.Run(DRIVE_FILE_ERROR_NOT_FOUND, + if (error != FILE_ERROR_OK) { + get_file_callback.Run(FILE_ERROR_NOT_FOUND, base::FilePath(), std::string(), REGULAR_FILE); @@ -622,14 +622,14 @@ void DriveFileSystem::GetFileContentByPathAfterGetEntry( const GetFileContentInitializedCallback& initialized_callback, const google_apis::GetContentCallback& get_content_callback, const FileOperationCallback& completion_callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!initialized_callback.is_null()); DCHECK(!get_content_callback.is_null()); DCHECK(!completion_callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { completion_callback.Run(error); return; } @@ -675,12 +675,12 @@ void DriveFileSystem::GetEntryInfoByPath(const base::FilePath& file_path, void DriveFileSystem::GetEntryInfoByPathAfterGetEntry1( const base::FilePath& file_path, const GetEntryInfoCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { CheckLocalModificationAndRun(entry_proto.Pass(), callback); return; } @@ -699,11 +699,11 @@ void DriveFileSystem::GetEntryInfoByPathAfterGetEntry1( void DriveFileSystem::GetEntryInfoByPathAfterLoad( const base::FilePath& file_path, const GetEntryInfoCallback& callback, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, scoped_ptr<DriveEntryProto>()); return; } @@ -717,12 +717,12 @@ void DriveFileSystem::GetEntryInfoByPathAfterLoad( void DriveFileSystem::GetEntryInfoByPathAfterGetEntry2( const GetEntryInfoCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, scoped_ptr<DriveEntryProto>()); return; } @@ -751,12 +751,12 @@ void DriveFileSystem::ReadDirectoryByPath( void DriveFileSystem::ReadDirectoryByPathAfterGetEntry( const base::FilePath& directory_path, const ReadDirectoryWithSettingCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { // If we don't know about the directory, start loading. change_list_loader_->LoadIfNeeded( DirectoryFetchInfo(), @@ -768,7 +768,7 @@ void DriveFileSystem::ReadDirectoryByPathAfterGetEntry( } if (!entry_proto->file_info().is_directory()) { - callback.Run(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, + callback.Run(FILE_ERROR_NOT_A_DIRECTORY, hide_hosted_docs_, scoped_ptr<DriveEntryProtoVector>()); return; @@ -790,11 +790,11 @@ void DriveFileSystem::ReadDirectoryByPathAfterGetEntry( void DriveFileSystem::ReadDirectoryByPathAfterLoad( const base::FilePath& directory_path, const ReadDirectoryWithSettingCallback& callback, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, hide_hosted_docs_, scoped_ptr<DriveEntryProtoVector>()); @@ -810,12 +810,12 @@ void DriveFileSystem::ReadDirectoryByPathAfterLoad( void DriveFileSystem::ReadDirectoryByPathAfterRead( const ReadDirectoryWithSettingCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProtoVector> entries) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, hide_hosted_docs_, scoped_ptr<DriveEntryProtoVector>()); @@ -823,7 +823,7 @@ void DriveFileSystem::ReadDirectoryByPathAfterRead( } DCHECK(entries.get()); // This is valid for empty directories too. - callback.Run(DRIVE_FILE_OK, hide_hosted_docs_, entries.Pass()); + callback.Run(FILE_ERROR_OK, hide_hosted_docs_, entries.Pass()); } void DriveFileSystem::GetResolvedFileByPath( @@ -832,7 +832,7 @@ void DriveFileSystem::GetResolvedFileByPath( DCHECK(params); if (!params->entry_proto->has_file_specific_info()) { - params->OnError(DRIVE_FILE_ERROR_NOT_FOUND); + params->OnError(FILE_ERROR_NOT_FOUND); return; } @@ -874,11 +874,11 @@ void DriveFileSystem::GetResolvedFileByPath( void DriveFileSystem::GetResolvedFileByPathAfterCreateDocumentJsonFile( scoped_ptr<GetResolvedFileParams> params, const base::FilePath* file_path, - DriveFileError error) { + FileError error) { DCHECK(params); DCHECK(file_path); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { params->OnError(error); return; } @@ -889,13 +889,13 @@ void DriveFileSystem::GetResolvedFileByPathAfterCreateDocumentJsonFile( void DriveFileSystem::GetResolvedFileByPathAfterGetFileFromCache( scoped_ptr<GetResolvedFileParams> params, - DriveFileError error, + FileError error, const base::FilePath& cache_file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(params); // Have we found the file in cache? If so, return it back to the caller. - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { params->OnCacheFileFound(cache_file_path); params->OnComplete(cache_file_path); return; @@ -928,8 +928,8 @@ void DriveFileSystem::GetResolvedFileByPathAfterGetResourceEntry( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(params); - const DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + const FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { params->OnError(error); return; } @@ -943,7 +943,7 @@ void DriveFileSystem::GetResolvedFileByPathAfterGetResourceEntry( // The content URL can be empty for non-downloadable files (such as files // shared from others with "prevent downloading by viewers" flag set.) if (download_url.is_empty()) { - params->OnError(DRIVE_FILE_ERROR_ACCESS_DENIED); + params->OnError(FILE_ERROR_ACCESS_DENIED); return; } @@ -959,13 +959,13 @@ void DriveFileSystem::GetResolvedFileByPathAfterGetResourceEntry( void DriveFileSystem::GetResolvedFileByPathAfterRefreshEntry( scoped_ptr<GetResolvedFileParams> params, const GURL& download_url, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(params); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { params->OnError(error); return; } @@ -988,8 +988,8 @@ void DriveFileSystem::GetResolvedFileByPathAfterFreeDiskSpace( DCHECK(params); if (!has_enough_space) { - // If no enough space, return DRIVE_FILE_ERROR_NO_SPACE. - params->OnError(DRIVE_FILE_ERROR_NO_SPACE); + // If no enough space, return FILE_ERROR_NO_SPACE. + params->OnError(FILE_ERROR_NO_SPACE); return; } @@ -1019,7 +1019,7 @@ void DriveFileSystem::GetResolveFileByPathAfterCreateTemporaryFile( DCHECK(params); if (!success) { - params->OnError(DRIVE_FILE_ERROR_FAILED); + params->OnError(FILE_ERROR_FAILED); return; } @@ -1056,8 +1056,8 @@ void DriveFileSystem::GetResolvedFileByPathAfterDownloadFile( params->entry_proto->file_specific_info().file_md5())); } - DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { params->OnError(error); return; } @@ -1091,11 +1091,11 @@ void DriveFileSystem::GetResolvedFileByPathAfterGetCacheEntryForCancel( void DriveFileSystem::GetResolvedFileByPathAfterStore( scoped_ptr<GetResolvedFileParams> params, const base::FilePath& downloaded_file_path, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(params); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { blocking_task_runner_->PostTask( FROM_HERE, base::Bind(base::IgnoreResult(&file_util::Delete), @@ -1118,12 +1118,12 @@ void DriveFileSystem::GetResolvedFileByPathAfterStore( void DriveFileSystem::GetResolvedFileByPathAfterGetFile( scoped_ptr<GetResolvedFileParams> params, - DriveFileError error, + FileError error, const base::FilePath& cache_file) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(params); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { params->OnError(error); return; } @@ -1148,22 +1148,22 @@ void DriveFileSystem::RefreshDirectory( void DriveFileSystem::RefreshDirectoryAfterGetEntryInfo( const base::FilePath& directory_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } if (!entry_proto->file_info().is_directory()) { - callback.Run(DRIVE_FILE_ERROR_NOT_A_DIRECTORY); + callback.Run(FILE_ERROR_NOT_A_DIRECTORY); return; } if (util::IsSpecialResourceId(entry_proto->resource_id())) { // Do not load special directories. Just return. - callback.Run(DRIVE_FILE_OK); + callback.Run(FILE_ERROR_OK); return; } @@ -1200,25 +1200,25 @@ void DriveFileSystem::OnGetAboutResource( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { callback.Run(error, -1, -1); return; } DCHECK(about_resource); - callback.Run(DRIVE_FILE_OK, + callback.Run(FILE_ERROR_OK, about_resource->quota_bytes_total(), about_resource->quota_bytes_used()); } void DriveFileSystem::OnSearch(const SearchCallback& search_callback, ScopedVector<ChangeList> change_lists, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!search_callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { search_callback.Run(error, GURL(), scoped_ptr<std::vector<SearchResultInfo> >()); @@ -1238,7 +1238,7 @@ void DriveFileSystem::OnSearch(const SearchCallback& search_callback, const GURL& next_feed = change_list->next_url(); const base::Closure callback = base::Bind( - search_callback, DRIVE_FILE_OK, next_feed, base::Passed(&result_vec)); + search_callback, FILE_ERROR_OK, next_feed, base::Passed(&result_vec)); const std::vector<DriveEntryProto>& entries = change_list->entries(); if (entries.empty()) { @@ -1269,7 +1269,7 @@ void DriveFileSystem::AddToSearchResults( std::vector<SearchResultInfo>* results, bool should_run_callback, const base::Closure& callback, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -1278,11 +1278,11 @@ void DriveFileSystem::AddToSearchResults( // CheckForUpdates to refresh the snapshot with a delta feed. This may happen // if the entry has recently been added to the drive (and we still haven't // received its delta feed). - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { DCHECK(entry_proto.get()); results->push_back(SearchResultInfo(drive_file_path, *entry_proto.get())); DVLOG(1) << "AddToSearchResults " << drive_file_path.value(); - } else if (error == DRIVE_FILE_ERROR_NOT_FOUND) { + } else if (error == FILE_ERROR_NOT_FOUND) { CheckForUpdates(); } else { NOTREACHED(); @@ -1372,14 +1372,14 @@ void DriveFileSystem::AddUploadedFile( void DriveFileSystem::AddUploadedFileToCache( const AddUploadedFileParams& params, - DriveFileError error, + FileError error, const base::FilePath& file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!params.resource_id.empty()); DCHECK(!params.md5.empty()); DCHECK(!params.callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { params.callback.Run(error); return; } @@ -1423,12 +1423,12 @@ void DriveFileSystem::MarkCacheFileAsMounted( void DriveFileSystem::MarkCacheFileAsMountedAfterGetEntryInfo( const OpenFileCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, base::FilePath()); return; } @@ -1446,7 +1446,7 @@ void DriveFileSystem::MarkCacheFileAsUnmounted( DCHECK(!callback.is_null()); if (!cache_->IsUnderDriveCacheDirectory(cache_file_path)) { - callback.Run(DRIVE_FILE_ERROR_FAILED); + callback.Run(FILE_ERROR_FAILED); return; } cache_->MarkAsUnmounted(cache_file_path, callback); @@ -1498,7 +1498,7 @@ void DriveFileSystem::OpenFile(const base::FilePath& file_path, if (open_files_.find(file_path) != open_files_.end()) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, - base::Bind(callback, DRIVE_FILE_ERROR_IN_USE, base::FilePath())); + base::Bind(callback, FILE_ERROR_IN_USE, base::FilePath())); return; } open_files_.insert(file_path); @@ -1517,24 +1517,24 @@ void DriveFileSystem::OpenFile(const base::FilePath& file_path, void DriveFileSystem::OnGetEntryInfoCompleteForOpenFile( const base::FilePath& file_path, const OpenFileCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - DCHECK(entry_proto.get() || error != DRIVE_FILE_OK); + DCHECK(entry_proto.get() || error != FILE_ERROR_OK); if (entry_proto.get() && !entry_proto->has_file_specific_info()) - error = DRIVE_FILE_ERROR_NOT_FOUND; + error = FILE_ERROR_NOT_FOUND; - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { if (entry_proto->file_specific_info().file_md5().empty() || entry_proto->file_specific_info().is_hosted_document()) { // No support for opening a directory or hosted document. - error = DRIVE_FILE_ERROR_INVALID_OPERATION; + error = FILE_ERROR_INVALID_OPERATION; } } - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, base::FilePath()); return; } @@ -1559,14 +1559,14 @@ void DriveFileSystem::OnGetEntryInfoCompleteForOpenFile( void DriveFileSystem::OnGetFileCompleteForOpenFile( const GetFileCompleteForOpenParams& params, - DriveFileError error, + FileError error, const base::FilePath& file_path, const std::string& mime_type, DriveFileType file_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!params.callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { params.callback.Run(error, base::FilePath()); return; } @@ -1584,11 +1584,11 @@ void DriveFileSystem::OnGetFileCompleteForOpenFile( void DriveFileSystem::OnMarkDirtyInCacheCompleteForOpenFile( const GetFileCompleteForOpenParams& params, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!params.callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { params.callback.Run(error, base::FilePath()); return; } @@ -1599,7 +1599,7 @@ void DriveFileSystem::OnMarkDirtyInCacheCompleteForOpenFile( void DriveFileSystem::OnOpenFileFinished( const base::FilePath& file_path, const OpenFileCallback& callback, - DriveFileError result, + FileError result, const base::FilePath& cache_file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -1607,7 +1607,7 @@ void DriveFileSystem::OnOpenFileFinished( // All the invocation of |callback| from operations initiated from OpenFile // must go through here. Removes the |file_path| from the remembered set when // the file was not successfully opened. - if (result != DRIVE_FILE_OK) + if (result != FILE_ERROR_OK) open_files_.erase(file_path); callback.Run(result, cache_file_path); @@ -1622,7 +1622,7 @@ void DriveFileSystem::CloseFile(const base::FilePath& file_path, // The file is not being opened. base::MessageLoopProxy::current()->PostTask( FROM_HERE, - base::Bind(callback, DRIVE_FILE_ERROR_NOT_FOUND)); + base::Bind(callback, FILE_ERROR_NOT_FOUND)); return; } @@ -1641,15 +1641,15 @@ void DriveFileSystem::CloseFile(const base::FilePath& file_path, void DriveFileSystem::CloseFileAfterGetEntryInfo( const base::FilePath& file_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); if (entry_proto.get() && !entry_proto->has_file_specific_info()) - error = DRIVE_FILE_ERROR_NOT_FOUND; + error = FILE_ERROR_NOT_FOUND; - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -1667,7 +1667,7 @@ void DriveFileSystem::CloseFileAfterGetEntryInfo( void DriveFileSystem::CloseFileFinalize(const base::FilePath& file_path, const FileOperationCallback& callback, - DriveFileError result) { + FileError result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -1691,7 +1691,7 @@ void DriveFileSystem::CheckLocalModificationAndRun( // 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(DRIVE_FILE_OK, entry_proto.Pass()); + callback.Run(FILE_ERROR_OK, entry_proto.Pass()); return; } @@ -1718,7 +1718,7 @@ void DriveFileSystem::CheckLocalModificationAndRunAfterGetCacheEntry( // When no dirty cache is found, use the original entry info as is. if (!success || !cache_entry.is_dirty()) { - callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); + callback.Run(FILE_ERROR_OK, entry_proto.Pass()); return; } @@ -1738,14 +1738,14 @@ void DriveFileSystem::CheckLocalModificationAndRunAfterGetCacheEntry( void DriveFileSystem::CheckLocalModificationAndRunAfterGetCacheFile( scoped_ptr<DriveEntryProto> entry_proto, const GetEntryInfoCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& local_cache_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); // When no dirty cache is found, use the original entry info as is. - if (error != DRIVE_FILE_OK) { - callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); + if (error != FILE_ERROR_OK) { + callback.Run(FILE_ERROR_OK, entry_proto.Pass()); return; } @@ -1773,14 +1773,14 @@ void DriveFileSystem::CheckLocalModificationAndRunAfterGetFileInfo( DCHECK(!callback.is_null()); if (!get_file_info_result) { - callback.Run(DRIVE_FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); + callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); return; } PlatformFileInfoProto entry_file_info; util::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); *entry_proto->mutable_file_info() = entry_file_info; - callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); + callback.Run(FILE_ERROR_OK, entry_proto.Pass()); } } // namespace drive diff --git a/chrome/browser/chromeos/drive/drive_file_system.h b/chrome/browser/chromeos/drive/drive_file_system.h index 8a87206..1152f96 100644 --- a/chrome/browser/chromeos/drive/drive_file_system.h +++ b/chrome/browser/chromeos/drive/drive_file_system.h @@ -186,7 +186,7 @@ class DriveFileSystem : public DriveFileSystemInterface, // |error| is the error code returned by ChangeListLoader. void OnSearch(const SearchCallback& callback, ScopedVector<ChangeList> change_lists, - DriveFileError error); + FileError error); // Callback for DriveResourceMetadata::RefreshEntry, from OnSearch. // Adds |drive_file_path| to |results|. When |entry_proto| is not present in @@ -196,7 +196,7 @@ class DriveFileSystem : public DriveFileSystemInterface, void AddToSearchResults(std::vector<SearchResultInfo>* results, bool should_run_callback, const base::Closure& callback, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto); @@ -210,17 +210,17 @@ class DriveFileSystem : public DriveFileSystemInterface, void OnGetEntryInfoForCreateFile(const base::FilePath& file_path, bool is_exclusive, const FileOperationCallback& callback, - DriveFileError result, + FileError result, scoped_ptr<DriveEntryProto> entry_proto); // Used to implement Pin(). void PinAfterGetEntryInfoByPath(const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry); // Used to implement Unpin(). void UnpinAfterGetEntryInfoByPath(const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry); // Invoked upon completion of GetEntryInfoByPath initiated by @@ -229,7 +229,7 @@ class DriveFileSystem : public DriveFileSystemInterface, void OnGetEntryInfoCompleteForGetFileByPath( const base::FilePath& file_path, const GetFileCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> file_info); // Invoked upon completion of GetEntryInfoByPath initiated by OpenFile. @@ -238,7 +238,7 @@ class DriveFileSystem : public DriveFileSystemInterface, void OnGetEntryInfoCompleteForOpenFile( const base::FilePath& file_path, const OpenFileCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> file_info); // Invoked at the last step of OpenFile. It removes |file_path| from the @@ -246,7 +246,7 @@ class DriveFileSystem : public DriveFileSystemInterface, // |callback| function. void OnOpenFileFinished(const base::FilePath& file_path, const OpenFileCallback& callback, - DriveFileError result, + FileError result, const base::FilePath& cache_file_path); // Invoked during the process of CloseFile. What is done here is as follows: @@ -257,18 +257,18 @@ class DriveFileSystem : public DriveFileSystemInterface, // |callback| must not be null. void CloseFileAfterGetEntryInfo(const base::FilePath& file_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); void CloseFileFinalize(const base::FilePath& file_path, const FileOperationCallback& callback, - DriveFileError result); + FileError result); // Invoked upon completion of GetFileByPath initiated by OpenFile. If // GetFileByPath is successful, calls MarkDirtyInCache to mark the cache // file as dirty for the file identified by |file_info.resource_id| and // |file_info.md5|. void OnGetFileCompleteForOpenFile(const GetFileCompleteForOpenParams& params, - DriveFileError error, + FileError error, const base::FilePath& file_path, const std::string& mime_type, DriveFileType file_type); @@ -276,7 +276,7 @@ class DriveFileSystem : public DriveFileSystemInterface, // Invoked upon completion of MarkDirtyInCache initiated by OpenFile. void OnMarkDirtyInCacheCompleteForOpenFile( const GetFileCompleteForOpenParams& params, - DriveFileError error); + FileError error); // Callback for handling about resource fetch. void OnGetAboutResource( @@ -286,12 +286,12 @@ class DriveFileSystem : public DriveFileSystemInterface, // Adds the uploaded file to the cache. void AddUploadedFileToCache(const AddUploadedFileParams& params, - DriveFileError error, + FileError error, const base::FilePath& file_path); // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated // from CheckForUpdates(). - void OnUpdateChecked(DriveFileError error); + void OnUpdateChecked(FileError error); // Changes state of hosted documents visibility, triggers directory refresh. void SetHideHostedDocuments(bool hide); @@ -308,14 +308,14 @@ class DriveFileSystem : public DriveFileSystemInterface, void GetEntryInfoByPathAfterGetEntry1( const base::FilePath& file_path, const GetEntryInfoCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); void GetEntryInfoByPathAfterLoad(const base::FilePath& file_path, const GetEntryInfoCallback& callback, - DriveFileError error); + FileError error); void GetEntryInfoByPathAfterGetEntry2( const GetEntryInfoCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Part of ReadDirectoryByPath() @@ -326,15 +326,15 @@ class DriveFileSystem : public DriveFileSystemInterface, void ReadDirectoryByPathAfterGetEntry( const base::FilePath& directory_path, const ReadDirectoryWithSettingCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); void ReadDirectoryByPathAfterLoad( const base::FilePath& directory_path, const ReadDirectoryWithSettingCallback& callback, - DriveFileError error); + FileError error); void ReadDirectoryByPathAfterRead( const ReadDirectoryWithSettingCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProtoVector> entries); // Gets the file at |file_path| from the cache (if found in the cache), @@ -344,10 +344,10 @@ class DriveFileSystem : public DriveFileSystemInterface, void GetResolvedFileByPathAfterCreateDocumentJsonFile( scoped_ptr<GetResolvedFileParams> params, const base::FilePath* file_path, - DriveFileError error); + FileError error); void GetResolvedFileByPathAfterGetFileFromCache( scoped_ptr<GetResolvedFileParams> params, - DriveFileError error, + FileError error, const base::FilePath& cache_file_path); void GetResolvedFileByPathAfterGetResourceEntry( scoped_ptr<GetResolvedFileParams> params, @@ -356,7 +356,7 @@ class DriveFileSystem : public DriveFileSystemInterface, void GetResolvedFileByPathAfterRefreshEntry( scoped_ptr<GetResolvedFileParams> params, const GURL& download_url, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto); void GetResolvedFileByPathAfterFreeDiskSpace( @@ -380,10 +380,10 @@ class DriveFileSystem : public DriveFileSystemInterface, void GetResolvedFileByPathAfterStore( scoped_ptr<GetResolvedFileParams> params, const base::FilePath& downloaded_file_path, - DriveFileError error); + FileError error); void GetResolvedFileByPathAfterGetFile( scoped_ptr<GetResolvedFileParams> params, - DriveFileError error, + FileError error, const base::FilePath& cache_file); // Part of GetEntryInfoByResourceId(). Called after @@ -391,7 +391,7 @@ class DriveFileSystem : public DriveFileSystemInterface, // |callback| must not be null. void GetEntryInfoByResourceIdAfterGetEntry( const GetEntryInfoWithFilePathCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& file_path, scoped_ptr<DriveEntryProto> entry_proto); @@ -403,7 +403,7 @@ class DriveFileSystem : public DriveFileSystemInterface, const DriveClientContext& context, const GetFileCallback& get_file_callback, const google_apis::GetContentCallback& get_content_callback, - DriveFileError error, + FileError error, const base::FilePath& file_path, scoped_ptr<DriveEntryProto> entry_proto); @@ -416,7 +416,7 @@ class DriveFileSystem : public DriveFileSystemInterface, const GetFileContentInitializedCallback& initialized_callback, const google_apis::GetContentCallback& get_content_callback, const FileOperationCallback& completion_callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Part of RefreshDirectory(). Called after @@ -424,7 +424,7 @@ class DriveFileSystem : public DriveFileSystemInterface, void RefreshDirectoryAfterGetEntryInfo( const base::FilePath& directory_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Part of GetEntryByResourceId and GetEntryByPath. Checks whether there is a @@ -441,7 +441,7 @@ class DriveFileSystem : public DriveFileSystemInterface, void CheckLocalModificationAndRunAfterGetCacheFile( scoped_ptr<DriveEntryProto> entry_proto, const GetEntryInfoCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& local_cache_path); void CheckLocalModificationAndRunAfterGetFileInfo( scoped_ptr<DriveEntryProto> entry_proto, @@ -453,7 +453,7 @@ class DriveFileSystem : public DriveFileSystemInterface, // completed. |callback| must not be null. void MarkCacheFileAsMountedAfterGetEntryInfo( const OpenFileCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // The profile hosts the DriveFileSystem via DriveSystemService. @@ -470,7 +470,7 @@ class DriveFileSystem : public DriveFileSystemInterface, base::Time last_update_check_time_; // Error of the last update check. - DriveFileError last_update_check_error_; + FileError last_update_check_error_; // True if hosted documents should be hidden. bool hide_hosted_docs_; diff --git a/chrome/browser/chromeos/drive/drive_file_system_interface.h b/chrome/browser/chromeos/drive/drive_file_system_interface.h index 2b0b4a4..b6bc1e9 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_interface.h +++ b/chrome/browser/chromeos/drive/drive_file_system_interface.h @@ -68,13 +68,13 @@ struct MetadataSearchResult { typedef std::vector<MetadataSearchResult> MetadataSearchResultVector; // Used to get files from the file system. -typedef base::Callback<void(DriveFileError error, +typedef base::Callback<void(FileError error, const base::FilePath& file_path, const std::string& mime_type, DriveFileType file_type)> GetFileCallback; // Used to get file content from the file system. -typedef base::Callback<void(DriveFileError error, +typedef base::Callback<void(FileError error, scoped_ptr<DriveEntryProto> entry_proto, const base::FilePath& local_file)> GetFileContentInitializedCallback; @@ -82,33 +82,33 @@ typedef base::Callback<void(DriveFileError error, // Used to read a directory from the file system. // Similar to ReadDirectoryCallback but this one provides // |hide_hosted_documents| -// If |error| is not DRIVE_FILE_OK, |entries| is set to NULL. +// If |error| is not FILE_ERROR_OK, |entries| is set to NULL. // |entries| are contents, both files and directories, of the directory. -typedef base::Callback<void(DriveFileError error, +typedef base::Callback<void(FileError error, bool hide_hosted_documents, scoped_ptr<DriveEntryProtoVector> entries)> ReadDirectoryWithSettingCallback; // Used to get drive content search results. -// If |error| is not DRIVE_FILE_OK, |result_paths| is empty. +// If |error| is not FILE_ERROR_OK, |result_paths| is empty. typedef base::Callback<void( - DriveFileError error, + FileError error, const GURL& next_feed, scoped_ptr<std::vector<SearchResultInfo> > result_paths)> SearchCallback; -// Callback for SearchMetadata(). On success, |error| is DRIVE_FILE_OK, and +// Callback for SearchMetadata(). On success, |error| is FILE_ERROR_OK, and // |result| contains the search result. typedef base::Callback<void( - DriveFileError error, + FileError error, scoped_ptr<MetadataSearchResultVector> result)> SearchMetadataCallback; // Used to open files from the file system. |file_path| is the path on the local // file system for the opened file. -typedef base::Callback<void(DriveFileError error, +typedef base::Callback<void(FileError error, const base::FilePath& file_path)> OpenFileCallback; // Used to get available space for the account from Drive. -typedef base::Callback<void(DriveFileError error, +typedef base::Callback<void(FileError error, int64 bytes_total, int64 bytes_used)> GetAvailableSpaceCallback; diff --git a/chrome/browser/chromeos/drive/drive_file_system_metadata.cc b/chrome/browser/chromeos/drive/drive_file_system_metadata.cc index eaacb65..fee1c88 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_metadata.cc +++ b/chrome/browser/chromeos/drive/drive_file_system_metadata.cc @@ -9,7 +9,7 @@ namespace drive { DriveFileSystemMetadata::DriveFileSystemMetadata() : largest_changestamp(0), refreshing(false), - last_update_check_error(DRIVE_FILE_OK) { + last_update_check_error(FILE_ERROR_OK) { } DriveFileSystemMetadata::~DriveFileSystemMetadata() { diff --git a/chrome/browser/chromeos/drive/drive_file_system_metadata.h b/chrome/browser/chromeos/drive/drive_file_system_metadata.h index 9c23e54..e58ded8 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_metadata.h +++ b/chrome/browser/chromeos/drive/drive_file_system_metadata.h @@ -7,7 +7,7 @@ #include "base/basictypes.h" #include "base/time.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" namespace drive { @@ -27,7 +27,7 @@ struct DriveFileSystemMetadata { base::Time last_update_check_time; // Error code of the last update check. - DriveFileError last_update_check_error; + FileError last_update_check_error; }; } // namespace drive diff --git a/chrome/browser/chromeos/drive/drive_file_system_observer.h b/chrome/browser/chromeos/drive/drive_file_system_observer.h index 063ca34..a317c46b 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_observer.h +++ b/chrome/browser/chromeos/drive/drive_file_system_observer.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_OBSERVER_H_ #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_OBSERVER_H_ -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" namespace base { class FilePath; diff --git a/chrome/browser/chromeos/drive/drive_file_system_proxy.cc b/chrome/browser/chromeos/drive/drive_file_system_proxy.cc index 63dd419..da00608 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_proxy.cc +++ b/chrome/browser/chromeos/drive/drive_file_system_proxy.cc @@ -51,12 +51,12 @@ void OnGetFileByPathForOpen( const FileSystemOperation::OpenFileCallback& callback, int file_flags, base::ProcessHandle peer_handle, - DriveFileError file_error, + FileError file_error, const base::FilePath& local_path, const std::string& unused_mime_type, DriveFileType file_type) { base::PlatformFileError error = - DriveFileErrorToPlatformError(file_error); + FileErrorToPlatformError(file_error); if (error != base::PLATFORM_FILE_OK) { callback.Run(error, base::kInvalidPlatformFileValue, peer_handle); return; @@ -83,13 +83,13 @@ void OnGetFileByPathForOpen( void CallSnapshotFileCallback( const FileSystemOperation::SnapshotFileCallback& callback, const base::PlatformFileInfo& file_info, - DriveFileError file_error, + FileError file_error, const base::FilePath& local_path, const std::string& unused_mime_type, DriveFileType file_type) { scoped_refptr<ShareableFileReference> file_ref; base::PlatformFileError error = - DriveFileErrorToPlatformError(file_error); + FileErrorToPlatformError(file_error); // If the file is a hosted document, a temporary JSON file is created to // represent the document. The JSON file is not cached and its lifetime @@ -114,7 +114,7 @@ void CallSnapshotFileCallback( // Emits debug log when DriveFileSystem::CloseFile() is complete. void EmitDebugLogForCloseFile(const base::FilePath& local_path, - DriveFileError file_error) { + FileError file_error) { DVLOG(1) << "Closed: " << local_path.AsUTF8Unsafe() << ": " << file_error; } @@ -140,10 +140,10 @@ base::PlatformFileError DoTruncateOnBlockingPool( void DidCloseFileForTruncate( const FileSystemOperation::StatusCallback& callback, base::PlatformFileError truncate_result, - DriveFileError close_result) { + FileError close_result) { // Reports the first error. callback.Run(truncate_result == base::PLATFORM_FILE_OK ? - DriveFileErrorToPlatformError(close_result) : + FileErrorToPlatformError(close_result) : truncate_result); } @@ -381,12 +381,12 @@ void DriveFileSystemProxy::OnOpenFileForWriting( int file_flags, base::ProcessHandle peer_handle, const FileSystemOperation::OpenFileCallback& callback, - DriveFileError file_error, + FileError file_error, const base::FilePath& local_cache_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); base::PlatformFileError error = - DriveFileErrorToPlatformError(file_error); + FileErrorToPlatformError(file_error); if (error != base::PLATFORM_FILE_OK) { callback.Run(error, base::kInvalidPlatformFileValue, peer_handle); @@ -415,10 +415,10 @@ void DriveFileSystemProxy::OnCreateFileForOpen( int file_flags, base::ProcessHandle peer_handle, const FileSystemOperation::OpenFileCallback& callback, - DriveFileError file_error) { + FileError file_error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); base::PlatformFileError create_result = - DriveFileErrorToPlatformError(file_error); + FileErrorToPlatformError(file_error); if ((create_result == base::PLATFORM_FILE_OK) || ((create_result == base::PLATFORM_FILE_ERROR_EXISTS) && @@ -450,12 +450,12 @@ void DriveFileSystemProxy::OnFileOpenedForTruncate( const base::FilePath& virtual_path, int64 length, const fileapi::FileSystemOperation::StatusCallback& callback, - DriveFileError open_result, + FileError open_result, const base::FilePath& local_cache_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (open_result != DRIVE_FILE_OK) { - callback.Run(DriveFileErrorToPlatformError(open_result)); + if (open_result != FILE_ERROR_OK) { + callback.Run(FileErrorToPlatformError(open_result)); return; } @@ -632,11 +632,11 @@ void DriveFileSystemProxy::CreateSnapshotFile( void DriveFileSystemProxy::OnGetEntryInfoByPath( const base::FilePath& entry_path, const FileSystemOperation::SnapshotFileCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (error != DRIVE_FILE_OK || !entry_proto.get()) { + if (error != FILE_ERROR_OK || !entry_proto.get()) { callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, base::PlatformFileInfo(), base::FilePath(), @@ -718,19 +718,19 @@ void DriveFileSystemProxy::CallDriveFileSystemMethodOnUIThreadInternal( void DriveFileSystemProxy::OnStatusCallback( const fileapi::FileSystemOperation::StatusCallback& callback, - DriveFileError error) { - callback.Run(DriveFileErrorToPlatformError(error)); + FileError error) { + callback.Run(FileErrorToPlatformError(error)); } void DriveFileSystemProxy::OnGetMetadata( const base::FilePath& file_path, const FileSystemOperation::GetMetadataCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (error != DRIVE_FILE_OK) { - callback.Run(DriveFileErrorToPlatformError(error), + if (error != FILE_ERROR_OK) { + callback.Run(FileErrorToPlatformError(error), base::PlatformFileInfo(), base::FilePath()); return; @@ -746,13 +746,13 @@ void DriveFileSystemProxy::OnGetMetadata( void DriveFileSystemProxy::OnReadDirectory( const FileSystemOperation::ReadDirectoryCallback& callback, - DriveFileError error, + FileError error, bool hide_hosted_documents, scoped_ptr<DriveEntryProtoVector> proto_entries) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (error != DRIVE_FILE_OK) { - callback.Run(DriveFileErrorToPlatformError(error), + if (error != FILE_ERROR_OK) { + callback.Run(FileErrorToPlatformError(error), std::vector<base::FileUtilProxy::Entry>(), false); return; @@ -777,13 +777,13 @@ void DriveFileSystemProxy::OnReadDirectory( void DriveFileSystemProxy::OnCreateWritableSnapshotFile( const base::FilePath& virtual_path, const fileapi::WritableSnapshotFile& callback, - DriveFileError result, + FileError result, const base::FilePath& local_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); scoped_refptr<ShareableFileReference> file_ref; - if (result == DRIVE_FILE_OK) { + if (result == FILE_ERROR_OK) { file_ref = ShareableFileReference::GetOrCreate( local_path, ShareableFileReference::DONT_DELETE_ON_FINAL_RELEASE, @@ -794,7 +794,7 @@ void DriveFileSystemProxy::OnCreateWritableSnapshotFile( virtual_path)); } - callback.Run(DriveFileErrorToPlatformError(result), local_path, file_ref); + callback.Run(FileErrorToPlatformError(result), local_path, file_ref); } void DriveFileSystemProxy::CloseWritableSnapshotFile( diff --git a/chrome/browser/chromeos/drive/drive_file_system_proxy.h b/chrome/browser/chromeos/drive/drive_file_system_proxy.h index 7fcbd01..23c85f2 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_proxy.h +++ b/chrome/browser/chromeos/drive/drive_file_system_proxy.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_PROXY_H_ #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_PROXY_H_ -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "webkit/fileapi/remote_file_system_proxy.h" namespace fileapi { @@ -110,7 +110,7 @@ class DriveFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { // calling thread. void OnStatusCallback( const fileapi::FileSystemOperation::StatusCallback& callback, - DriveFileError error); + FileError error); // Helper callback for relaying reply for metadata retrieval request to the // calling thread. @@ -118,7 +118,7 @@ class DriveFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { const base::FilePath& file_path, const fileapi::FileSystemOperation::GetMetadataCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Helper callback for relaying reply for GetEntryInfoByPath() to the @@ -127,7 +127,7 @@ class DriveFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { const base::FilePath& entry_path, const fileapi::FileSystemOperation::SnapshotFileCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Helper callback for relaying reply for ReadDirectory() to the calling @@ -135,7 +135,7 @@ class DriveFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { void OnReadDirectory( const fileapi::FileSystemOperation::ReadDirectoryCallback& callback, - DriveFileError error, + FileError error, bool hide_hosted_documents, scoped_ptr<DriveEntryProtoVector> proto_entries); @@ -144,7 +144,7 @@ class DriveFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { void OnCreateWritableSnapshotFile( const base::FilePath& virtual_path, const fileapi::WritableSnapshotFile& callback, - DriveFileError result, + FileError result, const base::FilePath& local_path); // Helper callback for closing the local cache file and committing the dirty @@ -160,7 +160,7 @@ class DriveFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { const base::FilePath& virtual_path, int64 length, const fileapi::FileSystemOperation::StatusCallback& callback, - DriveFileError open_result, + FileError open_result, const base::FilePath& local_cache_path); // Invoked during Truncate() operation. This is called when the truncation of @@ -177,7 +177,7 @@ class DriveFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { int file_flags, base::ProcessHandle peer_handle, const fileapi::FileSystemOperation::OpenFileCallback& callback, - DriveFileError file_error, + FileError file_error, const base::FilePath& local_cache_path); // Invoked during OpenFile() operation when file create flags are set. @@ -186,7 +186,7 @@ class DriveFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { int file_flags, base::ProcessHandle peer_handle, const fileapi::FileSystemOperation::OpenFileCallback& callback, - DriveFileError file_error); + FileError file_error); // Invoked during OpenFile() operation when base::PLATFORM_FILE_OPEN_TRUNCATED // flag is set. This is called when the truncation of a local cache file is diff --git a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc index b85a962..c3911c4 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc @@ -57,7 +57,7 @@ void DriveSearchCallback( const SearchResultPair* expected_results, size_t expected_results_size, const GURL& expected_next_feed, - DriveFileError error, + FileError error, const GURL& next_feed, scoped_ptr<std::vector<SearchResultInfo> > results) { ASSERT_TRUE(results); @@ -89,8 +89,8 @@ int CountFiles(const DriveEntryProtoVector& entries) { // quits the current message loop. void AsyncInitializationCallback( int* counter, int expected_counter, MessageLoop* message_loop, - DriveFileError error, scoped_ptr<DriveEntryProto> entry) { - if (error != DRIVE_FILE_OK || !entry) { + FileError error, scoped_ptr<DriveEntryProto> 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 // value of |counter| is different from the expected one. @@ -175,11 +175,11 @@ class DriveFileSystemTest : public testing::Test { file_system_->AddObserver(mock_directory_observer_.get()); file_system_->Initialize(); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; resource_metadata_->Initialize( google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); } virtual void TearDown() OVERRIDE { @@ -193,12 +193,12 @@ class DriveFileSystemTest : public testing::Test { // Loads test json file as root ("/drive") element. bool LoadRootFeedDocument() { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->change_list_loader()->LoadIfNeeded( DirectoryFetchInfo(), google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - return error == DRIVE_FILE_OK; + return error == FILE_ERROR_OK; } bool LoadChangeFeed(const std::string& filename) { @@ -213,8 +213,8 @@ class DriveFileSystemTest : public testing::Test { return true; } - DriveFileError AddDirectory(const base::FilePath& directory_path) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError AddDirectory(const base::FilePath& directory_path) { + FileError error = FILE_ERROR_FAILED; file_system_->CreateDirectory( directory_path, false, // is_exclusive @@ -225,18 +225,18 @@ class DriveFileSystemTest : public testing::Test { } bool RemoveEntry(const base::FilePath& file_path) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->Remove( file_path, false, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - return error == DRIVE_FILE_OK; + return error == FILE_ERROR_OK; } // Gets entry info by path synchronously. scoped_ptr<DriveEntryProto> GetEntryInfoByPathSync( const base::FilePath& file_path) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry_proto; file_system_->GetEntryInfoByPath( file_path, @@ -249,7 +249,7 @@ class DriveFileSystemTest : public testing::Test { // Gets directory info by path synchronously. scoped_ptr<DriveEntryProtoVector> ReadDirectoryByPathSync( const base::FilePath& file_path) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; bool unused_hide_hosted_documents; scoped_ptr<DriveEntryProtoVector> entries; file_system_->ReadDirectoryByPath( @@ -319,18 +319,18 @@ class DriveFileSystemTest : public testing::Test { cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META), blocking_task_runner_)); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; resource_metadata->Initialize( google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) return false; resource_metadata->SetLargestChangestamp( param == USE_SERVER_TIMESTAMP ? 654321 : 1, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) return false; // drive/root is already prepared by DriveResourceMetadata. @@ -341,7 +341,7 @@ class DriveFileSystemTest : public testing::Test { util::CreateMyDriveRootEntry(root_resource_id), google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) return false; // drive/root/File1 @@ -356,7 +356,7 @@ class DriveFileSystemTest : public testing::Test { file1, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) return false; // drive/root/Dir1 @@ -369,7 +369,7 @@ class DriveFileSystemTest : public testing::Test { dir1, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) return false; // drive/root/Dir1/File2 @@ -384,7 +384,7 @@ class DriveFileSystemTest : public testing::Test { file2, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) return false; // drive/root/Dir1/SubDir2 @@ -397,7 +397,7 @@ class DriveFileSystemTest : public testing::Test { dir2, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) return false; // drive/root/Dir1/SubDir2/File3 @@ -412,7 +412,7 @@ class DriveFileSystemTest : public testing::Test { file3, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) return false; // Recreate resource metadata. @@ -914,14 +914,14 @@ TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { EXPECT_FALSE(EntryExists(remote_dest_file_path)); // Transfer the local file to Drive. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->TransferFileFromLocalToRemote( local_src_file_path, remote_dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Now the remote file should exist. EXPECT_TRUE(EntryExists(remote_dest_file_path)); @@ -957,14 +957,14 @@ TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_HostedDocument) { .Times(1); // Transfer the local file to Drive. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->TransferFileFromLocalToRemote( local_src_file_path, remote_dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Now the remote file should exist. EXPECT_TRUE(EntryExists(remote_dest_file_path)); @@ -993,14 +993,14 @@ TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_RegularFile) { fake_free_disk_space_getter_->set_fake_free_disk_space( file_size + kMinFreeSpace); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->TransferFileFromRemoteToLocal( remote_src_file_path, local_dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // The content is "x"s of the file size. base::FilePath cache_file_path; @@ -1009,7 +1009,7 @@ TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_RegularFile) { google_apis::test_util::CreateCopyResultCallback( &error, &cache_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); const std::string kExpectedContent = "xxxxxxxxxx"; std::string cache_file_data; @@ -1031,14 +1031,14 @@ TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_HostedDocument) { temp_dir.path().AppendASCII("local_copy.txt"); base::FilePath remote_src_file_path( FILE_PATH_LITERAL("drive/root/Document 1 excludeDir-test.gdoc")); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->TransferFileFromRemoteToLocal( remote_src_file_path, local_dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); scoped_ptr<DriveEntryProto> entry_proto = GetEntryInfoByPathSync( remote_src_file_path); @@ -1054,13 +1054,13 @@ TEST_F(DriveFileSystemTest, CopyNotExistingFile) { EXPECT_FALSE(EntryExists(src_file_path)); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; file_system_->Copy( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(EntryExists(src_file_path)); EXPECT_FALSE(EntryExists(dest_file_path)); @@ -1083,13 +1083,13 @@ TEST_F(DriveFileSystemTest, CopyFileToNonExistingDirectory) { EXPECT_FALSE(EntryExists(dest_parent_path)); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; file_system_->Move( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_TRUE(EntryExists(src_file_path)); EXPECT_FALSE(EntryExists(dest_parent_path)); @@ -1121,13 +1121,13 @@ TEST_F(DriveFileSystemTest, CopyFileToInvalidPath) { dest_parent_path); ASSERT_TRUE(dest_entry_proto); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; file_system_->Copy( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, error); + EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error); EXPECT_TRUE(EntryExists(src_file_path)); EXPECT_TRUE(EntryExists(src_file_path)); @@ -1157,13 +1157,13 @@ TEST_F(DriveFileSystemTest, RenameFile) { Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) .Times(1); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->Move( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_FALSE(EntryExists(src_file_path)); EXPECT_TRUE(EntryExists(dest_file_path)); @@ -1200,13 +1200,13 @@ TEST_F(DriveFileSystemTest, MoveFileFromRootToSubDirectory) { Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) .Times(1); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->Move( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_FALSE(EntryExists(src_file_path)); EXPECT_TRUE(EntryExists(dest_file_path)); @@ -1243,13 +1243,13 @@ TEST_F(DriveFileSystemTest, MoveFileFromSubDirectoryToRoot) { Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) .Times(1); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->Move( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_FALSE(EntryExists(src_file_path)); ASSERT_TRUE(EntryExists(dest_file_path)); @@ -1270,7 +1270,7 @@ TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) { EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); - EXPECT_EQ(DRIVE_FILE_OK, AddDirectory(dest_parent_path)); + EXPECT_EQ(FILE_ERROR_OK, AddDirectory(dest_parent_path)); ASSERT_TRUE(EntryExists(src_file_path)); scoped_ptr<DriveEntryProto> src_entry_proto = GetEntryInfoByPathSync( @@ -1304,13 +1304,13 @@ TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) { Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/New Folder 1"))))) .Times(1); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->Move( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_FALSE(EntryExists(src_file_path)); EXPECT_FALSE(EntryExists(interim_file_path)); @@ -1328,13 +1328,13 @@ TEST_F(DriveFileSystemTest, MoveNotExistingFile) { EXPECT_FALSE(EntryExists(src_file_path)); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; file_system_->Move( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(EntryExists(src_file_path)); EXPECT_FALSE(EntryExists(dest_file_path)); @@ -1357,13 +1357,13 @@ TEST_F(DriveFileSystemTest, MoveFileToNonExistingDirectory) { EXPECT_FALSE(EntryExists(dest_parent_path)); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; file_system_->Move( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(EntryExists(dest_parent_path)); EXPECT_FALSE(EntryExists(dest_file_path)); @@ -1393,13 +1393,13 @@ TEST_F(DriveFileSystemTest, MoveFileToInvalidPath) { dest_parent_path); ASSERT_TRUE(dest_parent_proto); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; file_system_->Move( src_file_path, dest_file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, error); + EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error); EXPECT_TRUE(EntryExists(src_file_path)); EXPECT_TRUE(EntryExists(dest_parent_path)); @@ -1470,7 +1470,7 @@ TEST_F(DriveFileSystemTest, CreateDirectory) { // Create directory in root. base::FilePath dir_path(FILE_PATH_LITERAL("drive/root/New Folder 1")); EXPECT_FALSE(EntryExists(dir_path)); - EXPECT_EQ(DRIVE_FILE_OK, AddDirectory(dir_path)); + EXPECT_EQ(FILE_ERROR_OK, AddDirectory(dir_path)); EXPECT_TRUE(EntryExists(dir_path)); EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( @@ -1481,7 +1481,7 @@ TEST_F(DriveFileSystemTest, CreateDirectory) { base::FilePath subdir_path( FILE_PATH_LITERAL("drive/root/New Folder 1/New Folder 2")); EXPECT_FALSE(EntryExists(subdir_path)); - EXPECT_EQ(DRIVE_FILE_OK, AddDirectory(subdir_path)); + EXPECT_EQ(FILE_ERROR_OK, AddDirectory(subdir_path)); EXPECT_TRUE(EntryExists(subdir_path)); } @@ -1495,24 +1495,24 @@ TEST_F(DriveFileSystemTest, PinAndUnpin) { ASSERT_TRUE(entry); // Pin the file. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; EXPECT_CALL(*mock_cache_observer_, OnCachePinned(entry->resource_id(), entry->file_specific_info().file_md5())).Times(1); file_system_->Pin(file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Unpin the file. - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; EXPECT_CALL(*mock_cache_observer_, OnCacheUnpinned(entry->resource_id(), entry->file_specific_info().file_md5())).Times(1); file_system_->Unpin(file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); } TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { @@ -1531,7 +1531,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { fake_free_disk_space_getter_->set_fake_free_disk_space( file_size + kMinFreeSpace); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath file_path; std::string mime_type; DriveFileType file_type; @@ -1540,7 +1540,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { &error, &file_path, &mime_type, &file_type)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(REGULAR_FILE, file_type); } @@ -1553,7 +1553,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { // Pretend we have no space at all. fake_free_disk_space_getter_->set_fake_free_disk_space(0); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; base::FilePath file_path; std::string mime_type; DriveFileType file_type; @@ -1562,7 +1562,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { &error, &file_path, &mime_type, &file_type)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, error); + EXPECT_EQ(FILE_ERROR_NO_SPACE, error); } TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { @@ -1597,12 +1597,12 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { ASSERT_EQ(file_size, file_util::WriteFile(tmp_file, content.data(), content.size())); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; cache_->Store("<resource_id>", "<md5>", tmp_file, DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(CacheEntryExists("<resource_id>", "<md5>")); base::FilePath file_path; @@ -1613,7 +1613,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { &error, &file_path, &mime_type, &file_type)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(REGULAR_FILE, file_type); // The cache entry should be removed in order to free up space. @@ -1636,7 +1636,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpaceButBecomeFull) { fake_free_disk_space_getter_->set_fake_free_disk_space(kMinFreeSpace - 1); fake_free_disk_space_getter_->set_fake_free_disk_space(kMinFreeSpace - 1); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; base::FilePath file_path; std::string mime_type; DriveFileType file_type; @@ -1645,7 +1645,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpaceButBecomeFull) { &error, &file_path, &mime_type, &file_type)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NO_SPACE, error); + EXPECT_EQ(FILE_ERROR_NO_SPACE, error); } TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { @@ -1657,7 +1657,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); // Store something as cached version of this file. - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->Store(entry_proto->resource_id(), entry_proto->file_specific_info().file_md5(), google_apis::test_util::GetTestFilePath( @@ -1665,7 +1665,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); base::FilePath file_path; std::string mime_type; @@ -1675,7 +1675,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { &error, &file_path, &mime_type, &file_type)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(REGULAR_FILE, file_type); } @@ -1688,7 +1688,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_HostedDocument) { GetEntryInfoByPathSync(file_in_root); ASSERT_TRUE(src_entry_proto); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath file_path; std::string mime_type; DriveFileType file_type; @@ -1717,7 +1717,7 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId) { base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; base::FilePath file_path; std::string mime_type; DriveFileType file_type; @@ -1729,7 +1729,7 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId) { google_apis::GetContentCallback()); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(REGULAR_FILE, file_type); } @@ -1745,13 +1745,13 @@ TEST_F(DriveFileSystemTest, GetFileContentByPath) { base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); - DriveFileError initialized_error = DRIVE_FILE_ERROR_FAILED; + FileError initialized_error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry_proto; base::FilePath local_path; std::vector<std::string> content_buffer; - DriveFileError completion_error = DRIVE_FILE_ERROR_FAILED; + FileError completion_error = FILE_ERROR_FAILED; file_system_->GetFileContentByPath( file_in_root, @@ -1761,7 +1761,7 @@ TEST_F(DriveFileSystemTest, GetFileContentByPath) { google_apis::test_util::CreateCopyResultCallback(&completion_error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, initialized_error); + EXPECT_EQ(FILE_ERROR_OK, initialized_error); ASSERT_TRUE(entry_proto); ASSERT_TRUE(local_path.empty()); size_t content_size = 0; @@ -1770,7 +1770,7 @@ TEST_F(DriveFileSystemTest, GetFileContentByPath) { } EXPECT_EQ(static_cast<size_t>(entry_proto->file_info().size()), content_size); - EXPECT_EQ(DRIVE_FILE_OK, completion_error); + EXPECT_EQ(FILE_ERROR_OK, completion_error); } TEST_F(DriveFileSystemTest, CancelGetFile) { @@ -1788,7 +1788,7 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId_FromCache) { scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); // Store something as cached version of this file. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; cache_->Store(entry_proto->resource_id(), entry_proto->file_specific_info().file_md5(), google_apis::test_util::GetTestFilePath( @@ -1796,7 +1796,7 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId_FromCache) { DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // The file is obtained from the cache. // Hence the downloading should work even if the drive service is offline. @@ -1813,7 +1813,7 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId_FromCache) { google_apis::GetContentCallback()); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(REGULAR_FILE, file_type); } @@ -1829,11 +1829,11 @@ TEST_F(DriveFileSystemTest, UpdateFileByResourceId_PersistentFile) { // Pin the file so it'll be store in "persistent" directory. EXPECT_CALL(*mock_cache_observer_, OnCachePinned(kResourceId, kMd5)).Times(1); - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->Pin(kResourceId, kMd5, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // First store a file to cache. cache_->Store(kResourceId, @@ -1844,20 +1844,20 @@ TEST_F(DriveFileSystemTest, UpdateFileByResourceId_PersistentFile) { DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Add the dirty bit. cache_->MarkDirty(kResourceId, kMd5, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Commit the dirty bit. EXPECT_CALL(*mock_cache_observer_, OnCacheCommitted(kResourceId)).Times(1); cache_->CommitDirty(kResourceId, kMd5, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // We'll notify the directory change to the observer upon completion. EXPECT_CALL(*mock_directory_observer_, @@ -1878,7 +1878,7 @@ TEST_F(DriveFileSystemTest, UpdateFileByResourceId_PersistentFile) { DriveClientContext(USER_INITIATED), google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Make sure that the number of files did not change (i.e. we updated an // existing file, rather than adding a new file. The number of files @@ -1897,13 +1897,13 @@ TEST_F(DriveFileSystemTest, UpdateFileByResourceId_NonexistentFile) { // The callback will be called upon completion of // UpdateFileByResourceId(). - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; file_system_->UpdateFileByResourceId( kResourceId, DriveClientContext(USER_INITIATED), google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); } TEST_F(DriveFileSystemTest, ContentSearch) { @@ -1978,7 +1978,7 @@ TEST_F(DriveFileSystemTest, ContentSearchEmptyResult) { } TEST_F(DriveFileSystemTest, GetAvailableSpace) { - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; int64 bytes_total; int64 bytes_used; file_system_->GetAvailableSpace( @@ -1996,12 +1996,12 @@ TEST_F(DriveFileSystemTest, RefreshDirectory) { EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(Eq(util::GetDriveMyDriveRootPath()))).Times(1); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; file_system_->RefreshDirectory( util::GetDriveMyDriveRootPath(), google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); } TEST_F(DriveFileSystemTest, OpenAndCloseFile) { @@ -2028,7 +2028,7 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { file_size + kMinFreeSpace); // Open kFileInRoot ("drive/root/File 1.txt"). - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath file_path; file_system_->OpenFile( kFileInRoot, @@ -2037,7 +2037,7 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { const base::FilePath opened_file_path = file_path; // Verify that the file was properly opened. - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Try to open the already opened file. file_system_->OpenFile( @@ -2046,7 +2046,7 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { google_apis::test_util::RunBlockingPoolTask(); // It must fail. - EXPECT_EQ(DRIVE_FILE_ERROR_IN_USE, error); + EXPECT_EQ(FILE_ERROR_IN_USE, error); // Verify that the file contents match the expected contents. // The content is "x"s of the file size. @@ -2067,7 +2067,7 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { google_apis::test_util::CreateCopyResultCallback( &error, &cache_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(cache_file_path, opened_file_path); // Close kFileInRoot ("drive/root/File 1.txt"). @@ -2077,7 +2077,7 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { google_apis::test_util::RunBlockingPoolTask(); // Verify that the file was properly closed. - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Verify that the cache state was changed as expected. EXPECT_TRUE(GetCacheEntryFromOriginThread(file_resource_id, file_md5, @@ -2093,7 +2093,7 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { google_apis::test_util::RunBlockingPoolTask(); // It must fail. - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); } // TODO(satorux): Testing if WebAppsRegistry is loaded here is awkward. We @@ -2131,7 +2131,7 @@ TEST_F(DriveFileSystemTest, MarkCacheFileAsMountedAndUnmounted) { ASSERT_TRUE(entry); // Write to cache. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; cache_->Store(entry->resource_id(), entry->file_specific_info().file_md5(), google_apis::test_util::GetTestFilePath( @@ -2139,7 +2139,7 @@ TEST_F(DriveFileSystemTest, MarkCacheFileAsMountedAndUnmounted) { DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); // Test for mounting. base::FilePath file_path; @@ -2147,7 +2147,7 @@ TEST_F(DriveFileSystemTest, MarkCacheFileAsMountedAndUnmounted) { file_in_root, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); bool success = false; DriveCacheEntry cache_entry; @@ -2161,13 +2161,13 @@ TEST_F(DriveFileSystemTest, MarkCacheFileAsMountedAndUnmounted) { EXPECT_TRUE(cache_entry.is_mounted()); // Test for unmounting. - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; file_system_->MarkCacheFileAsUnmounted( file_path, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); success = false; cache_->GetCacheEntry( diff --git a/chrome/browser/chromeos/drive/drive_file_system_util.cc b/chrome/browser/chromeos/drive/drive_file_system_util.cc index c56b321..cbac112 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_util.cc +++ b/chrome/browser/chromeos/drive/drive_file_system_util.cc @@ -301,7 +301,7 @@ void PrepareWritableFileAndRun(Profile* profile, file_write_helper->PrepareWritableFileAndRun(remote_path, callback); } else { content::BrowserThread::GetBlockingPool()->PostTask( - FROM_HERE, base::Bind(callback, DRIVE_FILE_OK, path)); + FROM_HERE, base::Bind(callback, FILE_ERROR_OK, path)); } } @@ -321,31 +321,31 @@ void EnsureDirectoryExists(Profile* profile, callback); } else { base::MessageLoopProxy::current()->PostTask( - FROM_HERE, base::Bind(callback, DRIVE_FILE_OK)); + FROM_HERE, base::Bind(callback, FILE_ERROR_OK)); } } -DriveFileError GDataToDriveFileError(google_apis::GDataErrorCode status) { +FileError GDataToFileError(google_apis::GDataErrorCode status) { switch (status) { case google_apis::HTTP_SUCCESS: case google_apis::HTTP_CREATED: case google_apis::HTTP_NO_CONTENT: - return DRIVE_FILE_OK; + return FILE_ERROR_OK; case google_apis::HTTP_UNAUTHORIZED: case google_apis::HTTP_FORBIDDEN: - return DRIVE_FILE_ERROR_ACCESS_DENIED; + return FILE_ERROR_ACCESS_DENIED; case google_apis::HTTP_NOT_FOUND: - return DRIVE_FILE_ERROR_NOT_FOUND; + return FILE_ERROR_NOT_FOUND; case google_apis::GDATA_PARSE_ERROR: case google_apis::GDATA_FILE_ERROR: - return DRIVE_FILE_ERROR_ABORT; + return FILE_ERROR_ABORT; case google_apis::GDATA_NO_CONNECTION: - return DRIVE_FILE_ERROR_NO_CONNECTION; + return FILE_ERROR_NO_CONNECTION; case google_apis::HTTP_SERVICE_UNAVAILABLE: case google_apis::HTTP_INTERNAL_SERVER_ERROR: - return DRIVE_FILE_ERROR_THROTTLED; + return FILE_ERROR_THROTTLED; default: - return DRIVE_FILE_ERROR_FAILED; + return FILE_ERROR_FAILED; } } @@ -372,7 +372,7 @@ void ConvertPlatformFileInfoToProto(const base::PlatformFileInfo& file_info, proto->set_creation_time(file_info.creation_time.ToInternalValue()); } -void EmptyFileOperationCallback(DriveFileError error) { +void EmptyFileOperationCallback(FileError error) { } } // namespace util diff --git a/chrome/browser/chromeos/drive/drive_file_system_util.h b/chrome/browser/chromeos/drive/drive_file_system_util.h index bc080c5..0322604 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_util.h +++ b/chrome/browser/chromeos/drive/drive_file_system_util.h @@ -10,7 +10,7 @@ #include "base/callback_forward.h" #include "base/platform_file.h" #include "chrome/browser/chromeos/drive/drive.pb.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/google_apis/gdata_errorcode.h" #include "googleurl/src/gurl.h" @@ -160,7 +160,7 @@ void ParseCacheFilePath(const base::FilePath& path, std::string* extra_extension); // Callback type for PrepareWritablebase::FilePathAndRun. -typedef base::Callback<void (DriveFileError, const base::FilePath& path)> +typedef base::Callback<void (FileError, const base::FilePath& path)> OpenFileCallback; // Invokes |callback| on blocking thread pool, after converting virtual |path| @@ -178,7 +178,7 @@ void PrepareWritableFileAndRun(Profile* profile, // Ensures the existence of |directory| of '/special/drive/foo'. This will // create |directory| and its ancestors if they don't exist. |callback| is // invoked after making sure that |directory| exists. |callback| should -// interpret error codes of either DRIVE_FILE_OK or DRIVE_FILE_ERROR_EXISTS as +// interpret error codes of either FILE_ERROR_OK or FILE_ERROR_EXISTS as // indicating that |directory| now exists. // // If |directory| is not a Drive path, it won't check the existence and just @@ -190,7 +190,7 @@ void EnsureDirectoryExists(Profile* profile, const FileOperationCallback& callback); // Converts GData error code into file platform error code. -DriveFileError GDataToDriveFileError(google_apis::GDataErrorCode status); +FileError GDataToFileError(google_apis::GDataErrorCode status); // Converts the proto representation to the platform file. void ConvertProtoToPlatformFileInfo(const PlatformFileInfoProto& proto, @@ -201,7 +201,7 @@ void ConvertPlatformFileInfoToProto(const base::PlatformFileInfo& file_info, PlatformFileInfoProto* proto); // Does nothing with |error|. Used with functions taking FileOperationCallback. -void EmptyFileOperationCallback(DriveFileError error); +void EmptyFileOperationCallback(FileError error); // Helper to destroy objects which needs Destroy() to be called on destruction. struct DestroyHelper { diff --git a/chrome/browser/chromeos/drive/drive_prefetcher.cc b/chrome/browser/chromeos/drive/drive_prefetcher.cc index 05d188c..f97618e 100644 --- a/chrome/browser/chromeos/drive/drive_prefetcher.cc +++ b/chrome/browser/chromeos/drive/drive_prefetcher.cc @@ -117,15 +117,15 @@ void DrivePrefetcher::DoPrefetch() { } void DrivePrefetcher::OnPrefetchFinished(const std::string& resource_id, - DriveFileError error, + FileError error, const base::FilePath& file_path, const std::string& mime_type, DriveFileType file_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) - LOG(WARNING) << "Prefetch failed: " << DriveFileErrorToString(error); + if (error != FILE_ERROR_OK) + LOG(WARNING) << "Prefetch failed: " << FileErrorToString(error); event_logger_->Log("Prefetcher: Finish fetching (%s) %s", - DriveFileErrorToString(error).c_str(), + FileErrorToString(error).c_str(), resource_id.c_str()); } @@ -156,12 +156,12 @@ void DrivePrefetcher::VisitDirectory(const base::FilePath& directory_path) { void DrivePrefetcher::OnReadDirectory( const base::FilePath& directory_path, - DriveFileError error, + FileError error, bool hide_hosted_documents, scoped_ptr<DriveEntryProtoVector> entries) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { LOG(WARNING) << "Directory cannot be scanned by prefetcher: " << directory_path.value(); OnReadDirectoryFinished(); diff --git a/chrome/browser/chromeos/drive/drive_prefetcher.h b/chrome/browser/chromeos/drive/drive_prefetcher.h index e2eca07..6a3caeb 100644 --- a/chrome/browser/chromeos/drive/drive_prefetcher.h +++ b/chrome/browser/chromeos/drive/drive_prefetcher.h @@ -59,7 +59,7 @@ class DrivePrefetcher : public DriveFileSystemObserver { // Called when DoPrefetch is done. void OnPrefetchFinished(const std::string& resource_id, - DriveFileError error, + FileError error, const base::FilePath& file_path, const std::string& mime_type, DriveFileType file_type); @@ -71,7 +71,7 @@ class DrivePrefetcher : public DriveFileSystemObserver { void VisitFile(const DriveEntryProto& entry); void VisitDirectory(const base::FilePath& directory_path); void OnReadDirectory(const base::FilePath& directory_path, - DriveFileError error, + FileError error, bool hide_hosted_documents, scoped_ptr<DriveEntryProtoVector> entries); void OnReadDirectoryFinished(); diff --git a/chrome/browser/chromeos/drive/drive_prefetcher_unittest.cc b/chrome/browser/chromeos/drive/drive_prefetcher_unittest.cc index 42183c2..3213471 100644 --- a/chrome/browser/chromeos/drive/drive_prefetcher_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_prefetcher_unittest.cc @@ -69,7 +69,7 @@ struct TestEntry { // resource_id (arg0) to |fetched_list|, and calls back a successful completion. ACTION_P(MockGetFile, fetched_list) { fetched_list->push_back(arg0); - arg2.Run(DRIVE_FILE_OK, base::FilePath(), std::string(), REGULAR_FILE); + arg2.Run(FILE_ERROR_OK, base::FilePath(), std::string(), REGULAR_FILE); } // Mocks DriveFileSystem::ReadDirectory. It holds the flat list of all entries @@ -84,7 +84,7 @@ ACTION_P(MockReadDirectory, test_entries) { if (test_entries[i].IsDirectChildOf(directory)) entries->push_back(test_entries[i].ToDriveEntryProto()); } - callback.Run(DRIVE_FILE_OK, false /* hide_hosted_document */, entries.Pass()); + callback.Run(FILE_ERROR_OK, false /* hide_hosted_document */, entries.Pass()); } #define FPL FILE_PATH_LITERAL diff --git a/chrome/browser/chromeos/drive/drive_resource_metadata.cc b/chrome/browser/chromeos/drive/drive_resource_metadata.cc index fda302e..86cbfcf 100644 --- a/chrome/browser/chromeos/drive/drive_resource_metadata.cc +++ b/chrome/browser/chromeos/drive/drive_resource_metadata.cc @@ -58,7 +58,7 @@ std::string DirectoryFetchInfo::ToString() const { ", changestamp: " + base::Int64ToString(changestamp_)); } -EntryInfoResult::EntryInfoResult() : error(DRIVE_FILE_ERROR_FAILED) { +EntryInfoResult::EntryInfoResult() : error(FILE_ERROR_FAILED) { } EntryInfoResult::~EntryInfoResult() { @@ -72,14 +72,14 @@ EntryInfoPairResult::~EntryInfoPairResult() { // Struct to hold result values passed to FileMoveCallback. struct DriveResourceMetadata::FileMoveResult { - FileMoveResult(DriveFileError error, const base::FilePath& path) + FileMoveResult(FileError error, const base::FilePath& path) : error(error), path(path) {} - explicit FileMoveResult(DriveFileError error) + explicit FileMoveResult(FileError error) : error(error) {} - FileMoveResult() : error(DRIVE_FILE_OK) {} + FileMoveResult() : error(FILE_ERROR_OK) {} // Runs GetEntryInfoCallback with the values stored in |result|. static void RunCallbackWithResult(const FileMoveCallback& callback, @@ -88,17 +88,17 @@ struct DriveResourceMetadata::FileMoveResult { callback.Run(result.error, result.path); } - DriveFileError error; + FileError error; base::FilePath path; }; // Struct to hold result values passed to GetEntryInfoCallback. struct DriveResourceMetadata::GetEntryInfoResult { - GetEntryInfoResult(DriveFileError error, scoped_ptr<DriveEntryProto> entry) + GetEntryInfoResult(FileError error, scoped_ptr<DriveEntryProto> entry) : error(error), entry(entry.Pass()) {} - explicit GetEntryInfoResult(DriveFileError error) + explicit GetEntryInfoResult(FileError error) : error(error) {} // Runs GetEntryInfoCallback with the values stored in |result|. @@ -109,20 +109,20 @@ struct DriveResourceMetadata::GetEntryInfoResult { callback.Run(result->error, result->entry.Pass()); } - DriveFileError error; + FileError error; scoped_ptr<DriveEntryProto> entry; }; // Struct to hold result values passed to GetEntryInfoWithFilePathCallback. struct DriveResourceMetadata::GetEntryInfoWithFilePathResult { - GetEntryInfoWithFilePathResult(DriveFileError error, + GetEntryInfoWithFilePathResult(FileError error, const base::FilePath& path, scoped_ptr<DriveEntryProto> entry) : error(error), path(path), entry(entry.Pass()) {} - explicit GetEntryInfoWithFilePathResult(DriveFileError error) + explicit GetEntryInfoWithFilePathResult(FileError error) : error(error) {} // Runs GetEntryInfoWithFilePathCallback with the values stored in |result|. @@ -134,14 +134,14 @@ struct DriveResourceMetadata::GetEntryInfoWithFilePathResult { callback.Run(result->error, result->path, result->entry.Pass()); } - DriveFileError error; + FileError error; base::FilePath path; scoped_ptr<DriveEntryProto> entry; }; // Struct to hold result values passed to ReadDirectoryCallback. struct DriveResourceMetadata::ReadDirectoryResult { - ReadDirectoryResult(DriveFileError error, + ReadDirectoryResult(FileError error, scoped_ptr<DriveEntryProtoVector> entries) : error(error), entries(entries.Pass()) {} @@ -154,7 +154,7 @@ struct DriveResourceMetadata::ReadDirectoryResult { callback.Run(result->error, result->entries.Pass()); } - DriveFileError error; + FileError error; scoped_ptr<DriveEntryProtoVector> entries; }; @@ -207,19 +207,19 @@ DriveResourceMetadata::~DriveResourceMetadata() { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); } -DriveFileError DriveResourceMetadata::InitializeOnBlockingPool() { +FileError DriveResourceMetadata::InitializeOnBlockingPool() { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) - return DRIVE_FILE_ERROR_NO_SPACE; + return FILE_ERROR_NO_SPACE; // Initialize the storage. if (!storage_->Initialize()) - return DRIVE_FILE_ERROR_FAILED; + return FILE_ERROR_FAILED; SetUpDefaultEntries(); - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } void DriveResourceMetadata::SetUpDefaultEntries() { @@ -247,7 +247,7 @@ void DriveResourceMetadata::DestroyOnBlockingPool() { void DriveResourceMetadata::ResetOnBlockingPool() { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); - // TODO(hashimoto): Return DRIVE_FILE_ERROR_NO_SPACE here. + // TODO(hashimoto): Return FILE_ERROR_NO_SPACE here. if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) { LOG(ERROR) << "Required disk space not available."; return; @@ -466,15 +466,15 @@ int64 DriveResourceMetadata::GetLargestChangestampOnBlockingPool() { return storage_->GetLargestChangestamp(); } -DriveFileError DriveResourceMetadata::SetLargestChangestampOnBlockingPool( +FileError DriveResourceMetadata::SetLargestChangestampOnBlockingPool( int64 value) { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) - return DRIVE_FILE_ERROR_NO_SPACE; + return FILE_ERROR_NO_SPACE; storage_->SetLargestChangestamp(value); - return DRIVE_FILE_OK; + return FILE_ERROR_OK; } DriveResourceMetadata::FileMoveResult @@ -486,29 +486,29 @@ DriveResourceMetadata::MoveEntryToDirectoryOnBlockingPool( DCHECK(!file_path.empty()); if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) - return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); + return FileMoveResult(FILE_ERROR_NO_SPACE); scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(file_path); if (!entry) - return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); + return FileMoveResult(FILE_ERROR_NOT_FOUND); // Cannot move an entry without its parent. (i.e. the root) if (entry->parent_resource_id().empty()) - return FileMoveResult(DRIVE_FILE_ERROR_INVALID_OPERATION); + return FileMoveResult(FILE_ERROR_INVALID_OPERATION); scoped_ptr<DriveEntryProto> destination = FindEntryByPathSync(directory_path); base::FilePath moved_file_path; - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; if (!destination) { - error = DRIVE_FILE_ERROR_NOT_FOUND; + error = FILE_ERROR_NOT_FOUND; } else if (!destination->file_info().is_directory()) { - error = DRIVE_FILE_ERROR_NOT_A_DIRECTORY; + error = FILE_ERROR_NOT_A_DIRECTORY; } else { DetachEntryFromDirectory(entry->resource_id()); entry->set_parent_resource_id(destination->resource_id()); AddEntryToDirectory(*entry); moved_file_path = GetFilePath(entry->resource_id()); - error = DRIVE_FILE_OK; + error = FILE_ERROR_OK; } DVLOG(1) << "MoveEntryToDirectory " << moved_file_path.value(); return FileMoveResult(error, moved_file_path); @@ -525,14 +525,14 @@ DriveResourceMetadata::RenameEntryOnBlockingPool( DVLOG(1) << "RenameEntry " << file_path.value() << " to " << new_name; if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) - return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); + return FileMoveResult(FILE_ERROR_NO_SPACE); scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(file_path); if (!entry) - return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); + return FileMoveResult(FILE_ERROR_NOT_FOUND); if (base::FilePath::FromUTF8Unsafe(new_name) == file_path.BaseName()) - return FileMoveResult(DRIVE_FILE_ERROR_EXISTS); + return FileMoveResult(FILE_ERROR_EXISTS); entry->set_title(new_name); scoped_ptr<GetEntryInfoWithFilePathResult> result = @@ -546,18 +546,18 @@ DriveResourceMetadata::RemoveEntryOnBlockingPool( DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) - return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); + return FileMoveResult(FILE_ERROR_NO_SPACE); // Disallow deletion of special entries "/drive" and "/drive/other". if (util::IsSpecialResourceId(resource_id)) - return FileMoveResult(DRIVE_FILE_ERROR_ACCESS_DENIED); + return FileMoveResult(FILE_ERROR_ACCESS_DENIED); scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); if (!entry) - return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); + return FileMoveResult(FILE_ERROR_NOT_FOUND); RemoveDirectoryChild(entry->resource_id()); - return FileMoveResult(DRIVE_FILE_OK, + return FileMoveResult(FILE_ERROR_OK, GetFilePath(entry->parent_resource_id())); } @@ -600,13 +600,13 @@ DriveResourceMetadata::GetEntryInfoByResourceIdOnBlockingPool( DCHECK(!resource_id.empty()); scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(resource_id); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; if (entry) { - error = DRIVE_FILE_OK; + error = FILE_ERROR_OK; drive_file_path = GetFilePath(resource_id); } else { - error = DRIVE_FILE_ERROR_NOT_FOUND; + error = FILE_ERROR_NOT_FOUND; } return make_scoped_ptr( @@ -619,7 +619,7 @@ DriveResourceMetadata::GetEntryInfoByPathOnBlockingPool( DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(path); - DriveFileError error = entry ? DRIVE_FILE_OK : DRIVE_FILE_ERROR_NOT_FOUND; + FileError error = entry ? FILE_ERROR_OK : FILE_ERROR_NOT_FOUND; return make_scoped_ptr(new GetEntryInfoResult(error, entry.Pass())); } @@ -630,16 +630,16 @@ DriveResourceMetadata::ReadDirectoryByPathOnBlockingPool( DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); scoped_ptr<DriveEntryProtoVector> entries; - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry = FindEntryByPathSync(path); if (entry && entry->file_info().is_directory()) { entries = DirectoryChildrenToProtoVector(entry->resource_id()); - error = DRIVE_FILE_OK; + error = FILE_ERROR_OK; } else if (entry && !entry->file_info().is_directory()) { - error = DRIVE_FILE_ERROR_NOT_A_DIRECTORY; + error = FILE_ERROR_NOT_A_DIRECTORY; } else { - error = DRIVE_FILE_ERROR_NOT_FOUND; + error = FILE_ERROR_NOT_FOUND; } return make_scoped_ptr(new ReadDirectoryResult(error, entries.Pass())); @@ -669,21 +669,21 @@ DriveResourceMetadata::RefreshEntryOnBlockingPool( if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) { return make_scoped_ptr( - new GetEntryInfoWithFilePathResult(DRIVE_FILE_ERROR_NO_SPACE)); + new GetEntryInfoWithFilePathResult(FILE_ERROR_NO_SPACE)); } scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(entry_proto.resource_id()); if (!entry) { return make_scoped_ptr( - new GetEntryInfoWithFilePathResult(DRIVE_FILE_ERROR_NOT_FOUND)); + new GetEntryInfoWithFilePathResult(FILE_ERROR_NOT_FOUND)); } if (entry->parent_resource_id().empty() || // Rejct root. entry->file_info().is_directory() != // Reject incompatible input. entry_proto.file_info().is_directory()) { return make_scoped_ptr( - new GetEntryInfoWithFilePathResult(DRIVE_FILE_ERROR_INVALID_OPERATION)); + new GetEntryInfoWithFilePathResult(FILE_ERROR_INVALID_OPERATION)); } // Update data. @@ -692,7 +692,7 @@ DriveResourceMetadata::RefreshEntryOnBlockingPool( if (!new_parent) { return make_scoped_ptr( - new GetEntryInfoWithFilePathResult(DRIVE_FILE_ERROR_NOT_FOUND)); + new GetEntryInfoWithFilePathResult(FILE_ERROR_NOT_FOUND)); } // Remove from the old parent and add it to the new parent with the new data. @@ -703,7 +703,7 @@ DriveResourceMetadata::RefreshEntryOnBlockingPool( scoped_ptr<DriveEntryProto> result_entry_proto = storage_->GetEntry(entry->resource_id()); return make_scoped_ptr( - new GetEntryInfoWithFilePathResult(DRIVE_FILE_OK, + new GetEntryInfoWithFilePathResult(FILE_ERROR_OK, GetFilePath(entry->resource_id()), result_entry_proto.Pass())); } @@ -716,16 +716,16 @@ DriveResourceMetadata::RefreshDirectoryOnBlockingPool( DCHECK(!directory_fetch_info.empty()); if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) - return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); + return FileMoveResult(FILE_ERROR_NO_SPACE); scoped_ptr<DriveEntryProto> directory = storage_->GetEntry( directory_fetch_info.resource_id()); if (!directory) - return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); + return FileMoveResult(FILE_ERROR_NOT_FOUND); if (!directory->file_info().is_directory()) - return FileMoveResult(DRIVE_FILE_ERROR_NOT_A_DIRECTORY); + return FileMoveResult(FILE_ERROR_NOT_A_DIRECTORY); directory->mutable_directory_specific_info()->set_changestamp( directory_fetch_info.changestamp()); @@ -736,7 +736,7 @@ DriveResourceMetadata::RefreshDirectoryOnBlockingPool( for (DriveEntryProtoMap::const_iterator it = entry_proto_map.begin(); it != entry_proto_map.end(); ++it) { if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) - return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); + return FileMoveResult(FILE_ERROR_NO_SPACE); const DriveEntryProto& entry_proto = it->second; // Skip if the parent resource ID does not match. This is needed to @@ -765,14 +765,14 @@ DriveResourceMetadata::RefreshDirectoryOnBlockingPool( DirectoryChildrenToProtoVector(directory->resource_id()); for (size_t i = 0; i < entries->size(); ++i) { if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) - return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); + return FileMoveResult(FILE_ERROR_NO_SPACE); const DriveEntryProto& entry_proto = entries->at(i); if (entry_proto_map.count(entry_proto.resource_id()) == 0) RemoveDirectoryChild(entry_proto.resource_id()); } - return FileMoveResult(DRIVE_FILE_OK, GetFilePath(directory->resource_id())); + return FileMoveResult(FILE_ERROR_OK, GetFilePath(directory->resource_id())); } DriveResourceMetadata::FileMoveResult @@ -781,20 +781,20 @@ DriveResourceMetadata::AddEntryOnBlockingPool( DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) - return FileMoveResult(DRIVE_FILE_ERROR_NO_SPACE); + return FileMoveResult(FILE_ERROR_NO_SPACE); scoped_ptr<DriveEntryProto> existing_entry = storage_->GetEntry(entry_proto.resource_id()); if (existing_entry) - return FileMoveResult(DRIVE_FILE_ERROR_EXISTS); + return FileMoveResult(FILE_ERROR_EXISTS); scoped_ptr<DriveEntryProto> parent = GetDirectory(entry_proto.parent_resource_id()); if (!parent) - return FileMoveResult(DRIVE_FILE_ERROR_NOT_FOUND); + return FileMoveResult(FILE_ERROR_NOT_FOUND); AddEntryToDirectory(entry_proto); - return FileMoveResult(DRIVE_FILE_OK, GetFilePath(entry_proto.resource_id())); + return FileMoveResult(FILE_ERROR_OK, GetFilePath(entry_proto.resource_id())); } scoped_ptr<DriveEntryProto> DriveResourceMetadata::GetDirectory( @@ -854,7 +854,7 @@ void DriveResourceMetadata::GetDescendantDirectoryPaths( void DriveResourceMetadata::RemoveAllOnBlockingPool() { DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); - // TODO(hashimoto): Return DRIVE_FILE_ERROR_NO_SPACE here. + // TODO(hashimoto): Return FILE_ERROR_NO_SPACE here. if (!EnoughDiskSpaceIsAvailableForDBOperation(data_directory_path_)) { LOG(ERROR) << "Required disk space not available."; return; @@ -876,7 +876,7 @@ void DriveResourceMetadata::GetEntryInfoPairByPathsAfterGetFirst( const base::FilePath& first_path, const base::FilePath& second_path, const GetEntryInfoPairCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); @@ -887,7 +887,7 @@ void DriveResourceMetadata::GetEntryInfoPairByPathsAfterGetFirst( result->first.proto = entry_proto.Pass(); // If the first one is not found, don't continue. - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(result.Pass()); return; } @@ -906,7 +906,7 @@ void DriveResourceMetadata::GetEntryInfoPairByPathsAfterGetSecond( const base::FilePath& second_path, const GetEntryInfoPairCallback& callback, scoped_ptr<EntryInfoPairResult> result, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); diff --git a/chrome/browser/chromeos/drive/drive_resource_metadata.h b/chrome/browser/chromeos/drive/drive_resource_metadata.h index e08822d..9924947 100644 --- a/chrome/browser/chromeos/drive/drive_resource_metadata.h +++ b/chrome/browser/chromeos/drive/drive_resource_metadata.h @@ -15,8 +15,8 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" #include "chrome/browser/chromeos/drive/drive_resource_metadata_storage.h" +#include "chrome/browser/chromeos/drive/file_errors.h" namespace base { class SequencedTaskRunner; @@ -69,27 +69,27 @@ enum DriveFileType { // Callback similar to FileOperationCallback but with a given |file_path|. // Used for operations that change a file path like moving files. -typedef base::Callback<void(DriveFileError error, +typedef base::Callback<void(FileError error, const base::FilePath& file_path)> FileMoveCallback; // Used to get entry info from the file system. -// If |error| is not DRIVE_FILE_OK, |entry_info| is set to NULL. -typedef base::Callback<void(DriveFileError error, +// If |error| is not FILE_ERROR_OK, |entry_info| is set to NULL. +typedef base::Callback<void(FileError error, scoped_ptr<DriveEntryProto> entry_proto)> GetEntryInfoCallback; -typedef base::Callback<void(DriveFileError error, +typedef base::Callback<void(FileError error, scoped_ptr<DriveEntryProtoVector> entries)> ReadDirectoryCallback; // Used to get entry info from the file system, with the Drive file path. -// If |error| is not DRIVE_FILE_OK, |entry_proto| is set to NULL. +// If |error| is not FILE_ERROR_OK, |entry_proto| is set to NULL. // // |drive_file_path| parameter is provided as DriveEntryProto does not contain // the Drive file path (i.e. only contains the base name without parent // directory names). -typedef base::Callback<void(DriveFileError error, +typedef base::Callback<void(FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto)> GetEntryInfoWithFilePathCallback; @@ -106,7 +106,7 @@ struct EntryInfoResult { ~EntryInfoResult(); base::FilePath path; - DriveFileError error; + FileError error; scoped_ptr<DriveEntryProto> proto; }; @@ -240,7 +240,7 @@ class DriveResourceMetadata { virtual ~DriveResourceMetadata(); // Used to implement Initialize(); - DriveFileError InitializeOnBlockingPool() WARN_UNUSED_RESULT; + FileError InitializeOnBlockingPool() WARN_UNUSED_RESULT; // Sets up entries which should be present by default. void SetUpDefaultEntries(); @@ -255,7 +255,7 @@ class DriveResourceMetadata { int64 GetLargestChangestampOnBlockingPool(); // Used to implement SetLargestChangestamp(). - DriveFileError SetLargestChangestampOnBlockingPool(int64 value); + FileError SetLargestChangestampOnBlockingPool(int64 value); // Used to implement AddEntry(). FileMoveResult AddEntryOnBlockingPool(const DriveEntryProto& entry_proto); @@ -310,7 +310,7 @@ class DriveResourceMetadata { const base::FilePath& first_path, const base::FilePath& second_path, const GetEntryInfoPairCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Continues with GetIntroInfoPairByPaths after the second DriveEntry has been @@ -319,7 +319,7 @@ class DriveResourceMetadata { const base::FilePath& second_path, const GetEntryInfoPairCallback& callback, scoped_ptr<EntryInfoPairResult> result, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Searches for |file_path| synchronously. diff --git a/chrome/browser/chromeos/drive/drive_resource_metadata_unittest.cc b/chrome/browser/chromeos/drive/drive_resource_metadata_unittest.cc index c6dee3c..f0e4d5d 100644 --- a/chrome/browser/chromeos/drive/drive_resource_metadata_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_resource_metadata_unittest.cc @@ -107,13 +107,13 @@ class DriveResourceMetadataTest : public testing::Test { // Gets the entry info by path synchronously. Returns NULL on failure. scoped_ptr<DriveEntryProto> GetEntryInfoByPathSync( const base::FilePath& file_path) { - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; scoped_ptr<DriveEntryProto> entry_proto; resource_metadata_->GetEntryInfoByPath( file_path, google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_TRUE(error == DRIVE_FILE_OK || !entry_proto); + EXPECT_TRUE(error == FILE_ERROR_OK || !entry_proto); return entry_proto.Pass(); } @@ -121,13 +121,13 @@ class DriveResourceMetadataTest : public testing::Test { // failure. scoped_ptr<DriveEntryProtoVector> ReadDirectoryByPathSync( const base::FilePath& directory_path) { - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; scoped_ptr<DriveEntryProtoVector> entries; resource_metadata_->ReadDirectoryByPath( directory_path, google_apis::test_util::CreateCopyResultCallback(&error, &entries)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_TRUE(error == DRIVE_FILE_OK || !entries); + EXPECT_TRUE(error == FILE_ERROR_OK || !entries); return entries.Pass(); } @@ -143,21 +143,21 @@ class DriveResourceMetadataTest : public testing::Test { // static void DriveResourceMetadataTest::Init(DriveResourceMetadata* resource_metadata) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; resource_metadata->Initialize( google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); // Create mydrive root directory. { - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; base::FilePath drive_path; resource_metadata->AddEntry( util::CreateMyDriveRootEntry(kTestRootResourceId), google_apis::test_util::CreateCopyResultCallback(&error, &drive_path)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); } int sequence_id = 1; @@ -189,7 +189,7 @@ void DriveResourceMetadataTest::Init(DriveResourceMetadata* resource_metadata) { kTestChangestamp, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); } // static @@ -229,32 +229,32 @@ bool DriveResourceMetadataTest::AddDriveEntryProto( DriveEntryProto entry_proto = CreateDriveEntryProto(sequence_id, is_directory, parent_resource_id); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath drive_path; resource_metadata->AddEntry( entry_proto, google_apis::test_util::CreateCopyResultCallback(&error, &drive_path)); google_apis::test_util::RunBlockingPoolTask(); - return DRIVE_FILE_OK == error; + return FILE_ERROR_OK == error; } TEST_F(DriveResourceMetadataTest, LargestChangestamp) { scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> resource_metadata(new DriveResourceMetadata(temp_dir_.path(), blocking_task_runner_)); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; resource_metadata->Initialize( google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); int64 in_changestamp = 123456; resource_metadata->SetLargestChangestamp( in_changestamp, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); int64 out_changestamp = 0; resource_metadata->GetLargestChangestamp( @@ -267,11 +267,11 @@ TEST_F(DriveResourceMetadataTest, GetEntryInfoByResourceId_RootDirectory) { scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> resource_metadata(new DriveResourceMetadata(temp_dir_.path(), blocking_task_runner_)); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; resource_metadata->Initialize( google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); base::FilePath drive_file_path; scoped_ptr<DriveEntryProto> entry_proto; @@ -282,7 +282,7 @@ TEST_F(DriveResourceMetadataTest, GetEntryInfoByResourceId_RootDirectory) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + 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()); @@ -290,7 +290,7 @@ TEST_F(DriveResourceMetadataTest, GetEntryInfoByResourceId_RootDirectory) { TEST_F(DriveResourceMetadataTest, GetEntryInfoByResourceId) { // Confirm that an existing file is found. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; scoped_ptr<DriveEntryProto> entry_proto; resource_metadata_->GetEntryInfoByResourceId( @@ -298,86 +298,86 @@ TEST_F(DriveResourceMetadataTest, GetEntryInfoByResourceId) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + 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()); // Confirm that a non existing file is not found. - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; entry_proto.reset(); resource_metadata_->GetEntryInfoByResourceId( "file:non_existing", google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(entry_proto.get()); } TEST_F(DriveResourceMetadataTest, GetEntryInfoByPath) { // Confirm that an existing file is found. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry_proto; resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(entry_proto.get()); EXPECT_EQ("file4", entry_proto->base_name()); // Confirm that a non existing file is not found. - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; entry_proto.reset(); resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("drive/root/dir1/non_existing"), google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(entry_proto.get()); // Confirm that the root is found. - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; entry_proto.reset(); resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("drive"), google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_TRUE(entry_proto.get()); // Confirm that a non existing file is not found at the root level. - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; entry_proto.reset(); resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("non_existing"), google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(entry_proto.get()); // Confirm that an entry is not found with a wrong root. - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; entry_proto.reset(); resource_metadata_->GetEntryInfoByPath( base::FilePath::FromUTF8Unsafe("non_existing/root"), google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(entry_proto.get()); } TEST_F(DriveResourceMetadataTest, ReadDirectoryByPath) { // Confirm that an existing directory is found. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProtoVector> entries; resource_metadata_->ReadDirectoryByPath( base::FilePath::FromUTF8Unsafe("drive/root/dir1"), google_apis::test_util::CreateCopyResultCallback(&error, &entries)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(entries.get()); ASSERT_EQ(3U, entries->size()); // The order is not guaranteed so we should sort the base names. @@ -387,23 +387,23 @@ TEST_F(DriveResourceMetadataTest, ReadDirectoryByPath) { EXPECT_EQ("file5", base_names[2]); // Confirm that a non existing directory is not found. - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; entries.reset(); resource_metadata_->ReadDirectoryByPath( base::FilePath::FromUTF8Unsafe("drive/root/non_existing"), google_apis::test_util::CreateCopyResultCallback(&error, &entries)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(entries.get()); - // Confirm that reading a file results in DRIVE_FILE_ERROR_NOT_A_DIRECTORY. - error = DRIVE_FILE_ERROR_FAILED; + // Confirm that reading a file results in FILE_ERROR_NOT_A_DIRECTORY. + error = FILE_ERROR_FAILED; entries.reset(); resource_metadata_->ReadDirectoryByPath( base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), google_apis::test_util::CreateCopyResultCallback(&error, &entries)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, error); + EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error); EXPECT_FALSE(entries.get()); } @@ -416,13 +416,13 @@ TEST_F(DriveResourceMetadataTest, GetEntryInfoPairByPaths) { google_apis::test_util::CreateCopyResultCallback(&pair_result)); google_apis::test_util::RunBlockingPoolTask(); // The first entry should be found. - EXPECT_EQ(DRIVE_FILE_OK, pair_result->first.error); + 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()); // The second entry should be found. - EXPECT_EQ(DRIVE_FILE_OK, pair_result->second.error); + 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()); @@ -436,12 +436,12 @@ TEST_F(DriveResourceMetadataTest, GetEntryInfoPairByPaths) { google_apis::test_util::CreateCopyResultCallback(&pair_result)); google_apis::test_util::RunBlockingPoolTask(); // The first entry should not be found. - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, pair_result->first.error); + 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()); // The second entry should not be found, because the first one failed. - EXPECT_EQ(DRIVE_FILE_ERROR_FAILED, pair_result->second.error); + EXPECT_EQ(FILE_ERROR_FAILED, pair_result->second.error); EXPECT_EQ(base::FilePath(), pair_result->second.path); ASSERT_FALSE(pair_result->second.proto.get()); @@ -453,13 +453,13 @@ TEST_F(DriveResourceMetadataTest, GetEntryInfoPairByPaths) { google_apis::test_util::CreateCopyResultCallback(&pair_result)); google_apis::test_util::RunBlockingPoolTask(); // The first entry should be found. - EXPECT_EQ(DRIVE_FILE_OK, pair_result->first.error); + 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()); // The second entry should not be found. - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, pair_result->second.error); + 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()); @@ -467,7 +467,7 @@ TEST_F(DriveResourceMetadataTest, GetEntryInfoPairByPaths) { TEST_F(DriveResourceMetadataTest, RemoveEntry) { // Make sure file9 is found. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; const std::string file9_resource_id = "resource_id:file9"; scoped_ptr<DriveEntryProto> entry_proto; @@ -476,7 +476,7 @@ TEST_F(DriveResourceMetadataTest, RemoveEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file9"), drive_file_path); ASSERT_TRUE(entry_proto.get()); @@ -488,7 +488,7 @@ TEST_F(DriveResourceMetadataTest, RemoveEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3"), drive_file_path); @@ -498,7 +498,7 @@ TEST_F(DriveResourceMetadataTest, RemoveEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(entry_proto.get()); // Look for dir3. @@ -508,7 +508,7 @@ TEST_F(DriveResourceMetadataTest, RemoveEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3"), drive_file_path); ASSERT_TRUE(entry_proto.get()); @@ -520,7 +520,7 @@ TEST_F(DriveResourceMetadataTest, RemoveEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1"), drive_file_path); // dir3 should no longer exist. @@ -529,7 +529,7 @@ TEST_F(DriveResourceMetadataTest, RemoveEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(entry_proto.get()); // Remove unknown resource_id using RemoveEntry. @@ -538,7 +538,7 @@ TEST_F(DriveResourceMetadataTest, RemoveEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); // Try removing root. This should fail. resource_metadata_->RemoveEntry( @@ -546,11 +546,11 @@ TEST_F(DriveResourceMetadataTest, RemoveEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_ACCESS_DENIED, error); + EXPECT_EQ(FILE_ERROR_ACCESS_DENIED, error); } TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; scoped_ptr<DriveEntryProto> entry_proto; @@ -561,7 +561,7 @@ TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file8"), drive_file_path); @@ -571,7 +571,7 @@ TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/file8"), drive_file_path); @@ -582,7 +582,7 @@ TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_EQ(base::FilePath(), drive_file_path); // Move existing file to non-existent directory. This should fail. @@ -592,7 +592,7 @@ TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_EQ(base::FilePath(), drive_file_path); // Move existing file to existing file (non-directory). This should fail. @@ -602,7 +602,7 @@ TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, error); + EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error); EXPECT_EQ(base::FilePath(), drive_file_path); // Move the file to root. @@ -612,7 +612,7 @@ TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/file8"), drive_file_path); @@ -623,7 +623,7 @@ TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir2/file8"), drive_file_path); @@ -633,13 +633,13 @@ TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir2/file8"), drive_file_path); } TEST_F(DriveResourceMetadataTest, RenameEntry) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; scoped_ptr<DriveEntryProto> entry_proto; @@ -650,7 +650,7 @@ TEST_F(DriveResourceMetadataTest, RenameEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir2/file11"), drive_file_path); @@ -660,7 +660,7 @@ TEST_F(DriveResourceMetadataTest, RenameEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir2/file11"), drive_file_path); @@ -671,7 +671,7 @@ TEST_F(DriveResourceMetadataTest, RenameEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir2/file7 (2)"), drive_file_path); @@ -682,7 +682,7 @@ TEST_F(DriveResourceMetadataTest, RenameEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_EXISTS, error); + EXPECT_EQ(FILE_ERROR_EXISTS, error); EXPECT_EQ(base::FilePath(), drive_file_path); // Rename non-existent. @@ -692,12 +692,12 @@ TEST_F(DriveResourceMetadataTest, RenameEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_EQ(base::FilePath(), drive_file_path); } TEST_F(DriveResourceMetadataTest, RefreshEntry) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; scoped_ptr<DriveEntryProto> entry_proto; @@ -720,7 +720,7 @@ TEST_F(DriveResourceMetadataTest, RefreshEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file100"), drive_file_path); ASSERT_TRUE(entry_proto.get()); @@ -753,7 +753,7 @@ TEST_F(DriveResourceMetadataTest, RefreshEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/dir100"), drive_file_path); ASSERT_TRUE(entry_proto.get()); @@ -783,7 +783,7 @@ TEST_F(DriveResourceMetadataTest, RefreshEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_INVALID_OPERATION, error); + EXPECT_EQ(FILE_ERROR_INVALID_OPERATION, error); } TEST_F(DriveResourceMetadataTest, RefreshDirectory_EmtpyMap) { @@ -791,7 +791,7 @@ TEST_F(DriveResourceMetadataTest, RefreshDirectory_EmtpyMap) { const int64 kNewChangestamp = kTestChangestamp + 1; // Read the directory. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProtoVector> entries; entries = ReadDirectoryByPathSync(base::FilePath(kDirectoryPath)); ASSERT_TRUE(entries.get()); @@ -818,7 +818,7 @@ TEST_F(DriveResourceMetadataTest, RefreshDirectory_EmtpyMap) { entry_map, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(kDirectoryPath, file_path); // Get the directory again. @@ -841,7 +841,7 @@ TEST_F(DriveResourceMetadataTest, RefreshDirectory_NonEmptyMap) { const int64 kNewChangestamp = kTestChangestamp + 1; // Read the directory. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProtoVector> entries; entries = ReadDirectoryByPathSync(kDirectoryPath); ASSERT_TRUE(entries.get()); @@ -909,7 +909,7 @@ TEST_F(DriveResourceMetadataTest, RefreshDirectory_NonEmptyMap) { entry_map, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(kDirectoryPath, file_path); // Get the directory again. @@ -998,13 +998,13 @@ TEST_F(DriveResourceMetadataTest, RefreshDirectory_WrongParentResourceId) { // Update the directory with the map. base::FilePath file_path; - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; resource_metadata_->RefreshDirectory( DirectoryFetchInfo(dir1_proto->resource_id(), kNewChangestamp), entry_map, google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(kDirectoryPath, file_path); // Read the directory. Confirm that the new file is not added. @@ -1019,7 +1019,7 @@ TEST_F(DriveResourceMetadataTest, AddEntry) { DriveEntryProto file_entry_proto = CreateDriveEntryProto( sequence_id++, false, "resource_id:dir3"); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath drive_file_path; // Add to dir3. @@ -1028,7 +1028,7 @@ TEST_F(DriveResourceMetadataTest, AddEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file100"), drive_file_path); @@ -1041,7 +1041,7 @@ TEST_F(DriveResourceMetadataTest, AddEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir101"), drive_file_path); @@ -1054,7 +1054,7 @@ TEST_F(DriveResourceMetadataTest, AddEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); // Add an existing file. resource_metadata_->AddEntry( @@ -1062,7 +1062,7 @@ TEST_F(DriveResourceMetadataTest, AddEntry) { google_apis::test_util::CreateCopyResultCallback( &error, &drive_file_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_EXISTS, error); + EXPECT_EQ(FILE_ERROR_EXISTS, error); } TEST_F(DriveResourceMetadataTest, GetChildDirectories) { diff --git a/chrome/browser/chromeos/drive/drive_scheduler.cc b/chrome/browser/chromeos/drive/drive_scheduler.cc index 9c0bbd0..ec5b5a8 100644 --- a/chrome/browser/chromeos/drive/drive_scheduler.cc +++ b/chrome/browser/chromeos/drive/drive_scheduler.cc @@ -702,7 +702,7 @@ void DriveScheduler::ResetThrottleAndContinueJobLoop(QueueType queue_type) { scoped_ptr<DriveScheduler::QueueEntry> DriveScheduler::OnJobDone( scoped_ptr<DriveScheduler::QueueEntry> queue_entry, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); JobInfo* job_info = job_map_.Lookup(queue_entry->job_id); @@ -713,7 +713,7 @@ scoped_ptr<DriveScheduler::QueueEntry> DriveScheduler::OnJobDone( --jobs_running_[queue_type]; // Retry, depending on the error. - if (error == DRIVE_FILE_ERROR_THROTTLED) { + if (error == FILE_ERROR_THROTTLED) { job_info->state = STATE_RETRY; NotifyJobUpdated(*job_info); @@ -742,7 +742,7 @@ void DriveScheduler::OnGetResourceListJobDone( scoped_ptr<google_apis::ResourceList> resource_list) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveFileError drive_error(util::GDataToDriveFileError(error)); + FileError drive_error(util::GDataToFileError(error)); queue_entry = OnJobDone(queue_entry.Pass(), drive_error); @@ -763,7 +763,7 @@ void DriveScheduler::OnGetResourceEntryJobDone( scoped_ptr<google_apis::ResourceEntry> entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveFileError drive_error(util::GDataToDriveFileError(error)); + FileError drive_error(util::GDataToFileError(error)); queue_entry = OnJobDone(queue_entry.Pass(), drive_error); @@ -784,7 +784,7 @@ void DriveScheduler::OnGetAboutResourceJobDone( scoped_ptr<google_apis::AboutResource> about_resource) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveFileError drive_error(util::GDataToDriveFileError(error)); + FileError drive_error(util::GDataToFileError(error)); queue_entry = OnJobDone(queue_entry.Pass(), drive_error); @@ -801,7 +801,7 @@ void DriveScheduler::OnGetAccountMetadataJobDone( scoped_ptr<google_apis::AccountMetadata> account_metadata) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveFileError drive_error(util::GDataToDriveFileError(error)); + FileError drive_error(util::GDataToFileError(error)); queue_entry = OnJobDone(queue_entry.Pass(), drive_error); @@ -819,7 +819,7 @@ void DriveScheduler::OnGetAppListJobDone( scoped_ptr<google_apis::AppList> app_list) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveFileError drive_error(util::GDataToDriveFileError(error)); + FileError drive_error(util::GDataToFileError(error)); queue_entry = OnJobDone(queue_entry.Pass(), drive_error); @@ -833,7 +833,7 @@ void DriveScheduler::OnGetAppListJobDone( void DriveScheduler::OnEntryActionJobDone( scoped_ptr<DriveScheduler::QueueEntry> queue_entry, google_apis::GDataErrorCode error) { - DriveFileError drive_error(util::GDataToDriveFileError(error)); + FileError drive_error(util::GDataToFileError(error)); queue_entry = OnJobDone(queue_entry.Pass(), drive_error); @@ -849,7 +849,7 @@ void DriveScheduler::OnDownloadActionJobDone( scoped_ptr<DriveScheduler::QueueEntry> queue_entry, google_apis::GDataErrorCode error, const base::FilePath& temp_file) { - DriveFileError drive_error(util::GDataToDriveFileError(error)); + FileError drive_error(util::GDataToFileError(error)); queue_entry = OnJobDone(queue_entry.Pass(), drive_error); @@ -867,7 +867,7 @@ void DriveScheduler::OnUploadCompletionJobDone( const base::FilePath& drive_path, const base::FilePath& file_path, scoped_ptr<google_apis::ResourceEntry> resource_entry) { - DriveFileError drive_error(DriveUploadErrorToDriveFileError(error)); + FileError drive_error(DriveUploadErrorToFileError(error)); queue_entry = OnJobDone(queue_entry.Pass(), drive_error); @@ -937,7 +937,7 @@ void DriveScheduler::NotifyJobAdded(const JobInfo& job_info) { } void DriveScheduler::NotifyJobDone(const JobInfo& job_info, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); FOR_EACH_OBSERVER(JobListObserver, observer_list_, OnJobDone(job_info, error)); diff --git a/chrome/browser/chromeos/drive/drive_scheduler.h b/chrome/browser/chromeos/drive/drive_scheduler.h index c165de4..1918840 100644 --- a/chrome/browser/chromeos/drive/drive_scheduler.h +++ b/chrome/browser/chromeos/drive/drive_scheduler.h @@ -313,7 +313,7 @@ class DriveScheduler // up the job information and returns |queue_entry| as is so that callers can // extract and invoke the callback function object stored there. scoped_ptr<QueueEntry> OnJobDone(scoped_ptr<QueueEntry> queue_entry, - DriveFileError error); + FileError error); // Callback for job finishing with a GetResourceListCallback. void OnGetResourceListJobDone( @@ -377,7 +377,7 @@ class DriveScheduler // Notifies updates to observers. void NotifyJobAdded(const JobInfo& job_info); - void NotifyJobDone(const JobInfo& job_info, DriveFileError error); + void NotifyJobDone(const JobInfo& job_info, FileError error); void NotifyJobUpdated(const JobInfo& job_info); // Number of jobs in flight for each queue. diff --git a/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc b/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc index 4565805..1d1db8f 100644 --- a/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc @@ -88,7 +88,7 @@ class JobListLogger : public JobListObserver { events.push_back(EventLog(UPDATED, info)); } - virtual void OnJobDone(const JobInfo& info, DriveFileError error) OVERRIDE { + virtual void OnJobDone(const JobInfo& info, FileError error) OVERRIDE { events.push_back(EventLog(DONE, info)); } diff --git a/chrome/browser/chromeos/drive/drive_sync_client.cc b/chrome/browser/chromeos/drive/drive_sync_client.cc index 21e6ae3..44714d0 100644 --- a/chrome/browser/chromeos/drive/drive_sync_client.cc +++ b/chrome/browser/chromeos/drive/drive_sync_client.cc @@ -244,15 +244,15 @@ void DriveSyncClient::OnGetResourceIdOfExistingPinnedFile( void DriveSyncClient::OnGetEntryInfoByResourceId( const std::string& resource_id, const DriveCacheEntry& cache_entry, - DriveFileError error, + FileError error, const base::FilePath& /* drive_file_path */, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (entry_proto.get() && !entry_proto->has_file_specific_info()) - error = DRIVE_FILE_ERROR_NOT_FOUND; + error = FILE_ERROR_NOT_FOUND; - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { LOG(WARNING) << "Entry not found: " << resource_id; return; } @@ -270,10 +270,10 @@ void DriveSyncClient::OnGetEntryInfoByResourceId( } void DriveSyncClient::OnRemove(const std::string& resource_id, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { LOG(WARNING) << "Failed to remove cache entry: " << resource_id; return; } @@ -288,10 +288,10 @@ void DriveSyncClient::OnRemove(const std::string& resource_id, } void DriveSyncClient::OnPinned(const std::string& resource_id, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { LOG(WARNING) << "Failed to pin cache entry: " << resource_id; return; } @@ -301,7 +301,7 @@ void DriveSyncClient::OnPinned(const std::string& resource_id, } void DriveSyncClient::OnFetchFileComplete(const std::string& resource_id, - DriveFileError error, + FileError error, const base::FilePath& local_path, const std::string& ununsed_mime_type, DriveFileType file_type) { @@ -309,34 +309,34 @@ void DriveSyncClient::OnFetchFileComplete(const std::string& resource_id, fetch_list_.erase(resource_id); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { DVLOG(1) << "Fetched " << resource_id << ": " << local_path.value(); } else { switch (error) { - case DRIVE_FILE_ERROR_NO_CONNECTION: + case FILE_ERROR_NO_CONNECTION: // Re-queue the task so that we'll retry once the connection is back. AddTaskToQueue(FETCH, resource_id); break; default: LOG(WARNING) << "Failed to fetch " << resource_id - << ": " << DriveFileErrorToString(error); + << ": " << FileErrorToString(error); } } } void DriveSyncClient::OnUploadFileComplete(const std::string& resource_id, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); upload_list_.erase(resource_id); - if (error == DRIVE_FILE_OK) { + if (error == FILE_ERROR_OK) { DVLOG(1) << "Uploaded " << resource_id; } else { // TODO(satorux): We should re-queue if the error is recoverable. LOG(WARNING) << "Failed to upload " << resource_id << ": " - << DriveFileErrorToString(error); + << FileErrorToString(error); } } diff --git a/chrome/browser/chromeos/drive/drive_sync_client.h b/chrome/browser/chromeos/drive/drive_sync_client.h index 25a352a..180ee9b 100644 --- a/chrome/browser/chromeos/drive/drive_sync_client.h +++ b/chrome/browser/chromeos/drive/drive_sync_client.h @@ -107,7 +107,7 @@ class DriveSyncClient : public DriveFileSystemObserver, // Called when a file entry is obtained. void OnGetEntryInfoByResourceId(const std::string& resource_id, const DriveCacheEntry& cache_entry, - DriveFileError error, + FileError error, const base::FilePath& file_path, scoped_ptr<DriveEntryProto> entry_proto); @@ -118,15 +118,15 @@ class DriveSyncClient : public DriveFileSystemObserver, const DriveCacheEntry& cache_entry); // Called when an existing cache entry and the local files are removed. - void OnRemove(const std::string& resource_id, DriveFileError error); + void OnRemove(const std::string& resource_id, FileError error); // Called when a file is pinned. - void OnPinned(const std::string& resource_id, DriveFileError error); + void OnPinned(const std::string& resource_id, FileError error); // Called when the file for |resource_id| is fetched. // Calls DoSyncLoop() to go back to the sync loop. void OnFetchFileComplete(const std::string& resource_id, - DriveFileError error, + FileError error, const base::FilePath& local_path, const std::string& ununsed_mime_type, DriveFileType file_type); @@ -134,7 +134,7 @@ class DriveSyncClient : public DriveFileSystemObserver, // Called when the file for |resource_id| is uploaded. // Calls DoSyncLoop() to go back to the sync loop. void OnUploadFileComplete(const std::string& resource_id, - DriveFileError error); + FileError error); DriveFileSystemInterface* file_system_; // Owned by DriveSystemService. DriveCache* cache_; // Owned by DriveSystemService. diff --git a/chrome/browser/chromeos/drive/drive_sync_client_unittest.cc b/chrome/browser/chromeos/drive/drive_sync_client_unittest.cc index 79fd61b..5e08560 100644 --- a/chrome/browser/chromeos/drive/drive_sync_client_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_sync_client_unittest.cc @@ -100,21 +100,21 @@ class DriveSyncClientTest : public testing::Test { file_util::WriteFile(temp_file, content.data(), content.size())); // Prepare 3 pinned-but-not-present files. - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->Pin("resource_id_not_fetched_foo", "", google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); cache_->Pin("resource_id_not_fetched_bar", "", google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); cache_->Pin("resource_id_not_fetched_baz", "", google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Prepare a pinned-and-fetched file. const std::string resource_id_fetched = "resource_id_fetched"; @@ -124,11 +124,11 @@ class DriveSyncClientTest : public testing::Test { DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); cache_->Pin(resource_id_fetched, md5_fetched, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Prepare a pinned-and-fetched-and-dirty file. const std::string resource_id_dirty = "resource_id_dirty"; @@ -137,21 +137,21 @@ class DriveSyncClientTest : public testing::Test { DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); cache_->Pin(resource_id_dirty, md5_dirty, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); cache_->MarkDirty( resource_id_dirty, md5_dirty, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); cache_->CommitDirty( resource_id_dirty, md5_dirty, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); } // Sets the expectation for MockDriveFileSystem::GetFileByResourceId(), @@ -161,7 +161,7 @@ class DriveSyncClientTest : public testing::Test { GetFileByResourceId(resource_id, _, _, _)) .WillOnce( MockGetFileByResourceId( - DRIVE_FILE_OK, + FILE_ERROR_OK, base::FilePath::FromUTF8Unsafe("local_path_does_not_matter"), std::string("mime_type_does_not_matter"), REGULAR_FILE)); @@ -173,7 +173,7 @@ class DriveSyncClientTest : public testing::Test { const std::string& resource_id) { EXPECT_CALL(*mock_file_system_, UpdateFileByResourceId(resource_id, _, _)) - .WillOnce(MockUpdateFileByResourceId(DRIVE_FILE_OK)); + .WillOnce(MockUpdateFileByResourceId(FILE_ERROR_OK)); } // Sets the expectation for MockDriveFileSystem::GetFileInfoByResourceId(), @@ -188,7 +188,7 @@ class DriveSyncClientTest : public testing::Test { EXPECT_CALL(*mock_file_system_, GetEntryInfoByResourceId(resource_id, _)) .WillOnce(MockUpdateFileByResourceId( - DRIVE_FILE_OK, + FILE_ERROR_OK, new_md5)); } diff --git a/chrome/browser/chromeos/drive/drive_system_service.cc b/chrome/browser/chromeos/drive/drive_system_service.cc index a924f0b..42af4248 100644 --- a/chrome/browser/chromeos/drive/drive_system_service.cc +++ b/chrome/browser/chromeos/drive/drive_system_service.cc @@ -262,11 +262,11 @@ void DriveSystemService::ReinitializeResourceMetadataAfterClearCache( void DriveSystemService::AddBackDriveMountPoint( const base::Callback<void(bool)>& callback, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(false); return; } @@ -361,12 +361,12 @@ void DriveSystemService::InitializeAfterCacheInitialized(bool success) { } void DriveSystemService::InitializeAfterResourceMetadataInitialized( - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { LOG(WARNING) << "Failed to initialize resource metadata. Disabling Drive : " - << DriveFileErrorToString(error); + << FileErrorToString(error); DisableDrive(); return; } diff --git a/chrome/browser/chromeos/drive/drive_system_service.h b/chrome/browser/chromeos/drive/drive_system_service.h index 5bb3653..088a084 100644 --- a/chrome/browser/chromeos/drive/drive_system_service.h +++ b/chrome/browser/chromeos/drive/drive_system_service.h @@ -13,9 +13,9 @@ #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/threading/sequenced_worker_pool.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" #include "chrome/browser/chromeos/drive/drive_file_system_util.h" #include "chrome/browser/chromeos/drive/drive_scheduler.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/profiles/profile_keyed_service.h" #include "chrome/browser/profiles/profile_keyed_service_factory.h" #include "sync/notifier/invalidation_handler.h" @@ -138,7 +138,7 @@ class DriveSystemService : public ProfileKeyedService, // Adds back the drive mount point. // Used to implement ClearCacheAndRemountFileSystem(). void AddBackDriveMountPoint(const base::Callback<void(bool)>& callback, - DriveFileError error); + FileError error); // Called when cache initialization is done. Continues initialization if // the cache initialization is successful. @@ -146,7 +146,7 @@ class DriveSystemService : public ProfileKeyedService, // Called when resource metadata initialization is done. Continues // initialization if resource metadata initialization is successful. - void InitializeAfterResourceMetadataInitialized(DriveFileError error); + void InitializeAfterResourceMetadataInitialized(FileError error); // Disables Drive. Used to disable Drive when needed (ex. initialization of // the Drive cache failed). diff --git a/chrome/browser/chromeos/drive/drive_task_executor.cc b/chrome/browser/chromeos/drive/drive_task_executor.cc index d20ac80..941b918 100644 --- a/chrome/browser/chromeos/drive/drive_task_executor.cc +++ b/chrome/browser/chromeos/drive/drive_task_executor.cc @@ -75,7 +75,7 @@ bool DriveTaskExecutor::ExecuteAndNotify( } void DriveTaskExecutor::OnFileEntryFetched( - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { // If we aborted, then this will be zero. if (!current_index_) @@ -86,9 +86,9 @@ void DriveTaskExecutor::OnFileEntryFetched( // Here, we are only interested in files. if (entry_proto.get() && !entry_proto->has_file_specific_info()) - error = DRIVE_FILE_ERROR_NOT_FOUND; + error = FILE_ERROR_NOT_FOUND; - if (!system_service || error != DRIVE_FILE_OK) { + if (!system_service || error != FILE_ERROR_OK) { Done(false); return; } diff --git a/chrome/browser/chromeos/drive/drive_task_executor.h b/chrome/browser/chromeos/drive/drive_task_executor.h index 85b3e7d..5d8c4a5 100644 --- a/chrome/browser/chromeos/drive/drive_task_executor.h +++ b/chrome/browser/chromeos/drive/drive_task_executor.h @@ -8,7 +8,7 @@ #include <string> #include <vector> -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/extensions/file_manager/file_handler_util.h" #include "chrome/browser/google_apis/gdata_errorcode.h" @@ -37,7 +37,7 @@ class DriveTaskExecutor : public file_handler_util::FileTaskExecutor { const std::string& action_id); virtual ~DriveTaskExecutor(); - void OnFileEntryFetched(DriveFileError error, + void OnFileEntryFetched(FileError error, scoped_ptr<DriveEntryProto> entry_proto); void OnAppAuthorized(const std::string& resource_id, google_apis::GDataErrorCode error, diff --git a/chrome/browser/chromeos/drive/drive_url_request_job.cc b/chrome/browser/chromeos/drive/drive_url_request_job.cc index 8832cde..80362cc 100644 --- a/chrome/browser/chromeos/drive/drive_url_request_job.cc +++ b/chrome/browser/chromeos/drive/drive_url_request_job.cc @@ -106,7 +106,7 @@ void GetEntryInfoByPathOnUIThread( DriveFileSystemInterface* file_system = file_system_getter.Run(); if (!file_system) { - callback.Run(DRIVE_FILE_ERROR_FAILED, scoped_ptr<DriveEntryProto>()); + callback.Run(FILE_ERROR_FAILED, scoped_ptr<DriveEntryProto>()); return; } file_system->GetEntryInfoByPath(path, callback); @@ -141,7 +141,7 @@ void GetFileByResourceIdOnUIThread( DriveFileSystemInterface* file_system = file_system_getter.Run(); if (!file_system) { - get_file_callback.Run(DRIVE_FILE_ERROR_FAILED, + get_file_callback.Run(FILE_ERROR_FAILED, base::FilePath(), std::string(), REGULAR_FILE); @@ -423,14 +423,14 @@ DriveURLRequestJob::~DriveURLRequestJob() { //======================= DriveURLRequestJob private methods =================== void DriveURLRequestJob::OnGetEntryInfoByPath( - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (entry_proto.get() && !entry_proto->has_file_specific_info()) - error = DRIVE_FILE_ERROR_NOT_FOUND; + error = FILE_ERROR_NOT_FOUND; - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { mime_type_.clear(); drive_file_path_.clear(); initial_file_size_ = 0; @@ -556,14 +556,14 @@ bool DriveURLRequestJob::ReadFromDownloadData() { } void DriveURLRequestJob::OnGetFileByResourceId( - DriveFileError error, + FileError error, const base::FilePath& local_file_path, const std::string& mime_type, DriveFileType file_type) { DVLOG(1) << "Got OnGetFileByResourceId"; DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (error != DRIVE_FILE_OK || file_type != REGULAR_FILE) { + if (error != FILE_ERROR_OK || file_type != REGULAR_FILE) { LOG(WARNING) << "Failed to start request: can't get file for resource id"; NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FILE_NOT_FOUND)); diff --git a/chrome/browser/chromeos/drive/drive_url_request_job.h b/chrome/browser/chromeos/drive/drive_url_request_job.h index 5f23216..c1448af 100644 --- a/chrome/browser/chromeos/drive/drive_url_request_job.h +++ b/chrome/browser/chromeos/drive/drive_url_request_job.h @@ -14,8 +14,8 @@ #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "base/strings/string_piece.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/google_apis/gdata_errorcode.h" #include "net/url_request/url_request_job.h" @@ -84,7 +84,7 @@ class DriveURLRequestJob : public net::URLRequestJob { // Helper callback for handling async responses from // DriveFileSystem::GetFileByResourceId(). - void OnGetFileByResourceId(DriveFileError error, + void OnGetFileByResourceId(FileError error, const base::FilePath& local_file_path, const std::string& mime_type, DriveFileType file_type); @@ -93,7 +93,7 @@ class DriveURLRequestJob : public net::URLRequestJob { void OnGetFileSize(int64 *file_size, bool success); // Helper callback for GetEntryInfoByPath invoked by Start(). - void OnGetEntryInfoByPath(DriveFileError error, + void OnGetEntryInfoByPath(FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Helper methods for ReadRawData to open file and read from its corresponding 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 115f573..7f0a724 100644 --- a/chrome/browser/chromeos/drive/drive_url_request_job_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_url_request_job_unittest.cc @@ -202,7 +202,7 @@ TEST_F(DriveURLRequestJobTest, NonGetMethod) { TEST_F(DriveURLRequestJobTest, HostedDocument) { // Get a hosted document's path. - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry; base::FilePath file_path; drive_file_system_->GetEntryInfoByResourceId( @@ -211,7 +211,7 @@ TEST_F(DriveURLRequestJobTest, HostedDocument) { &error, &file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(entry); ASSERT_TRUE(entry->file_specific_info().is_hosted_document()); diff --git a/chrome/browser/chromeos/drive/fake_drive_file_system.cc b/chrome/browser/chromeos/drive/fake_drive_file_system.cc index f2d45ca..e2a9aaf 100644 --- a/chrome/browser/chromeos/drive/fake_drive_file_system.cc +++ b/chrome/browser/chromeos/drive/fake_drive_file_system.cc @@ -10,8 +10,8 @@ #include "base/files/file_path.h" #include "base/logging.h" #include "chrome/browser/chromeos/drive/drive.pb.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" #include "chrome/browser/chromeos/drive/drive_file_system_util.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" #include "chrome/browser/google_apis/drive_api_parser.h" #include "chrome/browser/google_apis/gdata_wapi_parser.h" @@ -271,7 +271,7 @@ void FakeDriveFileSystem::GetFilePathAfterGetAboutResource( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // We assume the call always success for test. - DCHECK_EQ(util::GDataToDriveFileError(error), DRIVE_FILE_OK); + DCHECK_EQ(util::GDataToFileError(error), FILE_ERROR_OK); DCHECK(about_resource); GetFilePathInternal(about_resource->root_folder_id(), resource_id, @@ -308,7 +308,7 @@ void FakeDriveFileSystem::GetFilePathAfterGetResourceEntry( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // We assume the call always success for test. - DCHECK_EQ(util::GDataToDriveFileError(error_in), DRIVE_FILE_OK); + DCHECK_EQ(util::GDataToFileError(error_in), FILE_ERROR_OK); DCHECK(resource_entry); DriveEntryProto entry_proto = @@ -328,8 +328,8 @@ void FakeDriveFileSystem::GetEntryInfoByResourceIdAfterGetResourceEntry( scoped_ptr<google_apis::ResourceEntry> resource_entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveFileError error = util::GDataToDriveFileError(error_in); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(error_in); + if (error != FILE_ERROR_OK) { callback.Run(error, base::FilePath(), scoped_ptr<DriveEntryProto>()); return; } @@ -349,7 +349,7 @@ void FakeDriveFileSystem::GetEntryInfoByResourceIdAfterGetResourceEntry( void FakeDriveFileSystem::GetEntryInfoByResourceIdAfterGetFilePath( const GetEntryInfoWithFilePathCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto, const base::FilePath& parent_file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -364,11 +364,11 @@ void FakeDriveFileSystem::GetFileContentByPathAfterGetEntryInfo( const GetFileContentInitializedCallback& initialized_callback, const google_apis::GetContentCallback& get_content_callback, const FileOperationCallback& completion_callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { completion_callback.Run(error); return; } @@ -378,15 +378,15 @@ void FakeDriveFileSystem::GetFileContentByPathAfterGetEntryInfo( cache_dir_.path().AppendASCII(entry_proto->resource_id()); if (file_util::PathExists(cache_path)) { // Cache file is found. - initialized_callback.Run(DRIVE_FILE_OK, entry_proto.Pass(), cache_path); - completion_callback.Run(DRIVE_FILE_OK); + initialized_callback.Run(FILE_ERROR_OK, entry_proto.Pass(), cache_path); + 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( - DRIVE_FILE_OK, entry_proto.Pass(), base::FilePath()); + FILE_ERROR_OK, entry_proto.Pass(), base::FilePath()); drive_service_->DownloadFile( file_path, cache_path, @@ -403,7 +403,7 @@ void FakeDriveFileSystem::GetFileContentByPathAfterDownloadFile( google_apis::GDataErrorCode gdata_error, const base::FilePath& temp_file) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - completion_callback.Run(util::GDataToDriveFileError(gdata_error)); + completion_callback.Run(util::GDataToFileError(gdata_error)); } // Implementation of GetEntryInfoByPath. @@ -413,8 +413,8 @@ void FakeDriveFileSystem::GetEntryInfoByPathAfterGetAboutResource( scoped_ptr<google_apis::AboutResource> about_resource) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveFileError error = util::GDataToDriveFileError(gdata_error); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(gdata_error); + if (error != FILE_ERROR_OK) { callback.Run(error, scoped_ptr<DriveEntryProto>()); return; } @@ -430,11 +430,11 @@ void FakeDriveFileSystem::GetEntryInfoByPathAfterGetAboutResource( void FakeDriveFileSystem::GetEntryInfoByPathAfterGetParentEntryInfo( const base::FilePath& base_name, const GetEntryInfoCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> parent_entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error, scoped_ptr<DriveEntryProto>()); return; } @@ -454,8 +454,8 @@ void FakeDriveFileSystem::GetEntryInfoByPathAfterGetResourceList( scoped_ptr<google_apis::ResourceList> resource_list) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DriveFileError error = util::GDataToDriveFileError(gdata_error); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(gdata_error); + if (error != FILE_ERROR_OK) { callback.Run(error, scoped_ptr<DriveEntryProto>()); return; } @@ -468,12 +468,12 @@ void FakeDriveFileSystem::GetEntryInfoByPathAfterGetResourceList( ConvertResourceEntryToDriveEntryProto(*entries[i]))); if (entry->base_name() == base_name.AsUTF8Unsafe()) { // Found the target entry. - callback.Run(DRIVE_FILE_OK, entry.Pass()); + callback.Run(FILE_ERROR_OK, entry.Pass()); return; } } - callback.Run(DRIVE_FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); + callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); } } // namespace test_util diff --git a/chrome/browser/chromeos/drive/fake_drive_file_system.h b/chrome/browser/chromeos/drive/fake_drive_file_system.h index 0ebe175..f2f7956 100644 --- a/chrome/browser/chromeos/drive/fake_drive_file_system.h +++ b/chrome/browser/chromeos/drive/fake_drive_file_system.h @@ -11,8 +11,8 @@ #include "base/callback_forward.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/google_apis/gdata_errorcode.h" namespace google_apis { @@ -175,7 +175,7 @@ class FakeDriveFileSystem : public DriveFileSystemInterface { scoped_ptr<google_apis::ResourceEntry> resource_entry); void GetEntryInfoByResourceIdAfterGetFilePath( const GetEntryInfoWithFilePathCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto, const base::FilePath& parent_file_path); @@ -190,7 +190,7 @@ class FakeDriveFileSystem : public DriveFileSystemInterface { const GetFileContentInitializedCallback& initialized_callback, const google_apis::GetContentCallback& get_content_callback, const FileOperationCallback& completion_callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); void GetFileContentByPathAfterDownloadFile( const FileOperationCallback& completion_callback, @@ -215,7 +215,7 @@ class FakeDriveFileSystem : public DriveFileSystemInterface { void GetEntryInfoByPathAfterGetParentEntryInfo( const base::FilePath& base_name, const GetEntryInfoCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> parent_entry_proto); void GetEntryInfoByPathAfterGetResourceList( const base::FilePath& base_name, diff --git a/chrome/browser/chromeos/drive/fake_drive_file_system_unittest.cc b/chrome/browser/chromeos/drive/fake_drive_file_system_unittest.cc index bbc2c91..bbb97e2 100644 --- a/chrome/browser/chromeos/drive/fake_drive_file_system_unittest.cc +++ b/chrome/browser/chromeos/drive/fake_drive_file_system_unittest.cc @@ -47,7 +47,7 @@ class FakeDriveFileSystemTest : public ::testing::Test { }; TEST_F(FakeDriveFileSystemTest, GetEntryInfoByResourceId) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry; base::FilePath file_path; @@ -57,7 +57,7 @@ TEST_F(FakeDriveFileSystemTest, GetEntryInfoByResourceId) { &error, &file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); EXPECT_EQ( util::GetDriveMyDriveRootPath().AppendASCII( "Directory 1/Sub Directory Folder"), @@ -69,7 +69,7 @@ TEST_F(FakeDriveFileSystemTest, GetEntryInfoByResourceId_PathCompatibleWithGetEntryInfoByPath) { const std::string document_resource_id = "document:5_document_resource_id"; - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry; base::FilePath file_path; @@ -80,29 +80,29 @@ TEST_F(FakeDriveFileSystemTest, &error, &file_path, &entry)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(entry); EXPECT_TRUE(entry->file_specific_info().is_hosted_document()); // Get entry info by path given by GetEntryInfoByResourceId. - error = DRIVE_FILE_ERROR_FAILED; + error = FILE_ERROR_FAILED; entry.reset(); fake_drive_file_system_->GetEntryInfoByPath( file_path, google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(entry); EXPECT_EQ(document_resource_id, entry->resource_id()); } TEST_F(FakeDriveFileSystemTest, GetFileContentByPath) { - DriveFileError initialize_error = DRIVE_FILE_ERROR_FAILED; + FileError initialize_error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry_proto; base::FilePath cache_file_path; google_apis::test_util::TestGetContentCallback get_content_callback; - DriveFileError completion_error = DRIVE_FILE_ERROR_FAILED; + FileError completion_error = FILE_ERROR_FAILED; const base::FilePath kDriveFile = util::GetDriveMyDriveRootPath().AppendASCII("File 1.txt"); @@ -116,7 +116,7 @@ TEST_F(FakeDriveFileSystemTest, GetFileContentByPath) { google_apis::test_util::CreateCopyResultCallback(&completion_error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, initialize_error); + EXPECT_EQ(FILE_ERROR_OK, initialize_error); EXPECT_TRUE(entry_proto); // No cache file is available yet. @@ -126,12 +126,12 @@ TEST_F(FakeDriveFileSystemTest, GetFileContentByPath) { // should have the actual data. std::string content = get_content_callback.GetConcatenatedData(); EXPECT_EQ(10U, content.size()); - EXPECT_EQ(DRIVE_FILE_OK, completion_error); + EXPECT_EQ(FILE_ERROR_OK, completion_error); - initialize_error = DRIVE_FILE_ERROR_FAILED; + initialize_error = FILE_ERROR_FAILED; entry_proto.reset(); get_content_callback.mutable_data()->clear(); - completion_error = DRIVE_FILE_ERROR_FAILED; + completion_error = FILE_ERROR_FAILED; // For the second time, the cache file should be found. fake_drive_file_system_->GetFileContentByPath( @@ -142,7 +142,7 @@ TEST_F(FakeDriveFileSystemTest, GetFileContentByPath) { google_apis::test_util::CreateCopyResultCallback(&completion_error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, initialize_error); + EXPECT_EQ(FILE_ERROR_OK, initialize_error); EXPECT_TRUE(entry_proto); // Cache file should be available. @@ -150,7 +150,7 @@ TEST_F(FakeDriveFileSystemTest, GetFileContentByPath) { // There should be a cache file so no data should be downloaded. EXPECT_TRUE(get_content_callback.data().empty()); - EXPECT_EQ(DRIVE_FILE_OK, completion_error); + EXPECT_EQ(FILE_ERROR_OK, completion_error); // Make sure the cached file's content. std::string cache_file_content; @@ -160,7 +160,7 @@ TEST_F(FakeDriveFileSystemTest, GetFileContentByPath) { } TEST_F(FakeDriveFileSystemTest, GetEntryInfoByPath) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry; fake_drive_file_system_->GetEntryInfoByPath( util::GetDriveMyDriveRootPath().AppendASCII( @@ -168,20 +168,20 @@ TEST_F(FakeDriveFileSystemTest, GetEntryInfoByPath) { google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(entry); EXPECT_EQ("folder:sub_dir_folder_resource_id", entry->resource_id()); } TEST_F(FakeDriveFileSystemTest, GetEntryInfoByPath_Root) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry; fake_drive_file_system_->GetEntryInfoByPath( util::GetDriveMyDriveRootPath(), google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(entry); EXPECT_TRUE(entry->file_info().is_directory()); EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); @@ -189,14 +189,14 @@ TEST_F(FakeDriveFileSystemTest, GetEntryInfoByPath_Root) { } TEST_F(FakeDriveFileSystemTest, GetEntryInfoByPath_Invalid) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<DriveEntryProto> entry; fake_drive_file_system_->GetEntryInfoByPath( util::GetDriveMyDriveRootPath().AppendASCII("Invalid File Name"), google_apis::test_util::CreateCopyResultCallback(&error, &entry)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + ASSERT_EQ(FILE_ERROR_NOT_FOUND, error); ASSERT_FALSE(entry); } diff --git a/chrome/browser/chromeos/drive/file_errors.cc b/chrome/browser/chromeos/drive/file_errors.cc new file mode 100644 index 0000000..e578655 --- /dev/null +++ b/chrome/browser/chromeos/drive/file_errors.cc @@ -0,0 +1,156 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/drive/file_errors.h" + +#include "base/logging.h" + +namespace drive { + +std::string FileErrorToString(FileError error) { + switch (error) { + case FILE_ERROR_OK: + return "FILE_ERROR_OK"; + + case FILE_ERROR_FAILED: + return "FILE_ERROR_FAILED"; + + case FILE_ERROR_IN_USE: + return "FILE_ERROR_IN_USE"; + + case FILE_ERROR_EXISTS: + return "FILE_ERROR_EXISTS"; + + case FILE_ERROR_NOT_FOUND: + return "FILE_ERROR_NOT_FOUND"; + + case FILE_ERROR_ACCESS_DENIED: + return "FILE_ERROR_ACCESS_DENIED"; + + case FILE_ERROR_TOO_MANY_OPENED: + return "FILE_ERROR_TOO_MANY_OPENED"; + + case FILE_ERROR_NO_MEMORY: + return "FILE_ERROR_NO_MEMORY"; + + case FILE_ERROR_NO_SPACE: + return "FILE_ERROR_NO_SPACE"; + + case FILE_ERROR_NOT_A_DIRECTORY: + return "FILE_ERROR_NOT_A_DIRECTORY"; + + case FILE_ERROR_INVALID_OPERATION: + return "FILE_ERROR_INVALID_OPERATION"; + + case FILE_ERROR_SECURITY: + return "FILE_ERROR_SECURITY"; + + case FILE_ERROR_ABORT: + return "FILE_ERROR_ABORT"; + + case FILE_ERROR_NOT_A_FILE: + return "FILE_ERROR_NOT_A_FILE"; + + case FILE_ERROR_NOT_EMPTY: + return "FILE_ERROR_NOT_EMPTY"; + + case FILE_ERROR_INVALID_URL: + return "FILE_ERROR_INVALID_URL"; + + case FILE_ERROR_NO_CONNECTION: + return "FILE_ERROR_NO_CONNECTION"; + + case FILE_ERROR_THROTTLED: + return "FILE_ERROR_THROTTLED"; + } + + NOTREACHED(); + return ""; +} + +base::PlatformFileError FileErrorToPlatformError(FileError error) { + switch (error) { + case FILE_ERROR_OK: + return base::PLATFORM_FILE_OK; + + case FILE_ERROR_FAILED: + return base::PLATFORM_FILE_ERROR_FAILED; + + case FILE_ERROR_IN_USE: + return base::PLATFORM_FILE_ERROR_IN_USE; + + case FILE_ERROR_EXISTS: + return base::PLATFORM_FILE_ERROR_EXISTS; + + case FILE_ERROR_NOT_FOUND: + return base::PLATFORM_FILE_ERROR_NOT_FOUND; + + case FILE_ERROR_ACCESS_DENIED: + return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; + + case FILE_ERROR_TOO_MANY_OPENED: + return base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED; + + case FILE_ERROR_NO_MEMORY: + return base::PLATFORM_FILE_ERROR_NO_MEMORY; + + case FILE_ERROR_NO_SPACE: + return base::PLATFORM_FILE_ERROR_NO_SPACE; + + case FILE_ERROR_NOT_A_DIRECTORY: + return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; + + case FILE_ERROR_INVALID_OPERATION: + return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; + + case FILE_ERROR_SECURITY: + return base::PLATFORM_FILE_ERROR_SECURITY; + + case FILE_ERROR_ABORT: + return base::PLATFORM_FILE_ERROR_ABORT; + + case FILE_ERROR_NOT_A_FILE: + return base::PLATFORM_FILE_ERROR_NOT_A_FILE; + + case FILE_ERROR_NOT_EMPTY: + return base::PLATFORM_FILE_ERROR_NOT_EMPTY; + + case FILE_ERROR_INVALID_URL: + return base::PLATFORM_FILE_ERROR_INVALID_URL; + + case FILE_ERROR_NO_CONNECTION: + return base::PLATFORM_FILE_ERROR_FAILED; + + case FILE_ERROR_THROTTLED: + return base::PLATFORM_FILE_ERROR_FAILED; + } + + NOTREACHED(); + return base::PLATFORM_FILE_ERROR_FAILED; +} + +FileError DriveUploadErrorToFileError( + google_apis::DriveUploadError error) { + switch (error) { + case google_apis::DRIVE_UPLOAD_OK: + return FILE_ERROR_OK; + + case google_apis::DRIVE_UPLOAD_ERROR_NOT_FOUND: + return FILE_ERROR_NOT_FOUND; + + case google_apis::DRIVE_UPLOAD_ERROR_NO_SPACE: + return FILE_ERROR_NO_SPACE; + + case google_apis::DRIVE_UPLOAD_ERROR_CONFLICT: + return FILE_ERROR_THROTTLED; + + case google_apis::DRIVE_UPLOAD_ERROR_ABORT: + return FILE_ERROR_ABORT; + } + + NOTREACHED(); + return FILE_ERROR_FAILED; +} + +} // namespace drive diff --git a/chrome/browser/chromeos/drive/file_errors.h b/chrome/browser/chromeos/drive/file_errors.h new file mode 100644 index 0000000..9199974 --- /dev/null +++ b/chrome/browser/chromeos/drive/file_errors.h @@ -0,0 +1,50 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_ERRORS_H_ +#define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_ERRORS_H_ + +#include "base/callback_forward.h" +#include "base/platform_file.h" +#include "chrome/browser/google_apis/drive_upload_error.h" + +namespace drive { + +enum FileError { + FILE_ERROR_OK = 0, + FILE_ERROR_FAILED = -1, + FILE_ERROR_IN_USE = -2, + FILE_ERROR_EXISTS = -3, + FILE_ERROR_NOT_FOUND = -4, + FILE_ERROR_ACCESS_DENIED = -5, + FILE_ERROR_TOO_MANY_OPENED = -6, + FILE_ERROR_NO_MEMORY = -7, + FILE_ERROR_NO_SPACE = -8, + FILE_ERROR_NOT_A_DIRECTORY = -9, + FILE_ERROR_INVALID_OPERATION = -10, + FILE_ERROR_SECURITY = -11, + FILE_ERROR_ABORT = -12, + FILE_ERROR_NOT_A_FILE = -13, + FILE_ERROR_NOT_EMPTY = -14, + FILE_ERROR_INVALID_URL = -15, + FILE_ERROR_NO_CONNECTION = -16, + FILE_ERROR_THROTTLED = -17, +}; + +// Used as callbacks for file operations. +typedef base::Callback<void(FileError error)> FileOperationCallback; + +// Returns a string representation of FileError. +std::string FileErrorToString(FileError error); + +// Returns a PlatformFileError that corresponds to the FileError provided. +base::PlatformFileError FileErrorToPlatformError(FileError error); + +// Returns a FileError that corresponds to the DriveUploadError provided. +FileError DriveUploadErrorToFileError( + google_apis::DriveUploadError error); + +} // namespace drive + +#endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_ERRORS_H_ diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc b/chrome/browser/chromeos/drive/file_system/copy_operation.cc index 126684b..91c1177 100644 --- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc @@ -33,12 +33,12 @@ const char kMimeTypeOctetStream[] = "application/octet-stream"; // Copies a file from |src_file_path| to |dest_file_path| on the local // file system using file_util::CopyFile. -// Returns DRIVE_FILE_OK on success or DRIVE_FILE_ERROR_FAILED otherwise. -DriveFileError CopyLocalFileOnBlockingPool( +// Returns FILE_ERROR_OK on success or FILE_ERROR_FAILED otherwise. +FileError CopyLocalFileOnBlockingPool( const base::FilePath& src_file_path, const base::FilePath& dest_file_path) { return file_util::CopyFile(src_file_path, dest_file_path) ? - DRIVE_FILE_OK : DRIVE_FILE_ERROR_FAILED; + FILE_ERROR_OK : FILE_ERROR_FAILED; } // Checks if a local file at |local_file_path| is a JSON file referencing a @@ -129,14 +129,14 @@ void CopyOperation::TransferFileFromRemoteToLocal( void CopyOperation::OnGetFileCompleteForTransferFile( const base::FilePath& local_dest_file_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& local_file_path, const std::string& unused_mime_type, DriveFileType file_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -218,8 +218,8 @@ void CopyOperation::OnCopyHostedDocumentCompleted( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -238,14 +238,14 @@ void CopyOperation::OnCopyHostedDocumentCompleted( void CopyOperation::MoveEntryFromRootDirectory( const base::FilePath& directory_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); DCHECK_EQ(util::kDriveMyDriveRootPath, file_path.DirName().value()); // Return if there is an error or |dir_path| is the root directory. - if (error != DRIVE_FILE_OK || + if (error != FILE_ERROR_OK || directory_path == util::GetDriveMyDriveRootPath()) { callback.Run(error); return; @@ -264,10 +264,10 @@ void CopyOperation::CopyAfterGetEntryInfoPair( DCHECK(!callback.is_null()); DCHECK(result.get()); - if (result->first.error != DRIVE_FILE_OK) { + if (result->first.error != FILE_ERROR_OK) { callback.Run(result->first.error); return; - } else if (result->second.error != DRIVE_FILE_OK) { + } else if (result->second.error != FILE_ERROR_OK) { callback.Run(result->second.error); return; } @@ -276,13 +276,13 @@ void CopyOperation::CopyAfterGetEntryInfoPair( scoped_ptr<DriveEntryProto> dest_parent_proto = result->second.proto.Pass(); if (!dest_parent_proto->file_info().is_directory()) { - callback.Run(DRIVE_FILE_ERROR_NOT_A_DIRECTORY); + callback.Run(FILE_ERROR_NOT_A_DIRECTORY); return; } else if (src_file_proto->file_info().is_directory()) { // TODO(kochi): Implement copy for directories. In the interim, // we handle recursive directory copy in the file manager. // crbug.com/141596 - callback.Run(DRIVE_FILE_ERROR_INVALID_OPERATION); + callback.Run(FILE_ERROR_INVALID_OPERATION); return; } @@ -310,14 +310,14 @@ void CopyOperation::CopyAfterGetEntryInfoPair( void CopyOperation::OnGetFileCompleteForCopy( const base::FilePath& remote_dest_file_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& local_file_path, const std::string& unused_mime_type, DriveFileType file_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -345,15 +345,15 @@ void CopyOperation::StartFileUpload(const StartFileUploadParams& params, void CopyOperation::StartFileUploadAfterGetEntryInfo( const StartFileUploadParams& params, const std::string& content_type, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!params.callback.is_null()); if (entry_proto.get() && !entry_proto->file_info().is_directory()) - error = DRIVE_FILE_ERROR_NOT_A_DIRECTORY; + error = FILE_ERROR_NOT_A_DIRECTORY; - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { params.callback.Run(error); return; } @@ -385,7 +385,7 @@ void CopyOperation::OnTransferCompleted( file_path, callback); } else { - callback.Run(DriveUploadErrorToDriveFileError(error)); + callback.Run(DriveUploadErrorToFileError(error)); } } @@ -393,12 +393,12 @@ void CopyOperation::TransferFileFromLocalToRemoteAfterGetEntryInfo( const base::FilePath& local_src_file_path, const base::FilePath& remote_dest_file_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -406,7 +406,7 @@ void CopyOperation::TransferFileFromLocalToRemoteAfterGetEntryInfo( DCHECK(entry_proto.get()); if (!entry_proto->file_info().is_directory()) { // The parent of |remote_dest_file_path| is not a directory. - callback.Run(DRIVE_FILE_ERROR_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 54d491d..902bff2 100644 --- a/chrome/browser/chromeos/drive/file_system/copy_operation.h +++ b/chrome/browser/chromeos/drive/file_system/copy_operation.h @@ -100,7 +100,7 @@ class CopyOperation { void OnGetFileCompleteForTransferFile( const base::FilePath& local_dest_file_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& local_file_path, const std::string& unused_mime_type, DriveFileType file_type); @@ -131,7 +131,7 @@ class CopyOperation { // |callback| must not be null. void MoveEntryFromRootDirectory(const base::FilePath& directory_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& file_path); // Part of Copy(). Called after GetEntryInfoPairByPaths() is @@ -147,7 +147,7 @@ class CopyOperation { // Can be called from UI thread. |callback| is run on the calling thread. void OnGetFileCompleteForCopy(const base::FilePath& remote_dest_file_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& local_file_path, const std::string& unused_mime_type, DriveFileType file_type); @@ -162,7 +162,7 @@ class CopyOperation { void StartFileUploadAfterGetEntryInfo( const StartFileUploadParams& params, const std::string& content_type, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Helper function that completes bookkeeping tasks related to @@ -180,7 +180,7 @@ class CopyOperation { const base::FilePath& local_src_file_path, const base::FilePath& remote_dest_file_path, const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Initiates transfer of |local_file_path| with |resource_id| to 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 ac7e2de..351643b 100644 --- a/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc @@ -115,12 +115,12 @@ void CreateDirectoryOperation::CreateDirectoryAfterFindFirstMissingPath( switch (result.error) { case FIND_FIRST_FOUND_INVALID: { - params->callback.Run(DRIVE_FILE_ERROR_NOT_FOUND); + params->callback.Run(FILE_ERROR_NOT_FOUND); return; } case FIND_FIRST_DIRECTORY_ALREADY_PRESENT: { params->callback.Run( - params->is_exclusive ? DRIVE_FILE_ERROR_EXISTS : DRIVE_FILE_OK); + params->is_exclusive ? FILE_ERROR_EXISTS : FILE_ERROR_OK); return; } case FIND_FIRST_FOUND_MISSING: { @@ -138,7 +138,7 @@ void CreateDirectoryOperation::CreateDirectoryAfterFindFirstMissingPath( // directory if this is not a recursive operation. if (params->target_directory_path != result.first_missing_parent_path && !params->is_recursive) { - params->callback.Run(DRIVE_FILE_ERROR_NOT_FOUND); + params->callback.Run(FILE_ERROR_NOT_FOUND); return; } @@ -159,8 +159,8 @@ void CreateDirectoryOperation::AddNewDirectory( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!params->callback.is_null()); - DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { params->callback.Run(error); return; } @@ -176,12 +176,12 @@ void CreateDirectoryOperation::AddNewDirectory( void CreateDirectoryOperation::ContinueCreateDirectory( scoped_ptr<CreateDirectoryParams> params, const base::FilePath& created_directory_path, - DriveFileError error, + FileError error, const base::FilePath& moved_file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!params->callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { params->callback.Run(error); return; } @@ -196,7 +196,7 @@ void CreateDirectoryOperation::ContinueCreateDirectory( params->is_recursive, params->callback); } else { // Finally done with the create request. - params->callback.Run(DRIVE_FILE_OK); + params->callback.Run(FILE_ERROR_OK); } } @@ -250,19 +250,19 @@ void CreateDirectoryOperation::FindFirstMissingParentDirectoryInternal( void CreateDirectoryOperation::ContinueFindFirstMissingParentDirectory( scoped_ptr<FindFirstMissingParentDirectoryParams> params, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(params.get()); FindFirstMissingParentDirectoryResult result; - if (error == DRIVE_FILE_ERROR_NOT_FOUND) { + if (error == FILE_ERROR_NOT_FOUND) { // Found the missing parent. result.Init(FIND_FIRST_FOUND_MISSING, params->current_path, params->last_dir_resource_id); params->callback.Run(result); - } else if (error != DRIVE_FILE_OK || + } else if (error != FILE_ERROR_OK || !entry_proto->file_info().is_directory()) { // Unexpected error, or found a file when we were expecting a directory. result.Init(FIND_FIRST_FOUND_INVALID, base::FilePath(), ""); 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 880ee45..13ea48f 100644 --- a/chrome/browser/chromeos/drive/file_system/create_directory_operation.h +++ b/chrome/browser/chromeos/drive/file_system/create_directory_operation.h @@ -10,7 +10,7 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/google_apis/gdata_errorcode.h" #include "googleurl/src/gurl.h" @@ -120,7 +120,7 @@ class CreateDirectoryOperation { // recursive creation of a directory path by calling CreateDirectory again. void ContinueCreateDirectory(scoped_ptr<CreateDirectoryParams> params, const base::FilePath& created_directory_path, - DriveFileError error, + FileError error, const base::FilePath& moved_file_path); // Finds the first missing parent directory of |directory_path|. @@ -138,7 +138,7 @@ class CreateDirectoryOperation { // FindFirstMissingParentDirectory. void ContinueFindFirstMissingParentDirectory( scoped_ptr<FindFirstMissingParentDirectoryParams> params, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); DriveScheduler* drive_scheduler_; diff --git a/chrome/browser/chromeos/drive/file_system/create_directory_operation_unittest.cc b/chrome/browser/chromeos/drive/file_system/create_directory_operation_unittest.cc index 70084cf..52a61bf 100644 --- a/chrome/browser/chromeos/drive/file_system/create_directory_operation_unittest.cc +++ b/chrome/browser/chromeos/drive/file_system/create_directory_operation_unittest.cc @@ -49,11 +49,11 @@ class CreateDirectoryOperationTest metadata_.reset(new DriveResourceMetadata(temp_dir_.path(), blocking_task_runner_)); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; metadata_->Initialize( google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); scheduler_.reset( new DriveScheduler(profile_.get(), fake_drive_service_.get())); @@ -67,7 +67,7 @@ class CreateDirectoryOperationTest DirectoryFetchInfo(), google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); operation_.reset( new CreateDirectoryOperation(scheduler_.get(), metadata_.get(), this)); diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.cc b/chrome/browser/chromeos/drive/file_system/move_operation.cc index ffc761b..4fd5294 100644 --- a/chrome/browser/chromeos/drive/file_system/move_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/move_operation.cc @@ -53,16 +53,16 @@ void MoveOperation::MoveAfterGetEntryInfoPair( DCHECK(!callback.is_null()); DCHECK(src_dest_info.get()); - if (src_dest_info->first.error != DRIVE_FILE_OK) { + if (src_dest_info->first.error != FILE_ERROR_OK) { callback.Run(src_dest_info->first.error); return; } - if (src_dest_info->second.error != DRIVE_FILE_OK) { + if (src_dest_info->second.error != FILE_ERROR_OK) { callback.Run(src_dest_info->second.error); return; } if (!src_dest_info->second.proto->file_info().is_directory()) { - callback.Run(DRIVE_FILE_ERROR_NOT_A_DIRECTORY); + callback.Run(FILE_ERROR_NOT_A_DIRECTORY); return; } @@ -85,11 +85,11 @@ void MoveOperation::MoveAfterGetEntryInfoPair( void MoveOperation::MoveAfterRename( const FileOperationCallback& callback, scoped_ptr<EntryInfoPairResult> src_dest_info, - DriveFileError error, + FileError error, const base::FilePath& src_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -101,7 +101,7 @@ void MoveOperation::MoveAfterRename( // The source and the destination directory are the same. Nothing more to do. if (src_path.DirName() == dest_dir_path) { observer_->OnDirectoryChangedByOperation(dest_dir_path); - callback.Run(DRIVE_FILE_OK); + callback.Run(FILE_ERROR_OK); return; } @@ -115,11 +115,11 @@ void MoveOperation::MoveAfterRename( void MoveOperation::MoveAfterAddToDirectory( const FileOperationCallback& callback, scoped_ptr<EntryInfoPairResult> src_dest_info, - DriveFileError error, + FileError error, const base::FilePath& new_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -142,7 +142,7 @@ void MoveOperation::Rename(const std::string& src_id, // It is a no-op if the file is renamed to the same name. if (src_path.BaseName() == new_name) { - callback.Run(DRIVE_FILE_OK, src_path); + callback.Run(FILE_ERROR_OK, src_path); return; } @@ -168,8 +168,8 @@ void MoveOperation::RenameLocally(const base::FilePath& src_path, google_apis::GDataErrorCode status) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - const DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + const FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { callback.Run(error, base::FilePath()); return; } @@ -199,8 +199,8 @@ void MoveOperation::AddToDirectoryLocally(const base::FilePath& src_path, google_apis::GDataErrorCode status) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - const DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + const FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { callback.Run(error, base::FilePath()); return; } @@ -225,7 +225,7 @@ void MoveOperation::RemoveFromDirectoryCompleted( const FileOperationCallback& callback, google_apis::GDataErrorCode status) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - callback.Run(util::GDataToDriveFileError(status)); + callback.Run(util::GDataToFileError(status)); } } // namespace file_system diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.h b/chrome/browser/chromeos/drive/file_system/move_operation.h index f8df056..493f994 100644 --- a/chrome/browser/chromeos/drive/file_system/move_operation.h +++ b/chrome/browser/chromeos/drive/file_system/move_operation.h @@ -56,7 +56,7 @@ class MoveOperation { // to the destination directory. void MoveAfterRename(const FileOperationCallback& callback, scoped_ptr<EntryInfoPairResult> src_dest_info, - DriveFileError error, + FileError error, const base::FilePath& src_path); // Step 3 of Move(), called after the resource is added to the new directory. @@ -66,7 +66,7 @@ class MoveOperation { // resource is contained in both the new and the old directories. void MoveAfterAddToDirectory(const FileOperationCallback& callback, scoped_ptr<EntryInfoPairResult> src_dest_info, - DriveFileError error, + FileError error, const base::FilePath& src_path); // Step 4 of Move(), called after the resource is removed from the old diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.cc b/chrome/browser/chromeos/drive/file_system/remove_operation.cc index 2c1ee3e..98ce787 100644 --- a/chrome/browser/chromeos/drive/file_system/remove_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.cc @@ -18,7 +18,7 @@ namespace file_system { namespace { -void EmptyFileOperationCallback(DriveFileError error) {} +void EmptyFileOperationCallback(FileError error) {} } // namespace @@ -57,12 +57,12 @@ void RemoveOperation::Remove( void RemoveOperation::RemoveAfterGetEntryInfo( const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -83,8 +83,8 @@ void RemoveOperation::RemoveResourceLocally( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - DriveFileError error = util::GDataToDriveFileError(status); - if (error != DRIVE_FILE_OK) { + FileError error = util::GDataToFileError(status); + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -99,12 +99,12 @@ void RemoveOperation::RemoveResourceLocally( void RemoveOperation::NotifyDirectoryChanged( const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& directory_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error == DRIVE_FILE_OK) + if (error == FILE_ERROR_OK) observer_->OnDirectoryChangedByOperation(directory_path); callback.Run(error); diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.h b/chrome/browser/chromeos/drive/file_system/remove_operation.h index df0c0d7..fb520da 100644 --- a/chrome/browser/chromeos/drive/file_system/remove_operation.h +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.h @@ -54,7 +54,7 @@ class RemoveOperation { // |callback| must not be null. void RemoveAfterGetEntryInfo( const FileOperationCallback& callback, - DriveFileError error, + FileError error, scoped_ptr<DriveEntryProto> entry_proto); // Callback for DriveServiceInterface::DeleteResource. Removes the entry with @@ -69,7 +69,7 @@ class RemoveOperation { // and runs |callback| with |error|. |callback| must not be null. void NotifyDirectoryChanged( const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& directory_path); DriveScheduler* drive_scheduler_; diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.cc b/chrome/browser/chromeos/drive/file_system/update_operation.cc index 924b9a2..8ddf185 100644 --- a/chrome/browser/chromeos/drive/file_system/update_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/update_operation.cc @@ -57,20 +57,20 @@ void UpdateOperation::UpdateFileByResourceId( void UpdateOperation::UpdateFileByEntryInfo( DriveClientContext context, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } DCHECK(entry_proto.get()); if (entry_proto->file_info().is_directory()) { - callback.Run(DRIVE_FILE_ERROR_NOT_FOUND); + callback.Run(FILE_ERROR_NOT_FOUND); return; } @@ -91,12 +91,12 @@ void UpdateOperation::OnGetFileCompleteForUpdateFile( const FileOperationCallback& callback, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto, - DriveFileError error, + FileError error, const base::FilePath& cache_file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } @@ -122,8 +122,8 @@ void UpdateOperation::OnUpdatedFileUploaded( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - DriveFileError drive_error = DriveUploadErrorToDriveFileError(error); - if (drive_error != DRIVE_FILE_OK) { + FileError drive_error = DriveUploadErrorToFileError(error); + if (drive_error != FILE_ERROR_OK) { callback.Run(drive_error); return; } @@ -136,13 +136,13 @@ void UpdateOperation::OnUpdatedFileUploaded( void UpdateOperation::OnUpdatedFileRefreshed( const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { callback.Run(error); return; } diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.h b/chrome/browser/chromeos/drive/file_system/update_operation.h index 50419eb..c4b163f 100644 --- a/chrome/browser/chromeos/drive/file_system/update_operation.h +++ b/chrome/browser/chromeos/drive/file_system/update_operation.h @@ -60,7 +60,7 @@ class UpdateOperation { void UpdateFileByEntryInfo( DriveClientContext context, const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto); @@ -73,7 +73,7 @@ class UpdateOperation { const FileOperationCallback& callback, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto, - DriveFileError error, + FileError error, const base::FilePath& cache_file_path); // Part of UpdateFileByResourceId(). @@ -90,7 +90,7 @@ class UpdateOperation { // Part of UpdateFileByResourceId(). // |callback| must not be null. void OnUpdatedFileRefreshed(const FileOperationCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto); diff --git a/chrome/browser/chromeos/drive/file_write_helper.cc b/chrome/browser/chromeos/drive/file_write_helper.cc index 39126e6..96086f6 100644 --- a/chrome/browser/chromeos/drive/file_write_helper.cc +++ b/chrome/browser/chromeos/drive/file_write_helper.cc @@ -15,8 +15,8 @@ namespace { // Emits debug log when DriveFileSystem::CloseFile() is complete. void EmitDebugLogForCloseFile(const base::FilePath& file_path, - DriveFileError file_error) { - if (file_error != DRIVE_FILE_OK) { + FileError file_error) { + if (file_error != FILE_ERROR_OK) { LOG(WARNING) << "CloseFile failed: " << file_path.AsUTF8Unsafe() << ": " << file_error; } @@ -54,11 +54,11 @@ void FileWriteHelper::PrepareWritableFileAndRun( void FileWriteHelper::PrepareWritableFileAndRunAfterCreateFile( const base::FilePath& file_path, const OpenFileCallback& callback, - DriveFileError error) { + FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { content::BrowserThread::GetBlockingPool()->PostTask( FROM_HERE, base::Bind(callback, error, base::FilePath())); @@ -75,12 +75,12 @@ void FileWriteHelper::PrepareWritableFileAndRunAfterCreateFile( void FileWriteHelper::PrepareWritableFileAndRunAfterOpenFile( const base::FilePath& file_path, const OpenFileCallback& callback, - DriveFileError error, + FileError error, const base::FilePath& local_cache_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!callback.is_null()); - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { content::BrowserThread::GetBlockingPool()->PostTask( FROM_HERE, base::Bind(callback, error, base::FilePath())); @@ -89,7 +89,7 @@ void FileWriteHelper::PrepareWritableFileAndRunAfterOpenFile( content::BrowserThread::GetBlockingPool()->PostTaskAndReply( FROM_HERE, - base::Bind(callback, DRIVE_FILE_OK, local_cache_path), + base::Bind(callback, FILE_ERROR_OK, local_cache_path), base::Bind(&FileWriteHelper::PrepareWritableFileAndRunAfterCallback, weak_ptr_factory_.GetWeakPtr(), file_path)); diff --git a/chrome/browser/chromeos/drive/file_write_helper.h b/chrome/browser/chromeos/drive/file_write_helper.h index da30212..0caa970 100644 --- a/chrome/browser/chromeos/drive/file_write_helper.h +++ b/chrome/browser/chromeos/drive/file_write_helper.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_WRITE_HELPER_H_ #include "base/memory/weak_ptr.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" +#include "chrome/browser/chromeos/drive/file_errors.h" namespace base { class FilePath; @@ -38,11 +38,11 @@ class FileWriteHelper { void PrepareWritableFileAndRunAfterCreateFile( const base::FilePath& file_path, const OpenFileCallback& callback, - DriveFileError result); + FileError result); void PrepareWritableFileAndRunAfterOpenFile( const base::FilePath& file_path, const OpenFileCallback& callback, - DriveFileError result, + FileError result, const base::FilePath& local_cache_path); void PrepareWritableFileAndRunAfterCallback(const base::FilePath& file_path); diff --git a/chrome/browser/chromeos/drive/file_write_helper_unittest.cc b/chrome/browser/chromeos/drive/file_write_helper_unittest.cc index 594c8c0..a9b748d 100644 --- a/chrome/browser/chromeos/drive/file_write_helper_unittest.cc +++ b/chrome/browser/chromeos/drive/file_write_helper_unittest.cc @@ -36,9 +36,9 @@ ACTION_P(MockCloseFile, error) { arg1.Run(error); } -void RecordOpenFileCallbackArguments(DriveFileError* error, +void RecordOpenFileCallbackArguments(FileError* error, base::FilePath* path, - DriveFileError error_arg, + FileError error_arg, const base::FilePath& path_arg) { base::ThreadRestrictions::AssertIOAllowed(); *error = error_arg; @@ -65,20 +65,20 @@ TEST_F(FileWriteHelperTest, PrepareFileForWritingSuccess) { const base::FilePath kLocalPath("/tmp/dummy.txt"); EXPECT_CALL(*mock_file_system_, CreateFile(kDrivePath, false, _)) - .WillOnce(MockCreateFile(DRIVE_FILE_OK)); + .WillOnce(MockCreateFile(FILE_ERROR_OK)); EXPECT_CALL(*mock_file_system_, OpenFile(kDrivePath, _)) - .WillOnce(MockOpenFile(DRIVE_FILE_OK, kLocalPath)); + .WillOnce(MockOpenFile(FILE_ERROR_OK, kLocalPath)); EXPECT_CALL(*mock_file_system_, CloseFile(kDrivePath, _)) - .WillOnce(MockCloseFile(DRIVE_FILE_OK)); + .WillOnce(MockCloseFile(FILE_ERROR_OK)); FileWriteHelper file_write_helper(mock_file_system_.get()); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath path; file_write_helper.PrepareWritableFileAndRun( kDrivePath, base::Bind(&RecordOpenFileCallbackArguments, &error, &path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); EXPECT_EQ(kLocalPath, path); } @@ -86,18 +86,18 @@ TEST_F(FileWriteHelperTest, PrepareFileForWritingCreateFail) { const base::FilePath kDrivePath("/drive/file.txt"); EXPECT_CALL(*mock_file_system_, CreateFile(kDrivePath, false, _)) - .WillOnce(MockCreateFile(DRIVE_FILE_ERROR_ACCESS_DENIED)); + .WillOnce(MockCreateFile(FILE_ERROR_ACCESS_DENIED)); EXPECT_CALL(*mock_file_system_, OpenFile(_, _)).Times(0); EXPECT_CALL(*mock_file_system_, CloseFile(_, _)).Times(0); FileWriteHelper file_write_helper(mock_file_system_.get()); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath path; file_write_helper.PrepareWritableFileAndRun( kDrivePath, base::Bind(&RecordOpenFileCallbackArguments, &error, &path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_ACCESS_DENIED, error); + EXPECT_EQ(FILE_ERROR_ACCESS_DENIED, error); EXPECT_EQ(base::FilePath(), path); } @@ -105,19 +105,19 @@ TEST_F(FileWriteHelperTest, PrepareFileForWritingOpenFail) { const base::FilePath kDrivePath("/drive/file.txt"); EXPECT_CALL(*mock_file_system_, CreateFile(kDrivePath, false, _)) - .WillOnce(MockCreateFile(DRIVE_FILE_OK)); + .WillOnce(MockCreateFile(FILE_ERROR_OK)); EXPECT_CALL(*mock_file_system_, OpenFile(kDrivePath, _)) - .WillOnce(MockOpenFile(DRIVE_FILE_ERROR_IN_USE, base::FilePath())); + .WillOnce(MockOpenFile(FILE_ERROR_IN_USE, base::FilePath())); EXPECT_CALL(*mock_file_system_, CloseFile(_, _)).Times(0); FileWriteHelper file_write_helper(mock_file_system_.get()); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath path; file_write_helper.PrepareWritableFileAndRun( kDrivePath, base::Bind(&RecordOpenFileCallbackArguments, &error, &path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_IN_USE, error); + EXPECT_EQ(FILE_ERROR_IN_USE, error); EXPECT_EQ(base::FilePath(), path); } diff --git a/chrome/browser/chromeos/drive/job_list_interface.h b/chrome/browser/chromeos/drive/job_list_interface.h index 186e1c5..e93ded1 100644 --- a/chrome/browser/chromeos/drive/job_list_interface.h +++ b/chrome/browser/chromeos/drive/job_list_interface.h @@ -7,7 +7,7 @@ #include "base/basictypes.h" #include "base/files/file_path.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" namespace drive { @@ -88,10 +88,10 @@ class JobListObserver { virtual void OnJobAdded(const JobInfo& job_info) {} // Called when a job id finished. - // |error| is DRIVE_FILE_OK when the job successfully finished, and a value + // |error| is FILE_ERROR_OK when the job successfully finished, and a value // telling the reason of failure when the jobs is failed. virtual void OnJobDone(const JobInfo& job_info, - DriveFileError error) {} + FileError error) {} // Called when a job status is updated. virtual void OnJobUpdated(const JobInfo& job_info) {} diff --git a/chrome/browser/chromeos/drive/search_metadata.cc b/chrome/browser/chromeos/drive/search_metadata.cc index 39dc4f5..d1269c1 100644 --- a/chrome/browser/chromeos/drive/search_metadata.cc +++ b/chrome/browser/chromeos/drive/search_metadata.cc @@ -157,7 +157,7 @@ class SearchMetadataHelper { // Prepares results by popping candidates one by one. void PrepareResults() { if (result_candidates_.empty()) { - Finish(DRIVE_FILE_OK); + Finish(FILE_ERROR_OK); return; } resource_metadata_->GetEntryInfoByResourceId( @@ -167,10 +167,10 @@ class SearchMetadataHelper { } // Implements PrepareResults(). - void ContinuePrepareResults(DriveFileError error, + void ContinuePrepareResults(FileError error, const base::FilePath& path, scoped_ptr<DriveEntryProto> unused_entry) { - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { Finish(error); return; } @@ -181,12 +181,12 @@ class SearchMetadataHelper { } // Sends the result to the callback and deletes this instance. - void Finish(DriveFileError error) { + void Finish(FileError error) { // Reverse the order here because |result_candidates_| puts the most // uninterested candidate at the top. std::reverse(results_->begin(), results_->end()); - if (error != DRIVE_FILE_OK) + if (error != FILE_ERROR_OK) results_.reset(); callback_.Run(error, results_.Pass()); delete this; diff --git a/chrome/browser/chromeos/drive/search_metadata_unittest.cc b/chrome/browser/chromeos/drive/search_metadata_unittest.cc index f00e189..10dab6f 100644 --- a/chrome/browser/chromeos/drive/search_metadata_unittest.cc +++ b/chrome/browser/chromeos/drive/search_metadata_unittest.cc @@ -38,11 +38,11 @@ class SearchMetadataTest : public testing::Test { temp_dir_.path(), blocking_task_runner_)); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; resource_metadata_->Initialize( google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); AddEntriesToMetadata(); } @@ -105,14 +105,14 @@ class SearchMetadataTest : public testing::Test { } void AddEntryToMetadata(const DriveEntryProto& entry) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; base::FilePath drive_path; resource_metadata_->AddEntry( entry, google_apis::test_util::CreateCopyResultCallback(&error, &drive_path)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); } MessageLoopForUI message_loop_; @@ -124,7 +124,7 @@ class SearchMetadataTest : public testing::Test { }; TEST_F(SearchMetadataTest, SearchMetadata_ZeroMatches) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; SearchMetadata(resource_metadata_.get(), @@ -134,12 +134,12 @@ TEST_F(SearchMetadataTest, SearchMetadata_ZeroMatches) { google_apis::test_util::CreateCopyResultCallback( &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(0U, result->size()); } TEST_F(SearchMetadataTest, SearchMetadata_RegularFile) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; SearchMetadata(resource_metadata_.get(), @@ -149,7 +149,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_RegularFile) { google_apis::test_util::CreateCopyResultCallback( &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(1U, result->size()); EXPECT_EQ("drive/root/Directory 1/SubDirectory File 1.txt", result->at(0).path.AsUTF8Unsafe()); @@ -158,7 +158,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_RegularFile) { // This test checks if |FindAndHighlight| does case-insensitive search. // Tricker test cases for |FindAndHighlight| can be found below. TEST_F(SearchMetadataTest, SearchMetadata_CaseInsensitiveSearch) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; // The query is all in lower case. @@ -169,14 +169,14 @@ TEST_F(SearchMetadataTest, SearchMetadata_CaseInsensitiveSearch) { google_apis::test_util::CreateCopyResultCallback( &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(1U, result->size()); EXPECT_EQ("drive/root/Directory 1/SubDirectory File 1.txt", result->at(0).path.AsUTF8Unsafe()); } TEST_F(SearchMetadataTest, SearchMetadata_RegularFiles) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; SearchMetadata(resource_metadata_.get(), @@ -186,7 +186,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_RegularFiles) { google_apis::test_util::CreateCopyResultCallback( &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(2U, result->size()); // The results should be sorted by the last accessed time in descending order. @@ -201,7 +201,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_RegularFiles) { } TEST_F(SearchMetadataTest, SearchMetadata_AtMostOneFile) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; // There are two files matching "SubDir" but only one file should be @@ -213,14 +213,14 @@ TEST_F(SearchMetadataTest, SearchMetadata_AtMostOneFile) { google_apis::test_util::CreateCopyResultCallback( &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(1U, result->size()); EXPECT_EQ("drive/root/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt", result->at(0).path.AsUTF8Unsafe()); } TEST_F(SearchMetadataTest, SearchMetadata_Directory) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; SearchMetadata(resource_metadata_.get(), @@ -230,13 +230,13 @@ TEST_F(SearchMetadataTest, SearchMetadata_Directory) { google_apis::test_util::CreateCopyResultCallback( &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(1U, result->size()); EXPECT_EQ("drive/root/Directory 1", result->at(0).path.AsUTF8Unsafe()); } TEST_F(SearchMetadataTest, SearchMetadata_HostedDocument) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; SearchMetadata(resource_metadata_.get(), @@ -246,7 +246,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_HostedDocument) { google_apis::test_util::CreateCopyResultCallback( &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(1U, result->size()); EXPECT_EQ("drive/root/Document 1 excludeDir-test.gdoc", @@ -254,7 +254,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_HostedDocument) { } TEST_F(SearchMetadataTest, SearchMetadata_ExcludeHostedDocument) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; SearchMetadata(resource_metadata_.get(), @@ -264,12 +264,12 @@ TEST_F(SearchMetadataTest, SearchMetadata_ExcludeHostedDocument) { google_apis::test_util::CreateCopyResultCallback( &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(0U, result->size()); } TEST_F(SearchMetadataTest, SearchMetadata_SharedWithMe) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; SearchMetadata(resource_metadata_.get(), @@ -279,14 +279,14 @@ TEST_F(SearchMetadataTest, SearchMetadata_SharedWithMe) { google_apis::test_util::CreateCopyResultCallback( &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(1U, result->size()); EXPECT_EQ("drive/root/Directory 1/Shared To The Account Owner.txt", result->at(0).path.AsUTF8Unsafe()); } TEST_F(SearchMetadataTest, SearchMetadata_FileAndDirectory) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; SearchMetadata(resource_metadata_.get(), @@ -297,7 +297,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_FileAndDirectory) { &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(2U, result->size()); EXPECT_EQ("drive/root/Document 1 excludeDir-test.gdoc", @@ -307,7 +307,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_FileAndDirectory) { } TEST_F(SearchMetadataTest, SearchMetadata_ExcludeDirectory) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; SearchMetadata(resource_metadata_.get(), @@ -318,7 +318,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_ExcludeDirectory) { &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_EQ(1U, result->size()); EXPECT_EQ("drive/root/Document 1 excludeDir-test.gdoc", @@ -329,7 +329,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_ExcludeDirectory) { TEST_F(SearchMetadataTest, SearchMetadata_ExcludeSpecialDirectories) { const char* kQueries[] = { "drive", "root", "other" }; for (size_t i = 0; i < arraysize(kQueries); ++i) { - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; scoped_ptr<MetadataSearchResultVector> result; const std::string query = kQueries[i]; @@ -341,7 +341,7 @@ TEST_F(SearchMetadataTest, SearchMetadata_ExcludeSpecialDirectories) { &error, &result)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); ASSERT_TRUE(result->empty()) << ": " << query << " should not match"; } } diff --git a/chrome/browser/chromeos/drive/stale_cache_files_remover.cc b/chrome/browser/chromeos/drive/stale_cache_files_remover.cc index 1029644..0c1189b 100644 --- a/chrome/browser/chromeos/drive/stale_cache_files_remover.cc +++ b/chrome/browser/chromeos/drive/stale_cache_files_remover.cc @@ -18,8 +18,8 @@ namespace { // Emits the log when the remove failed. void EmitErrorLog(const std::string& resource_id, - DriveFileError error) { - if (error != DRIVE_FILE_OK) { + FileError error) { + if (error != FILE_ERROR_OK) { LOG(WARNING) << "Failed to remove a stale cache file. resource_id:" << resource_id; } @@ -66,13 +66,13 @@ void StaleCacheFilesRemover::GetEntryInfoAndRemoveCacheIfNecessary( void StaleCacheFilesRemover::RemoveCacheIfNecessary( const std::string& resource_id, const std::string& cache_md5, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // The entry is not found in the file system. - if (error != DRIVE_FILE_OK) { + if (error != FILE_ERROR_OK) { 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 9c6a31e..c203bd21 100644 --- a/chrome/browser/chromeos/drive/stale_cache_files_remover.h +++ b/chrome/browser/chromeos/drive/stale_cache_files_remover.h @@ -45,7 +45,7 @@ class StaleCacheFilesRemover : public DriveFileSystemObserver { void RemoveCacheIfNecessary( const std::string& resource_id, const std::string& cache_md5, - DriveFileError error, + FileError error, const base::FilePath& drive_file_path, scoped_ptr<DriveEntryProto> entry_proto); 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 ef697c8..5a8e345 100644 --- a/chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc +++ b/chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc @@ -107,11 +107,11 @@ class StaleCacheFilesRemoverTest : public testing::Test { cache_->RequestInitializeForTesting(); google_apis::test_util::RunBlockingPoolTask(); - DriveFileError error = DRIVE_FILE_ERROR_FAILED; + FileError error = FILE_ERROR_FAILED; resource_metadata_->Initialize( google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - ASSERT_EQ(DRIVE_FILE_OK, error); + ASSERT_EQ(FILE_ERROR_OK, error); stale_cache_files_remover_.reset(new StaleCacheFilesRemover(file_system_, cache_.get())); @@ -158,11 +158,11 @@ TEST_F(StaleCacheFilesRemoverTest, RemoveStaleCacheFiles) { fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); // Create a stale cache file. - DriveFileError error = DRIVE_FILE_OK; + FileError error = FILE_ERROR_OK; cache_->Store(resource_id, md5, dummy_file, DriveCache::FILE_OPERATION_COPY, google_apis::test_util::CreateCopyResultCallback(&error)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_OK, error); + EXPECT_EQ(FILE_ERROR_OK, error); // Verify that the cache entry exists. bool success = false; @@ -180,7 +180,7 @@ TEST_F(StaleCacheFilesRemoverTest, RemoveStaleCacheFiles) { google_apis::test_util::CreateCopyResultCallback( &error, &unused, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); + EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); EXPECT_FALSE(entry_proto.get()); // Load a root feed again to kick the StaleCacheFilesRemover. 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 74602ba..909b41a 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 @@ -655,7 +655,7 @@ void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( SetResult(dict); dict->SetString("name", name); dict->SetString("path", root_path.spec()); - dict->SetInteger("error", drive::DRIVE_FILE_OK); + dict->SetInteger("error", drive::FILE_ERROR_OK); SendResponse(true); } @@ -1296,7 +1296,7 @@ void FileBrowserFunction::GetSelectedFileInfoInternal( // |system_service| is NULL if Drive is disabled. if (!system_service) { ContinueGetSelectedFileInfo(params.Pass(), - drive::DRIVE_FILE_ERROR_FAILED, + drive::FILE_ERROR_FAILED, base::FilePath(), std::string(), drive::REGULAR_FILE); @@ -1318,14 +1318,14 @@ void FileBrowserFunction::GetSelectedFileInfoInternal( void FileBrowserFunction::ContinueGetSelectedFileInfo( scoped_ptr<GetSelectedFileInfoParams> params, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& local_file_path, const std::string& mime_type, drive::DriveFileType file_type) { const int index = params->selected_files.size(); const base::FilePath& file_path = params->file_paths[index]; base::FilePath local_path; - if (error == drive::DRIVE_FILE_OK) { + if (error == drive::FILE_ERROR_OK) { local_path = local_file_path; } else { DLOG(ERROR) << "Failed to get " << file_path.value() @@ -1531,7 +1531,7 @@ bool AddMountFunction::RunImpl() { this, mount_type_str, display_name)); } else { OnMountedStateSet(mount_type_str, display_name, - drive::DRIVE_FILE_OK, path); + drive::FILE_ERROR_OK, path); } break; } @@ -1543,7 +1543,7 @@ bool AddMountFunction::RunImpl() { void AddMountFunction::MarkCacheAsMounted( const std::string& mount_type, const base::FilePath::StringType& display_name, - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::DriveEntryProto> entry_proto) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -1552,7 +1552,7 @@ void AddMountFunction::MarkCacheAsMounted( drive::DriveCache* cache = system_service ? system_service->cache() : NULL; if (!cache || - error != drive::DRIVE_FILE_OK || + error != drive::FILE_ERROR_OK || !entry_proto || !entry_proto->has_file_specific_info()) { SendResponse(false); @@ -1567,11 +1567,11 @@ void AddMountFunction::MarkCacheAsMounted( void AddMountFunction::OnMountedStateSet( const std::string& mount_type, const base::FilePath::StringType& file_name, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != drive::DRIVE_FILE_OK) { + if (error != drive::FILE_ERROR_OK) { SendResponse(false); return; } @@ -1748,10 +1748,10 @@ bool GetSizeStatsFunction::RunImpl() { } void GetSizeStatsFunction::GetDriveAvailableSpaceCallback( - drive::DriveFileError error, + drive::FileError error, int64 bytes_total, int64 bytes_used) { - if (error == drive::DRIVE_FILE_OK) { + if (error == drive::FILE_ERROR_OK) { int64 bytes_remaining = bytes_total - bytes_used; const size_t total_size_kb = static_cast<size_t>(bytes_total/1024); const size_t remaining_size_kb = static_cast<size_t>(bytes_remaining/1024); @@ -2347,7 +2347,7 @@ void GetDriveFilePropertiesFunction::DoOperation( // Nothing to do here so simply call OnOperationComplete(). OnOperationComplete(file_path, property_dict, - drive::DRIVE_FILE_OK, + drive::FILE_ERROR_OK, entry_proto.Pass()); } @@ -2405,7 +2405,7 @@ void GetDriveFilePropertiesFunction::GetNextFileProperties() { if (!system_service) { OnOperationComplete(file_path, property_dict, - drive::DRIVE_FILE_ERROR_FAILED, + drive::FILE_ERROR_FAILED, scoped_ptr<drive::DriveEntryProto>()); return; } @@ -2429,14 +2429,14 @@ void GetDriveFilePropertiesFunction::CompleteGetFileProperties() { void GetDriveFilePropertiesFunction::OnGetFileInfo( const base::FilePath& file_path, base::DictionaryValue* property_dict, - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::DriveEntryProto> entry_proto) { DCHECK(property_dict); if (entry_proto.get() && !entry_proto->has_file_specific_info()) - error = drive::DRIVE_FILE_ERROR_NOT_FOUND; + error = drive::FILE_ERROR_NOT_FOUND; - if (error == drive::DRIVE_FILE_OK) + if (error == drive::FILE_ERROR_OK) DoOperation(file_path, property_dict, entry_proto.Pass()); else OnOperationComplete(file_path, property_dict, error, entry_proto.Pass()); @@ -2445,12 +2445,12 @@ void GetDriveFilePropertiesFunction::OnGetFileInfo( void GetDriveFilePropertiesFunction::OnOperationComplete( const base::FilePath& file_path, base::DictionaryValue* property_dict, - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::DriveEntryProto> entry_proto) { if (entry_proto.get() && !entry_proto->has_file_specific_info()) - error = drive::DRIVE_FILE_ERROR_NOT_FOUND; + error = drive::FILE_ERROR_NOT_FOUND; - if (error != drive::DRIVE_FILE_OK) { + if (error != drive::FILE_ERROR_OK) { property_dict->SetInteger("errorCode", error); CompleteGetFileProperties(); return; @@ -2572,13 +2572,13 @@ bool PinDriveFileFunction::RunImpl() { return true; } -void PinDriveFileFunction::OnPinStateSet(drive::DriveFileError error) { +void PinDriveFileFunction::OnPinStateSet(drive::FileError error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error == drive::DRIVE_FILE_OK) { + if (error == drive::FILE_ERROR_OK) { SendResponse(true); } else { - error_ = drive::DriveFileErrorToString(error); + error_ = drive::FileErrorToString(error); SendResponse(false); } } @@ -2662,7 +2662,7 @@ void GetDriveFilesFunction::GetFileOrSendResponse() { drive::DriveSystemServiceFactory::GetForProfile(profile_); // |system_service| is NULL if Drive is disabled. if (!system_service) { - OnFileReady(drive::DRIVE_FILE_ERROR_FAILED, + OnFileReady(drive::FILE_ERROR_FAILED, drive_path, "", // mime_type drive::REGULAR_FILE); @@ -2676,13 +2676,13 @@ void GetDriveFilesFunction::GetFileOrSendResponse() { void GetDriveFilesFunction::OnFileReady( - drive::DriveFileError error, + drive::FileError error, const base::FilePath& local_path, const std::string& unused_mime_type, drive::DriveFileType file_type) { base::FilePath drive_path = remaining_drive_paths_.front(); - if (error == drive::DRIVE_FILE_OK) { + if (error == drive::FILE_ERROR_OK) { local_paths_->Append(new base::StringValue(local_path.value())); DVLOG(1) << "Got " << drive_path.value() << " as " << local_path.value(); @@ -2828,13 +2828,13 @@ bool TransferFileFunction::RunImpl() { return true; } -void TransferFileFunction::OnTransferCompleted(drive::DriveFileError error) { - if (error == drive::DRIVE_FILE_OK) { +void TransferFileFunction::OnTransferCompleted(drive::FileError error) { + if (error == drive::FILE_ERROR_OK) { SendResponse(true); } else { error_ = base::StringPrintf("%d", static_cast<int>( fileapi::PlatformFileErrorToWebFileError( - drive::DriveFileErrorToPlatformError(error)))); + drive::FileErrorToPlatformError(error)))); SendResponse(false); } } @@ -2945,10 +2945,10 @@ void SearchDriveFunction::OnFileSystemOpened( } void SearchDriveFunction::OnSearch( - drive::DriveFileError error, + drive::FileError error, const GURL& next_feed, scoped_ptr<std::vector<drive::SearchResultInfo> > results) { - if (error != drive::DRIVE_FILE_OK) { + if (error != drive::FILE_ERROR_OK) { SendResponse(false); return; } @@ -3039,9 +3039,9 @@ void SearchDriveMetadataFunction::OnFileSystemOpened( } void SearchDriveMetadataFunction::OnSearchMetadata( - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::MetadataSearchResultVector> results) { - if (error != drive::DRIVE_FILE_OK) { + if (error != drive::FILE_ERROR_OK) { SendResponse(false); return; } 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 40fcc7d..bb2bf4d 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 @@ -14,7 +14,7 @@ #include "base/platform_file.h" #include "base/prefs/pref_service.h" #include "chrome/browser/chromeos/drive/drive_cache.h" -#include "chrome/browser/chromeos/drive/drive_file_error.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/search_metadata.h" #include "chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.h" #include "chrome/browser/chromeos/extensions/file_manager/zip_file_creator.h" @@ -287,7 +287,7 @@ class FileBrowserFunction : public AsyncExtensionFunction { // Used to implement GetSelectedFileInfo(). void ContinueGetSelectedFileInfo(scoped_ptr<GetSelectedFileInfoParams> params, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& local_file_path, const std::string& mime_type, drive::DriveFileType file_type); @@ -379,13 +379,13 @@ class AddMountFunction : public FileBrowserFunction { // Calls DriveCache::MarkCacheAsMounted. void MarkCacheAsMounted(const std::string& mount_type, const base::FilePath::StringType& display_name, - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::DriveEntryProto> entry_proto); // A callback method to handle the result of MarkCacheAsMounted. void OnMountedStateSet(const std::string& mount_type, const base::FilePath::StringType& file_name, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& file_path); }; @@ -466,7 +466,7 @@ class GetSizeStatsFunction : public FileBrowserFunction { virtual bool RunImpl() OVERRIDE; private: - void GetDriveAvailableSpaceCallback(drive::DriveFileError error, + void GetDriveAvailableSpaceCallback(drive::FileError error, int64 bytes_total, int64 bytes_used); @@ -507,7 +507,7 @@ class FileDialogStringsFunction : public SyncExtensionFunction { // Retrieve property information for multiple files, returning a list of the // same length as the input list of file URLs. If a particular file has an // error, then return a dictionary with the key "error" set to the error number -// (drive::DriveFileError) for that entry in the returned list. +// (drive::FileError) for that entry in the returned list. class GetDriveFilePropertiesFunction : public FileBrowserFunction { public: DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveFileProperties", @@ -528,7 +528,7 @@ class GetDriveFilePropertiesFunction : public FileBrowserFunction { void OnOperationComplete(const base::FilePath& file_path, base::DictionaryValue* properties, - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::DriveEntryProto> entry_proto); // AsyncExtensionFunction overrides. @@ -540,7 +540,7 @@ class GetDriveFilePropertiesFunction : public FileBrowserFunction { private: void OnGetFileInfo(const base::FilePath& file_path, base::DictionaryValue* property_dict, - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::DriveEntryProto> entry_proto); void CacheStateReceived(base::DictionaryValue* property_dict, @@ -568,7 +568,7 @@ class PinDriveFileFunction : public FileBrowserFunction { private: // Callback for RunImpl(). - void OnPinStateSet(drive::DriveFileError error); + void OnPinStateSet(drive::FileError error); }; // Get file locations for the given list of file URLs. Returns a list of @@ -616,7 +616,7 @@ class GetDriveFilesFunction : public FileBrowserFunction { // Called by DriveFileSystem::GetFile(). Pops the file from // |remaining_drive_paths_|, and calls GetFileOrSendResponse(). - void OnFileReady(drive::DriveFileError error, + void OnFileReady(drive::FileError error, const base::FilePath& local_path, const std::string& unused_mime_type, drive::DriveFileType file_type); @@ -674,7 +674,7 @@ class TransferFileFunction : public FileBrowserFunction { private: // Helper callback for handling response from DriveFileSystem::TransferFile(). - void OnTransferCompleted(drive::DriveFileError error); + void OnTransferCompleted(drive::FileError error); }; // Read setting value. @@ -719,7 +719,7 @@ class SearchDriveFunction : public AsyncExtensionFunction { const std::string& file_system_name, const GURL& file_system_url); // Callback for google_apis::SearchAsync called after file system is opened. - void OnSearch(drive::DriveFileError error, + void OnSearch(drive::FileError error, const GURL& next_feed, scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths); @@ -753,7 +753,7 @@ class SearchDriveMetadataFunction : public AsyncExtensionFunction { const GURL& file_system_url); // Callback for LocalSearch(). void OnSearchMetadata( - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::MetadataSearchResultVector> results); // Query for which the search is being performed. 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 b049b8d..7370175 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc @@ -587,14 +587,14 @@ bool FileManagerBrowserDriveTest::PathExists(const base::FilePath& file_path) { DCHECK(system_service_); DCHECK(system_service_->file_system()); - drive::DriveFileError error = drive::DRIVE_FILE_ERROR_FAILED; + drive::FileError error = drive::FILE_ERROR_FAILED; scoped_ptr<drive::DriveEntryProto> entry_proto; system_service_->file_system()->GetEntryInfoByPath( file_path, google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - return error == drive::DRIVE_FILE_OK; + return error == drive::FILE_ERROR_OK; } bool FileManagerBrowserDriveTest::WaitUntilFilePresentWithSize( @@ -632,14 +632,14 @@ bool FileManagerBrowserDriveTest::FileIsPresentWithSize( DCHECK(system_service_); DCHECK(system_service_->file_system()); - drive::DriveFileError error = drive::DRIVE_FILE_ERROR_FAILED; + drive::FileError error = drive::FILE_ERROR_FAILED; scoped_ptr<drive::DriveEntryProto> entry_proto; system_service_->file_system()->GetEntryInfoByPath( file_path, google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - return (error == drive::DRIVE_FILE_OK && + return (error == drive::FILE_ERROR_OK && entry_proto->file_info().size() == file_size); } @@ -648,14 +648,14 @@ bool FileManagerBrowserDriveTest::FileIsNotPresent( DCHECK(system_service_); DCHECK(system_service_->file_system()); - drive::DriveFileError error = drive::DRIVE_FILE_ERROR_FAILED; + drive::FileError error = drive::FILE_ERROR_FAILED; scoped_ptr<drive::DriveEntryProto> entry_proto; system_service_->file_system()->GetEntryInfoByPath( file_path, google_apis::test_util::CreateCopyResultCallback(&error, &entry_proto)); google_apis::test_util::RunBlockingPoolTask(); - return error == drive::DRIVE_FILE_ERROR_NOT_FOUND; + return error == drive::FILE_ERROR_NOT_FOUND; } void FileManagerBrowserDriveTest::CheckForUpdates() { diff --git a/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.cc b/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.cc index 18b8725..343b5d3 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.cc @@ -64,8 +64,8 @@ DictionaryValue* DiskToDictionaryValue( } // Used as a callback for DriveCache::MarkAsUnmounted(). -void OnMarkAsUnmounted(drive::DriveFileError error) { - LOG_IF(ERROR, error != drive::DRIVE_FILE_OK) +void OnMarkAsUnmounted(drive::FileError error) { + LOG_IF(ERROR, error != drive::FILE_ERROR_OK) << "Failed to unmount: " << error; } diff --git a/chrome/browser/chromeos/extensions/file_manager/file_manager_util.cc b/chrome/browser/chromeos/extensions/file_manager/file_manager_util.cc index aabc2f4..9f01fbd 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_manager_util.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_util.cc @@ -288,11 +288,11 @@ void InstallCRX(Browser* browser, const base::FilePath& path) { // Called when a crx file on Drive was downloaded. void OnCRXDownloadCallback(Browser* browser, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& file, const std::string& unused_mime_type, drive::DriveFileType file_type) { - if (error != drive::DRIVE_FILE_OK || file_type != drive::REGULAR_FILE) + if (error != drive::FILE_ERROR_OK || file_type != drive::REGULAR_FILE) return; InstallCRX(browser, file); } diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc index 9efb950..d77875f 100644 --- a/chrome/browser/extensions/api/file_system/file_system_api.cc +++ b/chrome/browser/extensions/api/file_system/file_system_api.cc @@ -207,10 +207,10 @@ void CheckLocalWritableFile(const base::FilePath& path, #if defined(OS_CHROMEOS) void CheckRemoteWritableFile(const base::Closure& on_success, const base::Closure& on_failure, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& path) { content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, - error == drive::DRIVE_FILE_OK ? on_success : on_failure); + error == drive::FILE_ERROR_OK ? on_success : on_failure); } #endif diff --git a/chrome/browser/extensions/platform_app_launcher.cc b/chrome/browser/extensions/platform_app_launcher.cc index 8a072ae..6ee4b01 100644 --- a/chrome/browser/extensions/platform_app_launcher.cc +++ b/chrome/browser/extensions/platform_app_launcher.cc @@ -36,10 +36,10 @@ #include "webkit/fileapi/isolated_context.h" #if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/drive/drive_file_error.h" #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" #include "chrome/browser/chromeos/drive/drive_file_system_util.h" #include "chrome/browser/chromeos/drive/drive_system_service.h" +#include "chrome/browser/chromeos/drive/file_errors.h" #endif #if defined(OS_WIN) @@ -181,13 +181,13 @@ class PlatformAppPathLauncher base::Bind(&PlatformAppPathLauncher::OnGotDriveFile, this)); } - void OnGotDriveFile(drive::DriveFileError error, + void OnGotDriveFile(drive::FileError error, const base::FilePath& file_path, const std::string& mime_type, drive::DriveFileType file_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (error != drive::DRIVE_FILE_OK || file_type != drive::REGULAR_FILE) { + if (error != drive::FILE_ERROR_OK || file_type != drive::REGULAR_FILE) { LaunchWithNoLaunchData(); return; } diff --git a/chrome/browser/ui/ash/screenshot_taker.cc b/chrome/browser/ui/ash/screenshot_taker.cc index 5d40901..3875636 100644 --- a/chrome/browser/ui/ash/screenshot_taker.cc +++ b/chrome/browser/ui/ash/screenshot_taker.cc @@ -136,12 +136,12 @@ void SaveScreenshot(const ShowNotificationCallback& callback, void SaveScreenshotToDrive(const ShowNotificationCallback& callback, const base::FilePath& screenshot_path, scoped_refptr<base::RefCountedBytes> png_data, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& local_path) { // |screenshot_path| is used in the notification callback. // |local_path| is a temporary file in a hidden cache directory used for // internal work generated by drive::util::PrepareWritableFileAndRun. - if (error != drive::DRIVE_FILE_OK) { + if (error != drive::FILE_ERROR_OK) { LOG(ERROR) << "Failed to write screenshot image to Google Drive: " << error; content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, @@ -158,11 +158,11 @@ void EnsureDirectoryExistsCallback( Profile* profile, const base::FilePath& screenshot_path, scoped_refptr<base::RefCountedBytes> png_data, - drive::DriveFileError error) { - // It is okay to fail with DRIVE_FILE_ERROR_EXISTS since anyway the directory + drive::FileError error) { + // It is okay to fail with FILE_ERROR_EXISTS since anyway the directory // of the target file exists. - if (error == drive::DRIVE_FILE_OK || - error == drive::DRIVE_FILE_ERROR_EXISTS) { + if (error == drive::FILE_ERROR_OK || + error == drive::FILE_ERROR_EXISTS) { drive::util::PrepareWritableFileAndRun( profile, screenshot_path, diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc index bd9b04b..6b4b10b 100644 --- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc +++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc @@ -224,12 +224,12 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { // Called when GetEntryInfoByPath() is complete. void OnGetEntryInfoByPath(const base::FilePath& path, - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::DriveEntryProto> entry); // Called when ReadDirectoryByPath() is complete. void OnReadDirectoryByPath(const base::FilePath& parent_path, - drive::DriveFileError error, + drive::FileError error, bool hide_hosted_documents, scoped_ptr<drive::DriveEntryProtoVector> entries); @@ -527,7 +527,7 @@ void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate( metadata.last_update_check_time)); delta_update_status.SetString( "last-update-check-error", - drive::DriveFileErrorToString(metadata.last_update_check_error)); + drive::FileErrorToString(metadata.last_update_check_error)); web_ui()->CallJavascriptFunction("updateDeltaUpdateStatus", delta_update_status); @@ -663,9 +663,9 @@ void DriveInternalsWebUIHandler::OnGetGCacheContents( void DriveInternalsWebUIHandler::OnGetEntryInfoByPath( const base::FilePath& path, - drive::DriveFileError error, + drive::FileError error, scoped_ptr<drive::DriveEntryProto> entry) { - if (error == drive::DRIVE_FILE_OK) { + if (error == drive::FILE_ERROR_OK) { DCHECK(entry.get()); const base::StringValue value(FormatEntry(path, *entry) + "\n"); web_ui()->CallJavascriptFunction("updateFileSystemContents", value); @@ -674,10 +674,10 @@ void DriveInternalsWebUIHandler::OnGetEntryInfoByPath( void DriveInternalsWebUIHandler::OnReadDirectoryByPath( const base::FilePath& parent_path, - drive::DriveFileError error, + drive::FileError error, bool hide_hosted_documents, scoped_ptr<drive::DriveEntryProtoVector> entries) { - if (error == drive::DRIVE_FILE_OK) { + if (error == drive::FILE_ERROR_OK) { DCHECK(entries.get()); std::string file_system_as_text; diff --git a/chrome/browser/ui/webui/feedback_ui.cc b/chrome/browser/ui/webui/feedback_ui.cc index b28e065..e32ac94 100644 --- a/chrome/browser/ui/webui/feedback_ui.cc +++ b/chrome/browser/ui/webui/feedback_ui.cc @@ -115,10 +115,10 @@ bool ScreenshotDriveTimestampComp(const drive::DriveEntryProto& entry1, void ReadDirectoryCallback(size_t max_saved, std::vector<std::string>* saved_screenshots, base::Closure callback, - drive::DriveFileError error, + drive::FileError error, bool hide_hosted_documents, scoped_ptr<drive::DriveEntryProtoVector> entries) { - if (error != drive::DRIVE_FILE_OK) { + if (error != drive::FILE_ERROR_OK) { callback.Run(); return; } diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index 16cb569..d4ecea5 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc @@ -226,9 +226,9 @@ void PrintToPdfCallback(Metafile* metafile, const base::FilePath& path) { #if defined(OS_CHROMEOS) void PrintToPdfCallbackWithCheck(Metafile* metafile, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& path) { - if (error != drive::DRIVE_FILE_OK) { + if (error != drive::FILE_ERROR_OK) { LOG(ERROR) << "Save to pdf failed to write: " << error; } else { metafile->SaveTo(path); diff --git a/chrome/browser/ui/webui/screenshot_source.cc b/chrome/browser/ui/webui/screenshot_source.cc index dac5835..7a8d1de 100644 --- a/chrome/browser/ui/webui/screenshot_source.cc +++ b/chrome/browser/ui/webui/screenshot_source.cc @@ -243,11 +243,11 @@ void ScreenshotSource::SendSavedScreenshot( void ScreenshotSource::GetSavedScreenshotCallback( const std::string& screenshot_path, const content::URLDataSource::GotDataCallback& callback, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& file, const std::string& unused_mime_type, drive::DriveFileType file_type) { - if (error != drive::DRIVE_FILE_OK || file_type != drive::REGULAR_FILE) { + if (error != drive::FILE_ERROR_OK || file_type != drive::REGULAR_FILE) { ScreenshotDataPtr read_bytes(new ScreenshotData); CacheAndSendScreenshot(screenshot_path, callback, read_bytes); return; diff --git a/chrome/browser/ui/webui/screenshot_source.h b/chrome/browser/ui/webui/screenshot_source.h index 50bb3dc..61f35ff 100644 --- a/chrome/browser/ui/webui/screenshot_source.h +++ b/chrome/browser/ui/webui/screenshot_source.h @@ -98,7 +98,7 @@ class ScreenshotSource : public content::URLDataSource { void GetSavedScreenshotCallback( const std::string& screenshot_path, const content::URLDataSource::GotDataCallback& callback, - drive::DriveFileError error, + drive::FileError error, const base::FilePath& file, const std::string& unused_mime_type, drive::DriveFileType file_type); diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi index 3d2b5bc..9b05191 100644 --- a/chrome/chrome_browser_chromeos.gypi +++ b/chrome/chrome_browser_chromeos.gypi @@ -220,8 +220,6 @@ 'browser/chromeos/drive/change_list_loader_observer.h', 'browser/chromeos/drive/change_list_processor.cc', 'browser/chromeos/drive/change_list_processor.h', - 'browser/chromeos/drive/drive_file_error.cc', - 'browser/chromeos/drive/drive_file_error.h', 'browser/chromeos/drive/drive_file_stream_reader.cc', 'browser/chromeos/drive/drive_file_stream_reader.h', 'browser/chromeos/drive/drive_file_system.cc', @@ -256,6 +254,8 @@ 'browser/chromeos/drive/drive_webapps_registry.h', 'browser/chromeos/drive/file_change.cc', 'browser/chromeos/drive/file_change.h', + 'browser/chromeos/drive/file_errors.cc', + 'browser/chromeos/drive/file_errors.h', 'browser/chromeos/drive/file_system/copy_operation.cc', 'browser/chromeos/drive/file_system/copy_operation.h', 'browser/chromeos/drive/file_system/create_directory_operation.cc', |