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

Side by Side Diff: webkit/browser/fileapi/file_system_operation_runner.cc

Issue 23223003: Chromium Blob hacking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/browser/fileapi/file_system_operation_runner.h" 5 #include "webkit/browser/fileapi/file_system_operation_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/url_request/url_request_context.h" 10 #include "net/url_request/url_request_context.h"
11 #include "webkit/browser/blob/blob_url_request_job_factory.h"
11 #include "webkit/browser/fileapi/file_observers.h" 12 #include "webkit/browser/fileapi/file_observers.h"
12 #include "webkit/browser/fileapi/file_stream_writer.h" 13 #include "webkit/browser/fileapi/file_stream_writer.h"
13 #include "webkit/browser/fileapi/file_system_context.h" 14 #include "webkit/browser/fileapi/file_system_context.h"
14 #include "webkit/browser/fileapi/file_system_operation_impl.h" 15 #include "webkit/browser/fileapi/file_system_operation_impl.h"
15 #include "webkit/browser/fileapi/file_writer_delegate.h" 16 #include "webkit/browser/fileapi/file_writer_delegate.h"
16 #include "webkit/common/blob/shareable_file_reference.h" 17 #include "webkit/common/blob/shareable_file_reference.h"
17 18
18 namespace fileapi { 19 namespace fileapi {
19 20
20 typedef FileSystemOperationRunner::OperationID OperationID; 21 typedef FileSystemOperationRunner::OperationID OperationID;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 operation->Remove( 224 operation->Remove(
224 url, recursive, 225 url, recursive,
225 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 226 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
226 handle, callback)); 227 handle, callback));
227 return handle.id; 228 return handle.id;
228 } 229 }
229 230
230 OperationID FileSystemOperationRunner::Write( 231 OperationID FileSystemOperationRunner::Write(
231 const net::URLRequestContext* url_request_context, 232 const net::URLRequestContext* url_request_context,
232 const FileSystemURL& url, 233 const FileSystemURL& url,
233 const GURL& blob_url, 234 scoped_ptr<webkit_blob::BlobDataHandle> blob,
234 int64 offset, 235 int64 offset,
235 const WriteCallback& callback) { 236 const WriteCallback& callback) {
236 base::PlatformFileError error = base::PLATFORM_FILE_OK; 237 base::PlatformFileError error = base::PLATFORM_FILE_OK;
237 FileSystemOperation* operation = 238 FileSystemOperation* operation =
238 file_system_context_->CreateFileSystemOperation(url, &error); 239 file_system_context_->CreateFileSystemOperation(url, &error);
239 240
240 BeginOperationScoper scope; 241 BeginOperationScoper scope;
241 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); 242 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
242 if (!operation) { 243 if (!operation) {
243 DidWrite(handle, callback, error, 0, true); 244 DidWrite(handle, callback, error, 0, true);
244 return handle.id; 245 return handle.id;
245 } 246 }
246 247
247 scoped_ptr<FileStreamWriter> writer( 248 scoped_ptr<FileStreamWriter> writer(
248 file_system_context_->CreateFileStreamWriter(url, offset)); 249 file_system_context_->CreateFileStreamWriter(url, offset));
249 if (!writer) { 250 if (!writer) {
250 // Write is not supported. 251 // Write is not supported.
251 DidWrite(handle, callback, base::PLATFORM_FILE_ERROR_SECURITY, 0, true); 252 DidWrite(handle, callback, base::PLATFORM_FILE_ERROR_SECURITY, 0, true);
252 return handle.id; 253 return handle.id;
253 } 254 }
254 255
255 DCHECK(blob_url.is_valid());
256 scoped_ptr<FileWriterDelegate> writer_delegate( 256 scoped_ptr<FileWriterDelegate> writer_delegate(
257 new FileWriterDelegate(writer.Pass())); 257 new FileWriterDelegate(writer.Pass()));
258 scoped_ptr<net::URLRequest> blob_request(url_request_context->CreateRequest( 258
259 blob_url, writer_delegate.get())); 259 scoped_ptr<net::URLRequest> blob_request(
260 webkit_blob::BlobProtocolHandler::CreateBlobRequest(
261 blob.Pass(),
262 url_request_context,
263 writer_delegate.get()));
260 264
261 PrepareForWrite(handle.id, url); 265 PrepareForWrite(handle.id, url);
262 operation->Write( 266 operation->Write(
263 url, writer_delegate.Pass(), blob_request.Pass(), 267 url, writer_delegate.Pass(), blob_request.Pass(),
264 base::Bind(&FileSystemOperationRunner::DidWrite, AsWeakPtr(), 268 base::Bind(&FileSystemOperationRunner::DidWrite, AsWeakPtr(),
265 handle, callback)); 269 handle, callback));
266 return handle.id; 270 return handle.id;
267 } 271 }
268 272
269 OperationID FileSystemOperationRunner::Truncate( 273 OperationID FileSystemOperationRunner::Truncate(
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 stray_cancel_callbacks_.find(id); 649 stray_cancel_callbacks_.find(id);
646 if (found_cancel != stray_cancel_callbacks_.end()) { 650 if (found_cancel != stray_cancel_callbacks_.end()) {
647 // This cancel has been requested after the operation has finished, 651 // This cancel has been requested after the operation has finished,
648 // so report that we failed to stop it. 652 // so report that we failed to stop it.
649 found_cancel->second.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); 653 found_cancel->second.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
650 stray_cancel_callbacks_.erase(found_cancel); 654 stray_cancel_callbacks_.erase(found_cancel);
651 } 655 }
652 } 656 }
653 657
654 } // namespace fileapi 658 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/file_system_operation_runner.h ('k') | webkit/child/weburlloader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698