OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 GIN_MODULES_FILE_MODULE_PROVIDER_H_ | 5 #ifndef GIN_MODULES_FILE_MODULE_PROVIDER_H_ |
6 #define GIN_MODULES_FILE_MODULE_PROVIDER_H_ | 6 #define GIN_MODULES_FILE_MODULE_PROVIDER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "gin/gin_export.h" |
13 #include "gin/runner.h" | 14 #include "gin/runner.h" |
14 | 15 |
15 namespace gin { | 16 namespace gin { |
16 | 17 |
17 // FileModuleProvider knows how to load AMD modules off disk. It searches for | 18 // FileModuleProvider knows how to load AMD modules off disk. It searches for |
18 // modules in the directories indiciated by |search_paths|. Although we still | 19 // modules in the directories indiciated by |search_paths|. Although we still |
19 // read from the file system on the main thread, we'll eventually want to move | 20 // read from the file system on the main thread, we'll eventually want to move |
20 // the reads to a background thread. | 21 // the reads to a background thread. |
21 class FileModuleProvider { | 22 class GIN_EXPORT FileModuleProvider { |
22 public: | 23 public: |
23 explicit FileModuleProvider( | 24 explicit FileModuleProvider( |
24 const std::vector<base::FilePath>& search_paths); | 25 const std::vector<base::FilePath>& search_paths); |
25 ~FileModuleProvider(); | 26 ~FileModuleProvider(); |
26 | 27 |
27 // Searches for modules with |ids| in the file system. If found, the modules | 28 // Searches for modules with |ids| in the file system. If found, the modules |
28 // will be executed asynchronously by |runner|. | 29 // will be executed asynchronously by |runner|. |
29 void AttempToLoadModules(Runner* runner, const std::set<std::string>& ids); | 30 void AttempToLoadModules(Runner* runner, const std::set<std::string>& ids); |
30 | 31 |
31 private: | 32 private: |
32 std::vector<base::FilePath> search_paths_; | 33 std::vector<base::FilePath> search_paths_; |
33 | 34 |
34 // We'll only search for a given module once. We remember the set of modules | 35 // We'll only search for a given module once. We remember the set of modules |
35 // we've already looked for in |attempted_ids_|. | 36 // we've already looked for in |attempted_ids_|. |
36 std::set<std::string> attempted_ids_; | 37 std::set<std::string> attempted_ids_; |
37 | 38 |
38 DISALLOW_COPY_AND_ASSIGN(FileModuleProvider); | 39 DISALLOW_COPY_AND_ASSIGN(FileModuleProvider); |
39 }; | 40 }; |
40 | 41 |
41 } // namespace gin | 42 } // namespace gin |
42 | 43 |
43 #endif // GIN_MODULES_FILE_MODULE_PROVIDER_H_ | 44 #endif // GIN_MODULES_FILE_MODULE_PROVIDER_H_ |
OLD | NEW |