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 SERVICES_CATALOG_PUBLIC_CPP_RESOURCE_LOADER_H_ |
| 6 #define SERVICES_CATALOG_PUBLIC_CPP_RESOURCE_LOADER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 #include <set> |
| 11 #include <string> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "components/filesystem/public/interfaces/directory.mojom.h" |
| 15 |
| 16 namespace base { |
| 17 class File; |
| 18 } |
| 19 |
| 20 namespace catalog { |
| 21 |
| 22 // ResourceLoader asks the catalog (synchronously) to open the provided paths |
| 23 // and return the file handles. Use TakeFile() to retrieve a base::File to use |
| 24 // in client code. |
| 25 class ResourceLoader { |
| 26 public: |
| 27 ResourceLoader(); |
| 28 ~ResourceLoader(); |
| 29 |
| 30 // (Synchronously) opens all of the files in |paths| for reading. Use |
| 31 // TakeFile() subsequently to obtain base::Files to use. Returns true if the |
| 32 // sync operation completed, false if it did not. |
| 33 bool OpenFiles(filesystem::DirectoryPtr directory, |
| 34 const std::set<std::string>& paths); |
| 35 |
| 36 // Releases and returns the file wrapping the handle. |
| 37 base::File TakeFile(const std::string& path); |
| 38 |
| 39 private: |
| 40 using ResourceMap = std::map<std::string, std::unique_ptr<base::File>>; |
| 41 |
| 42 ResourceMap resource_map_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); |
| 45 }; |
| 46 |
| 47 } // namespace |
| 48 |
| 49 #endif // SERVICES_CATALOG_PUBLIC_CPP_RESOURCE_LOADER_H_ |
OLD | NEW |