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 "extensions/renderer/module_system.h" | 5 #include "extensions/renderer/module_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | |
9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
12 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
13 #include "content/public/renderer/render_frame.h" | 14 #include "content/public/renderer/render_frame.h" |
14 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
15 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
16 #include "extensions/common/extensions_client.h" | 17 #include "extensions/common/extensions_client.h" |
17 #include "extensions/renderer/console.h" | 18 #include "extensions/renderer/console.h" |
18 #include "extensions/renderer/safe_builtins.h" | 19 #include "extensions/renderer/safe_builtins.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 global->SetHiddenValue(v8::String::NewFromUtf8(isolate, kModuleSystem), | 145 global->SetHiddenValue(v8::String::NewFromUtf8(isolate, kModuleSystem), |
145 v8::External::New(isolate, this)); | 146 v8::External::New(isolate, this)); |
146 | 147 |
147 gin::ModuleRegistry::From(context->v8_context())->AddObserver(this); | 148 gin::ModuleRegistry::From(context->v8_context())->AddObserver(this); |
148 if (context_->GetRenderFrame()) { | 149 if (context_->GetRenderFrame()) { |
149 context_->GetRenderFrame()->EnsureMojoBuiltinsAreAvailable( | 150 context_->GetRenderFrame()->EnsureMojoBuiltinsAreAvailable( |
150 context->isolate(), context->v8_context()); | 151 context->isolate(), context->v8_context()); |
151 } | 152 } |
152 } | 153 } |
153 | 154 |
154 ModuleSystem::~ModuleSystem() { Invalidate(); } | 155 ModuleSystem::~ModuleSystem() { |
156 } | |
155 | 157 |
156 void ModuleSystem::Invalidate() { | 158 void ModuleSystem::Invalidate() { |
157 if (!is_valid()) | 159 CHECK(is_valid()); |
Devlin
2015/04/10 18:10:40
It's a little odd that each subclass is expected t
not at google - send to devlin
2015/04/10 18:39:01
Done.
| |
158 return; | |
159 | 160 |
160 // Clear the module system properties from the global context. It's polite, | 161 // Clear the module system properties from the global context. It's polite, |
161 // and we use this as a signal in lazy handlers that we no longer exist. | 162 // and we use this as a signal in lazy handlers that we no longer exist. |
162 { | 163 { |
163 v8::HandleScope scope(GetIsolate()); | 164 v8::HandleScope scope(GetIsolate()); |
164 v8::Handle<v8::Object> global = context()->v8_context()->Global(); | 165 v8::Handle<v8::Object> global = context()->v8_context()->Global(); |
165 global->DeleteHiddenValue( | 166 global->DeleteHiddenValue( |
166 v8::String::NewFromUtf8(GetIsolate(), kModulesField)); | 167 v8::String::NewFromUtf8(GetIsolate(), kModulesField)); |
167 global->DeleteHiddenValue( | 168 global->DeleteHiddenValue( |
168 v8::String::NewFromUtf8(GetIsolate(), kModuleSystem)); | 169 v8::String::NewFromUtf8(GetIsolate(), kModuleSystem)); |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 v8::Handle<v8::Value> value) { | 680 v8::Handle<v8::Value> value) { |
680 if (!is_valid()) | 681 if (!is_valid()) |
681 return; | 682 return; |
682 v8::HandleScope handle_scope(GetIsolate()); | 683 v8::HandleScope handle_scope(GetIsolate()); |
683 v8::Handle<v8::Promise::Resolver> resolver_local( | 684 v8::Handle<v8::Promise::Resolver> resolver_local( |
684 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); | 685 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); |
685 resolver_local->Resolve(value); | 686 resolver_local->Resolve(value); |
686 } | 687 } |
687 | 688 |
688 } // namespace extensions | 689 } // namespace extensions |
OLD | NEW |