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 WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ | 6 #define WEBKIT_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" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
17 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
18 #include "webkit/browser/fileapi/file_stream_writer.h" | 18 #include "webkit/browser/fileapi/file_stream_writer.h" |
19 #include "webkit/browser/webkit_storage_browser_export.h" | 19 #include "webkit/browser/webkit_storage_browser_export.h" |
20 | 20 |
| 21 namespace content { |
| 22 class LocalFileStreamWriterTest; |
| 23 } |
| 24 |
21 namespace net { | 25 namespace net { |
22 class FileStream; | 26 class FileStream; |
23 } | 27 } |
24 | 28 |
25 namespace fileapi { | 29 namespace fileapi { |
26 | 30 |
27 // This class is a thin wrapper around net::FileStream for writing local files. | 31 // This class is a thin wrapper around net::FileStream for writing local files. |
28 class WEBKIT_STORAGE_BROWSER_EXPORT LocalFileStreamWriter | 32 class WEBKIT_STORAGE_BROWSER_EXPORT LocalFileStreamWriter |
29 : public NON_EXPORTED_BASE(FileStreamWriter) { | 33 : public NON_EXPORTED_BASE(FileStreamWriter) { |
30 public: | 34 public: |
31 virtual ~LocalFileStreamWriter(); | 35 virtual ~LocalFileStreamWriter(); |
32 | 36 |
33 // FileStreamWriter overrides. | 37 // FileStreamWriter overrides. |
34 virtual int Write(net::IOBuffer* buf, int buf_len, | 38 virtual int Write(net::IOBuffer* buf, int buf_len, |
35 const net::CompletionCallback& callback) OVERRIDE; | 39 const net::CompletionCallback& callback) OVERRIDE; |
36 virtual int Cancel(const net::CompletionCallback& callback) OVERRIDE; | 40 virtual int Cancel(const net::CompletionCallback& callback) OVERRIDE; |
37 virtual int Flush(const net::CompletionCallback& callback) OVERRIDE; | 41 virtual int Flush(const net::CompletionCallback& callback) OVERRIDE; |
38 | 42 |
39 private: | 43 private: |
| 44 friend class content::LocalFileStreamWriterTest; |
40 friend class FileStreamWriter; | 45 friend class FileStreamWriter; |
41 friend class LocalFileStreamWriterTest; | |
42 LocalFileStreamWriter(base::TaskRunner* task_runner, | 46 LocalFileStreamWriter(base::TaskRunner* task_runner, |
43 const base::FilePath& file_path, | 47 const base::FilePath& file_path, |
44 int64 initial_offset, | 48 int64 initial_offset, |
45 OpenOrCreate open_or_create); | 49 OpenOrCreate open_or_create); |
46 | 50 |
47 // Opens |file_path_| and if it succeeds, proceeds to InitiateSeek(). | 51 // Opens |file_path_| and if it succeeds, proceeds to InitiateSeek(). |
48 // If failed, the error code is returned by calling |error_callback|. | 52 // If failed, the error code is returned by calling |error_callback|. |
49 int InitiateOpen(const net::CompletionCallback& error_callback, | 53 int InitiateOpen(const net::CompletionCallback& error_callback, |
50 const base::Closure& main_operation); | 54 const base::Closure& main_operation); |
51 void DidOpen(const net::CompletionCallback& error_callback, | 55 void DidOpen(const net::CompletionCallback& error_callback, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 scoped_ptr<net::FileStream> stream_impl_; | 92 scoped_ptr<net::FileStream> stream_impl_; |
89 net::CompletionCallback cancel_callback_; | 93 net::CompletionCallback cancel_callback_; |
90 | 94 |
91 base::WeakPtrFactory<LocalFileStreamWriter> weak_factory_; | 95 base::WeakPtrFactory<LocalFileStreamWriter> weak_factory_; |
92 DISALLOW_COPY_AND_ASSIGN(LocalFileStreamWriter); | 96 DISALLOW_COPY_AND_ASSIGN(LocalFileStreamWriter); |
93 }; | 97 }; |
94 | 98 |
95 } // namespace fileapi | 99 } // namespace fileapi |
96 | 100 |
97 #endif // WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ | 101 #endif // WEBKIT_BROWSER_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ |
OLD | NEW |