| OLD | NEW | 
|   1 // Copyright 2016 the V8 project authors. All rights reserved. |   1 // Copyright 2016 the V8 project 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 "src/inspector/inspected-context.h" |   5 #include "src/inspector/inspected-context.h" | 
|   6  |   6  | 
|   7 #include "src/inspector/injected-script.h" |   7 #include "src/inspector/injected-script.h" | 
|   8 #include "src/inspector/string-util.h" |   8 #include "src/inspector/string-util.h" | 
|   9 #include "src/inspector/v8-console.h" |   9 #include "src/inspector/v8-console.h" | 
|  10 #include "src/inspector/v8-inspector-impl.h" |  10 #include "src/inspector/v8-inspector-impl.h" | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|  41       m_humanReadableName(toString16(info.humanReadableName)), |  41       m_humanReadableName(toString16(info.humanReadableName)), | 
|  42       m_auxData(toString16(info.auxData)), |  42       m_auxData(toString16(info.auxData)), | 
|  43       m_reported(false) { |  43       m_reported(false) { | 
|  44   m_context.SetWeak(&m_context, &clearContext, |  44   m_context.SetWeak(&m_context, &clearContext, | 
|  45                     v8::WeakCallbackType::kParameter); |  45                     v8::WeakCallbackType::kParameter); | 
|  46  |  46  | 
|  47   v8::Isolate* isolate = m_inspector->isolate(); |  47   v8::Isolate* isolate = m_inspector->isolate(); | 
|  48   v8::Local<v8::Object> global = info.context->Global(); |  48   v8::Local<v8::Object> global = info.context->Global(); | 
|  49   v8::Local<v8::Object> console = |  49   v8::Local<v8::Object> console = | 
|  50       V8Console::createConsole(this, info.hasMemoryOnConsole); |  50       V8Console::createConsole(this, info.hasMemoryOnConsole); | 
|  51   if (!global |  51   v8::PropertyDescriptor descriptor(console, /* writable */ true); | 
|  52            ->Set(info.context, toV8StringInternalized(isolate, "console"), |  52   descriptor.set_enumerable(false); | 
|  53                  console) |  53   descriptor.set_configurable(true); | 
 |  54   v8::Local<v8::String> consoleKey = toV8StringInternalized(isolate, "console"); | 
 |  55   if (!global->DefineProperty(info.context, consoleKey, descriptor) | 
|  54            .FromMaybe(false)) |  56            .FromMaybe(false)) | 
|  55     return; |  57     return; | 
|  56   m_console.Reset(isolate, console); |  58   m_console.Reset(isolate, console); | 
|  57   m_console.SetWeak(); |  59   m_console.SetWeak(); | 
|  58 } |  60 } | 
|  59  |  61  | 
|  60 InspectedContext::~InspectedContext() { |  62 InspectedContext::~InspectedContext() { | 
|  61   if (!m_console.IsEmpty()) { |  63   if (!m_console.IsEmpty()) { | 
|  62     v8::HandleScope scope(isolate()); |  64     v8::HandleScope scope(isolate()); | 
|  63     V8Console::clearInspectedContextIfNeeded(context(), |  65     V8Console::clearInspectedContextIfNeeded(context(), | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  74 } |  76 } | 
|  75  |  77  | 
|  76 void InspectedContext::createInjectedScript() { |  78 void InspectedContext::createInjectedScript() { | 
|  77   DCHECK(!m_injectedScript); |  79   DCHECK(!m_injectedScript); | 
|  78   m_injectedScript = InjectedScript::create(this); |  80   m_injectedScript = InjectedScript::create(this); | 
|  79 } |  81 } | 
|  80  |  82  | 
|  81 void InspectedContext::discardInjectedScript() { m_injectedScript.reset(); } |  83 void InspectedContext::discardInjectedScript() { m_injectedScript.reset(); } | 
|  82  |  84  | 
|  83 }  // namespace v8_inspector |  85 }  // namespace v8_inspector | 
| OLD | NEW |