diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-27 18:11:32 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-27 18:11:32 +0000 |
commit | 4271ae64be26d4b9eb003dac5bd7e51328a22baa (patch) | |
tree | 1bb02a86e94c735989c56d469d3b486c3a2ab637 /chrome/browser/chromeos/gdata | |
parent | 572b1e71377bf56ed81cbfb0b59029aaececa94b (diff) | |
download | chromium_src-4271ae64be26d4b9eb003dac5bd7e51328a22baa.zip chromium_src-4271ae64be26d4b9eb003dac5bd7e51328a22baa.tar.gz chromium_src-4271ae64be26d4b9eb003dac5bd7e51328a22baa.tar.bz2 |
Cleanup of screenshot_taker and drive_file_system_util.
According to achuith's comment on https://chromiumcodereview.appspot.com/10958025/,
I fixed the code slightly:
- gdata::util::EnsureDirectoryExists accepts FileOperationCallback rather than base::Closure
- move the callback to screenshot_taker
- cleanup code a little -- not callback.is_null() check but adding it as DCHECK()
- added a little more comments
BUG=None
TEST=compilation succeeds
Review URL: https://chromiumcodereview.appspot.com/10979039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159070 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/gdata')
-rw-r--r-- | chrome/browser/chromeos/gdata/drive_file_system_util.cc | 23 | ||||
-rw-r--r-- | chrome/browser/chromeos/gdata/drive_file_system_util.h | 7 |
2 files changed, 11 insertions, 19 deletions
diff --git a/chrome/browser/chromeos/gdata/drive_file_system_util.cc b/chrome/browser/chromeos/gdata/drive_file_system_util.cc index fa8185f..7c88c26 100644 --- a/chrome/browser/chromeos/gdata/drive_file_system_util.cc +++ b/chrome/browser/chromeos/gdata/drive_file_system_util.cc @@ -15,6 +15,7 @@ #include "base/file_util.h" #include "base/json/json_reader.h" #include "base/logging.h" +#include "base/message_loop_proxy.h" #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/stringprintf.h" @@ -176,19 +177,6 @@ void OnGetEntryInfoForInsertDriveCachePathsPermissions( callback.Run(); } -void EnsureDirectoryExistsCallback(const base::Closure& callback, - DriveFileError error) { - if (error != gdata::DRIVE_FILE_OK && - error != gdata::DRIVE_FILE_ERROR_EXISTS) { - LOG(ERROR) << "Failed to ensure the existence of the specified directory " - << "in Google Drive: " << error; - return; - } - - if (!callback.is_null()) - callback.Run(); -} - } // namespace const FilePath& GetDriveMountPointPath() { @@ -411,9 +399,10 @@ void PrepareWritableFileAndRun(Profile* profile, void EnsureDirectoryExists(Profile* profile, const FilePath& directory, - const base::Closure& callback) { + const FileOperationCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK(!callback.is_null()); if (IsUnderDriveMountPoint(directory)) { DriveFileSystemInterface* file_system = GetDriveFileSystem(profile); DCHECK(file_system); @@ -421,10 +410,10 @@ void EnsureDirectoryExists(Profile* profile, ExtractDrivePath(directory), true /* is_exclusive */, true /* is_recursive */, - base::Bind(&EnsureDirectoryExistsCallback, callback)); + callback); } else { - if (!callback.is_null()) - callback.Run(); + base::MessageLoopProxy::current()->PostTask( + FROM_HERE, base::Bind(callback, DRIVE_FILE_OK)); } } diff --git a/chrome/browser/chromeos/gdata/drive_file_system_util.h b/chrome/browser/chromeos/gdata/drive_file_system_util.h index 358e2e8..eff80bf 100644 --- a/chrome/browser/chromeos/gdata/drive_file_system_util.h +++ b/chrome/browser/chromeos/gdata/drive_file_system_util.h @@ -11,6 +11,7 @@ #include "base/callback_forward.h" #include "base/memory/scoped_ptr.h" +#include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" #include "chrome/browser/google_apis/gdata_errorcode.h" #include "googleurl/src/gurl.h" @@ -117,7 +118,9 @@ 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. +// invoked after making sure that |directory| exists. |callback| should +// interpret error codes of either DRIVE_FILE_OK or DRIVE_FILE_ERROR_EXISTS as +// indicating that |directory| now exists. // // If |directory| is not a Drive path, it won't check the existence and just // runs |callback|. @@ -125,7 +128,7 @@ void PrepareWritableFileAndRun(Profile* profile, // Must be called from UI/IO thread. void EnsureDirectoryExists(Profile* profile, const FilePath& directory, - const base::Closure& callback); + const FileOperationCallback& callback); // Converts GData error code into file platform error code. DriveFileError GDataToDriveFileError(GDataErrorCode status); |