Retry aa3219ce27ef5471c19670fe5145b136925cbc89:
[chromium-blink-merge.git] / gin / modules / file_module_provider.h
blobdd75a0feaf1ef2d7e0031533c15ae3e7cd0928a1
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.
5 #ifndef GIN_MODULES_FILE_MODULE_PROVIDER_H_
6 #define GIN_MODULES_FILE_MODULE_PROVIDER_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/files/file_path.h"
13 #include "gin/gin_export.h"
14 #include "gin/runner.h"
16 namespace gin {
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.
22 class GIN_EXPORT FileModuleProvider {
23 public:
24 explicit FileModuleProvider(
25 const std::vector<base::FilePath>& search_paths);
26 ~FileModuleProvider();
28 // Searches for modules with |ids| in the file system. If found, the modules
29 // will be executed asynchronously by |runner|.
30 void AttempToLoadModules(Runner* runner, const std::set<std::string>& ids);
32 private:
33 std::vector<base::FilePath> search_paths_;
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_|.
37 std::set<std::string> attempted_ids_;
39 DISALLOW_COPY_AND_ASSIGN(FileModuleProvider);
42 } // namespace gin
44 #endif // GIN_MODULES_FILE_MODULE_PROVIDER_H_