Commit f5b5aa73 authored by satorux@chromium.org's avatar satorux@chromium.org

gdata: Make callback parameters mandatory for TransferFile functions

The public functions TransferFileFromRemoteToLocal() and
TransferFileFromLocalToRemote() are called from file_browser_private_api.cc
with callbacks, hence it's safe to make the callback parameter mandatory.

BUG=126634, 139446
TEST=out/Release/unit_tests --gtest_filter=GData*

Review URL: https://chromiumcodereview.appspot.com/10824240

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150896 0039d316-1c4b-4281-b951-d872f2087c98
parent 248d4db2
......@@ -710,6 +710,7 @@ void GDataFileSystem::TransferFileFromRemoteToLocal(
const FilePath& local_dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
GetFileByPath(remote_src_file_path,
base::Bind(&GDataFileSystem::OnGetFileCompleteForTransferFile,
......@@ -724,6 +725,7 @@ void GDataFileSystem::TransferFileFromLocalToRemote(
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
// Make sure the destination directory exists.
directory_service_->GetEntryInfoByPath(
......@@ -743,22 +745,17 @@ void GDataFileSystem::TransferFileFromLocalToRemoteAfterGetEntryInfo(
GDataFileError error,
scoped_ptr<GDataEntryProto> entry_proto) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
if (error != GDATA_FILE_OK) {
if (!callback.is_null()) {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE, base::Bind(callback, error));
}
callback.Run(error);
return;
}
DCHECK(entry_proto.get());
if (!entry_proto->file_info().is_directory()) {
// The parent of |remote_dest_file_path| is not a directory.
if (!callback.is_null()) {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE, base::Bind(callback, GDATA_FILE_ERROR_NOT_A_DIRECTORY));
}
callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY);
return;
}
......@@ -784,6 +781,7 @@ void GDataFileSystem::TransferFileForResourceId(
std::string* resource_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(resource_id);
DCHECK(!callback.is_null());
if (resource_id->empty()) {
// If |resource_id| is empty, upload the local file as a regular file.
......@@ -1038,11 +1036,10 @@ void GDataFileSystem::OnGetFileCompleteForTransferFile(
const std::string& unused_mime_type,
GDataFileType file_type) {
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;
}
......@@ -1069,6 +1066,7 @@ void GDataFileSystem::CopyDocumentToDirectory(
const FilePath::StringType& new_name,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
documents_service_->CopyDocument(resource_id, new_name,
base::Bind(&GDataFileSystem::OnCopyDocumentCompleted,
......@@ -2468,29 +2466,24 @@ void GDataFileSystem::OnCopyDocumentCompleted(
GDataErrorCode status,
scoped_ptr<base::Value> data) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
GDataFileError error = util::GDataToGDataFileError(status);
if (error != GDATA_FILE_OK) {
if (!callback.is_null())
callback.Run(error);
callback.Run(error);
return;
}
scoped_ptr<DocumentEntry> doc_entry(DocumentEntry::ExtractAndParse(*data));
if (!doc_entry.get()) {
if (!callback.is_null())
callback.Run(GDATA_FILE_ERROR_FAILED);
callback.Run(GDATA_FILE_ERROR_FAILED);
return;
}
GDataEntry* entry = GDataEntry::FromDocumentEntry(
NULL, doc_entry.get(), directory_service_.get());
if (!entry) {
if (!callback.is_null())
callback.Run(GDATA_FILE_ERROR_FAILED);
callback.Run(GDATA_FILE_ERROR_FAILED);
return;
}
......
......@@ -201,6 +201,7 @@ class GDataFileSystem : public GDataFileSystemInterface,
// TransferRegularFile.
//
// Must be called from *UI* thread. |callback| is run on the calling thread.
// |callback| must not be null.
void TransferFileForResourceId(const FilePath& local_file_path,
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback,
......@@ -321,6 +322,7 @@ class GDataFileSystem : public GDataFileSystemInterface,
// |local_dest_file_path|.
//
// Can be called from UI thread. |callback| is run on the calling thread.
// |callback| must not be null.
void OnGetFileCompleteForTransferFile(const FilePath& local_dest_file_path,
const FileOperationCallback& callback,
GDataFileError error,
......@@ -346,6 +348,7 @@ class GDataFileSystem : public GDataFileSystemInterface,
// and names the copied document as |new_name|.
//
// Can be called from UI thread. |callback| is run on the calling thread.
// |callback| must not be null.
void CopyDocumentToDirectory(const FilePath& dir_path,
const std::string& resource_id,
const FilePath::StringType& new_name,
......@@ -413,6 +416,7 @@ class GDataFileSystem : public GDataFileSystemInterface,
const FilePath& cache_file_path);
// Callback for handling document copy attempt.
// |callback| must not be null.
void OnCopyDocumentCompleted(const FilePath& dir_path,
const FileOperationCallback& callback,
GDataErrorCode status,
......@@ -742,7 +746,7 @@ class GDataFileSystem : public GDataFileSystemInterface,
const base::Closure& callback);
// Part of CopyOnUIThread(). Called after GetEntryInfoPairByPaths() is
// complete.
// complete. |callback| must not be null.
void CopyOnUIThreadAfterGetEntryInfoPair(
const FilePath& dest_file_path,
const FileOperationCallback& callback,
......
......@@ -146,6 +146,7 @@ class GDataFileSystemInterface {
// |local_dest_file_path| is the destination path on the local file system.
//
// Must be called from *UI* thread. |callback| is run on the calling thread.
// |callback| must not be null.
virtual void TransferFileFromRemoteToLocal(
const FilePath& remote_src_file_path,
const FilePath& local_dest_file_path,
......@@ -157,6 +158,7 @@ class GDataFileSystemInterface {
// system.
//
// Must be called from *UI* thread. |callback| is run on the calling thread.
// |callback| must not be null.
virtual void TransferFileFromLocalToRemote(
const FilePath& local_src_file_path,
const FilePath& remote_dest_file_path,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment