| 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 "storage/browser/fileapi/local_file_stream_writer.h" | 5 #include "storage/browser/fileapi/local_file_stream_writer.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "net/base/file_stream.h" | 10 #include "net/base/file_stream.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 DCHECK(!has_pending_operation_); | 48 DCHECK(!has_pending_operation_); |
| 49 DCHECK(cancel_callback_.is_null()); | 49 DCHECK(cancel_callback_.is_null()); |
| 50 | 50 |
| 51 has_pending_operation_ = true; | 51 has_pending_operation_ = true; |
| 52 if (stream_impl_) { | 52 if (stream_impl_) { |
| 53 int result = InitiateWrite(buf, buf_len, callback); | 53 int result = InitiateWrite(buf, buf_len, callback); |
| 54 if (result != net::ERR_IO_PENDING) | 54 if (result != net::ERR_IO_PENDING) |
| 55 has_pending_operation_ = false; | 55 has_pending_operation_ = false; |
| 56 return result; | 56 return result; |
| 57 } | 57 } |
| 58 return InitiateOpen(callback, | 58 return InitiateOpen( |
| 59 base::Bind(&LocalFileStreamWriter::ReadyToWrite, | 59 callback, base::Bind(&LocalFileStreamWriter::ReadyToWrite, |
| 60 weak_factory_.GetWeakPtr(), | 60 weak_factory_.GetWeakPtr(), base::RetainedRef(buf), |
| 61 make_scoped_refptr(buf), buf_len, callback)); | 61 buf_len, callback)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 int LocalFileStreamWriter::Cancel(const net::CompletionCallback& callback) { | 64 int LocalFileStreamWriter::Cancel(const net::CompletionCallback& callback) { |
| 65 if (!has_pending_operation_) | 65 if (!has_pending_operation_) |
| 66 return net::ERR_UNEXPECTED; | 66 return net::ERR_UNEXPECTED; |
| 67 | 67 |
| 68 DCHECK(!callback.is_null()); | 68 DCHECK(!callback.is_null()); |
| 69 cancel_callback_ = callback; | 69 cancel_callback_ = callback; |
| 70 return net::ERR_IO_PENDING; | 70 return net::ERR_IO_PENDING; |
| 71 } | 71 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 return false; | 248 return false; |
| 249 | 249 |
| 250 net::CompletionCallback pending_cancel = cancel_callback_; | 250 net::CompletionCallback pending_cancel = cancel_callback_; |
| 251 has_pending_operation_ = false; | 251 has_pending_operation_ = false; |
| 252 cancel_callback_.Reset(); | 252 cancel_callback_.Reset(); |
| 253 pending_cancel.Run(net::OK); | 253 pending_cancel.Run(net::OK); |
| 254 return true; | 254 return true; |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace storage | 257 } // namespace storage |
| OLD | NEW |