OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_ARC_TEST_FAKE_FILE_SYSTEM_INSTANCE_H_ | 5 #ifndef COMPONENTS_ARC_TEST_FAKE_FILE_SYSTEM_INSTANCE_H_ |
6 #define COMPONENTS_ARC_TEST_FAKE_FILE_SYSTEM_INSTANCE_H_ | 6 #define COMPONENTS_ARC_TEST_FAKE_FILE_SYSTEM_INSTANCE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace arc { | 22 namespace arc { |
23 | 23 |
24 // Fake implementation to operate on documents in memory. | 24 // Fake implementation to operate on documents in memory. |
25 // | 25 // |
26 // ArcFileSystemOperationRunner provides two types of methods: content URL | 26 // ArcFileSystemOperationRunner provides two types of methods: content URL |
27 // based and documents provider based. According to backend type, you need | 27 // based and documents provider based. According to backend type, you need |
28 // to setup the fake with different functions. | 28 // to setup the fake with different functions. |
29 // | 29 // |
30 // Content URL based functions are: | 30 // Content URL based functions are: |
31 // - GetFileSize() | 31 // - GetFileSize() |
| 32 // - GetMimeType() |
32 // - OpenFileToRead() | 33 // - OpenFileToRead() |
33 // Fake files for those functions can be set up by AddFile(). | 34 // Fake files for those functions can be set up by AddFile(). |
34 // | 35 // |
35 // Documents provider based functions are: | 36 // Documents provider based functions are: |
36 // - GetDocument() | 37 // - GetDocument() |
37 // - GetChildDocuments() | 38 // - GetChildDocuments() |
38 // Fake documents for those functions can be set up by AddDocument(). | 39 // Fake documents for those functions can be set up by AddDocument(). |
39 // | 40 // |
40 // Notes: | 41 // Notes: |
41 // - GetChildDocuments() returns child documents in the same order as they were | 42 // - GetChildDocuments() returns child documents in the same order as they were |
42 // added with AddDocument(). | 43 // added with AddDocument(). |
43 // - All member functions must be called on the same thread. | 44 // - All member functions must be called on the same thread. |
44 class FakeFileSystemInstance : public mojom::FileSystemInstance { | 45 class FakeFileSystemInstance : public mojom::FileSystemInstance { |
45 public: | 46 public: |
46 // Specification of a fake file available to content URL based methods. | 47 // Specification of a fake file available to content URL based methods. |
47 struct File { | 48 struct File { |
48 enum class Seekable { | 49 enum class Seekable { |
49 NO, | 50 NO, |
50 YES, | 51 YES, |
51 }; | 52 }; |
52 | 53 |
53 // Content URL of a file. | 54 // Content URL of a file. |
54 std::string url; | 55 std::string url; |
55 | 56 |
56 // The content of a file. | 57 // The content of a file. |
57 std::string content; | 58 std::string content; |
58 | 59 |
| 60 // The MIME type of a file. |
| 61 std::string mime_type; |
| 62 |
59 // Whether this file is seekable or not. | 63 // Whether this file is seekable or not. |
60 Seekable seekable; | 64 Seekable seekable; |
61 | 65 |
62 File(const std::string& url, const std::string& content, Seekable seekable); | 66 File(const std::string& url, |
| 67 const std::string& content, |
| 68 const std::string& mime_type, |
| 69 Seekable seekable); |
63 File(const File& that); | 70 File(const File& that); |
64 ~File(); | 71 ~File(); |
65 }; | 72 }; |
66 | 73 |
67 // Specification of a fake document available to documents provider based | 74 // Specification of a fake document available to documents provider based |
68 // methods. | 75 // methods. |
69 struct Document { | 76 struct Document { |
70 // Authority. | 77 // Authority. |
71 std::string authority; | 78 std::string authority; |
72 | 79 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 const std::string& document_id, | 130 const std::string& document_id, |
124 const AddWatcherCallback& callback) override; | 131 const AddWatcherCallback& callback) override; |
125 void GetChildDocuments(const std::string& authority, | 132 void GetChildDocuments(const std::string& authority, |
126 const std::string& document_id, | 133 const std::string& document_id, |
127 const GetChildDocumentsCallback& callback) override; | 134 const GetChildDocumentsCallback& callback) override; |
128 void GetDocument(const std::string& authority, | 135 void GetDocument(const std::string& authority, |
129 const std::string& document_id, | 136 const std::string& document_id, |
130 const GetDocumentCallback& callback) override; | 137 const GetDocumentCallback& callback) override; |
131 void GetFileSize(const std::string& url, | 138 void GetFileSize(const std::string& url, |
132 const GetFileSizeCallback& callback) override; | 139 const GetFileSizeCallback& callback) override; |
| 140 void GetMimeType(const std::string& url, |
| 141 const GetMimeTypeCallback& callback) override; |
133 void Init(mojom::FileSystemHostPtr host) override; | 142 void Init(mojom::FileSystemHostPtr host) override; |
134 void OpenFileToRead(const std::string& url, | 143 void OpenFileToRead(const std::string& url, |
135 const OpenFileToReadCallback& callback) override; | 144 const OpenFileToReadCallback& callback) override; |
136 void RemoveWatcher(int64_t watcher_id, | 145 void RemoveWatcher(int64_t watcher_id, |
137 const RemoveWatcherCallback& callback) override; | 146 const RemoveWatcherCallback& callback) override; |
138 void RequestMediaScan(const std::vector<std::string>& paths) override; | 147 void RequestMediaScan(const std::vector<std::string>& paths) override; |
139 | 148 |
140 private: | 149 private: |
141 // A pair of an authority and a document ID which identifies the location | 150 // A pair of an authority and a document ID which identifies the location |
142 // of a document in documents providers. | 151 // of a document in documents providers. |
(...skipping 21 matching lines...) Expand all Loading... |
164 std::map<int64_t, DocumentKey> watcher_to_document_; | 173 std::map<int64_t, DocumentKey> watcher_to_document_; |
165 | 174 |
166 int64_t next_watcher_id_ = 1; | 175 int64_t next_watcher_id_ = 1; |
167 | 176 |
168 DISALLOW_COPY_AND_ASSIGN(FakeFileSystemInstance); | 177 DISALLOW_COPY_AND_ASSIGN(FakeFileSystemInstance); |
169 }; | 178 }; |
170 | 179 |
171 } // namespace arc | 180 } // namespace arc |
172 | 181 |
173 #endif // COMPONENTS_ARC_TEST_FAKE_FILE_SYSTEM_INSTANCE_H_ | 182 #endif // COMPONENTS_ARC_TEST_FAKE_FILE_SYSTEM_INSTANCE_H_ |
OLD | NEW |