Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | |
| 6 #define V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | |
| 7 | |
| 8 #include "include/v8-inspector.h" | |
| 9 #include "include/v8.h" | |
| 10 #include "src/base/macros.h" | |
| 11 #include "src/base/platform/platform.h" | |
| 12 #include "test/inspector-protocol/task-runner.h" | |
| 13 | |
| 14 class InspectorClientImpl : public v8_inspector::V8InspectorClient { | |
| 15 public: | |
| 16 class FrontendChannel { | |
| 17 public: | |
| 18 virtual ~FrontendChannel() {} | |
| 19 virtual void SendMessageToFrontend( | |
| 20 const v8_inspector::StringView& message) = 0; | |
| 21 }; | |
| 22 | |
| 23 InspectorClientImpl(TaskRunner* task_runner, | |
| 24 FrontendChannel* frontend_channel, | |
| 25 v8::base::Semaphore* ready_semaphore); | |
| 26 virtual ~InspectorClientImpl(); | |
| 27 | |
| 28 private: | |
| 29 // V8InspectorClient implementation. | |
| 30 v8::Local<v8::Context> ensureDefaultContextInGroup(int) override; | |
| 31 double currentTimeMS() override; | |
| 32 void runMessageLoopOnPause(int) override; | |
| 33 void quitMessageLoopOnPause() override; | |
| 34 | |
| 35 static v8_inspector::V8InspectorSession* SessionFromContext( | |
| 36 v8::Local<v8::Context> context); | |
| 37 | |
| 38 friend class ProcessMessageOnBackend; | |
| 39 | |
| 40 friend class ConnectTask; | |
| 41 void connect(v8::Local<v8::Context> context); | |
| 42 | |
| 43 std::unique_ptr<v8_inspector::V8Inspector> inspector_; | |
| 44 std::unique_ptr<v8_inspector::V8InspectorSession> session_; | |
| 45 std::unique_ptr<v8_inspector::V8Inspector::Channel> channel_; | |
| 46 | |
| 47 v8::Isolate* isolate_; | |
| 48 v8::Global<v8::Context> context_; | |
| 49 | |
| 50 TaskRunner* task_runner_; | |
| 51 FrontendChannel* frontend_channel_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl); | |
| 54 }; | |
| 55 | |
| 56 class FrontendExtension : public v8::Extension { | |
|
dgozman
2016/09/28 16:10:58
SendMessageToBackendExtension
kozy
2016/09/28 17:03:03
Done.
| |
| 57 public: | |
| 58 FrontendExtension() | |
| 59 : v8::Extension("v8_inspector/frontend", | |
| 60 "native function sendMessageToBackend();") {} | |
| 61 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | |
| 62 v8::Isolate* isolate, v8::Local<v8::String> name); | |
| 63 | |
| 64 static void set_backend_task_runner(TaskRunner* task_runner) { | |
| 65 backend_task_runner_ = task_runner; | |
| 66 } | |
| 67 | |
| 68 private: | |
| 69 static void SendMessageToBackend( | |
| 70 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 71 | |
| 72 static TaskRunner* backend_task_runner_; | |
| 73 }; | |
| 74 | |
| 75 #endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | |
| OLD | NEW |