OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/fileapi/remote_file_stream_writer.h" | 5 #include "chrome/browser/chromeos/fileapi/remote_file_stream_writer.h" |
6 | 6 |
7 #include "net/base/io_buffer.h" | 7 #include "net/base/io_buffer.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "webkit/browser/blob/local_file_stream_reader.h" | 9 #include "webkit/browser/blob/local_file_stream_reader.h" |
10 #include "webkit/browser/fileapi/local_file_stream_writer.h" | 10 #include "webkit/browser/fileapi/local_file_stream_writer.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 callback.Run(net::PlatformFileErrorToNetError(open_result)); | 71 callback.Run(net::PlatformFileErrorToNetError(open_result)); |
72 return; | 72 return; |
73 } | 73 } |
74 | 74 |
75 // Hold the reference to the file. Releasing the reference notifies the file | 75 // Hold the reference to the file. Releasing the reference notifies the file |
76 // system about to close file. | 76 // system about to close file. |
77 file_ref_ = file_ref; | 77 file_ref_ = file_ref; |
78 | 78 |
79 DCHECK(!local_file_writer_.get()); | 79 DCHECK(!local_file_writer_.get()); |
80 local_file_writer_.reset(new fileapi::LocalFileStreamWriter( | 80 local_file_writer_.reset(new fileapi::LocalFileStreamWriter( |
81 local_task_runner_, local_path, initial_offset_)); | 81 local_task_runner_.get(), local_path, initial_offset_)); |
82 int result = local_file_writer_->Write(buf, buf_len, callback); | 82 int result = local_file_writer_->Write(buf, buf_len, callback); |
83 if (result != net::ERR_IO_PENDING) | 83 if (result != net::ERR_IO_PENDING) |
84 callback.Run(result); | 84 callback.Run(result); |
85 } | 85 } |
86 | 86 |
87 int RemoteFileStreamWriter::Cancel(const net::CompletionCallback& callback) { | 87 int RemoteFileStreamWriter::Cancel(const net::CompletionCallback& callback) { |
88 DCHECK(!callback.is_null()); | 88 DCHECK(!callback.is_null()); |
89 DCHECK(pending_cancel_callback_.is_null()); | 89 DCHECK(pending_cancel_callback_.is_null()); |
90 | 90 |
91 // If file open operation is in-flight, wait for its completion and cancel | 91 // If file open operation is in-flight, wait for its completion and cancel |
(...skipping 21 matching lines...) Expand all Loading... |
113 return net::OK; | 113 return net::OK; |
114 } | 114 } |
115 | 115 |
116 void RemoteFileStreamWriter::InvokePendingCancelCallback(int result) { | 116 void RemoteFileStreamWriter::InvokePendingCancelCallback(int result) { |
117 net::CompletionCallback callback = pending_cancel_callback_; | 117 net::CompletionCallback callback = pending_cancel_callback_; |
118 pending_cancel_callback_.Reset(); | 118 pending_cancel_callback_.Reset(); |
119 callback.Run(result); | 119 callback.Run(result); |
120 } | 120 } |
121 | 121 |
122 } // namespace chromeos | 122 } // namespace chromeos |
OLD | NEW |