| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <tuple> |
| 10 | 11 |
| 11 #include "base/files/file_util_proxy.h" | 12 #include "base/files/file_util_proxy.h" |
| 12 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 14 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 #include "storage/browser/fileapi/file_observers.h" | 17 #include "storage/browser/fileapi/file_observers.h" |
| 17 #include "storage/browser/fileapi/file_stream_reader.h" | 18 #include "storage/browser/fileapi/file_stream_reader.h" |
| 18 #include "storage/browser/fileapi/file_system_context.h" | 19 #include "storage/browser/fileapi/file_system_context.h" |
| 19 #include "storage/browser/fileapi/file_system_operation_runner.h" | 20 #include "storage/browser/fileapi/file_system_operation_runner.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 return; | 221 return; |
| 221 callback.Run(write_response); | 222 callback.Run(write_response); |
| 222 return; | 223 return; |
| 223 } | 224 } |
| 224 | 225 |
| 225 if (total_bytes_written_ + write_response + initial_offset_ > file_size_) { | 226 if (total_bytes_written_ + write_response + initial_offset_ > file_size_) { |
| 226 int overlapped = file_size_ - total_bytes_written_ - initial_offset_; | 227 int overlapped = file_size_ - total_bytes_written_ - initial_offset_; |
| 227 if (overlapped < 0) | 228 if (overlapped < 0) |
| 228 overlapped = 0; | 229 overlapped = 0; |
| 229 observers_.Notify(&FileUpdateObserver::OnUpdate, | 230 observers_.Notify(&FileUpdateObserver::OnUpdate, |
| 230 base::MakeTuple(url_, write_response - overlapped)); | 231 std::make_tuple(url_, write_response - overlapped)); |
| 231 } | 232 } |
| 232 total_bytes_written_ += write_response; | 233 total_bytes_written_ += write_response; |
| 233 | 234 |
| 234 if (CancelIfRequested()) | 235 if (CancelIfRequested()) |
| 235 return; | 236 return; |
| 236 callback.Run(write_response); | 237 callback.Run(write_response); |
| 237 } | 238 } |
| 238 | 239 |
| 239 bool SandboxFileStreamWriter::CancelIfRequested() { | 240 bool SandboxFileStreamWriter::CancelIfRequested() { |
| 240 if (cancel_callback_.is_null()) | 241 if (cancel_callback_.is_null()) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 252 DCHECK(cancel_callback_.is_null()); | 253 DCHECK(cancel_callback_.is_null()); |
| 253 | 254 |
| 254 // Write() is not called yet, so there's nothing to flush. | 255 // Write() is not called yet, so there's nothing to flush. |
| 255 if (!local_file_writer_) | 256 if (!local_file_writer_) |
| 256 return net::OK; | 257 return net::OK; |
| 257 | 258 |
| 258 return local_file_writer_->Flush(callback); | 259 return local_file_writer_->Flush(callback); |
| 259 } | 260 } |
| 260 | 261 |
| 261 } // namespace storage | 262 } // namespace storage |
| OLD | NEW |