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 <stdint.h> |
| 9 |
9 #include "base/callback.h" | 10 #include "base/callback.h" |
10 #include "base/files/file.h" | 11 #include "base/files/file.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
14 #include "storage/browser/fileapi/file_stream_writer.h" | 16 #include "storage/browser/fileapi/file_stream_writer.h" |
15 | 17 |
16 namespace base { | 18 namespace base { |
17 class TaskRunner; | 19 class TaskRunner; |
18 } // namespace base | 20 } // namespace base |
19 | 21 |
20 namespace net { | 22 namespace net { |
21 class IOBuffer; | 23 class IOBuffer; |
(...skipping 14 matching lines...) Expand all Loading... |
36 // will be called on UI thread. | 38 // will be called on UI thread. |
37 typedef base::Callback<FileSystemInterface*()> FileSystemGetter; | 39 typedef base::Callback<FileSystemInterface*()> FileSystemGetter; |
38 | 40 |
39 // Creates a writer for a file at |file_path| on FileSystem returned by | 41 // Creates a writer for a file at |file_path| on FileSystem returned by |
40 // |file_system_getter| that starts writing from |offset|. | 42 // |file_system_getter| that starts writing from |offset|. |
41 // When invalid parameters are set, the first call to Write() method fails. | 43 // When invalid parameters are set, the first call to Write() method fails. |
42 // Uses |file_task_runner| for local file operations. | 44 // Uses |file_task_runner| for local file operations. |
43 WebkitFileStreamWriterImpl(const FileSystemGetter& file_system_getter, | 45 WebkitFileStreamWriterImpl(const FileSystemGetter& file_system_getter, |
44 base::TaskRunner* file_task_runner, | 46 base::TaskRunner* file_task_runner, |
45 const base::FilePath& file_path, | 47 const base::FilePath& file_path, |
46 int64 offset); | 48 int64_t offset); |
47 ~WebkitFileStreamWriterImpl() override; | 49 ~WebkitFileStreamWriterImpl() override; |
48 | 50 |
49 // FileWriter override. | 51 // FileWriter override. |
50 int Write(net::IOBuffer* buf, | 52 int Write(net::IOBuffer* buf, |
51 int buf_len, | 53 int buf_len, |
52 const net::CompletionCallback& callback) override; | 54 const net::CompletionCallback& callback) override; |
53 int Cancel(const net::CompletionCallback& callback) override; | 55 int Cancel(const net::CompletionCallback& callback) override; |
54 int Flush(const net::CompletionCallback& callback) override; | 56 int Flush(const net::CompletionCallback& callback) override; |
55 | 57 |
56 private: | 58 private: |
57 // Part of Write(). Called after CreateWritableSnapshotFile is completed. | 59 // Part of Write(). Called after CreateWritableSnapshotFile is completed. |
58 void WriteAfterCreateWritableSnapshotFile( | 60 void WriteAfterCreateWritableSnapshotFile( |
59 net::IOBuffer* buf, | 61 net::IOBuffer* buf, |
60 int buf_len, | 62 int buf_len, |
61 base::File::Error open_result, | 63 base::File::Error open_result, |
62 const base::FilePath& local_path, | 64 const base::FilePath& local_path, |
63 const base::Closure& close_callback_on_ui_thread); | 65 const base::Closure& close_callback_on_ui_thread); |
64 | 66 |
65 FileSystemGetter file_system_getter_; | 67 FileSystemGetter file_system_getter_; |
66 scoped_refptr<base::TaskRunner> file_task_runner_; | 68 scoped_refptr<base::TaskRunner> file_task_runner_; |
67 const base::FilePath file_path_; | 69 const base::FilePath file_path_; |
68 const int64 offset_; | 70 const int64_t offset_; |
69 | 71 |
70 scoped_ptr<storage::FileStreamWriter> local_file_writer_; | 72 scoped_ptr<storage::FileStreamWriter> local_file_writer_; |
71 base::Closure close_callback_on_ui_thread_; | 73 base::Closure close_callback_on_ui_thread_; |
72 net::CompletionCallback pending_write_callback_; | 74 net::CompletionCallback pending_write_callback_; |
73 net::CompletionCallback pending_cancel_callback_; | 75 net::CompletionCallback pending_cancel_callback_; |
74 | 76 |
75 // Note: This should remain the last member so it'll be destroyed and | 77 // Note: This should remain the last member so it'll be destroyed and |
76 // invalidate the weak pointers before any other members are destroyed. | 78 // invalidate the weak pointers before any other members are destroyed. |
77 base::WeakPtrFactory<WebkitFileStreamWriterImpl> weak_ptr_factory_; | 79 base::WeakPtrFactory<WebkitFileStreamWriterImpl> weak_ptr_factory_; |
78 | 80 |
79 DISALLOW_COPY_AND_ASSIGN(WebkitFileStreamWriterImpl); | 81 DISALLOW_COPY_AND_ASSIGN(WebkitFileStreamWriterImpl); |
80 }; | 82 }; |
81 | 83 |
82 } // namespace internal | 84 } // namespace internal |
83 } // namespace drive | 85 } // namespace drive |
84 | 86 |
85 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_WRITER_IMPL_
H_ | 87 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_WEBKIT_FILE_STREAM_WRITER_IMPL_
H_ |
OLD | NEW |