LCOV - code coverage report
Current view: top level - src/inspector - v8-console-message.h (source / functions) Hit Total Coverage
Test: app.info Lines: 3 3 100.0 %
Date: 2019-04-19 Functions: 2 2 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             : #ifndef V8_INSPECTOR_V8_CONSOLE_MESSAGE_H_
       6             : #define V8_INSPECTOR_V8_CONSOLE_MESSAGE_H_
       7             : 
       8             : #include <deque>
       9             : #include <map>
      10             : #include <set>
      11             : #include "include/v8.h"
      12             : #include "src/inspector/protocol/Console.h"
      13             : #include "src/inspector/protocol/Forward.h"
      14             : #include "src/inspector/protocol/Runtime.h"
      15             : 
      16             : namespace v8_inspector {
      17             : 
      18             : class InspectedContext;
      19             : class V8InspectorImpl;
      20             : class V8InspectorSessionImpl;
      21             : class V8StackTraceImpl;
      22             : 
      23             : enum class V8MessageOrigin { kConsole, kException, kRevokedException };
      24             : 
      25             : enum class ConsoleAPIType {
      26             :   kLog,
      27             :   kDebug,
      28             :   kInfo,
      29             :   kError,
      30             :   kWarning,
      31             :   kDir,
      32             :   kDirXML,
      33             :   kTable,
      34             :   kTrace,
      35             :   kStartGroup,
      36             :   kStartGroupCollapsed,
      37             :   kEndGroup,
      38             :   kClear,
      39             :   kAssert,
      40             :   kTimeEnd,
      41             :   kCount
      42             : };
      43             : 
      44       21390 : class V8ConsoleMessage {
      45             :  public:
      46             :   ~V8ConsoleMessage();
      47             : 
      48             :   static std::unique_ptr<V8ConsoleMessage> createForConsoleAPI(
      49             :       v8::Local<v8::Context> v8Context, int contextId, int groupId,
      50             :       V8InspectorImpl* inspector, double timestamp, ConsoleAPIType,
      51             :       const std::vector<v8::Local<v8::Value>>& arguments,
      52             :       const String16& consoleContext, std::unique_ptr<V8StackTraceImpl>);
      53             : 
      54             :   static std::unique_ptr<V8ConsoleMessage> createForException(
      55             :       double timestamp, const String16& detailedMessage, const String16& url,
      56             :       unsigned lineNumber, unsigned columnNumber,
      57             :       std::unique_ptr<V8StackTraceImpl>, int scriptId, v8::Isolate*,
      58             :       const String16& message, int contextId, v8::Local<v8::Value> exception,
      59             :       unsigned exceptionId);
      60             : 
      61             :   static std::unique_ptr<V8ConsoleMessage> createForRevokedException(
      62             :       double timestamp, const String16& message, unsigned revokedExceptionId);
      63             : 
      64             :   V8MessageOrigin origin() const;
      65             :   void reportToFrontend(protocol::Console::Frontend*) const;
      66             :   void reportToFrontend(protocol::Runtime::Frontend*, V8InspectorSessionImpl*,
      67             :                         bool generatePreview) const;
      68             :   ConsoleAPIType type() const;
      69             :   void contextDestroyed(int contextId);
      70             : 
      71             :   int estimatedSize() const {
      72       24365 :     return m_v8Size + static_cast<int>(m_message.length() * sizeof(UChar));
      73             :   }
      74             : 
      75             :  private:
      76             :   V8ConsoleMessage(V8MessageOrigin, double timestamp, const String16& message);
      77             : 
      78             :   using Arguments = std::vector<std::unique_ptr<v8::Global<v8::Value>>>;
      79             :   std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>>
      80             :   wrapArguments(V8InspectorSessionImpl*, bool generatePreview) const;
      81             :   std::unique_ptr<protocol::Runtime::RemoteObject> wrapException(
      82             :       V8InspectorSessionImpl*, bool generatePreview) const;
      83             :   void setLocation(const String16& url, unsigned lineNumber,
      84             :                    unsigned columnNumber, std::unique_ptr<V8StackTraceImpl>,
      85             :                    int scriptId);
      86             : 
      87             :   V8MessageOrigin m_origin;
      88             :   double m_timestamp;
      89             :   String16 m_message;
      90             :   String16 m_url;
      91             :   unsigned m_lineNumber;
      92             :   unsigned m_columnNumber;
      93             :   std::unique_ptr<V8StackTraceImpl> m_stackTrace;
      94             :   int m_scriptId;
      95             :   int m_contextId;
      96             :   ConsoleAPIType m_type;
      97             :   unsigned m_exceptionId;
      98             :   unsigned m_revokedExceptionId;
      99             :   int m_v8Size = 0;
     100             :   Arguments m_arguments;
     101             :   String16 m_detailedMessage;
     102             :   String16 m_consoleContext;
     103             : };
     104             : 
     105             : class V8ConsoleMessageStorage {
     106             :  public:
     107             :   V8ConsoleMessageStorage(V8InspectorImpl*, int contextGroupId);
     108             :   ~V8ConsoleMessageStorage();
     109             : 
     110             :   int contextGroupId() { return m_contextGroupId; }
     111             :   const std::deque<std::unique_ptr<V8ConsoleMessage>>& messages() const {
     112             :     return m_messages;
     113             :   }
     114             : 
     115             :   void addMessage(std::unique_ptr<V8ConsoleMessage>);
     116             :   void contextDestroyed(int contextId);
     117             :   void clear();
     118             : 
     119             :   bool shouldReportDeprecationMessage(int contextId, const String16& method);
     120             :   int count(int contextId, const String16& id);
     121             :   bool countReset(int contextId, const String16& id);
     122             :   void time(int contextId, const String16& id);
     123             :   double timeLog(int contextId, const String16& id);
     124             :   double timeEnd(int contextId, const String16& id);
     125             :   bool hasTimer(int contextId, const String16& id);
     126             : 
     127             :  private:
     128             :   V8InspectorImpl* m_inspector;
     129             :   int m_contextGroupId;
     130             :   int m_estimatedSize = 0;
     131             :   std::deque<std::unique_ptr<V8ConsoleMessage>> m_messages;
     132             : 
     133          90 :   struct PerContextData {
     134             :     std::set<String16> m_reportedDeprecationMessages;
     135             :     // Corresponds to https://console.spec.whatwg.org/#count-map
     136             :     std::map<String16, int> m_count;
     137             :     // Corresponds to https://console.spec.whatwg.org/#timer-table
     138             :     std::map<String16, double> m_time;
     139             :   };
     140             :   std::map<int, PerContextData> m_data;
     141             : };
     142             : 
     143             : }  // namespace v8_inspector
     144             : 
     145             : #endif  // V8_INSPECTOR_V8_CONSOLE_MESSAGE_H_

Generated by: LCOV version 1.10