| 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_MODULE_RUNNER_DELEGATE_H_ | 5 #ifndef GIN_MODULES_MODULE_RUNNER_DELEGATE_H_ |
| 6 #define GIN_MODULES_MODULE_RUNNER_DELEGATE_H_ | 6 #define GIN_MODULES_MODULE_RUNNER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "gin/modules/file_module_provider.h" | 11 #include "gin/modules/file_module_provider.h" |
| 12 #include "gin/runner.h" | 12 #include "gin/runner.h" |
| 13 | 13 |
| 14 namespace gin { | 14 namespace gin { |
| 15 | 15 |
| 16 typedef v8::Local<v8::ObjectTemplate> (*ModuleTemplateGetter)( | 16 typedef v8::Local<v8::ObjectTemplate> (*ModuleTemplateGetter)( |
| 17 v8::Isolate* isolate); | 17 v8::Isolate* isolate); |
| 18 | 18 |
| 19 class ModuleRunnerDelegate : public RunnerDelegate { | 19 class ModuleRunnerDelegate : public RunnerDelegate { |
| 20 public: | 20 public: |
| 21 explicit ModuleRunnerDelegate( | 21 explicit ModuleRunnerDelegate( |
| 22 const std::vector<base::FilePath>& search_paths); | 22 const std::vector<base::FilePath>& search_paths); |
| 23 virtual ~ModuleRunnerDelegate(); | 23 virtual ~ModuleRunnerDelegate(); |
| 24 | 24 |
| 25 void AddBuiltinModule(const std::string& id, ModuleTemplateGetter templ); | 25 void AddBuiltinModule(const std::string& id, ModuleTemplateGetter templ); |
| 26 | 26 |
| 27 protected: |
| 28 void AttemptToLoadMoreModules(Runner* runner); |
| 29 |
| 27 private: | 30 private: |
| 28 typedef std::map<std::string, ModuleTemplateGetter> BuiltinModuleMap; | 31 typedef std::map<std::string, ModuleTemplateGetter> BuiltinModuleMap; |
| 29 | 32 |
| 30 // From RunnerDelegate: | 33 // From RunnerDelegate: |
| 31 virtual v8::Handle<v8::ObjectTemplate> GetGlobalTemplate( | 34 virtual v8::Handle<v8::ObjectTemplate> GetGlobalTemplate( |
| 32 Runner* runner) OVERRIDE; | 35 Runner* runner) OVERRIDE; |
| 33 virtual void DidCreateContext(Runner* runner) OVERRIDE; | 36 virtual void DidCreateContext(Runner* runner) OVERRIDE; |
| 34 virtual void DidRunScript(Runner* runner) OVERRIDE; | 37 virtual void DidRunScript(Runner* runner) OVERRIDE; |
| 35 | 38 |
| 36 BuiltinModuleMap builtin_modules_; | 39 BuiltinModuleMap builtin_modules_; |
| 37 FileModuleProvider module_provider_; | 40 FileModuleProvider module_provider_; |
| 38 | 41 |
| 39 DISALLOW_COPY_AND_ASSIGN(ModuleRunnerDelegate); | 42 DISALLOW_COPY_AND_ASSIGN(ModuleRunnerDelegate); |
| 40 }; | 43 }; |
| 41 | 44 |
| 42 } // namespace gin | 45 } // namespace gin |
| 43 | 46 |
| 44 #endif // GIN_MODULES_MODULE_RUNNER_DELEGATE_H_ | 47 #endif // GIN_MODULES_MODULE_RUNNER_DELEGATE_H_ |
| OLD | NEW |