summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-07 07:37:25 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-07 07:37:25 +0000
commit69819f8c079c8ca8b37b2a21732b29562fbec721 (patch)
tree7338fa5eaf0670f34d67ed850ea4539866494f64
parent0a9fd4dd4f05423a83479ace4d2b2469eced588e (diff)
downloadchromium_src-69819f8c079c8ca8b37b2a21732b29562fbec721.zip
chromium_src-69819f8c079c8ca8b37b2a21732b29562fbec721.tar.gz
chromium_src-69819f8c079c8ca8b37b2a21732b29562fbec721.tar.bz2
drive: Make callback parameters mandatory
Looking at the code, most callback parameters always take callbacks hence can be mandatory. DriveSystemService::ClearCacheAndRemountFileSystem() was an exception, so add a dummy callback for now with a TODO comment. BUG=126634 TEST=none Review URL: https://codereview.chromium.org/11446056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171715 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/drive_scheduler.cc40
-rw-r--r--chrome/browser/chromeos/drive/drive_scheduler.h9
-rw-r--r--chrome/browser/chromeos/drive/drive_system_service.h6
-rw-r--r--chrome/browser/chromeos/drive/file_system/copy_operation.cc25
-rw-r--r--chrome/browser/chromeos/drive/file_system/copy_operation.h3
-rw-r--r--chrome/browser/chromeos/drive/file_system/drive_operations.cc31
-rw-r--r--chrome/browser/chromeos/drive/file_system/drive_operations.h7
-rw-r--r--chrome/browser/chromeos/drive/file_system/move_operation.cc5
-rw-r--r--chrome/browser/chromeos/drive/file_system/move_operation.h2
-rw-r--r--chrome/browser/chromeos/drive/file_system/remove_operation.cc6
-rw-r--r--chrome/browser/chromeos/drive/file_system/remove_operation.h3
-rw-r--r--chrome/browser/chromeos/drive/file_system/update_operation.h1
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_private_api.cc9
13 files changed, 109 insertions, 38 deletions
diff --git a/chrome/browser/chromeos/drive/drive_scheduler.cc b/chrome/browser/chromeos/drive/drive_scheduler.cc
index 8c356c3..3e55b50 100644
--- a/chrome/browser/chromeos/drive/drive_scheduler.cc
+++ b/chrome/browser/chromeos/drive/drive_scheduler.cc
@@ -31,15 +31,18 @@ DriveScheduler::JobInfo::JobInfo(JobType in_job_type, FilePath in_file_path)
total_bytes(0),
file_path(in_file_path),
state(STATE_NONE) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
DriveScheduler::QueueEntry::QueueEntry(JobType in_job_type,
FilePath in_file_path)
: job_info(in_job_type, in_file_path),
is_recursive(false) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
DriveScheduler::QueueEntry::~QueueEntry() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
DriveScheduler::DriveScheduler(
@@ -79,6 +82,7 @@ void DriveScheduler::Initialize() {
void DriveScheduler::GetAccountMetadata(
const google_apis::GetDataCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
scoped_ptr<QueueEntry> new_job(
new QueueEntry(TYPE_GET_ACCOUNT_METADATA, FilePath()));
@@ -92,6 +96,7 @@ void DriveScheduler::GetAccountMetadata(
void DriveScheduler::GetApplicationInfo(
const google_apis::GetDataCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
scoped_ptr<QueueEntry> new_job(
new QueueEntry(TYPE_GET_APPLICATION_INFO, FilePath()));
@@ -106,6 +111,7 @@ void DriveScheduler::Copy(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
scoped_ptr<QueueEntry> new_job(new QueueEntry(TYPE_COPY, src_file_path));
new_job->dest_file_path = dest_file_path;
@@ -124,6 +130,7 @@ void DriveScheduler::GetDocuments(
const std::string& directory_resource_id,
const google_apis::GetDataCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
scoped_ptr<QueueEntry> new_job(
new QueueEntry(TYPE_GET_DOCUMENTS, FilePath()));
@@ -144,6 +151,7 @@ void DriveScheduler::TransferFileFromRemoteToLocal(
const FilePath& local_dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
scoped_ptr<QueueEntry> new_job(new QueueEntry(TYPE_TRANSFER_REMOTE_TO_LOCAL,
remote_src_file_path));
@@ -160,6 +168,7 @@ void DriveScheduler::TransferFileFromLocalToRemote(
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
scoped_ptr<QueueEntry> new_job(new QueueEntry(TYPE_TRANSFER_LOCAL_TO_REMOTE,
local_src_file_path));
@@ -176,6 +185,7 @@ void DriveScheduler::TransferRegularFile(
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
scoped_ptr<QueueEntry> new_job(new QueueEntry(TYPE_TRANSFER_REGULAR_FILE,
local_src_file_path));
@@ -191,6 +201,7 @@ void DriveScheduler::Move(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
scoped_ptr<QueueEntry> new_job(new QueueEntry(TYPE_MOVE, src_file_path));
new_job->dest_file_path = dest_file_path;
@@ -205,6 +216,7 @@ void DriveScheduler::Remove(const FilePath& file_path,
bool is_recursive,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
scoped_ptr<QueueEntry> new_job(new QueueEntry(TYPE_REMOVE, file_path));
new_job->is_recursive = is_recursive;
@@ -354,6 +366,8 @@ void DriveScheduler::DoJobLoop() {
}
bool DriveScheduler::ShouldStopJobLoop() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
// Should stop if the gdata feature was disabled while running the fetch
// loop.
if (profile_->GetPrefs()->GetBoolean(prefs::kDisableDrive))
@@ -411,6 +425,8 @@ void DriveScheduler::ResetThrottleAndContinueJobLoop() {
scoped_ptr<DriveScheduler::QueueEntry> DriveScheduler::OnJobDone(
int job_id,
DriveFileError error) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
JobMap::iterator job_iter = job_info_map_.find(job_id);
DCHECK(job_iter != job_info_map_.end());
@@ -435,21 +451,24 @@ scoped_ptr<DriveScheduler::QueueEntry> DriveScheduler::OnJobDone(
}
void DriveScheduler::OnFileOperationJobDone(int job_id, DriveFileError error) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
scoped_ptr<DriveScheduler::QueueEntry> job_info = OnJobDone(job_id, error);
if (!job_info)
return;
// Handle the callback.
- if (!job_info->file_operation_callback.is_null()) {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(job_info->file_operation_callback, error));
- }
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(job_info->file_operation_callback, error));
}
void DriveScheduler::OnGetDataJobDone(int job_id,
google_apis::GDataErrorCode error,
scoped_ptr<base::Value> feed_data) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
DriveFileError drive_error(util::GDataToDriveFileError(error));
scoped_ptr<QueueEntry> job_info = OnJobDone(job_id, drive_error);
@@ -457,13 +476,12 @@ void DriveScheduler::OnGetDataJobDone(int job_id,
if (!job_info)
return;
- // Handle the callback.
- if (!job_info->get_data_callback.is_null()) {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(job_info->get_data_callback,
- error,
- base::Passed(&feed_data)));
- }
+ // Handle the callback.
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(job_info->get_data_callback,
+ error,
+ base::Passed(&feed_data)));
}
void DriveScheduler::OnConnectionTypeChanged(
diff --git a/chrome/browser/chromeos/drive/drive_scheduler.h b/chrome/browser/chromeos/drive/drive_scheduler.h
index 7f1c6f8..5f8c2ba 100644
--- a/chrome/browser/chromeos/drive/drive_scheduler.h
+++ b/chrome/browser/chromeos/drive/drive_scheduler.h
@@ -89,17 +89,21 @@ class DriveScheduler
void Initialize();
// Adds a GetAccountMetadata operation to the queue.
+ // |callback| must not be null.
void GetAccountMetadata(const google_apis::GetDataCallback& callback);
// Adds a GetApplicationInfo operation to the queue.
+ // |callback| must not be null.
void GetApplicationInfo(const google_apis::GetDataCallback& callback);
// Adds a copy operation to the queue.
+ // |callback| must not be null.
void Copy(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback);
// Adds a GetDocuments operation to the queue.
+ // |callback| must not be null.
void GetDocuments(const GURL& feed_url,
int64 start_changestamp,
const std::string& search_query,
@@ -108,26 +112,31 @@ class DriveScheduler
const google_apis::GetDataCallback& callback);
// Adds a transfer operation to the queue.
+ // |callback| must not be null.
void TransferFileFromRemoteToLocal(const FilePath& remote_src_file_path,
const FilePath& local_dest_file_path,
const FileOperationCallback& callback);
// Adds a transfer operation to the queue.
+ // |callback| must not be null.
void TransferFileFromLocalToRemote(const FilePath& local_src_file_path,
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback);
// Adds a transfer operation to the queue.
+ // |callback| must not be null.
void TransferRegularFile(const FilePath& local_src_file_path,
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback);
// Adds a move operation to the queue.
+ // |callback| must not be null.
void Move(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback);
// Adds a remove operation to the queue.
+ // |callback| must not be null.
void Remove(const FilePath& file_path,
bool is_recursive,
const FileOperationCallback& callback);
diff --git a/chrome/browser/chromeos/drive/drive_system_service.h b/chrome/browser/chromeos/drive/drive_system_service.h
index dbf54fa..da38b49 100644
--- a/chrome/browser/chromeos/drive/drive_system_service.h
+++ b/chrome/browser/chromeos/drive/drive_system_service.h
@@ -55,8 +55,10 @@ class DriveSystemService : public ProfileKeyedService,
DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); }
EventLogger* event_logger() { return event_logger_.get(); }
- // Clears all the local cache files and in-memory data, and remounts the file
- // system.
+ // Clears all the local cache files and in-memory data, and remounts the
+ // file system. |callback| is called with true when this operation is done
+ // successfully. Otherwise, |callback| is called with false.
+ // |callback| must not be null.
void ClearCacheAndRemountFileSystem(
const base::Callback<void(bool)>& callback);
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
index fbc033b..d495f45 100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
@@ -58,16 +58,6 @@ DriveFileError GetLocalFileInfoOnBlockingPool(
DRIVE_FILE_OK : DRIVE_FILE_ERROR_NOT_FOUND;
}
-// Helper function called upon completion of AddUploadFile invoked by
-// OnTransferCompleted.
-// TODO(mtomasz): The same method is in drive_file_system.cc. Share it.
-void OnAddUploadFileCompleted(const FileOperationCallback& callback,
- DriveFileError error) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (!callback.is_null())
- callback.Run(error);
-}
-
// Checks if a local file at |local_file_path| is a JSON file referencing a
// hosted document on blocking pool, and if so, gets the resource ID of the
// document.
@@ -201,6 +191,7 @@ void CopyOperation::TransferRegularFile(
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
int64* file_size = new int64;
std::string* content_type = new std::string;
@@ -439,11 +430,10 @@ void CopyOperation::StartFileUpload(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(file_size);
DCHECK(content_type);
+ DCHECK(!params.callback.is_null());
if (error != DRIVE_FILE_OK) {
- if (!params.callback.is_null())
- params.callback.Run(error);
-
+ params.callback.Run(error);
return;
}
@@ -465,13 +455,13 @@ void CopyOperation::StartFileUploadAfterGetEntryInfo(
DriveFileError 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;
if (error != DRIVE_FILE_OK) {
- if (!params.callback.is_null())
- params.callback.Run(error);
+ params.callback.Run(error);
return;
}
DCHECK(entry_proto.get());
@@ -496,6 +486,7 @@ void CopyOperation::OnTransferCompleted(
const FilePath& file_path,
scoped_ptr<DocumentEntry> document_entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
if (error == google_apis::DRIVE_UPLOAD_OK && document_entry.get()) {
drive_file_system_->AddUploadedFile(
@@ -503,8 +494,8 @@ void CopyOperation::OnTransferCompleted(
document_entry.Pass(),
file_path,
DriveCache::FILE_OPERATION_COPY,
- base::Bind(&OnAddUploadFileCompleted, callback));
- } else if (!callback.is_null()) {
+ callback);
+ } else {
callback.Run(DriveUploadErrorToDriveFileError(error));
}
}
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.h b/chrome/browser/chromeos/drive/file_system/copy_operation.h
index 02c77f1..8aa1380 100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation.h
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation.h
@@ -47,7 +47,7 @@ class CopyOperation {
// Performs the copy operation on the file at drive path |src_file_path|
// with a target of |dest_file_path|. Invokes |callback| when finished with
- // the result of the operation.
+ // the result of the operation. |callback| must not be null.
virtual void Copy(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback);
@@ -81,6 +81,7 @@ class CopyOperation {
// path within Drive file system.
//
// Must be called from *UI* thread. |callback| is run on the calling thread.
+ // |callback| must not be null.
virtual void TransferRegularFile(const FilePath& local_file_path,
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback);
diff --git a/chrome/browser/chromeos/drive/file_system/drive_operations.cc b/chrome/browser/chromeos/drive/file_system/drive_operations.cc
index 030dbe1..6e181ac 100644
--- a/chrome/browser/chromeos/drive/file_system/drive_operations.cc
+++ b/chrome/browser/chromeos/drive/file_system/drive_operations.cc
@@ -4,18 +4,24 @@
#include "chrome/browser/chromeos/drive/file_system/drive_operations.h"
+#include "base/callback.h"
#include "chrome/browser/chromeos/drive/file_system/copy_operation.h"
#include "chrome/browser/chromeos/drive/file_system/move_operation.h"
#include "chrome/browser/chromeos/drive/file_system/remove_operation.h"
#include "chrome/browser/chromeos/drive/file_system/update_operation.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
namespace drive {
namespace file_system {
DriveOperations::DriveOperations() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
DriveOperations::~DriveOperations() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
void DriveOperations::Init(
@@ -26,6 +32,8 @@ void DriveOperations::Init(
google_apis::DriveUploaderInterface* uploader,
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
OperationObserver* observer) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
copy_operation_.reset(new file_system::CopyOperation(drive_service,
drive_file_system,
metadata,
@@ -50,6 +58,8 @@ void DriveOperations::InitForTesting(CopyOperation* copy_operation,
MoveOperation* move_operation,
RemoveOperation* remove_operation,
UpdateOperation* update_operation) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
copy_operation_.reset(copy_operation);
move_operation_.reset(move_operation);
remove_operation_.reset(remove_operation);
@@ -59,6 +69,9 @@ void DriveOperations::InitForTesting(CopyOperation* copy_operation,
void DriveOperations::Copy(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
copy_operation_->Copy(src_file_path, dest_file_path, callback);
}
@@ -66,6 +79,9 @@ void DriveOperations::TransferFileFromRemoteToLocal(
const FilePath& remote_src_file_path,
const FilePath& local_dest_file_path,
const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
copy_operation_->TransferFileFromRemoteToLocal(remote_src_file_path,
local_dest_file_path,
callback);
@@ -75,6 +91,9 @@ void DriveOperations::TransferFileFromLocalToRemote(
const FilePath& local_src_file_path,
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
copy_operation_->TransferFileFromLocalToRemote(local_src_file_path,
remote_dest_file_path,
callback);
@@ -84,6 +103,9 @@ void DriveOperations::TransferRegularFile(
const FilePath& local_src_file_path,
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
copy_operation_->TransferRegularFile(local_src_file_path,
remote_dest_file_path,
callback);
@@ -92,18 +114,27 @@ void DriveOperations::TransferRegularFile(
void DriveOperations::Move(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
move_operation_->Move(src_file_path, dest_file_path, callback);
}
void DriveOperations::Remove(const FilePath& file_path,
bool is_recursive,
const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
remove_operation_->Remove(file_path, is_recursive, callback);
}
void DriveOperations::UpdateFileByResourceId(
const std::string& resource_id,
const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
update_operation_->UpdateFileByResourceId(resource_id, callback);
}
diff --git a/chrome/browser/chromeos/drive/file_system/drive_operations.h b/chrome/browser/chromeos/drive/file_system/drive_operations.h
index 602492a..d25b2d8 100644
--- a/chrome/browser/chromeos/drive/file_system/drive_operations.h
+++ b/chrome/browser/chromeos/drive/file_system/drive_operations.h
@@ -51,36 +51,43 @@ class DriveOperations {
UpdateOperation* update_operation);
// Wrapper function for copy_operation_.
+ // |callback| must not be null.
void Copy(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback);
// Wrapper function for copy_operation_.
+ // |callback| must not be null.
void TransferFileFromRemoteToLocal(const FilePath& remote_src_file_path,
const FilePath& local_dest_file_path,
const FileOperationCallback& callback);
// Wrapper function for copy_operation_.
+ // |callback| must not be null.
void TransferFileFromLocalToRemote(const FilePath& local_src_file_path,
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback);
// Wrapper function for copy_operation_.
+ // |callback| must not be null.
void TransferRegularFile(const FilePath& local_src_file_path,
const FilePath& remote_dest_file_path,
const FileOperationCallback& callback);
// Wrapper function for move_operation_.
+ // |callback| must not be null.
void Move(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback);
// Wrapper function for remove_operation_.
+ // |callback| must not be null.
void Remove(const FilePath& file_path,
bool is_recursive,
const FileOperationCallback& callback);
// Wrapper function for update_operation_.
+ // |callback| must not be null.
void UpdateFileByResourceId(const std::string& resource_id,
const FileOperationCallback& callback);
diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.cc b/chrome/browser/chromeos/drive/file_system/move_operation.cc
index 956530b..c62ebd7 100644
--- a/chrome/browser/chromeos/drive/file_system/move_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/move_operation.cc
@@ -109,8 +109,9 @@ void MoveOperation::OnFilePathUpdated(const FileOperationCallback& callback,
DriveFileError error,
const FilePath& /* file_path */) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (!callback.is_null())
- callback.Run(error);
+ DCHECK(!callback.is_null());
+
+ callback.Run(error);
}
void MoveOperation::Rename(const FilePath& file_path,
diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.h b/chrome/browser/chromeos/drive/file_system/move_operation.h
index 9f8f010..d62eef8 100644
--- a/chrome/browser/chromeos/drive/file_system/move_operation.h
+++ b/chrome/browser/chromeos/drive/file_system/move_operation.h
@@ -40,7 +40,7 @@ class MoveOperation {
// Performs the move operation on the file at drive path |src_file_path|
// with a target of |dest_file_path|. Invokes |callback| when finished with
- // the result of the operation.
+ // the result of the operation. |callback| must not be null.
virtual void Move(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback);
diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.cc b/chrome/browser/chromeos/drive/file_system/remove_operation.cc
index 86e9eb4..aae5c1f 100644
--- a/chrome/browser/chromeos/drive/file_system/remove_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/remove_operation.cc
@@ -107,11 +107,13 @@ void RemoveOperation::NotifyDirectoryChanged(
const FileOperationCallback& callback,
DriveFileError error,
const FilePath& directory_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
if (error == DRIVE_FILE_OK)
observer_->OnDirectoryChangedByOperation(directory_path);
- if (!callback.is_null())
- callback.Run(error);
+ callback.Run(error);
}
} // namespace file_system
diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.h b/chrome/browser/chromeos/drive/file_system/remove_operation.h
index 2d61c32..3054ceb 100644
--- a/chrome/browser/chromeos/drive/file_system/remove_operation.h
+++ b/chrome/browser/chromeos/drive/file_system/remove_operation.h
@@ -41,6 +41,7 @@ class RemoveOperation {
// Perform the remove operation on the file at drive path |file_path|.
// Invokes |callback| when finished with the result of the operation.
+ // |callback| must not be null.
virtual void Remove(const FilePath& file_path,
bool is_recursive,
const FileOperationCallback& callback);
@@ -62,7 +63,7 @@ class RemoveOperation {
google_apis::GDataErrorCode status);
// Sends notification for directory changes. Notifies of directory changes,
- // and runs |callback| with |error|. |callback| may be null.
+ // and runs |callback| with |error|. |callback| must not be null.
void NotifyDirectoryChanged(
const FileOperationCallback& callback,
DriveFileError error,
diff --git a/chrome/browser/chromeos/drive/file_system/update_operation.h b/chrome/browser/chromeos/drive/file_system/update_operation.h
index 7eb7e51..0349a5e 100644
--- a/chrome/browser/chromeos/drive/file_system/update_operation.h
+++ b/chrome/browser/chromeos/drive/file_system/update_operation.h
@@ -94,6 +94,7 @@ class UpdateOperation {
scoped_ptr<google_apis::DocumentEntry> document_entry);
// Part of UpdateFileByResourceId().
+ // |callback| must not be null.
void OnUpdatedFileRefreshed(const FileOperationCallback& callback,
DriveFileError error,
const FilePath& drive_file_path,
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
index 81c0587..6f794a80 100644
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
@@ -398,6 +398,12 @@ void LogDefaultTask(const std::set<std::string>& mime_types,
}
}
+// Does nothing with a bool parameter. Used as a placeholder for calling
+// ClearCacheAndRemountFileSystem(). TODO(yoshiki): Handle an error from
+// ClearCacheAndRemountFileSystem() properly: http://crbug.com/140511.
+void DoNothingWithBool(bool /* success */) {
+}
+
} // namespace
class RequestLocalFileSystemFunction::LocalFileSystemCallbackDispatcher {
@@ -2787,7 +2793,8 @@ bool ClearDriveCacheFunction::RunImpl() {
// TODO(yoshiki): Receive a callback from JS-side and pass it to
// ClearCacheAndRemountFileSystem(). http://crbug.com/140511
- system_service->ClearCacheAndRemountFileSystem(base::Callback<void(bool)>());
+ system_service->ClearCacheAndRemountFileSystem(
+ base::Bind(&DoNothingWithBool));
SendResponse(true);
return true;