| 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_reade
r.h" | 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reade
r.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 135 |
| 135 if (abort_callback_.is_null()) { | 136 if (abort_callback_.is_null()) { |
| 136 // No operation to be cancelled. At most a callback call, which will be | 137 // No operation to be cancelled. At most a callback call, which will be |
| 137 // discarded. | 138 // discarded. |
| 138 BrowserThread::PostTask(BrowserThread::IO, | 139 BrowserThread::PostTask(BrowserThread::IO, |
| 139 FROM_HERE, | 140 FROM_HERE, |
| 140 base::Bind(callback, base::File::FILE_OK)); | 141 base::Bind(callback, base::File::FILE_OK)); |
| 141 return; | 142 return; |
| 142 } | 143 } |
| 143 | 144 |
| 144 const ProvidedFileSystemInterface::AbortCallback abort_callback = | 145 const AbortCallback last_abort_callback = abort_callback_; |
| 145 abort_callback_; | 146 abort_callback_ = AbortCallback(); |
| 146 abort_callback_ = ProvidedFileSystemInterface::AbortCallback(); | 147 last_abort_callback.Run(base::Bind( |
| 147 abort_callback.Run(base::Bind( | |
| 148 &OperationRunner::OnAbortCompletedOnUIThread, this, callback)); | 148 &OperationRunner::OnAbortCompletedOnUIThread, this, callback)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 friend class base::RefCountedThreadSafe<OperationRunner>; | 152 friend class base::RefCountedThreadSafe<OperationRunner>; |
| 153 | 153 |
| 154 virtual ~OperationRunner() {} | 154 virtual ~OperationRunner() {} |
| 155 | 155 |
| 156 // Remembers a file handle for further operations and forwards the result to | 156 // Remembers a file handle for further operations and forwards the result to |
| 157 // the IO thread. | 157 // the IO thread. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 // Forwards a response of aborting an operation to the IO thread. | 195 // Forwards a response of aborting an operation to the IO thread. |
| 196 void OnAbortCompletedOnUIThread( | 196 void OnAbortCompletedOnUIThread( |
| 197 const storage::AsyncFileUtil::StatusCallback& callback, | 197 const storage::AsyncFileUtil::StatusCallback& callback, |
| 198 base::File::Error result) { | 198 base::File::Error result) { |
| 199 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 199 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 200 BrowserThread::PostTask( | 200 BrowserThread::PostTask( |
| 201 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); | 201 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); |
| 202 } | 202 } |
| 203 | 203 |
| 204 ProvidedFileSystemInterface::AbortCallback abort_callback_; | 204 AbortCallback abort_callback_; |
| 205 base::WeakPtr<ProvidedFileSystemInterface> file_system_; | 205 base::WeakPtr<ProvidedFileSystemInterface> file_system_; |
| 206 base::FilePath file_path_; | 206 base::FilePath file_path_; |
| 207 int file_handle_; | 207 int file_handle_; |
| 208 | 208 |
| 209 DISALLOW_COPY_AND_ASSIGN(OperationRunner); | 209 DISALLOW_COPY_AND_ASSIGN(OperationRunner); |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 FileStreamReader::FileStreamReader(storage::FileSystemContext* context, | 212 FileStreamReader::FileStreamReader(storage::FileSystemContext* context, |
| 213 const storage::FileSystemURL& url, | 213 const storage::FileSystemURL& url, |
| 214 int64 initial_offset, | 214 int64 initial_offset, |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); | 487 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); |
| 488 return; | 488 return; |
| 489 } | 489 } |
| 490 | 490 |
| 491 DCHECK_EQ(base::File::FILE_OK, result); | 491 DCHECK_EQ(base::File::FILE_OK, result); |
| 492 callback.Run(metadata->size); | 492 callback.Run(metadata->size); |
| 493 } | 493 } |
| 494 | 494 |
| 495 } // namespace file_system_provider | 495 } // namespace file_system_provider |
| 496 } // namespace chromeos | 496 } // namespace chromeos |
| OLD | NEW |