OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 STORAGE_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ |
6 #define STORAGE_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ | 6 #define STORAGE_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 int buf_len, | 38 int buf_len, |
39 const net::CompletionCallback& callback) override; | 39 const net::CompletionCallback& callback) override; |
40 int Cancel(const net::CompletionCallback& callback) override; | 40 int Cancel(const net::CompletionCallback& callback) override; |
41 int Flush(const net::CompletionCallback& callback) override; | 41 int Flush(const net::CompletionCallback& callback) override; |
42 | 42 |
43 private: | 43 private: |
44 friend class content::LocalFileStreamWriterTest; | 44 friend class content::LocalFileStreamWriterTest; |
45 friend class FileStreamWriter; | 45 friend class FileStreamWriter; |
46 LocalFileStreamWriter(base::TaskRunner* task_runner, | 46 LocalFileStreamWriter(base::TaskRunner* task_runner, |
47 const base::FilePath& file_path, | 47 const base::FilePath& file_path, |
48 int64 initial_offset, | 48 int64 initial_offset); |
49 OpenOrCreate open_or_create); | |
50 | 49 |
51 // Opens |file_path_| and if it succeeds, proceeds to InitiateSeek(). | 50 // Opens |file_path_| and if it succeeds, proceeds to InitiateSeek(). |
52 // If failed, the error code is returned by calling |error_callback|. | 51 // If failed, the error code is returned by calling |error_callback|. |
53 int InitiateOpen(const net::CompletionCallback& error_callback, | 52 int InitiateOpen(const net::CompletionCallback& error_callback, |
54 const base::Closure& main_operation); | 53 const base::Closure& main_operation); |
55 void DidOpen(const net::CompletionCallback& error_callback, | 54 void DidOpen(const net::CompletionCallback& error_callback, |
56 const base::Closure& main_operation, | 55 const base::Closure& main_operation, |
57 int result); | 56 int result); |
58 | 57 |
59 // Seeks to |initial_offset_| and proceeds to |main_operation| if it succeeds. | 58 // Seeks to |initial_offset_| and proceeds to |main_operation| if it succeeds. |
(...skipping 16 matching lines...) Expand all Loading... |
76 // Flushes asynchronously to the file. | 75 // Flushes asynchronously to the file. |
77 int InitiateFlush(const net::CompletionCallback& callback); | 76 int InitiateFlush(const net::CompletionCallback& callback); |
78 void DidFlush(const net::CompletionCallback& callback, int result); | 77 void DidFlush(const net::CompletionCallback& callback, int result); |
79 | 78 |
80 // Stops the in-flight operation and calls |cancel_callback_| if it has been | 79 // Stops the in-flight operation and calls |cancel_callback_| if it has been |
81 // set by Cancel() for the current operation. | 80 // set by Cancel() for the current operation. |
82 bool CancelIfRequested(); | 81 bool CancelIfRequested(); |
83 | 82 |
84 // Initialization parameters. | 83 // Initialization parameters. |
85 const base::FilePath file_path_; | 84 const base::FilePath file_path_; |
86 OpenOrCreate open_or_create_; | |
87 const int64 initial_offset_; | 85 const int64 initial_offset_; |
88 scoped_refptr<base::TaskRunner> task_runner_; | 86 scoped_refptr<base::TaskRunner> task_runner_; |
89 | 87 |
90 // Current states of the operation. | 88 // Current states of the operation. |
91 bool has_pending_operation_; | 89 bool has_pending_operation_; |
92 scoped_ptr<net::FileStream> stream_impl_; | 90 scoped_ptr<net::FileStream> stream_impl_; |
93 net::CompletionCallback cancel_callback_; | 91 net::CompletionCallback cancel_callback_; |
94 | 92 |
95 base::WeakPtrFactory<LocalFileStreamWriter> weak_factory_; | 93 base::WeakPtrFactory<LocalFileStreamWriter> weak_factory_; |
96 DISALLOW_COPY_AND_ASSIGN(LocalFileStreamWriter); | 94 DISALLOW_COPY_AND_ASSIGN(LocalFileStreamWriter); |
97 }; | 95 }; |
98 | 96 |
99 } // namespace storage | 97 } // namespace storage |
100 | 98 |
101 #endif // STORAGE_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ | 99 #endif // STORAGE_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ |
OLD | NEW |