OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_FILE_STREAM_R EADER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_FILE_STREAM_R EADER_H_ | |
7 | |
8 #include <memory> | |
9 #include <vector> | |
10 | |
11 #include "base/callback.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "storage/browser/fileapi/file_stream_reader.h" | |
15 | |
16 class GURL; | |
17 | |
18 namespace storage { | |
19 | |
20 class FileSystemURL; | |
21 | |
22 } // namespace storage | |
23 | |
24 namespace arc { | |
25 | |
26 class ArcDocumentsProviderRootMap; | |
27 | |
28 // FileStreamReader implementation for ARC documents provider file system. | |
29 // It actually delegates operations to ArcContentFileSystemFileStreamReader. | |
30 class ArcDocumentsProviderFileStreamReader : public storage::FileStreamReader { | |
hashimoto
2017/01/06 04:16:51
It'd be nice to have a test for this class (not ne
Shuhei Takahashi
2017/01/06 05:38:10
Sure, added a TODO.
| |
31 public: | |
32 // |roots| can be released soon after the constructor returns. | |
33 ArcDocumentsProviderFileStreamReader(const storage::FileSystemURL& url, | |
34 int64_t offset, | |
35 ArcDocumentsProviderRootMap* roots); | |
36 ~ArcDocumentsProviderFileStreamReader() override; | |
37 | |
38 // storage::FileStreamReader override: | |
39 int Read(net::IOBuffer* buffer, | |
40 int buffer_length, | |
41 const net::CompletionCallback& callback) override; | |
42 int64_t GetLength(const net::Int64CompletionCallback& callback) override; | |
43 | |
44 private: | |
45 void OnResolveToContentUrl(const GURL& content_url); | |
46 void RunPendingRead(scoped_refptr<net::IOBuffer> buffer, | |
47 int buffer_length, | |
48 const net::CompletionCallback& callback); | |
49 void RunPendingGetLength(const net::Int64CompletionCallback& callback); | |
50 | |
51 const int64_t offset_; | |
52 bool content_url_resolved_; | |
53 std::unique_ptr<storage::FileStreamReader> underlying_reader_; | |
54 std::vector<base::Closure> pending_operations_; | |
55 | |
56 base::WeakPtrFactory<ArcDocumentsProviderFileStreamReader> weak_ptr_factory_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderFileStreamReader); | |
59 }; | |
60 | |
61 } // namespace arc | |
62 | |
63 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_FILE_STREA M_READER_H_ | |
OLD | NEW |