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

Unified Diff: content/browser/fileapi/fileapi_message_filter.cc

Issue 10920087: Update callers of CreateFileSystemOperation so more detailed error codes can be returned. Where app… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes from Kinuko's review Created 8 years, 3 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: content/browser/fileapi/fileapi_message_filter.cc
diff --git a/content/browser/fileapi/fileapi_message_filter.cc b/content/browser/fileapi/fileapi_message_filter.cc
index 70ffc75bc58a42497066b1bcb0347c912ce82ba0..784846a2e85965e29c0caf43da221f589119f81c 100644
--- a/content/browser/fileapi/fileapi_message_filter.cc
+++ b/content/browser/fileapi/fileapi_message_filter.cc
@@ -136,8 +136,10 @@ void FileAPIMessageFilter::OnChannelClosing() {
open_filesystem_urls_.begin();
iter != open_filesystem_urls_.end(); ++iter) {
FileSystemURL url(*iter);
- FileSystemOperation* operation = context_->CreateFileSystemOperation(url);
- operation->NotifyCloseFile(url);
+ FileSystemOperation* operation = context_->CreateFileSystemOperation(
+ url, NULL);
+ if (operation)
+ operation->NotifyCloseFile(url);
}
}
@@ -234,7 +236,10 @@ void FileAPIMessageFilter::OnMove(
return;
}
- GetNewOperation(src_url, request_id)->Move(
+ FileSystemOperation* operation = GetNewOperation(src_url, request_id);
+ if (!operation)
+ return;
+ operation->Move(
src_url, dest_url,
base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id));
}
@@ -251,7 +256,10 @@ void FileAPIMessageFilter::OnCopy(
return;
}
- GetNewOperation(src_url, request_id)->Copy(
+ FileSystemOperation* operation = GetNewOperation(src_url, request_id);
+ if (!operation)
+ return
+ operation->Copy(
src_url, dest_url,
base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id));
}
@@ -266,7 +274,10 @@ void FileAPIMessageFilter::OnRemove(
return;
}
- GetNewOperation(url, request_id)->Remove(
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
+ operation->Remove(
url, recursive,
base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id));
}
@@ -281,7 +292,10 @@ void FileAPIMessageFilter::OnReadMetadata(
return;
}
- GetNewOperation(url, request_id)->GetMetadata(
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
+ operation->GetMetadata(
url,
base::Bind(&FileAPIMessageFilter::DidGetMetadata, this, request_id));
}
@@ -297,12 +311,15 @@ void FileAPIMessageFilter::OnCreate(
return;
}
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
if (is_directory) {
- GetNewOperation(url, request_id)->CreateDirectory(
+ operation->CreateDirectory(
url, exclusive, recursive,
base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id));
} else {
- GetNewOperation(url, request_id)->CreateFile(
+ operation->CreateFile(
url, exclusive,
base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id));
}
@@ -318,12 +335,15 @@ void FileAPIMessageFilter::OnExists(
return;
}
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
if (is_directory) {
- GetNewOperation(url, request_id)->DirectoryExists(
+ operation->DirectoryExists(
url,
base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id));
} else {
- GetNewOperation(url, request_id)->FileExists(
+ operation->FileExists(
url,
base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id));
}
@@ -339,7 +359,10 @@ void FileAPIMessageFilter::OnReadDirectory(
return;
}
- GetNewOperation(url, request_id)->ReadDirectory(
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
+ operation->ReadDirectory(
url, base::Bind(&FileAPIMessageFilter::DidReadDirectory,
this, request_id));
}
@@ -363,7 +386,10 @@ void FileAPIMessageFilter::OnWrite(
return;
}
- GetNewOperation(url, request_id)->Write(
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
+ operation->Write(
request_context_, url, blob_url, offset,
base::Bind(&FileAPIMessageFilter::DidWrite, this, request_id));
}
@@ -379,7 +405,10 @@ void FileAPIMessageFilter::OnTruncate(
return;
}
- GetNewOperation(url, request_id)->Truncate(
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
+ operation->Truncate(
url, length,
base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id));
}
@@ -397,7 +426,10 @@ void FileAPIMessageFilter::OnTouchFile(
return;
}
- GetNewOperation(url, request_id)->TouchFile(
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
+ operation->TouchFile(
url, last_access_time, last_modified_time,
base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id));
}
@@ -431,7 +463,10 @@ void FileAPIMessageFilter::OnOpenFile(
return;
}
- GetNewOperation(url, request_id)->OpenFile(
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
+ operation->OpenFile(
url, file_flags, peer_handle(),
base::Bind(&FileAPIMessageFilter::DidOpenFile, this, request_id, path));
}
@@ -449,7 +484,8 @@ void FileAPIMessageFilter::OnNotifyCloseFile(const GURL& path) {
// Do not use GetNewOperation() here, because NotifyCloseFile is a one-way
// operation that does not have request_id by which we respond back.
- FileSystemOperation* operation = context_->CreateFileSystemOperation(url);
+ FileSystemOperation* operation = context_->CreateFileSystemOperation(
+ url, NULL);
if (operation)
operation->NotifyCloseFile(url);
}
@@ -493,9 +529,11 @@ void FileAPIMessageFilter::OnSyncGetPlatformPath(
// TODO(kinuko): this hack should go away once appropriate upload-stream
// handling based on element types is supported.
LocalFileSystemOperation* operation =
- context_->CreateFileSystemOperation(url)->AsLocalFileSystemOperation();
+ context_->CreateFileSystemOperation(
+ url, NULL)->AsLocalFileSystemOperation();
DCHECK(operation);
- operation->SyncGetPlatformPath(url, platform_path);
+ if (operation)
+ operation->SyncGetPlatformPath(url, platform_path);
}
void FileAPIMessageFilter::OnCreateSnapshotFile(
@@ -505,7 +543,11 @@ void FileAPIMessageFilter::OnCreateSnapshotFile(
base::Callback<void(const FilePath&)> register_file_callback =
base::Bind(&FileAPIMessageFilter::RegisterFileAsBlob,
this, blob_url, url.path());
- GetNewOperation(url, request_id)->CreateSnapshotFile(
+
+ FileSystemOperation* operation = GetNewOperation(url, request_id);
+ if (!operation)
+ return;
+ operation->CreateSnapshotFile(
url,
base::Bind(&FileAPIMessageFilter::DidCreateSnapshot,
this, request_id, register_file_callback));
@@ -792,8 +834,14 @@ bool FileAPIMessageFilter::HasPermissionsForFile(
FileSystemOperation* FileAPIMessageFilter::GetNewOperation(
const FileSystemURL& target_url,
int request_id) {
+ base::PlatformFileError error_code;
FileSystemOperation* operation =
- context_->CreateFileSystemOperation(target_url);
+ context_->CreateFileSystemOperation(target_url, &error_code);
+ if (error_code != base::PLATFORM_FILE_OK) {
+ Send(new FileSystemMsg_DidFail(request_id, error_code));
+ return NULL;
+ }
+
DCHECK(operation);
operations_.AddWithID(operation, request_id);
return operation;

Powered by Google App Engine
This is Rietveld 408576698