LCOV - code coverage report
Current view: top level - src/inspector - v8-console.h (source / functions) Hit Total Coverage
Test: app.info Lines: 11 15 73.3 %
Date: 2017-04-26 Functions: 18 24 75.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_V8CONSOLE_H_
       6             : #define V8_INSPECTOR_V8CONSOLE_H_
       7             : 
       8             : #include "src/base/macros.h"
       9             : 
      10             : #include "include/v8.h"
      11             : #include "src/debug/interface-types.h"
      12             : 
      13             : namespace v8_inspector {
      14             : 
      15             : class InspectedContext;
      16             : class V8InspectorImpl;
      17             : 
      18             : // Console API
      19             : // https://console.spec.whatwg.org/#console-interface
      20        9086 : class V8Console : public v8::debug::ConsoleDelegate {
      21             :  public:
      22             :   v8::Local<v8::Object> createCommandLineAPI(v8::Local<v8::Context> context);
      23             :   void installMemoryGetter(v8::Local<v8::Context> context,
      24             :                            v8::Local<v8::Object> console);
      25             : 
      26             :   class CommandLineAPIScope {
      27             :    public:
      28             :     CommandLineAPIScope(v8::Local<v8::Context>,
      29             :                         v8::Local<v8::Object> commandLineAPI,
      30             :                         v8::Local<v8::Object> global);
      31             :     ~CommandLineAPIScope();
      32             : 
      33             :    private:
      34             :     static void accessorGetterCallback(
      35             :         v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
      36             :     static void accessorSetterCallback(v8::Local<v8::Name>,
      37             :                                        v8::Local<v8::Value>,
      38             :                                        const v8::PropertyCallbackInfo<void>&);
      39             : 
      40             :     v8::Local<v8::Context> m_context;
      41             :     v8::Local<v8::Object> m_commandLineAPI;
      42             :     v8::Local<v8::Object> m_global;
      43             :     v8::Local<v8::Set> m_installedMethods;
      44             :     bool m_cleanup;
      45             : 
      46             :     DISALLOW_COPY_AND_ASSIGN(CommandLineAPIScope);
      47             :   };
      48             : 
      49             :   explicit V8Console(V8InspectorImpl* inspector);
      50             : 
      51             :  private:
      52             :   void Debug(const v8::debug::ConsoleCallArguments&) override;
      53             :   void Error(const v8::debug::ConsoleCallArguments&) override;
      54             :   void Info(const v8::debug::ConsoleCallArguments&) override;
      55             :   void Log(const v8::debug::ConsoleCallArguments&) override;
      56             :   void Warn(const v8::debug::ConsoleCallArguments&) override;
      57             :   void Dir(const v8::debug::ConsoleCallArguments&) override;
      58             :   void DirXml(const v8::debug::ConsoleCallArguments&) override;
      59             :   void Table(const v8::debug::ConsoleCallArguments&) override;
      60             :   void Trace(const v8::debug::ConsoleCallArguments&) override;
      61             :   void Group(const v8::debug::ConsoleCallArguments&) override;
      62             :   void GroupCollapsed(const v8::debug::ConsoleCallArguments&) override;
      63             :   void GroupEnd(const v8::debug::ConsoleCallArguments&) override;
      64             :   void Clear(const v8::debug::ConsoleCallArguments&) override;
      65             :   void Count(const v8::debug::ConsoleCallArguments&) override;
      66             :   void Assert(const v8::debug::ConsoleCallArguments&) override;
      67             :   void MarkTimeline(const v8::debug::ConsoleCallArguments&) override;
      68             :   void Profile(const v8::debug::ConsoleCallArguments&) override;
      69             :   void ProfileEnd(const v8::debug::ConsoleCallArguments&) override;
      70             :   void Timeline(const v8::debug::ConsoleCallArguments&) override;
      71             :   void TimelineEnd(const v8::debug::ConsoleCallArguments&) override;
      72             :   void Time(const v8::debug::ConsoleCallArguments&) override;
      73             :   void TimeEnd(const v8::debug::ConsoleCallArguments&) override;
      74             :   void TimeStamp(const v8::debug::ConsoleCallArguments&) override;
      75             : 
      76             :   template <void (V8Console::*func)(const v8::FunctionCallbackInfo<v8::Value>&)>
      77         276 :   static void call(const v8::FunctionCallbackInfo<v8::Value>& info) {
      78             :     V8Console* console =
      79         276 :         static_cast<V8Console*>(info.Data().As<v8::External>()->Value());
      80         228 :     (console->*func)(info);
      81         276 :   }
      82             :   template <void (V8Console::*func)(const v8::debug::ConsoleCallArguments&)>
      83          78 :   static void call(const v8::FunctionCallbackInfo<v8::Value>& info) {
      84             :     V8Console* console =
      85          78 :         static_cast<V8Console*>(info.Data().As<v8::External>()->Value());
      86          78 :     v8::debug::ConsoleCallArguments args(info);
      87          78 :     (console->*func)(args);
      88          78 :   }
      89             : 
      90             :   // TODO(foolip): There is no spec for the Memory Info API, see blink-dev:
      91             :   // https://groups.google.com/a/chromium.org/d/msg/blink-dev/g5YRCGpC9vs/b4OJz71NmPwJ
      92             :   void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
      93             :   void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
      94             : 
      95             :   // CommandLineAPI
      96             :   void keysCallback(const v8::FunctionCallbackInfo<v8::Value>&);
      97             :   void valuesCallback(const v8::FunctionCallbackInfo<v8::Value>&);
      98             :   void debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&);
      99             :   void undebugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&);
     100             :   void monitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&);
     101             :   void unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&);
     102             :   void lastEvaluationResultCallback(const v8::FunctionCallbackInfo<v8::Value>&);
     103             :   void inspectCallback(const v8::FunctionCallbackInfo<v8::Value>&);
     104             :   void copyCallback(const v8::FunctionCallbackInfo<v8::Value>&);
     105             :   void inspectedObject(const v8::FunctionCallbackInfo<v8::Value>&,
     106             :                        unsigned num);
     107             :   void inspectedObject0(const v8::FunctionCallbackInfo<v8::Value>& info) {
     108           6 :     inspectedObject(info, 0);
     109             :   }
     110             :   void inspectedObject1(const v8::FunctionCallbackInfo<v8::Value>& info) {
     111           0 :     inspectedObject(info, 1);
     112             :   }
     113             :   void inspectedObject2(const v8::FunctionCallbackInfo<v8::Value>& info) {
     114           0 :     inspectedObject(info, 2);
     115             :   }
     116             :   void inspectedObject3(const v8::FunctionCallbackInfo<v8::Value>& info) {
     117           0 :     inspectedObject(info, 3);
     118             :   }
     119             :   void inspectedObject4(const v8::FunctionCallbackInfo<v8::Value>& info) {
     120           0 :     inspectedObject(info, 4);
     121             :   }
     122             : 
     123             :   V8InspectorImpl* m_inspector;
     124             : };
     125             : 
     126             : }  // namespace v8_inspector
     127             : 
     128             : #endif  // V8_INSPECTOR_V8CONSOLE_H_

Generated by: LCOV version 1.10