Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3235)

Unified Diff: chrome/browser/chromeos/gdata/gdata_file_system.cc

Issue 10834295: gdata: Make callback parameters mandatory for CloseFile functions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/gdata/gdata_file_system.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index 26f3ceec6b2b2d20d0f351979d718529ccdc75d6..d6c647516aabcd7007ad9a1625ca9aaf05a53c17 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -3180,6 +3180,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,
@@ -3190,6 +3192,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.
@@ -3216,12 +3219,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;
}
@@ -3244,10 +3249,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;
}
@@ -3276,10 +3281,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;
}
@@ -3289,22 +3294,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;
}
@@ -3312,8 +3315,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());
@@ -3342,12 +3344,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(
@@ -3355,6 +3357,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
@@ -3363,8 +3366,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(
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | chrome/browser/chromeos/gdata/gdata_file_system_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698