LCOV - code coverage report
Current view: top level - src/inspector - v8-inspector-impl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2019-03-21 Functions: 0 0 -

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2010, Google Inc. All rights reserved.
       3             :  *
       4             :  * Redistribution and use in source and binary forms, with or without
       5             :  * modification, are permitted provided that the following conditions are
       6             :  * met:
       7             :  *
       8             :  *     * Redistributions of source code must retain the above copyright
       9             :  * notice, this list of conditions and the following disclaimer.
      10             :  *     * Redistributions in binary form must reproduce the above
      11             :  * copyright notice, this list of conditions and the following disclaimer
      12             :  * in the documentation and/or other materials provided with the
      13             :  * distribution.
      14             :  *     * Neither the name of Google Inc. nor the names of its
      15             :  * contributors may be used to endorse or promote products derived from
      16             :  * this software without specific prior written permission.
      17             :  *
      18             :  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
      19             :  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
      20             :  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
      21             :  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
      22             :  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      23             :  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
      24             :  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      25             :  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      26             :  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      27             :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
      28             :  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      29             :  */
      30             : 
      31             : #ifndef V8_INSPECTOR_V8_INSPECTOR_IMPL_H_
      32             : #define V8_INSPECTOR_V8_INSPECTOR_IMPL_H_
      33             : 
      34             : #include <functional>
      35             : #include <map>
      36             : #include <unordered_map>
      37             : 
      38             : #include "src/base/macros.h"
      39             : #include "src/base/platform/mutex.h"
      40             : #include "src/inspector/injected-script.h"
      41             : #include "src/inspector/protocol/Protocol.h"
      42             : 
      43             : #include "include/v8-inspector.h"
      44             : 
      45             : namespace v8_inspector {
      46             : 
      47             : class InspectedContext;
      48             : class V8Console;
      49             : class V8ConsoleMessageStorage;
      50             : class V8Debugger;
      51             : class V8DebuggerAgentImpl;
      52             : class V8InspectorSessionImpl;
      53             : class V8ProfilerAgentImpl;
      54             : class V8RuntimeAgentImpl;
      55             : class V8StackTraceImpl;
      56             : 
      57             : class V8InspectorImpl : public V8Inspector {
      58             :  public:
      59             :   V8InspectorImpl(v8::Isolate*, V8InspectorClient*);
      60             :   ~V8InspectorImpl() override;
      61             : 
      62             :   v8::Isolate* isolate() const { return m_isolate; }
      63             :   V8InspectorClient* client() { return m_client; }
      64             :   V8Debugger* debugger() { return m_debugger.get(); }
      65             :   int contextGroupId(v8::Local<v8::Context>) const;
      66             :   int contextGroupId(int contextId) const;
      67             :   uint64_t isolateId() const { return m_isolateId; }
      68             : 
      69             :   v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::Context>,
      70             :                                                         v8::Local<v8::String>);
      71             :   v8::MaybeLocal<v8::Script> compileScript(v8::Local<v8::Context>,
      72             :                                            const String16& code,
      73             :                                            const String16& fileName);
      74             :   v8::Local<v8::Context> regexContext();
      75             : 
      76             :   // V8Inspector implementation.
      77             :   std::unique_ptr<V8InspectorSession> connect(int contextGroupId,
      78             :                                               V8Inspector::Channel*,
      79             :                                               const StringView& state) override;
      80             :   void contextCreated(const V8ContextInfo&) override;
      81             :   void contextDestroyed(v8::Local<v8::Context>) override;
      82             :   v8::MaybeLocal<v8::Context> contextById(int contextId) override;
      83             :   void contextCollected(int contextGroupId, int contextId);
      84             :   void resetContextGroup(int contextGroupId) override;
      85             :   void idleStarted() override;
      86             :   void idleFinished() override;
      87             :   unsigned exceptionThrown(v8::Local<v8::Context>, const StringView& message,
      88             :                            v8::Local<v8::Value> exception,
      89             :                            const StringView& detailedMessage,
      90             :                            const StringView& url, unsigned lineNumber,
      91             :                            unsigned columnNumber, std::unique_ptr<V8StackTrace>,
      92             :                            int scriptId) override;
      93             :   void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
      94             :                         const StringView& message) override;
      95             :   std::unique_ptr<V8StackTrace> createStackTrace(
      96             :       v8::Local<v8::StackTrace>) override;
      97             :   std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) override;
      98             :   void asyncTaskScheduled(const StringView& taskName, void* task,
      99             :                           bool recurring) override;
     100             :   void asyncTaskCanceled(void* task) override;
     101             :   void asyncTaskStarted(void* task) override;
     102             :   void asyncTaskFinished(void* task) override;
     103             :   void allAsyncTasksCanceled() override;
     104             : 
     105             :   V8StackTraceId storeCurrentStackTrace(const StringView& description) override;
     106             :   void externalAsyncTaskStarted(const V8StackTraceId& parent) override;
     107             :   void externalAsyncTaskFinished(const V8StackTraceId& parent) override;
     108             : 
     109        2011 :   unsigned nextExceptionId() { return ++m_lastExceptionId; }
     110             :   void enableStackCapturingIfNeeded();
     111             :   void disableStackCapturingIfNeeded();
     112             :   void muteExceptions(int contextGroupId);
     113             :   void unmuteExceptions(int contextGroupId);
     114             :   V8ConsoleMessageStorage* ensureConsoleMessageStorage(int contextGroupId);
     115             :   bool hasConsoleMessageStorage(int contextGroupId);
     116             :   void discardInspectedContext(int contextGroupId, int contextId);
     117             :   void disconnect(V8InspectorSessionImpl*);
     118             :   V8InspectorSessionImpl* sessionById(int contextGroupId, int sessionId);
     119             :   InspectedContext* getContext(int groupId, int contextId) const;
     120             :   InspectedContext* getContext(int contextId) const;
     121             :   V8Console* console();
     122             :   void forEachContext(int contextGroupId,
     123             :                       const std::function<void(InspectedContext*)>& callback);
     124             :   void forEachSession(
     125             :       int contextGroupId,
     126             :       const std::function<void(V8InspectorSessionImpl*)>& callback);
     127             : 
     128             :   class EvaluateScope {
     129             :    public:
     130             :     explicit EvaluateScope(const InjectedScript::Scope& scope);
     131             :     ~EvaluateScope();
     132             : 
     133             :     protocol::Response setTimeout(double timeout);
     134             : 
     135             :    private:
     136             :     class TerminateTask;
     137             :     struct CancelToken;
     138             : 
     139             :     const InjectedScript::Scope& m_scope;
     140             :     v8::Isolate* m_isolate;
     141             :     std::shared_ptr<CancelToken> m_cancelToken;
     142             :     v8::Isolate::SafeForTerminationScope m_safeForTerminationScope;
     143             :   };
     144             : 
     145             :  private:
     146             :   v8::Isolate* m_isolate;
     147             :   V8InspectorClient* m_client;
     148             :   std::unique_ptr<V8Debugger> m_debugger;
     149             :   v8::Global<v8::Context> m_regexContext;
     150             :   int m_capturingStackTracesCount;
     151             :   unsigned m_lastExceptionId;
     152             :   int m_lastContextId;
     153             :   int m_lastSessionId = 0;
     154             :   uint64_t m_isolateId;
     155             : 
     156             :   using MuteExceptionsMap = std::unordered_map<int, int>;
     157             :   MuteExceptionsMap m_muteExceptionsMap;
     158             : 
     159             :   using ContextByIdMap =
     160             :       std::unordered_map<int, std::unique_ptr<InspectedContext>>;
     161             :   using ContextsByGroupMap =
     162             :       std::unordered_map<int, std::unique_ptr<ContextByIdMap>>;
     163             :   ContextsByGroupMap m_contexts;
     164             : 
     165             :   // contextGroupId -> sessionId -> session
     166             :   std::unordered_map<int, std::map<int, V8InspectorSessionImpl*>> m_sessions;
     167             : 
     168             :   using ConsoleStorageMap =
     169             :       std::unordered_map<int, std::unique_ptr<V8ConsoleMessageStorage>>;
     170             :   ConsoleStorageMap m_consoleStorageMap;
     171             : 
     172             :   std::unordered_map<int, int> m_contextIdToGroupIdMap;
     173             : 
     174             :   std::unique_ptr<V8Console> m_console;
     175             : 
     176             :   DISALLOW_COPY_AND_ASSIGN(V8InspectorImpl);
     177             : };
     178             : 
     179             : }  // namespace v8_inspector
     180             : 
     181             : #endif  // V8_INSPECTOR_V8_INSPECTOR_IMPL_H_

Generated by: LCOV version 1.10