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/sandbox_file_stream_writer.h" | 5 #include "storage/browser/fileapi/sandbox_file_stream_writer.h" |
6 | 6 |
7 #include "base/files/file_util_proxy.h" | 7 #include "base/files/file_util_proxy.h" |
8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return; | 205 return; |
206 callback.Run(write_response); | 206 callback.Run(write_response); |
207 return; | 207 return; |
208 } | 208 } |
209 | 209 |
210 if (total_bytes_written_ + write_response + initial_offset_ > file_size_) { | 210 if (total_bytes_written_ + write_response + initial_offset_ > file_size_) { |
211 int overlapped = file_size_ - total_bytes_written_ - initial_offset_; | 211 int overlapped = file_size_ - total_bytes_written_ - initial_offset_; |
212 if (overlapped < 0) | 212 if (overlapped < 0) |
213 overlapped = 0; | 213 overlapped = 0; |
214 observers_.Notify(&FileUpdateObserver::OnUpdate, | 214 observers_.Notify(&FileUpdateObserver::OnUpdate, |
215 MakeTuple(url_, write_response - overlapped)); | 215 base::MakeTuple(url_, write_response - overlapped)); |
216 } | 216 } |
217 total_bytes_written_ += write_response; | 217 total_bytes_written_ += write_response; |
218 | 218 |
219 if (CancelIfRequested()) | 219 if (CancelIfRequested()) |
220 return; | 220 return; |
221 callback.Run(write_response); | 221 callback.Run(write_response); |
222 } | 222 } |
223 | 223 |
224 bool SandboxFileStreamWriter::CancelIfRequested() { | 224 bool SandboxFileStreamWriter::CancelIfRequested() { |
225 if (cancel_callback_.is_null()) | 225 if (cancel_callback_.is_null()) |
(...skipping 11 matching lines...) Expand all Loading... |
237 DCHECK(cancel_callback_.is_null()); | 237 DCHECK(cancel_callback_.is_null()); |
238 | 238 |
239 // Write() is not called yet, so there's nothing to flush. | 239 // Write() is not called yet, so there's nothing to flush. |
240 if (!local_file_writer_) | 240 if (!local_file_writer_) |
241 return net::OK; | 241 return net::OK; |
242 | 242 |
243 return local_file_writer_->Flush(callback); | 243 return local_file_writer_->Flush(callback); |
244 } | 244 } |
245 | 245 |
246 } // namespace storage | 246 } // namespace storage |
OLD | NEW |