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 "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "net/base/file_stream.h" | 8 #include "net/base/file_stream.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 const base::Closure& main_operation) { | 145 const base::Closure& main_operation) { |
146 DCHECK(has_pending_operation_); | 146 DCHECK(has_pending_operation_); |
147 DCHECK(stream_impl_.get()); | 147 DCHECK(stream_impl_.get()); |
148 | 148 |
149 if (initial_offset_ == 0) { | 149 if (initial_offset_ == 0) { |
150 // No need to seek. | 150 // No need to seek. |
151 main_operation.Run(); | 151 main_operation.Run(); |
152 return; | 152 return; |
153 } | 153 } |
154 | 154 |
155 int result = stream_impl_->Seek(base::File::FROM_BEGIN, initial_offset_, | 155 int result = stream_impl_->Seek( |
156 base::Bind(&LocalFileStreamWriter::DidSeek, | 156 initial_offset_, |
157 weak_factory_.GetWeakPtr(), | 157 base::Bind(&LocalFileStreamWriter::DidSeek, weak_factory_.GetWeakPtr(), |
158 error_callback, | 158 error_callback, main_operation)); |
159 main_operation)); | |
160 if (result != net::ERR_IO_PENDING) { | 159 if (result != net::ERR_IO_PENDING) { |
161 has_pending_operation_ = false; | 160 has_pending_operation_ = false; |
162 error_callback.Run(result); | 161 error_callback.Run(result); |
163 } | 162 } |
164 } | 163 } |
165 | 164 |
166 void LocalFileStreamWriter::DidSeek( | 165 void LocalFileStreamWriter::DidSeek( |
167 const net::CompletionCallback& error_callback, | 166 const net::CompletionCallback& error_callback, |
168 const base::Closure& main_operation, | 167 const base::Closure& main_operation, |
169 int64 result) { | 168 int64 result) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 return false; | 246 return false; |
248 | 247 |
249 net::CompletionCallback pending_cancel = cancel_callback_; | 248 net::CompletionCallback pending_cancel = cancel_callback_; |
250 has_pending_operation_ = false; | 249 has_pending_operation_ = false; |
251 cancel_callback_.Reset(); | 250 cancel_callback_.Reset(); |
252 pending_cancel.Run(net::OK); | 251 pending_cancel.Run(net::OK); |
253 return true; | 252 return true; |
254 } | 253 } |
255 | 254 |
256 } // namespace storage | 255 } // namespace storage |
OLD | NEW |