LCOV - code coverage report
Current view: top level - src/inspector - inspected-context.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 21 21 100.0 %
Date: 2017-04-26 Functions: 7 7 100.0 %

          Line data    Source code
       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
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/inspector/inspected-context.h"
       6             : 
       7             : #include "src/debug/debug-interface.h"
       8             : #include "src/inspector/injected-script.h"
       9             : #include "src/inspector/string-util.h"
      10             : #include "src/inspector/v8-console.h"
      11             : #include "src/inspector/v8-inspector-impl.h"
      12             : #include "src/inspector/v8-value-copier.h"
      13             : 
      14             : #include "include/v8-inspector.h"
      15             : 
      16             : namespace v8_inspector {
      17             : 
      18        4579 : InspectedContext::InspectedContext(V8InspectorImpl* inspector,
      19             :                                    const V8ContextInfo& info, int contextId)
      20             :     : m_inspector(inspector),
      21             :       m_context(info.context->GetIsolate(), info.context),
      22             :       m_contextId(contextId),
      23             :       m_contextGroupId(info.contextGroupId),
      24             :       m_origin(toString16(info.origin)),
      25             :       m_humanReadableName(toString16(info.humanReadableName)),
      26             :       m_auxData(toString16(info.auxData)),
      27       13737 :       m_reported(false) {
      28        4579 :   v8::debug::SetContextId(info.context, contextId);
      29        8405 :   if (!info.hasMemoryOnConsole) return;
      30             :   v8::Context::Scope contextScope(info.context);
      31         753 :   v8::Local<v8::Object> global = info.context->Global();
      32             :   v8::Local<v8::Value> console;
      33        2259 :   if (global->Get(info.context, toV8String(m_inspector->isolate(), "console"))
      34        2259 :           .ToLocal(&console) &&
      35         753 :       console->IsObject()) {
      36             :     m_inspector->console()->installMemoryGetter(
      37         753 :         info.context, v8::Local<v8::Object>::Cast(console));
      38             :   }
      39             : }
      40             : 
      41        4579 : InspectedContext::~InspectedContext() {
      42        4579 : }
      43             : 
      44             : // static
      45      878040 : int InspectedContext::contextId(v8::Local<v8::Context> context) {
      46      878040 :   return v8::debug::GetContextId(context);
      47             : }
      48             : 
      49     1029431 : v8::Local<v8::Context> InspectedContext::context() const {
      50     1029431 :   return m_context.Get(isolate());
      51             : }
      52             : 
      53      790966 : v8::Isolate* InspectedContext::isolate() const {
      54     1820397 :   return m_inspector->isolate();
      55             : }
      56             : 
      57        4109 : bool InspectedContext::createInjectedScript() {
      58             :   DCHECK(!m_injectedScript);
      59        4109 :   std::unique_ptr<InjectedScript> injectedScript = InjectedScript::create(this);
      60             :   // InjectedScript::create can destroy |this|.
      61        4109 :   if (!injectedScript) return false;
      62             :   m_injectedScript = std::move(injectedScript);
      63             :   return true;
      64             : }
      65             : 
      66        9938 : void InspectedContext::discardInjectedScript() { m_injectedScript.reset(); }
      67             : 
      68             : }  // namespace v8_inspector

Generated by: LCOV version 1.10