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

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

Issue 10880075: drive: Fix a crash caused by an empty edit URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor fix 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/drive_file_system.cc
diff --git a/chrome/browser/chromeos/gdata/drive_file_system.cc b/chrome/browser/chromeos/gdata/drive_file_system.cc
index b159ba5be844f176c25920be18aa4bcd7c7cf6b3..9ea2da6b3a7add085607573bd313d58da03111a4 100644
--- a/chrome/browser/chromeos/gdata/drive_file_system.cc
+++ b/chrome/browser/chromeos/gdata/drive_file_system.cc
@@ -1227,6 +1227,8 @@ void DriveFileSystem::Remove(const FilePath& file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(!callback.is_null());
+
RunTaskOnUIThread(base::Bind(&DriveFileSystem::RemoveOnUIThread,
ui_weak_ptr_,
file_path,
@@ -1237,6 +1239,7 @@ void DriveFileSystem::RemoveOnUIThread(
const FilePath& file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
// Get the edit URL of an entry at |file_path|.
resource_metadata_->GetEntryInfoByPath(
@@ -1252,16 +1255,20 @@ void DriveFileSystem::RemoveOnUIThreadAfterGetEntryInfo(
DriveFileError error,
scoped_ptr<DriveEntryProto> entry_proto) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
if (error != DRIVE_FILE_OK) {
- if (!callback.is_null()) {
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE, base::Bind(callback, error));
- }
+ callback.Run(error);
return;
}
-
DCHECK(entry_proto.get());
+
+ // The edit URL can be empty for some reason.
+ if (entry_proto->edit_url().empty()) {
+ callback.Run(DRIVE_FILE_ERROR_NOT_FOUND);
+ return;
+ }
+
drive_service_->DeleteDocument(
GURL(entry_proto->edit_url()),
base::Bind(&DriveFileSystem::RemoveResourceLocally,
@@ -2439,11 +2446,11 @@ void DriveFileSystem::RemoveResourceLocally(
GDataErrorCode status,
const GURL& /* document_url */) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
DriveFileError error = util::GDataToDriveFileError(status);
if (error != DRIVE_FILE_OK) {
- if (!callback.is_null())
- callback.Run(error);
+ callback.Run(error);
return;
}
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_file_system.h ('k') | chrome/browser/chromeos/gdata/drive_file_system_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698