| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "gin/modules/module_registry.h" | 5 #include "gin/modules/module_registry.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "gin/modules/module_registry_observer.h" | 9 #include "gin/modules/module_registry_observer.h" |
| 10 #include "gin/modules/module_runner_delegate.h" | 10 #include "gin/modules/module_runner_delegate.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 base::MessageLoop message_loop; | 28 base::MessageLoop message_loop; |
| 29 ModuleRunnerDelegate delegate; | 29 ModuleRunnerDelegate delegate; |
| 30 scoped_ptr<ShellRunner> runner; | 30 scoped_ptr<ShellRunner> runner; |
| 31 Runner::Scope scope; | 31 Runner::Scope scope; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 class ModuleRegistryObserverImpl : public ModuleRegistryObserver { | 34 class ModuleRegistryObserverImpl : public ModuleRegistryObserver { |
| 35 public: | 35 public: |
| 36 ModuleRegistryObserverImpl() : did_add_count_(0) {} | 36 ModuleRegistryObserverImpl() : did_add_count_(0) {} |
| 37 | 37 |
| 38 virtual void OnDidAddPendingModule( | 38 void OnDidAddPendingModule( |
| 39 const std::string& id, | 39 const std::string& id, |
| 40 const std::vector<std::string>& dependencies) override { | 40 const std::vector<std::string>& dependencies) override { |
| 41 did_add_count_++; | 41 did_add_count_++; |
| 42 id_ = id; | 42 id_ = id; |
| 43 dependencies_ = dependencies; | 43 dependencies_ = dependencies; |
| 44 } | 44 } |
| 45 | 45 |
| 46 int did_add_count() { return did_add_count_; } | 46 int did_add_count() { return did_add_count_; } |
| 47 const std::string& id() const { return id_; } | 47 const std::string& id() const { return id_; } |
| 48 const std::vector<std::string>& dependencies() const { return dependencies_; } | 48 const std::vector<std::string>& dependencies() const { return dependencies_; } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 for (int i = 0; i < 3; i++) { | 127 for (int i = 0; i < 3; i++) { |
| 128 ModuleRegistry::From(helper.runner->GetContextHolder()->context()) | 128 ModuleRegistry::From(helper.runner->GetContextHolder()->context()) |
| 129 ->LoadModule(instance_->isolate(), "one", callback); | 129 ->LoadModule(instance_->isolate(), "one", callback); |
| 130 } | 130 } |
| 131 EXPECT_EQ(0, counter); | 131 EXPECT_EQ(0, counter); |
| 132 helper.runner->Run(source, "script"); | 132 helper.runner->Run(source, "script"); |
| 133 EXPECT_EQ(3, counter); | 133 EXPECT_EQ(3, counter); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace gin | 136 } // namespace gin |
| OLD | NEW |