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_BLOB_LOCAL_FILE_STREAM_READER_H_ | 5 #ifndef WEBKIT_BROWSER_BLOB_LOCAL_FILE_STREAM_READER_H_ |
6 #define WEBKIT_BROWSER_BLOB_LOCAL_FILE_STREAM_READER_H_ | 6 #define WEBKIT_BROWSER_BLOB_LOCAL_FILE_STREAM_READER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.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/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "webkit/browser/blob/file_stream_reader.h" | 14 #include "storage/browser/blob/file_stream_reader.h" |
15 #include "webkit/browser/webkit_storage_browser_export.h" | 15 #include "storage/common/storage_export.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class TaskRunner; | 18 class TaskRunner; |
19 } | 19 } |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 class LocalFileStreamReaderTest; | 22 class LocalFileStreamReaderTest; |
23 } | 23 } |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 class FileStream; | 26 class FileStream; |
27 } | 27 } |
28 | 28 |
29 namespace webkit_blob { | 29 namespace storage { |
30 | 30 |
31 // A thin wrapper of net::FileStream with range support for sliced file | 31 // A thin wrapper of net::FileStream with range support for sliced file |
32 // handling. | 32 // handling. |
33 class WEBKIT_STORAGE_BROWSER_EXPORT LocalFileStreamReader | 33 class STORAGE_EXPORT LocalFileStreamReader |
34 : public NON_EXPORTED_BASE(FileStreamReader) { | 34 : public NON_EXPORTED_BASE(FileStreamReader) { |
35 public: | 35 public: |
36 virtual ~LocalFileStreamReader(); | 36 virtual ~LocalFileStreamReader(); |
37 | 37 |
38 // FileStreamReader overrides. | 38 // FileStreamReader overrides. |
39 virtual int Read(net::IOBuffer* buf, int buf_len, | 39 virtual int Read(net::IOBuffer* buf, |
| 40 int buf_len, |
40 const net::CompletionCallback& callback) OVERRIDE; | 41 const net::CompletionCallback& callback) OVERRIDE; |
41 virtual int64 GetLength( | 42 virtual int64 GetLength( |
42 const net::Int64CompletionCallback& callback) OVERRIDE; | 43 const net::Int64CompletionCallback& callback) OVERRIDE; |
43 | 44 |
44 private: | 45 private: |
45 friend class FileStreamReader; | 46 friend class FileStreamReader; |
46 friend class content::LocalFileStreamReaderTest; | 47 friend class content::LocalFileStreamReaderTest; |
47 | 48 |
48 LocalFileStreamReader(base::TaskRunner* task_runner, | 49 LocalFileStreamReader(base::TaskRunner* task_runner, |
49 const base::FilePath& file_path, | 50 const base::FilePath& file_path, |
50 int64 initial_offset, | 51 int64 initial_offset, |
51 const base::Time& expected_modification_time); | 52 const base::Time& expected_modification_time); |
52 int Open(const net::CompletionCallback& callback); | 53 int Open(const net::CompletionCallback& callback); |
53 | 54 |
54 // Callbacks that are chained from Open for Read. | 55 // Callbacks that are chained from Open for Read. |
55 void DidVerifyForOpen(const net::CompletionCallback& callback, | 56 void DidVerifyForOpen(const net::CompletionCallback& callback, |
56 int64 get_length_result); | 57 int64 get_length_result); |
57 void DidOpenFileStream(const net::CompletionCallback& callback, | 58 void DidOpenFileStream(const net::CompletionCallback& callback, int result); |
58 int result); | |
59 void DidSeekFileStream(const net::CompletionCallback& callback, | 59 void DidSeekFileStream(const net::CompletionCallback& callback, |
60 int64 seek_result); | 60 int64 seek_result); |
61 void DidOpenForRead(net::IOBuffer* buf, | 61 void DidOpenForRead(net::IOBuffer* buf, |
62 int buf_len, | 62 int buf_len, |
63 const net::CompletionCallback& callback, | 63 const net::CompletionCallback& callback, |
64 int open_result); | 64 int open_result); |
65 | 65 |
66 void DidGetFileInfoForGetLength(const net::Int64CompletionCallback& callback, | 66 void DidGetFileInfoForGetLength(const net::Int64CompletionCallback& callback, |
67 base::File::Error error, | 67 base::File::Error error, |
68 const base::File::Info& file_info); | 68 const base::File::Info& file_info); |
69 | 69 |
70 scoped_refptr<base::TaskRunner> task_runner_; | 70 scoped_refptr<base::TaskRunner> task_runner_; |
71 scoped_ptr<net::FileStream> stream_impl_; | 71 scoped_ptr<net::FileStream> stream_impl_; |
72 const base::FilePath file_path_; | 72 const base::FilePath file_path_; |
73 const int64 initial_offset_; | 73 const int64 initial_offset_; |
74 const base::Time expected_modification_time_; | 74 const base::Time expected_modification_time_; |
75 bool has_pending_open_; | 75 bool has_pending_open_; |
76 base::WeakPtrFactory<LocalFileStreamReader> weak_factory_; | 76 base::WeakPtrFactory<LocalFileStreamReader> weak_factory_; |
77 }; | 77 }; |
78 | 78 |
79 } // namespace webkit_blob | 79 } // namespace storage |
80 | 80 |
81 #endif // WEBKIT_BROWSER_BLOB_LOCAL_FILE_STREAM_READER_H_ | 81 #endif // WEBKIT_BROWSER_BLOB_LOCAL_FILE_STREAM_READER_H_ |
OLD | NEW |