| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 FakeFileSystemInstance(); | 102 FakeFileSystemInstance(); |
| 103 ~FakeFileSystemInstance() override; | 103 ~FakeFileSystemInstance() override; |
| 104 | 104 |
| 105 // Adds a file accessible by content URL based methods. | 105 // Adds a file accessible by content URL based methods. |
| 106 void AddFile(const File& file); | 106 void AddFile(const File& file); |
| 107 | 107 |
| 108 // Adds a document accessible by document provider based methods. | 108 // Adds a document accessible by document provider based methods. |
| 109 void AddDocument(const Document& document); | 109 void AddDocument(const Document& document); |
| 110 | 110 |
| 111 // mojom::FileSystemInstance: | 111 // mojom::FileSystemInstance: |
| 112 void AddWatcher(const std::string& authority, |
| 113 const std::string& document_id, |
| 114 const AddWatcherCallback& callback) override; |
| 112 void GetChildDocuments(const std::string& authority, | 115 void GetChildDocuments(const std::string& authority, |
| 113 const std::string& document_id, | 116 const std::string& document_id, |
| 114 const GetChildDocumentsCallback& callback) override; | 117 const GetChildDocumentsCallback& callback) override; |
| 115 void GetDocument(const std::string& authority, | 118 void GetDocument(const std::string& authority, |
| 116 const std::string& document_id, | 119 const std::string& document_id, |
| 117 const GetDocumentCallback& callback) override; | 120 const GetDocumentCallback& callback) override; |
| 118 void GetFileSize(const std::string& url, | 121 void GetFileSize(const std::string& url, |
| 119 const GetFileSizeCallback& callback) override; | 122 const GetFileSizeCallback& callback) override; |
| 123 void Init(mojom::FileSystemHostPtr host) override; |
| 120 void OpenFileToRead(const std::string& url, | 124 void OpenFileToRead(const std::string& url, |
| 121 const OpenFileToReadCallback& callback) override; | 125 const OpenFileToReadCallback& callback) override; |
| 126 void RemoveWatcher(int64_t watcher_id, |
| 127 const RemoveWatcherCallback& callback) override; |
| 122 void RequestMediaScan(const std::vector<std::string>& paths) override; | 128 void RequestMediaScan(const std::vector<std::string>& paths) override; |
| 123 | 129 |
| 124 private: | 130 private: |
| 125 // A pair of an authority and a document ID which identifies the location | 131 // A pair of an authority and a document ID which identifies the location |
| 126 // of a document in documents providers. | 132 // of a document in documents providers. |
| 127 using DocumentKey = std::pair<std::string, std::string>; | 133 using DocumentKey = std::pair<std::string, std::string>; |
| 128 | 134 |
| 129 base::ThreadChecker thread_checker_; | 135 base::ThreadChecker thread_checker_; |
| 130 | 136 |
| 131 base::ScopedTempDir temp_dir_; | 137 base::ScopedTempDir temp_dir_; |
| 132 | 138 |
| 133 // Mapping from a content URL to a file. | 139 // Mapping from a content URL to a file. |
| 134 std::map<std::string, File> files_; | 140 std::map<std::string, File> files_; |
| 135 | 141 |
| 136 // Mapping from a document key to a document. | 142 // Mapping from a document key to a document. |
| 137 std::map<DocumentKey, Document> documents_; | 143 std::map<DocumentKey, Document> documents_; |
| 138 | 144 |
| 139 // Mapping from a document key to its child documents. | 145 // Mapping from a document key to its child documents. |
| 140 std::map<DocumentKey, std::vector<DocumentKey>> child_documents_; | 146 std::map<DocumentKey, std::vector<DocumentKey>> child_documents_; |
| 141 | 147 |
| 142 DISALLOW_COPY_AND_ASSIGN(FakeFileSystemInstance); | 148 DISALLOW_COPY_AND_ASSIGN(FakeFileSystemInstance); |
| 143 }; | 149 }; |
| 144 | 150 |
| 145 } // namespace arc | 151 } // namespace arc |
| 146 | 152 |
| 147 #endif // COMPONENTS_ARC_TEST_FAKE_FILE_SYSTEM_INSTANCE_H_ | 153 #endif // COMPONENTS_ARC_TEST_FAKE_FILE_SYSTEM_INSTANCE_H_ |
| OLD | NEW |