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_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READER_
H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READER_
H_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READER_
H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READER_
H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include <stdint.h> |
| 9 |
9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
13 #include "storage/browser/fileapi/file_stream_reader.h" | 15 #include "storage/browser/fileapi/file_stream_reader.h" |
14 #include "storage/browser/fileapi/file_system_url.h" | 16 #include "storage/browser/fileapi/file_system_url.h" |
15 | 17 |
16 namespace chromeos { | 18 namespace chromeos { |
17 namespace file_system_provider { | 19 namespace file_system_provider { |
18 | 20 |
19 struct EntryMetadata; | 21 struct EntryMetadata; |
20 class ProvidedFileSystemInterface; | 22 class ProvidedFileSystemInterface; |
21 | 23 |
22 // Implements a streamed file reader. It is lazily initialized by the first call | 24 // Implements a streamed file reader. It is lazily initialized by the first call |
23 // to Read(). | 25 // to Read(). |
24 class FileStreamReader : public storage::FileStreamReader { | 26 class FileStreamReader : public storage::FileStreamReader { |
25 public: | 27 public: |
26 typedef base::Callback< | 28 typedef base::Callback< |
27 void(base::WeakPtr<ProvidedFileSystemInterface> file_system, | 29 void(base::WeakPtr<ProvidedFileSystemInterface> file_system, |
28 const base::FilePath& file_path, | 30 const base::FilePath& file_path, |
29 int file_handle, | 31 int file_handle, |
30 base::File::Error result)> OpenFileCompletedCallback; | 32 base::File::Error result)> OpenFileCompletedCallback; |
31 | 33 |
32 FileStreamReader(storage::FileSystemContext* context, | 34 FileStreamReader(storage::FileSystemContext* context, |
33 const storage::FileSystemURL& url, | 35 const storage::FileSystemURL& url, |
34 int64 initial_offset, | 36 int64_t initial_offset, |
35 const base::Time& expected_modification_time); | 37 const base::Time& expected_modification_time); |
36 | 38 |
37 ~FileStreamReader() override; | 39 ~FileStreamReader() override; |
38 | 40 |
39 // storage::FileStreamReader overrides. | 41 // storage::FileStreamReader overrides. |
40 int Read(net::IOBuffer* buf, | 42 int Read(net::IOBuffer* buf, |
41 int buf_len, | 43 int buf_len, |
42 const net::CompletionCallback& callback) override; | 44 const net::CompletionCallback& callback) override; |
43 int64 GetLength(const net::Int64CompletionCallback& callback) override; | 45 int64_t GetLength(const net::Int64CompletionCallback& callback) override; |
44 | 46 |
45 private: | 47 private: |
46 // Helper class for executing operations on the provided file system. All | 48 // Helper class for executing operations on the provided file system. All |
47 // of its methods must be called on UI thread. Callbacks are called on IO | 49 // of its methods must be called on UI thread. Callbacks are called on IO |
48 // thread. | 50 // thread. |
49 class OperationRunner; | 51 class OperationRunner; |
50 | 52 |
51 // State of the file stream reader. | 53 // State of the file stream reader. |
52 enum State { NOT_INITIALIZED, INITIALIZING, INITIALIZED, FAILED }; | 54 enum State { NOT_INITIALIZED, INITIALIZING, INITIALIZED, FAILED }; |
53 | 55 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 92 |
91 // Same as Read(), but called after initializing is completed. | 93 // Same as Read(), but called after initializing is completed. |
92 void ReadAfterInitialized(scoped_refptr<net::IOBuffer> buffer, | 94 void ReadAfterInitialized(scoped_refptr<net::IOBuffer> buffer, |
93 int buffer_length, | 95 int buffer_length, |
94 const net::CompletionCallback& callback); | 96 const net::CompletionCallback& callback); |
95 | 97 |
96 // Same as GetLength(), but called after initializing is completed. | 98 // Same as GetLength(), but called after initializing is completed. |
97 void GetLengthAfterInitialized(const net::Int64CompletionCallback& callback); | 99 void GetLengthAfterInitialized(const net::Int64CompletionCallback& callback); |
98 | 100 |
99 storage::FileSystemURL url_; | 101 storage::FileSystemURL url_; |
100 int64 current_offset_; | 102 int64_t current_offset_; |
101 int64 current_length_; | 103 int64_t current_length_; |
102 base::Time expected_modification_time_; | 104 base::Time expected_modification_time_; |
103 scoped_refptr<OperationRunner> runner_; | 105 scoped_refptr<OperationRunner> runner_; |
104 State state_; | 106 State state_; |
105 | 107 |
106 base::WeakPtrFactory<FileStreamReader> weak_ptr_factory_; | 108 base::WeakPtrFactory<FileStreamReader> weak_ptr_factory_; |
107 DISALLOW_COPY_AND_ASSIGN(FileStreamReader); | 109 DISALLOW_COPY_AND_ASSIGN(FileStreamReader); |
108 }; | 110 }; |
109 | 111 |
110 } // namespace file_system_provider | 112 } // namespace file_system_provider |
111 } // namespace chromeos | 113 } // namespace chromeos |
112 | 114 |
113 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READ
ER_H_ | 115 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READ
ER_H_ |
OLD | NEW |