| 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 30779569c20cb854a49062e09fb3adff5d4787c3..2237d55d6ecc57d7addbb44a47de4555bd5056d1 100644
|
| --- a/content/browser/fileapi/fileapi_message_filter.cc
|
| +++ b/content/browser/fileapi/fileapi_message_filter.cc
|
| @@ -138,8 +138,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);
|
| }
|
| }
|
|
|
| @@ -236,7 +238,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));
|
| }
|
| @@ -253,7 +258,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));
|
| }
|
| @@ -268,7 +276,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));
|
| }
|
| @@ -283,7 +294,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));
|
| }
|
| @@ -299,12 +313,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));
|
| }
|
| @@ -320,12 +337,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));
|
| }
|
| @@ -341,7 +361,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));
|
| }
|
| @@ -365,7 +388,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));
|
| }
|
| @@ -381,7 +407,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));
|
| }
|
| @@ -399,7 +428,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));
|
| }
|
| @@ -433,7 +465,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));
|
| }
|
| @@ -451,7 +486,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);
|
| }
|
| @@ -496,9 +532,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(
|
| @@ -508,7 +546,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));
|
| @@ -795,8 +837,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;
|
|
|