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