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

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

Issue 16311010: Make FileSystemOperation::Write take closure-friendly parameters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 "net/url_request/url_request_context.h"
8 #include "webkit/browser/fileapi/file_observers.h" 9 #include "webkit/browser/fileapi/file_observers.h"
10 #include "webkit/browser/fileapi/file_stream_writer.h"
9 #include "webkit/browser/fileapi/file_system_context.h" 11 #include "webkit/browser/fileapi/file_system_context.h"
12 #include "webkit/browser/fileapi/file_writer_delegate.h"
10 #include "webkit/browser/fileapi/local_file_system_operation.h" 13 #include "webkit/browser/fileapi/local_file_system_operation.h"
11 #include "webkit/common/blob/shareable_file_reference.h" 14 #include "webkit/common/blob/shareable_file_reference.h"
12 15
13 namespace fileapi { 16 namespace fileapi {
14 17
15 typedef FileSystemOperationRunner::OperationID OperationID; 18 typedef FileSystemOperationRunner::OperationID OperationID;
16 19
17 const OperationID FileSystemOperationRunner::kErrorOperationID = -1; 20 const OperationID FileSystemOperationRunner::kErrorOperationID = -1;
18 21
19 FileSystemOperationRunner::~FileSystemOperationRunner() { 22 FileSystemOperationRunner::~FileSystemOperationRunner() {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 const GURL& blob_url, 210 const GURL& blob_url,
208 int64 offset, 211 int64 offset,
209 const WriteCallback& callback) { 212 const WriteCallback& callback) {
210 base::PlatformFileError error = base::PLATFORM_FILE_OK; 213 base::PlatformFileError error = base::PLATFORM_FILE_OK;
211 FileSystemOperation* operation = 214 FileSystemOperation* operation =
212 file_system_context_->CreateFileSystemOperation(url, &error); 215 file_system_context_->CreateFileSystemOperation(url, &error);
213 if (!operation) { 216 if (!operation) {
214 callback.Run(error, 0, true); 217 callback.Run(error, 0, true);
215 return kErrorOperationID; 218 return kErrorOperationID;
216 } 219 }
220
221 scoped_ptr<FileStreamWriter> writer(
222 file_system_context_->CreateFileStreamWriter(url, offset));
223 if (!writer) {
224 // Write is not supported.
225 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, 0, true);
226 return kErrorOperationID;
227 }
228
229 DCHECK(blob_url.is_valid());
230 scoped_ptr<FileWriterDelegate> writer_delegate(
231 new FileWriterDelegate(writer.Pass()));
232 scoped_ptr<net::URLRequest> blob_request(url_request_context->CreateRequest(
233 blob_url, writer_delegate.get()));
234
217 OperationID id = operations_.Add(operation); 235 OperationID id = operations_.Add(operation);
218 PrepareForWrite(id, url); 236 PrepareForWrite(id, url);
219 operation->Write( 237 operation->Write(
220 url_request_context, url, blob_url, offset, 238 url, writer_delegate.Pass(), blob_request.Pass(),
221 base::Bind(&FileSystemOperationRunner::DidWrite, AsWeakPtr(), 239 base::Bind(&FileSystemOperationRunner::DidWrite, AsWeakPtr(),
222 id, callback)); 240 id, callback));
223 return id; 241 return id;
224 } 242 }
225 243
226 OperationID FileSystemOperationRunner::Truncate( 244 OperationID FileSystemOperationRunner::Truncate(
227 const FileSystemURL& url, int64 length, 245 const FileSystemURL& url, int64 length,
228 const StatusCallback& callback) { 246 const StatusCallback& callback) {
229 base::PlatformFileError error = base::PLATFORM_FILE_OK; 247 base::PlatformFileError error = base::PLATFORM_FILE_OK;
230 FileSystemOperation* operation = 248 FileSystemOperation* operation =
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 &FileUpdateObserver::OnEndUpdate, MakeTuple(*iter)); 556 &FileUpdateObserver::OnEndUpdate, MakeTuple(*iter));
539 } 557 }
540 } 558 }
541 write_target_urls_.erase(found); 559 write_target_urls_.erase(found);
542 } 560 }
543 DCHECK(operations_.Lookup(id)); 561 DCHECK(operations_.Lookup(id));
544 operations_.Remove(id); 562 operations_.Remove(id);
545 } 563 }
546 564
547 } // namespace fileapi 565 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698