OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/file_system_provider/fileapi/file_stream_write
r.h" | 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/file_stream_write
r.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "chrome/browser/chromeos/file_system_provider/abort_callback.h" |
10 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" | 11 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" |
11 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" | 12 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" |
12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 13 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.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 | 17 |
17 using content::BrowserThread; | 18 using content::BrowserThread; |
18 | 19 |
19 namespace chromeos { | 20 namespace chromeos { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 100 |
100 if (abort_callback_.is_null()) { | 101 if (abort_callback_.is_null()) { |
101 // No operation to be cancelled. At most a callback call, which will be | 102 // No operation to be cancelled. At most a callback call, which will be |
102 // discarded. | 103 // discarded. |
103 BrowserThread::PostTask(BrowserThread::IO, | 104 BrowserThread::PostTask(BrowserThread::IO, |
104 FROM_HERE, | 105 FROM_HERE, |
105 base::Bind(callback, base::File::FILE_OK)); | 106 base::Bind(callback, base::File::FILE_OK)); |
106 return; | 107 return; |
107 } | 108 } |
108 | 109 |
109 const ProvidedFileSystemInterface::AbortCallback abort_callback = | 110 const AbortCallback last_abort_callback = abort_callback_; |
110 abort_callback_; | 111 abort_callback_ = AbortCallback(); |
111 abort_callback_ = ProvidedFileSystemInterface::AbortCallback(); | 112 last_abort_callback.Run(base::Bind( |
112 abort_callback.Run(base::Bind( | |
113 &OperationRunner::OnAbortCompletedOnUIThread, this, callback)); | 113 &OperationRunner::OnAbortCompletedOnUIThread, this, callback)); |
114 } | 114 } |
115 | 115 |
116 private: | 116 private: |
117 friend class base::RefCountedThreadSafe<OperationRunner>; | 117 friend class base::RefCountedThreadSafe<OperationRunner>; |
118 | 118 |
119 virtual ~OperationRunner() {} | 119 virtual ~OperationRunner() {} |
120 | 120 |
121 // Remembers a file handle for further operations and forwards the result to | 121 // Remembers a file handle for further operations and forwards the result to |
122 // the IO thread. | 122 // the IO thread. |
(...skipping 19 matching lines...) Expand all Loading... |
142 | 142 |
143 // Forwards a response of aborting an operation to the IO thread. | 143 // Forwards a response of aborting an operation to the IO thread. |
144 void OnAbortCompletedOnUIThread( | 144 void OnAbortCompletedOnUIThread( |
145 const storage::AsyncFileUtil::StatusCallback& callback, | 145 const storage::AsyncFileUtil::StatusCallback& callback, |
146 base::File::Error result) { | 146 base::File::Error result) { |
147 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 147 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
148 BrowserThread::PostTask( | 148 BrowserThread::PostTask( |
149 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); | 149 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); |
150 } | 150 } |
151 | 151 |
152 ProvidedFileSystemInterface::AbortCallback abort_callback_; | 152 AbortCallback abort_callback_; |
153 base::WeakPtr<ProvidedFileSystemInterface> file_system_; | 153 base::WeakPtr<ProvidedFileSystemInterface> file_system_; |
154 int file_handle_; | 154 int file_handle_; |
155 | 155 |
156 DISALLOW_COPY_AND_ASSIGN(OperationRunner); | 156 DISALLOW_COPY_AND_ASSIGN(OperationRunner); |
157 }; | 157 }; |
158 | 158 |
159 FileStreamWriter::FileStreamWriter(const storage::FileSystemURL& url, | 159 FileStreamWriter::FileStreamWriter(const storage::FileSystemURL& url, |
160 int64 initial_offset) | 160 int64 initial_offset) |
161 : url_(url), | 161 : url_(url), |
162 current_offset_(initial_offset), | 162 current_offset_(initial_offset), |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 current_offset_, | 331 current_offset_, |
332 buffer_length, | 332 buffer_length, |
333 base::Bind(&FileStreamWriter::OnWriteFileCompleted, | 333 base::Bind(&FileStreamWriter::OnWriteFileCompleted, |
334 weak_ptr_factory_.GetWeakPtr(), | 334 weak_ptr_factory_.GetWeakPtr(), |
335 buffer_length, | 335 buffer_length, |
336 callback))); | 336 callback))); |
337 } | 337 } |
338 | 338 |
339 } // namespace file_system_provider | 339 } // namespace file_system_provider |
340 } // namespace chromeos | 340 } // namespace chromeos |
OLD | NEW |