Chromium Code Reviews| 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 | 11 |
| 12 namespace v8_inspector { | 12 namespace v8_inspector { |
| 13 | 13 |
| 14 class InspectedContext; | 14 class InspectedContext; |
| 15 class V8InspectorImpl; | 15 class V8InspectorImpl; |
| 16 | 16 |
| 17 // Console API | 17 // Console API |
| 18 // https://console.spec.whatwg.org/#console-interface | 18 // https://console.spec.whatwg.org/#console-interface |
| 19 class V8Console { | 19 class V8Console { |
| 20 public: | 20 public: |
| 21 static v8::Local<v8::Object> createConsole(InspectedContext*); | 21 v8::Local<v8::Object> createConsole(v8::Local<v8::Context> context); |
| 22 static v8::Local<v8::Object> createCommandLineAPI(InspectedContext*); | 22 v8::Local<v8::Object> createCommandLineAPI(v8::Local<v8::Context> context); |
| 23 static void installMemoryGetter(V8InspectorImpl* inspector, | 23 void installMemoryGetter(v8::Local<v8::Context> context, |
| 24 v8::Local<v8::Context> context, | 24 v8::Local<v8::Object> console); |
| 25 v8::Local<v8::Object> console); | |
| 26 | 25 |
| 27 class CommandLineAPIScope { | 26 class CommandLineAPIScope { |
| 28 public: | 27 public: |
| 29 CommandLineAPIScope(v8::Local<v8::Context>, | 28 CommandLineAPIScope(v8::Local<v8::Context>, |
| 30 v8::Local<v8::Object> commandLineAPI, | 29 v8::Local<v8::Object> commandLineAPI, |
| 31 v8::Local<v8::Object> global); | 30 v8::Local<v8::Object> global); |
| 32 ~CommandLineAPIScope(); | 31 ~CommandLineAPIScope(); |
| 33 | 32 |
| 34 private: | 33 private: |
| 35 static void accessorGetterCallback( | 34 static void accessorGetterCallback( |
| 36 v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&); | 35 v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&); |
| 37 static void accessorSetterCallback(v8::Local<v8::Name>, | 36 static void accessorSetterCallback(v8::Local<v8::Name>, |
| 38 v8::Local<v8::Value>, | 37 v8::Local<v8::Value>, |
| 39 const v8::PropertyCallbackInfo<void>&); | 38 const v8::PropertyCallbackInfo<void>&); |
| 40 | 39 |
| 41 v8::Local<v8::Context> m_context; | 40 v8::Local<v8::Context> m_context; |
| 42 v8::Local<v8::Object> m_commandLineAPI; | 41 v8::Local<v8::Object> m_commandLineAPI; |
| 43 v8::Local<v8::Object> m_global; | 42 v8::Local<v8::Object> m_global; |
| 44 v8::Local<v8::Set> m_installedMethods; | 43 v8::Local<v8::Set> m_installedMethods; |
| 45 bool m_cleanup; | 44 bool m_cleanup; |
| 46 | 45 |
| 47 DISALLOW_COPY_AND_ASSIGN(CommandLineAPIScope); | 46 DISALLOW_COPY_AND_ASSIGN(CommandLineAPIScope); |
| 48 }; | 47 }; |
| 49 | 48 |
| 49 explicit V8Console(V8InspectorImpl* inspector) : m_inspector(inspector) {} | |
|
dgozman
2017/03/30 21:08:24
Move implementation to cc.
kozy
2017/03/30 21:52:41
Done.
| |
| 50 | |
| 50 private: | 51 private: |
| 51 static void debugCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 52 void debugCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 52 static void errorCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 53 void errorCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 53 static void infoCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 54 void infoCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 54 static void logCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 55 void logCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 55 static void warnCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 56 void warnCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 56 static void dirCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 57 void dirCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 57 static void dirxmlCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 58 void dirxmlCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 58 static void tableCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 59 void tableCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 59 static void traceCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 60 void traceCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 60 static void groupCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 61 void groupCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 61 static void groupCollapsedCallback( | 62 void groupCollapsedCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 62 const v8::FunctionCallbackInfo<v8::Value>&); | 63 void groupEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 63 static void groupEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 64 void clearCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 64 static void clearCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 65 void countCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 65 static void countCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 66 void assertCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 66 static void assertCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 67 void markTimelineCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 67 static void markTimelineCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 68 void profileCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 68 static void profileCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 69 void profileEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 69 static void profileEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 70 void timelineCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 70 static void timelineCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 71 void timelineEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 71 static void timelineEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 72 void timeCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 72 static void timeCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 73 void timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 73 static void timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 74 void timeStampCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 74 static void timeStampCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 75 |
| 76 template <void (V8Console::*func)(const v8::FunctionCallbackInfo<v8::Value>&)> | |
| 77 static void call(const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 78 V8Console* console = | |
| 79 static_cast<V8Console*>(info.Data().As<v8::External>()->Value()); | |
| 80 (console->*func)(info); | |
| 81 } | |
| 82 | |
| 75 // 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: |
| 76 // 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 |
| 77 static void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 85 void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 78 static void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 86 void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 79 | 87 |
| 80 // CommandLineAPI | 88 // CommandLineAPI |
| 81 static void keysCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 89 void keysCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 82 static void valuesCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 90 void valuesCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 83 static void debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 91 void debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 84 static void undebugFunctionCallback( | 92 void undebugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 85 const v8::FunctionCallbackInfo<v8::Value>&); | 93 void monitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 86 static void monitorFunctionCallback( | 94 void unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 87 const v8::FunctionCallbackInfo<v8::Value>&); | 95 void lastEvaluationResultCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 88 static void unmonitorFunctionCallback( | 96 void inspectCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 89 const v8::FunctionCallbackInfo<v8::Value>&); | 97 void copyCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
| 90 static void lastEvaluationResultCallback( | 98 void inspectedObject(const v8::FunctionCallbackInfo<v8::Value>&, |
| 91 const v8::FunctionCallbackInfo<v8::Value>&); | 99 unsigned num); |
| 92 static void inspectCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 100 void inspectedObject0(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 93 static void copyCallback(const v8::FunctionCallbackInfo<v8::Value>&); | |
| 94 static void inspectedObject(const v8::FunctionCallbackInfo<v8::Value>&, | |
| 95 unsigned num); | |
| 96 static void inspectedObject0( | |
| 97 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 98 inspectedObject(info, 0); | 101 inspectedObject(info, 0); |
| 99 } | 102 } |
| 100 static void inspectedObject1( | 103 void inspectedObject1(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 101 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 102 inspectedObject(info, 1); | 104 inspectedObject(info, 1); |
| 103 } | 105 } |
| 104 static void inspectedObject2( | 106 void inspectedObject2(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 105 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 106 inspectedObject(info, 2); | 107 inspectedObject(info, 2); |
| 107 } | 108 } |
| 108 static void inspectedObject3( | 109 void inspectedObject3(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 109 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 110 inspectedObject(info, 3); | 110 inspectedObject(info, 3); |
| 111 } | 111 } |
| 112 static void inspectedObject4( | 112 void inspectedObject4(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 113 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 114 inspectedObject(info, 4); | 113 inspectedObject(info, 4); |
| 115 } | 114 } |
| 115 | |
| 116 V8InspectorImpl* m_inspector; | |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 } // namespace v8_inspector | 119 } // namespace v8_inspector |
| 119 | 120 |
| 120 #endif // V8_INSPECTOR_V8CONSOLE_H_ | 121 #endif // V8_INSPECTOR_V8CONSOLE_H_ |
| OLD | NEW |