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 // TODO(crbug.com/678886): Write unit tests. |
| 31 class ArcDocumentsProviderFileStreamReader : public storage::FileStreamReader { |
| 32 public: |
| 33 // |roots| can be released soon after the constructor returns. |
| 34 ArcDocumentsProviderFileStreamReader(const storage::FileSystemURL& url, |
| 35 int64_t offset, |
| 36 ArcDocumentsProviderRootMap* roots); |
| 37 ~ArcDocumentsProviderFileStreamReader() override; |
| 38 |
| 39 // storage::FileStreamReader override: |
| 40 int Read(net::IOBuffer* buffer, |
| 41 int buffer_length, |
| 42 const net::CompletionCallback& callback) override; |
| 43 int64_t GetLength(const net::Int64CompletionCallback& callback) override; |
| 44 |
| 45 private: |
| 46 void OnResolveToContentUrl(const GURL& content_url); |
| 47 void RunPendingRead(scoped_refptr<net::IOBuffer> buffer, |
| 48 int buffer_length, |
| 49 const net::CompletionCallback& callback); |
| 50 void RunPendingGetLength(const net::Int64CompletionCallback& callback); |
| 51 |
| 52 const int64_t offset_; |
| 53 bool content_url_resolved_; |
| 54 std::unique_ptr<storage::FileStreamReader> underlying_reader_; |
| 55 std::vector<base::Closure> pending_operations_; |
| 56 |
| 57 base::WeakPtrFactory<ArcDocumentsProviderFileStreamReader> weak_ptr_factory_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderFileStreamReader); |
| 60 }; |
| 61 |
| 62 } // namespace arc |
| 63 |
| 64 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_FILE_STREA
M_READER_H_ |
OLD | NEW |