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" | 11 #include "src/debug/interface-types.h" |
12 | 12 |
13 namespace v8_inspector { | 13 namespace v8_inspector { |
14 | 14 |
15 class InspectedContext; | 15 class InspectedContext; |
16 class V8InspectorImpl; | 16 class V8InspectorImpl; |
17 | 17 |
18 // Console API | 18 // Console API |
19 // https://console.spec.whatwg.org/#console-interface | 19 // https://console.spec.whatwg.org/#console-interface |
20 class V8Console : public v8::debug::ConsoleDelegate { | 20 class V8Console : public v8::debug::ConsoleDelegate { |
21 public: | 21 public: |
22 v8::Local<v8::Object> createCommandLineAPI(v8::Local<v8::Context> context); | 22 v8::Local<v8::Object> createCommandLineAPI(v8::Local<v8::Context> context, |
| 23 int sessionId); |
23 void installMemoryGetter(v8::Local<v8::Context> context, | 24 void installMemoryGetter(v8::Local<v8::Context> context, |
24 v8::Local<v8::Object> console); | 25 v8::Local<v8::Object> console); |
25 | 26 |
26 class CommandLineAPIScope { | 27 class CommandLineAPIScope { |
27 public: | 28 public: |
28 CommandLineAPIScope(v8::Local<v8::Context>, | 29 CommandLineAPIScope(v8::Local<v8::Context>, |
29 v8::Local<v8::Object> commandLineAPI, | 30 v8::Local<v8::Object> commandLineAPI, |
30 v8::Local<v8::Object> global); | 31 v8::Local<v8::Object> global); |
31 ~CommandLineAPIScope(); | 32 ~CommandLineAPIScope(); |
32 | 33 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 void Time(const v8::debug::ConsoleCallArguments&) override; | 73 void Time(const v8::debug::ConsoleCallArguments&) override; |
73 void TimeEnd(const v8::debug::ConsoleCallArguments&) override; | 74 void TimeEnd(const v8::debug::ConsoleCallArguments&) override; |
74 void TimeStamp(const v8::debug::ConsoleCallArguments&) override; | 75 void TimeStamp(const v8::debug::ConsoleCallArguments&) override; |
75 | 76 |
76 template <void (V8Console::*func)(const v8::FunctionCallbackInfo<v8::Value>&)> | 77 template <void (V8Console::*func)(const v8::FunctionCallbackInfo<v8::Value>&)> |
77 static void call(const v8::FunctionCallbackInfo<v8::Value>& info) { | 78 static void call(const v8::FunctionCallbackInfo<v8::Value>& info) { |
78 V8Console* console = | 79 V8Console* console = |
79 static_cast<V8Console*>(info.Data().As<v8::External>()->Value()); | 80 static_cast<V8Console*>(info.Data().As<v8::External>()->Value()); |
80 (console->*func)(info); | 81 (console->*func)(info); |
81 } | 82 } |
| 83 using CommandLineAPIData = std::pair<V8Console*, int>; |
| 84 template <void (V8Console::*func)(const v8::FunctionCallbackInfo<v8::Value>&, |
| 85 int)> |
| 86 static void call(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 87 CommandLineAPIData* data = static_cast<CommandLineAPIData*>( |
| 88 info.Data().As<v8::External>()->Value()); |
| 89 (data->first->*func)(info, data->second); |
| 90 } |
82 template <void (V8Console::*func)(const v8::debug::ConsoleCallArguments&)> | 91 template <void (V8Console::*func)(const v8::debug::ConsoleCallArguments&)> |
83 static void call(const v8::FunctionCallbackInfo<v8::Value>& info) { | 92 static void call(const v8::FunctionCallbackInfo<v8::Value>& info) { |
84 V8Console* console = | 93 CommandLineAPIData* data = static_cast<CommandLineAPIData*>( |
85 static_cast<V8Console*>(info.Data().As<v8::External>()->Value()); | 94 info.Data().As<v8::External>()->Value()); |
86 v8::debug::ConsoleCallArguments args(info); | 95 v8::debug::ConsoleCallArguments args(info); |
87 (console->*func)(args); | 96 (data->first->*func)(args); |
88 } | 97 } |
89 | 98 |
90 // TODO(foolip): There is no spec for the Memory Info API, see blink-dev: | 99 // 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 | 100 // https://groups.google.com/a/chromium.org/d/msg/blink-dev/g5YRCGpC9vs/b4OJz7
1NmPwJ |
92 void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 101 void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
93 void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 102 void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
94 | 103 |
95 // CommandLineAPI | 104 // CommandLineAPI |
96 void keysCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 105 void keysCallback(const v8::FunctionCallbackInfo<v8::Value>&, int sessionId); |
97 void valuesCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 106 void valuesCallback(const v8::FunctionCallbackInfo<v8::Value>&, |
98 void debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 107 int sessionId); |
99 void undebugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 108 void debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&, |
100 void monitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 109 int sessionId); |
101 void unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 110 void undebugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&, |
102 void lastEvaluationResultCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 111 int sessionId); |
103 void inspectCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 112 void monitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&, |
104 void copyCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 113 int sessionId); |
| 114 void unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&, |
| 115 int sessionId); |
| 116 void lastEvaluationResultCallback(const v8::FunctionCallbackInfo<v8::Value>&, |
| 117 int sessionId); |
| 118 void inspectCallback(const v8::FunctionCallbackInfo<v8::Value>&, |
| 119 int sessionId); |
| 120 void copyCallback(const v8::FunctionCallbackInfo<v8::Value>&, int sessionId); |
105 void inspectedObject(const v8::FunctionCallbackInfo<v8::Value>&, | 121 void inspectedObject(const v8::FunctionCallbackInfo<v8::Value>&, |
106 unsigned num); | 122 int sessionId, unsigned num); |
107 void inspectedObject0(const v8::FunctionCallbackInfo<v8::Value>& info) { | 123 void inspectedObject0(const v8::FunctionCallbackInfo<v8::Value>& info, |
108 inspectedObject(info, 0); | 124 int sessionId) { |
| 125 inspectedObject(info, sessionId, 0); |
109 } | 126 } |
110 void inspectedObject1(const v8::FunctionCallbackInfo<v8::Value>& info) { | 127 void inspectedObject1(const v8::FunctionCallbackInfo<v8::Value>& info, |
111 inspectedObject(info, 1); | 128 int sessionId) { |
| 129 inspectedObject(info, sessionId, 1); |
112 } | 130 } |
113 void inspectedObject2(const v8::FunctionCallbackInfo<v8::Value>& info) { | 131 void inspectedObject2(const v8::FunctionCallbackInfo<v8::Value>& info, |
114 inspectedObject(info, 2); | 132 int sessionId) { |
| 133 inspectedObject(info, sessionId, 2); |
115 } | 134 } |
116 void inspectedObject3(const v8::FunctionCallbackInfo<v8::Value>& info) { | 135 void inspectedObject3(const v8::FunctionCallbackInfo<v8::Value>& info, |
117 inspectedObject(info, 3); | 136 int sessionId) { |
| 137 inspectedObject(info, sessionId, 3); |
118 } | 138 } |
119 void inspectedObject4(const v8::FunctionCallbackInfo<v8::Value>& info) { | 139 void inspectedObject4(const v8::FunctionCallbackInfo<v8::Value>& info, |
120 inspectedObject(info, 4); | 140 int sessionId) { |
| 141 inspectedObject(info, sessionId, 4); |
121 } | 142 } |
122 | 143 |
123 V8InspectorImpl* m_inspector; | 144 V8InspectorImpl* m_inspector; |
124 }; | 145 }; |
125 | 146 |
126 } // namespace v8_inspector | 147 } // namespace v8_inspector |
127 | 148 |
128 #endif // V8_INSPECTOR_V8CONSOLE_H_ | 149 #endif // V8_INSPECTOR_V8CONSOLE_H_ |
OLD | NEW |