| 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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_WRITER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_WRITER_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_WRITER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_WRITER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "webkit/browser/fileapi/file_stream_writer.h" | 14 #include "webkit/browser/fileapi/file_stream_writer.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class TaskRunner; | 17 class TaskRunner; |
| 18 } // namespace base | 18 } // namespace base |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class IOBuffer; | 21 class IOBuffer; |
| 22 } // namespace net | 22 } // namespace net |
| 23 | 23 |
| 24 namespace drive { | 24 namespace drive { |
| 25 | 25 |
| 26 class FileSystemInterface; | 26 class FileSystemInterface; |
| 27 | 27 |
| 28 namespace internal { | 28 namespace internal { |
| 29 | 29 |
| 30 // The implementation of fileapi::FileStreamWriter for the Drive File System. | 30 // The implementation of storage::FileStreamWriter for the Drive File System. |
| 31 class WebkitFileStreamWriterImpl : public fileapi::FileStreamWriter { | 31 class WebkitFileStreamWriterImpl : public storage::FileStreamWriter { |
| 32 public: | 32 public: |
| 33 // Callback to return the FileSystemInterface instance. This is an | 33 // Callback to return the FileSystemInterface instance. This is an |
| 34 // injecting point for testing. | 34 // injecting point for testing. |
| 35 // Note that the callback will be copied between threads (IO and UI), and | 35 // Note that the callback will be copied between threads (IO and UI), and |
| 36 // will be called on UI thread. | 36 // will be called on UI thread. |
| 37 typedef base::Callback<FileSystemInterface*()> FileSystemGetter; | 37 typedef base::Callback<FileSystemInterface*()> FileSystemGetter; |
| 38 | 38 |
| 39 // Creates a writer for a file at |file_path| on FileSystem returned by | 39 // Creates a writer for a file at |file_path| on FileSystem returned by |
| 40 // |file_system_getter| that starts writing from |offset|. | 40 // |file_system_getter| that starts writing from |offset|. |
| 41 // When invalid parameters are set, the first call to Write() method fails. | 41 // When invalid parameters are set, the first call to Write() method fails. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 int buf_len, | 59 int buf_len, |
| 60 base::File::Error open_result, | 60 base::File::Error open_result, |
| 61 const base::FilePath& local_path, | 61 const base::FilePath& local_path, |
| 62 const base::Closure& close_callback_on_ui_thread); | 62 const base::Closure& close_callback_on_ui_thread); |
| 63 | 63 |
| 64 FileSystemGetter file_system_getter_; | 64 FileSystemGetter file_system_getter_; |
| 65 scoped_refptr<base::TaskRunner> file_task_runner_; | 65 scoped_refptr<base::TaskRunner> file_task_runner_; |
| 66 const base::FilePath file_path_; | 66 const base::FilePath file_path_; |
| 67 const int64 offset_; | 67 const int64 offset_; |
| 68 | 68 |
| 69 scoped_ptr<fileapi::FileStreamWriter> local_file_writer_; | 69 scoped_ptr<storage::FileStreamWriter> local_file_writer_; |
| 70 base::Closure close_callback_on_ui_thread_; | 70 base::Closure close_callback_on_ui_thread_; |
| 71 net::CompletionCallback pending_write_callback_; | 71 net::CompletionCallback pending_write_callback_; |
| 72 net::CompletionCallback pending_cancel_callback_; | 72 net::CompletionCallback pending_cancel_callback_; |
| 73 | 73 |
| 74 // Note: This should remain the last member so it'll be destroyed and | 74 // Note: This should remain the last member so it'll be destroyed and |
| 75 // invalidate the weak pointers before any other members are destroyed. | 75 // invalidate the weak pointers before any other members are destroyed. |
| 76 base::WeakPtrFactory<WebkitFileStreamWriterImpl> weak_ptr_factory_; | 76 base::WeakPtrFactory<WebkitFileStreamWriterImpl> weak_ptr_factory_; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(WebkitFileStreamWriterImpl); | 78 DISALLOW_COPY_AND_ASSIGN(WebkitFileStreamWriterImpl); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace internal | 81 } // namespace internal |
| 82 } // namespace drive | 82 } // namespace drive |
| 83 | 83 |
| 84 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_WRITER_IMPL_
H_ | 84 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_WRITER_IMPL_
H_ |
| OLD | NEW |