OLD | NEW |
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/fileapi/file_writer_delegate.h" | 5 #include "webkit/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 FileWriterDelegate::FileWriterDelegate( | 42 FileWriterDelegate::FileWriterDelegate( |
43 const DelegateWriteCallback& write_callback, | 43 const DelegateWriteCallback& write_callback, |
44 scoped_ptr<FileStreamWriter> file_stream_writer) | 44 scoped_ptr<FileStreamWriter> file_stream_writer) |
45 : write_callback_(write_callback), | 45 : write_callback_(write_callback), |
46 file_stream_writer_(file_stream_writer.Pass()), | 46 file_stream_writer_(file_stream_writer.Pass()), |
47 writing_started_(false), | 47 writing_started_(false), |
48 bytes_written_backlog_(0), | 48 bytes_written_backlog_(0), |
49 bytes_written_(0), | 49 bytes_written_(0), |
50 bytes_read_(0), | 50 bytes_read_(0), |
51 io_buffer_(new net::IOBufferWithSize(kReadBufSize)), | 51 io_buffer_(new net::IOBufferWithSize(kReadBufSize)), |
52 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 52 weak_factory_(this) { |
53 } | 53 } |
54 | 54 |
55 FileWriterDelegate::~FileWriterDelegate() { | 55 FileWriterDelegate::~FileWriterDelegate() { |
56 } | 56 } |
57 | 57 |
58 void FileWriterDelegate::Start(scoped_ptr<net::URLRequest> request) { | 58 void FileWriterDelegate::Start(scoped_ptr<net::URLRequest> request) { |
59 request_ = request.Pass(); | 59 request_ = request.Pass(); |
60 request_->Start(); | 60 request_->Start(); |
61 } | 61 } |
62 | 62 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 if (error == base::PLATFORM_FILE_OK && flush_error != net::OK) { | 242 if (error == base::PLATFORM_FILE_OK && flush_error != net::OK) { |
243 // If the Flush introduced an error, overwrite the status. | 243 // If the Flush introduced an error, overwrite the status. |
244 // Otherwise, keep the original error status. | 244 // Otherwise, keep the original error status. |
245 error = NetErrorToPlatformFileError(flush_error); | 245 error = NetErrorToPlatformFileError(flush_error); |
246 progress_status = GetCompletionStatusOnError(); | 246 progress_status = GetCompletionStatusOnError(); |
247 } | 247 } |
248 write_callback_.Run(error, bytes_written, progress_status); | 248 write_callback_.Run(error, bytes_written, progress_status); |
249 } | 249 } |
250 | 250 |
251 } // namespace fileapi | 251 } // namespace fileapi |
OLD | NEW |