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

Side by Side Diff: webkit/browser/fileapi/file_writer_delegate.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_writer_delegate.h" 5 #include "webkit/browser/fileapi/file_writer_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_util_proxy.h" 9 #include "base/files/file_util_proxy.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 22 matching lines...) Expand all
33 case net::ERR_ACCESS_DENIED: 33 case net::ERR_ACCESS_DENIED:
34 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; 34 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
35 default: 35 default:
36 return base::PLATFORM_FILE_ERROR_FAILED; 36 return base::PLATFORM_FILE_ERROR_FAILED;
37 } 37 }
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 FileWriterDelegate::FileWriterDelegate( 42 FileWriterDelegate::FileWriterDelegate(
43 const DelegateWriteCallback& write_callback,
44 scoped_ptr<FileStreamWriter> file_stream_writer) 43 scoped_ptr<FileStreamWriter> file_stream_writer)
45 : write_callback_(write_callback), 44 : file_stream_writer_(file_stream_writer.Pass()),
46 file_stream_writer_(file_stream_writer.Pass()),
47 writing_started_(false), 45 writing_started_(false),
48 bytes_written_backlog_(0), 46 bytes_written_backlog_(0),
49 bytes_written_(0), 47 bytes_written_(0),
50 bytes_read_(0), 48 bytes_read_(0),
51 io_buffer_(new net::IOBufferWithSize(kReadBufSize)) { 49 io_buffer_(new net::IOBufferWithSize(kReadBufSize)) {
52 } 50 }
53 51
54 FileWriterDelegate::~FileWriterDelegate() { 52 FileWriterDelegate::~FileWriterDelegate() {
55 } 53 }
56 54
57 void FileWriterDelegate::Start(scoped_ptr<net::URLRequest> request) { 55 void FileWriterDelegate::Start(scoped_ptr<net::URLRequest> request,
56 const DelegateWriteCallback& write_callback) {
57 write_callback_ = write_callback;
58 request_ = request.Pass(); 58 request_ = request.Pass();
59 request_->Start(); 59 request_->Start();
60 } 60 }
61 61
62 void FileWriterDelegate::Cancel() { 62 void FileWriterDelegate::Cancel() {
63 if (request_) { 63 if (request_) {
64 // This halts any callbacks on this delegate. 64 // This halts any callbacks on this delegate.
65 request_->set_delegate(NULL); 65 request_->set_delegate(NULL);
66 request_->Cancel(); 66 request_->Cancel();
67 } 67 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (error == base::PLATFORM_FILE_OK && flush_error != net::OK) { 243 if (error == base::PLATFORM_FILE_OK && flush_error != net::OK) {
244 // If the Flush introduced an error, overwrite the status. 244 // If the Flush introduced an error, overwrite the status.
245 // Otherwise, keep the original error status. 245 // Otherwise, keep the original error status.
246 error = NetErrorToPlatformFileError(flush_error); 246 error = NetErrorToPlatformFileError(flush_error);
247 progress_status = GetCompletionStatusOnError(); 247 progress_status = GetCompletionStatusOnError();
248 } 248 }
249 write_callback_.Run(error, bytes_written, progress_status); 249 write_callback_.Run(error, bytes_written, progress_status);
250 } 250 }
251 251
252 } // namespace fileapi 252 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698