diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 22:02:03 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 22:02:03 +0000 |
commit | 50db9b0e3d90d4bb5cb59b03072d1370f8daeb87 (patch) | |
tree | c7ee7ddb4c0bf5ee4bc42d80abb41c3201b18bf6 | |
parent | 301ad56533ad5fc64bef1ec98cbfeea45ba515ff (diff) | |
download | chromium_src-50db9b0e3d90d4bb5cb59b03072d1370f8daeb87.zip chromium_src-50db9b0e3d90d4bb5cb59b03072d1370f8daeb87.tar.gz chromium_src-50db9b0e3d90d4bb5cb59b03072d1370f8daeb87.tar.bz2 |
gdata: Make callback parameters mandatory for CloseFile functions
There was a place where CloseFile() is called with a null callback, but
with the caller fixed, it's safe to make the callback parameter mandatory.
Along the way, removed unused |file_path| parameter from
DataFileSystem::OnGetEntryCompleteForCloseFile()
BUG=126634
TEST=out/Release/unit_tests --gtest_filter=GData*
Review URL: https://chromiumcodereview.appspot.com/10834295
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151366 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 29 insertions, 22 deletions
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc index 1df7b7b..acc67f48 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system.cc +++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc @@ -3182,6 +3182,8 @@ void GDataFileSystem::CloseFile(const FilePath& file_path, const FileOperationCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK(!callback.is_null()); + RunTaskOnUIThread(base::Bind(&GDataFileSystem::CloseFileOnUIThread, ui_weak_ptr_, file_path, @@ -3192,6 +3194,7 @@ void GDataFileSystem::CloseFileOnUIThread( const FilePath& file_path, const FileOperationCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(!callback.is_null()); if (open_files_.find(file_path) == open_files_.end()) { // The file is not being opened. @@ -3218,12 +3221,14 @@ void GDataFileSystem::OnGetEntryInfoCompleteForCloseFile( const FileOperationCallback& callback, GDataFileError error, scoped_ptr<GDataEntryProto> entry_proto) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(!callback.is_null()); + if (entry_proto.get() && !entry_proto->has_file_specific_info()) error = GDATA_FILE_ERROR_NOT_FOUND; if (error != GDATA_FILE_OK) { - if (!callback.is_null()) - callback.Run(error); + callback.Run(error); return; } @@ -3246,10 +3251,10 @@ void GDataFileSystem::OnGetCacheFilePathCompleteForCloseFile( const std::string& md5, const FilePath& local_cache_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(!callback.is_null()); if (error != GDATA_FILE_OK) { - if (!callback.is_null()) - callback.Run(error); + callback.Run(error); return; } @@ -3278,10 +3283,10 @@ void GDataFileSystem::OnGetModifiedFileInfoCompleteForCloseFile( bool* get_file_info_result, const FileOperationCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(!callback.is_null()); if (!*get_file_info_result) { - if (!callback.is_null()) - callback.Run(GDATA_FILE_ERROR_NOT_FOUND); + callback.Run(GDATA_FILE_ERROR_NOT_FOUND); return; } @@ -3291,22 +3296,20 @@ void GDataFileSystem::OnGetModifiedFileInfoCompleteForCloseFile( file_path, base::Bind(&GDataFileSystem::OnGetEntryCompleteForCloseFile, ui_weak_ptr_, - file_path, *file_info, callback)); } void GDataFileSystem::OnGetEntryCompleteForCloseFile( - const FilePath& file_path, const base::PlatformFileInfo& file_info, const FileOperationCallback& callback, GDataFileError error, GDataEntry* entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(!callback.is_null()); if (error != GDATA_FILE_OK) { - if (!callback.is_null()) - callback.Run(error); + callback.Run(error); return; } @@ -3314,8 +3317,7 @@ void GDataFileSystem::OnGetEntryCompleteForCloseFile( GDataFile* file = entry->AsGDataFile(); if (!file || file->file_md5().empty() || file->is_hosted_document()) { // No support for opening a directory or hosted document. - if (!callback.is_null()) - callback.Run(GDATA_FILE_ERROR_INVALID_OPERATION); + callback.Run(GDATA_FILE_ERROR_INVALID_OPERATION); return; } DCHECK(!file->resource_id().empty()); @@ -3344,12 +3346,12 @@ void GDataFileSystem::OnGetEntryCompleteForCloseFile( void GDataFileSystem::OnCommitDirtyInCacheCompleteForCloseFile( const FileOperationCallback& callback, GDataFileError error, - const std::string& resource_id, - const std::string& md5) { + const std::string& /* resource_id */, + const std::string& /* md5 */) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(!callback.is_null()); - if (!callback.is_null()) - callback.Run(error); + callback.Run(error); } void GDataFileSystem::OnCloseFileFinished( @@ -3357,6 +3359,7 @@ void GDataFileSystem::OnCloseFileFinished( const FileOperationCallback& callback, GDataFileError result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(!callback.is_null()); // Step 7 of CloseFile. // All the invocation of |callback| from operations initiated from CloseFile @@ -3365,8 +3368,7 @@ void GDataFileSystem::OnCloseFileFinished( open_files_.erase(file_path); // Then invokes the user-supplied callback function. - if (!callback.is_null()) - callback.Run(result); + callback.Run(result); } void GDataFileSystem::CheckLocalModificationAndRun( diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.h b/chrome/browser/chromeos/gdata/gdata_file_system.h index e07dff6..79c8496 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system.h +++ b/chrome/browser/chromeos/gdata/gdata_file_system.h @@ -273,6 +273,7 @@ class GDataFileSystem : public GDataFileSystemInterface, // 5) Modifies GDataEntry using the new PlatformFileInfo. // 6) Commits the modification to the cache system. // 7) Invokes the user-supplied |callback|. + // |callback| must not be null. void OnGetEntryInfoCompleteForCloseFile( const FilePath& file_path, const FileOperationCallback& callback, @@ -291,7 +292,6 @@ class GDataFileSystem : public GDataFileSystemInterface, bool* get_file_info_result, const FileOperationCallback& callback); void OnGetEntryCompleteForCloseFile( - const FilePath& file_path, const base::PlatformFileInfo& file_info, const FileOperationCallback& callback, GDataFileError error, diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_interface.h b/chrome/browser/chromeos/gdata/gdata_file_system_interface.h index 912ea50..59568eb 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system_interface.h +++ b/chrome/browser/chromeos/gdata/gdata_file_system_interface.h @@ -180,6 +180,7 @@ class GDataFileSystemInterface { // which is opened via OpenFile(). It commits the dirty flag on the cache. // // Can be called from UI/IO thread. |callback| is run on the calling thread. + // |callback| must not be null. virtual void CloseFile(const FilePath& file_path, const FileOperationCallback& callback) = 0; diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc b/chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc index a94f261..08d0937 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc +++ b/chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc @@ -126,7 +126,9 @@ void CallSnapshotFileCallback( callback.Run(error, final_file_info, local_path, file_ref); } -void OnClose(const FilePath& local_path, GDataFileError error_code) { +// Emits debug log when GDataFileSystem::CloseFile() is complete. +void EmitDebugLogForCloseFile(const FilePath& local_path, + GDataFileError error_code) { DVLOG(1) << "Closed: " << local_path.AsUTF8Unsafe() << ": " << error_code; } @@ -548,7 +550,8 @@ void GDataFileSystemProxy::NotifyCloseFile(const FileSystemURL& url) { if (!ValidateUrl(url, &file_path)) return; - file_system_->CloseFile(file_path, FileOperationCallback()); + file_system_->CloseFile(file_path, + base::Bind(&EmitDebugLogForCloseFile, file_path)); } void GDataFileSystemProxy::CreateSnapshotFile( @@ -732,7 +735,8 @@ void GDataFileSystemProxy::CloseWritableSnapshotFile( const FilePath& local_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - file_system_->CloseFile(virtual_path, base::Bind(&OnClose, virtual_path)); + file_system_->CloseFile(virtual_path, + base::Bind(&EmitDebugLogForCloseFile, virtual_path)); } } // namespace gdata |