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 #ifndef V8_INSPECTOR_V8CONSOLE_H_ | 5 #ifndef V8_INSPECTOR_V8CONSOLE_H_ |
6 #define V8_INSPECTOR_V8CONSOLE_H_ | 6 #define V8_INSPECTOR_V8CONSOLE_H_ |
7 | 7 |
8 #include "src/base/macros.h" | 8 #include "src/base/macros.h" |
9 | 9 |
10 #include "include/v8.h" | 10 #include "include/v8.h" |
11 #include "src/debug/interface-types.h" | |
12 | 11 |
13 namespace v8_inspector { | 12 namespace v8_inspector { |
14 | 13 |
15 class InspectedContext; | 14 class InspectedContext; |
16 class V8InspectorImpl; | 15 class V8InspectorImpl; |
17 | 16 |
18 // Console API | 17 // Console API |
19 // https://console.spec.whatwg.org/#console-interface | 18 // https://console.spec.whatwg.org/#console-interface |
20 class V8Console : public v8::debug::ConsoleDelegate { | 19 class V8Console { |
21 public: | 20 public: |
| 21 v8::Local<v8::Object> createConsole(v8::Local<v8::Context> context); |
22 v8::Local<v8::Object> createCommandLineAPI(v8::Local<v8::Context> context); | 22 v8::Local<v8::Object> createCommandLineAPI(v8::Local<v8::Context> context); |
23 void installMemoryGetter(v8::Local<v8::Context> context, | 23 void installMemoryGetter(v8::Local<v8::Context> context, |
24 v8::Local<v8::Object> console); | 24 v8::Local<v8::Object> console); |
25 | 25 |
26 class CommandLineAPIScope { | 26 class CommandLineAPIScope { |
27 public: | 27 public: |
28 CommandLineAPIScope(v8::Local<v8::Context>, | 28 CommandLineAPIScope(v8::Local<v8::Context>, |
29 v8::Local<v8::Object> commandLineAPI, | 29 v8::Local<v8::Object> commandLineAPI, |
30 v8::Local<v8::Object> global); | 30 v8::Local<v8::Object> global); |
31 ~CommandLineAPIScope(); | 31 ~CommandLineAPIScope(); |
(...skipping 10 matching lines...) Expand all Loading... |
42 v8::Local<v8::Object> m_global; | 42 v8::Local<v8::Object> m_global; |
43 v8::Local<v8::Set> m_installedMethods; | 43 v8::Local<v8::Set> m_installedMethods; |
44 bool m_cleanup; | 44 bool m_cleanup; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(CommandLineAPIScope); | 46 DISALLOW_COPY_AND_ASSIGN(CommandLineAPIScope); |
47 }; | 47 }; |
48 | 48 |
49 explicit V8Console(V8InspectorImpl* inspector); | 49 explicit V8Console(V8InspectorImpl* inspector); |
50 | 50 |
51 private: | 51 private: |
52 void Debug(const v8::debug::ConsoleCallArguments&) override; | 52 void debugCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
53 void Error(const v8::debug::ConsoleCallArguments&) override; | 53 void errorCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
54 void Info(const v8::debug::ConsoleCallArguments&) override; | 54 void infoCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
55 void Log(const v8::debug::ConsoleCallArguments&) override; | 55 void logCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
56 void Warn(const v8::debug::ConsoleCallArguments&) override; | 56 void warnCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
57 void Dir(const v8::debug::ConsoleCallArguments&) override; | 57 void dirCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
58 void DirXml(const v8::debug::ConsoleCallArguments&) override; | 58 void dirxmlCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
59 void Table(const v8::debug::ConsoleCallArguments&) override; | 59 void tableCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
60 void Trace(const v8::debug::ConsoleCallArguments&) override; | 60 void traceCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
61 void Group(const v8::debug::ConsoleCallArguments&) override; | 61 void groupCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
62 void GroupCollapsed(const v8::debug::ConsoleCallArguments&) override; | 62 void groupCollapsedCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
63 void GroupEnd(const v8::debug::ConsoleCallArguments&) override; | 63 void groupEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
64 void Clear(const v8::debug::ConsoleCallArguments&) override; | 64 void clearCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
65 void Count(const v8::debug::ConsoleCallArguments&) override; | 65 void countCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
66 void Assert(const v8::debug::ConsoleCallArguments&) override; | 66 void assertCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
67 void MarkTimeline(const v8::debug::ConsoleCallArguments&) override; | 67 void markTimelineCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
68 void Profile(const v8::debug::ConsoleCallArguments&) override; | 68 void profileCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
69 void ProfileEnd(const v8::debug::ConsoleCallArguments&) override; | 69 void profileEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
70 void Timeline(const v8::debug::ConsoleCallArguments&) override; | 70 void timelineCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
71 void TimelineEnd(const v8::debug::ConsoleCallArguments&) override; | 71 void timelineEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
72 void Time(const v8::debug::ConsoleCallArguments&) override; | 72 void timeCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
73 void TimeEnd(const v8::debug::ConsoleCallArguments&) override; | 73 void timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
74 void TimeStamp(const v8::debug::ConsoleCallArguments&) override; | 74 void timeStampCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
75 | 75 |
76 template <void (V8Console::*func)(const v8::FunctionCallbackInfo<v8::Value>&)> | 76 template <void (V8Console::*func)(const v8::FunctionCallbackInfo<v8::Value>&)> |
77 static void call(const v8::FunctionCallbackInfo<v8::Value>& info) { | 77 static void call(const v8::FunctionCallbackInfo<v8::Value>& info) { |
78 V8Console* console = | 78 V8Console* console = |
79 static_cast<V8Console*>(info.Data().As<v8::External>()->Value()); | 79 static_cast<V8Console*>(info.Data().As<v8::External>()->Value()); |
80 (console->*func)(info); | 80 (console->*func)(info); |
81 } | 81 } |
82 template <void (V8Console::*func)(const v8::debug::ConsoleCallArguments&)> | |
83 static void call(const v8::FunctionCallbackInfo<v8::Value>& info) { | |
84 V8Console* console = | |
85 static_cast<V8Console*>(info.Data().As<v8::External>()->Value()); | |
86 v8::debug::ConsoleCallArguments args(info); | |
87 (console->*func)(args); | |
88 } | |
89 | 82 |
90 // TODO(foolip): There is no spec for the Memory Info API, see blink-dev: | 83 // 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/b4OJz7
1NmPwJ | 84 // https://groups.google.com/a/chromium.org/d/msg/blink-dev/g5YRCGpC9vs/b4OJz7
1NmPwJ |
92 void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 85 void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
93 void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 86 void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
94 | 87 |
95 // CommandLineAPI | 88 // CommandLineAPI |
96 void keysCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 89 void keysCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
97 void valuesCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 90 void valuesCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
98 void debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 91 void debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
(...skipping 20 matching lines...) Expand all Loading... |
119 void inspectedObject4(const v8::FunctionCallbackInfo<v8::Value>& info) { | 112 void inspectedObject4(const v8::FunctionCallbackInfo<v8::Value>& info) { |
120 inspectedObject(info, 4); | 113 inspectedObject(info, 4); |
121 } | 114 } |
122 | 115 |
123 V8InspectorImpl* m_inspector; | 116 V8InspectorImpl* m_inspector; |
124 }; | 117 }; |
125 | 118 |
126 } // namespace v8_inspector | 119 } // namespace v8_inspector |
127 | 120 |
128 #endif // V8_INSPECTOR_V8CONSOLE_H_ | 121 #endif // V8_INSPECTOR_V8CONSOLE_H_ |
OLD | NEW |