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 #include <tuple> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 SandboxFileStreamWriter::~SandboxFileStreamWriter() {} | 64 SandboxFileStreamWriter::~SandboxFileStreamWriter() {} |
65 | 65 |
66 int SandboxFileStreamWriter::Write( | 66 int SandboxFileStreamWriter::Write( |
67 net::IOBuffer* buf, int buf_len, | 67 net::IOBuffer* buf, int buf_len, |
68 const net::CompletionCallback& callback) { | 68 const net::CompletionCallback& callback) { |
69 has_pending_operation_ = true; | 69 has_pending_operation_ = true; |
70 if (local_file_writer_) | 70 if (local_file_writer_) |
71 return WriteInternal(buf, buf_len, callback); | 71 return WriteInternal(buf, buf_len, callback); |
72 | 72 |
73 net::CompletionCallback write_task = | 73 net::CompletionCallback write_task = base::Bind( |
74 base::Bind(&SandboxFileStreamWriter::DidInitializeForWrite, | 74 &SandboxFileStreamWriter::DidInitializeForWrite, |
75 weak_factory_.GetWeakPtr(), | 75 weak_factory_.GetWeakPtr(), base::RetainedRef(buf), buf_len, callback); |
76 make_scoped_refptr(buf), buf_len, callback); | |
77 file_system_context_->operation_runner()->CreateSnapshotFile( | 76 file_system_context_->operation_runner()->CreateSnapshotFile( |
78 url_, base::Bind(&SandboxFileStreamWriter::DidCreateSnapshotFile, | 77 url_, base::Bind(&SandboxFileStreamWriter::DidCreateSnapshotFile, |
79 weak_factory_.GetWeakPtr(), write_task)); | 78 weak_factory_.GetWeakPtr(), write_task)); |
80 return net::ERR_IO_PENDING; | 79 return net::ERR_IO_PENDING; |
81 } | 80 } |
82 | 81 |
83 int SandboxFileStreamWriter::Cancel(const net::CompletionCallback& callback) { | 82 int SandboxFileStreamWriter::Cancel(const net::CompletionCallback& callback) { |
84 if (!has_pending_operation_) | 83 if (!has_pending_operation_) |
85 return net::ERR_UNEXPECTED; | 84 return net::ERR_UNEXPECTED; |
86 | 85 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 DCHECK(cancel_callback_.is_null()); | 252 DCHECK(cancel_callback_.is_null()); |
254 | 253 |
255 // Write() is not called yet, so there's nothing to flush. | 254 // Write() is not called yet, so there's nothing to flush. |
256 if (!local_file_writer_) | 255 if (!local_file_writer_) |
257 return net::OK; | 256 return net::OK; |
258 | 257 |
259 return local_file_writer_->Flush(callback); | 258 return local_file_writer_->Flush(callback); |
260 } | 259 } |
261 | 260 |
262 } // namespace storage | 261 } // namespace storage |
OLD | NEW |