| 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_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | 5 #ifndef V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ |
| 6 #define V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | 6 #define V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ |
| 7 | 7 |
| 8 #include "include/v8-inspector.h" | 8 #include "include/v8-inspector.h" |
| 9 #include "include/v8.h" | 9 #include "include/v8.h" |
| 10 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 InspectorClientImpl(TaskRunner* task_runner, | 23 InspectorClientImpl(TaskRunner* task_runner, |
| 24 FrontendChannel* frontend_channel, | 24 FrontendChannel* frontend_channel, |
| 25 v8::base::Semaphore* ready_semaphore); | 25 v8::base::Semaphore* ready_semaphore); |
| 26 virtual ~InspectorClientImpl(); | 26 virtual ~InspectorClientImpl(); |
| 27 | 27 |
| 28 static v8_inspector::V8Inspector* InspectorFromContext( | 28 static v8_inspector::V8Inspector* InspectorFromContext( |
| 29 v8::Local<v8::Context> context); | 29 v8::Local<v8::Context> context); |
| 30 | 30 |
| 31 void setCurrentTimeMSForTest(double time); |
| 32 |
| 31 private: | 33 private: |
| 32 // V8InspectorClient implementation. | 34 // V8InspectorClient implementation. |
| 33 v8::Local<v8::Context> ensureDefaultContextInGroup( | 35 v8::Local<v8::Context> ensureDefaultContextInGroup( |
| 34 int context_group_id) override; | 36 int context_group_id) override; |
| 35 double currentTimeMS() override; | 37 double currentTimeMS() override; |
| 36 void runMessageLoopOnPause(int context_group_id) override; | 38 void runMessageLoopOnPause(int context_group_id) override; |
| 37 void quitMessageLoopOnPause() override; | 39 void quitMessageLoopOnPause() override; |
| 38 | 40 |
| 39 static v8_inspector::V8InspectorSession* SessionFromContext( | 41 static v8_inspector::V8InspectorSession* SessionFromContext( |
| 40 v8::Local<v8::Context> context); | 42 v8::Local<v8::Context> context); |
| 41 | 43 |
| 42 friend class SendMessageToBackendTask; | 44 friend class SendMessageToBackendTask; |
| 43 | 45 |
| 44 friend class ConnectTask; | 46 friend class ConnectTask; |
| 45 void connect(v8::Local<v8::Context> context); | 47 void connect(v8::Local<v8::Context> context); |
| 46 | 48 |
| 47 std::unique_ptr<v8_inspector::V8Inspector> inspector_; | 49 std::unique_ptr<v8_inspector::V8Inspector> inspector_; |
| 48 std::unique_ptr<v8_inspector::V8InspectorSession> session_; | 50 std::unique_ptr<v8_inspector::V8InspectorSession> session_; |
| 49 std::unique_ptr<v8_inspector::V8Inspector::Channel> channel_; | 51 std::unique_ptr<v8_inspector::V8Inspector::Channel> channel_; |
| 50 | 52 |
| 51 v8::Isolate* isolate_; | 53 v8::Isolate* isolate_; |
| 52 v8::Global<v8::Context> context_; | 54 v8::Global<v8::Context> context_; |
| 53 | 55 |
| 54 TaskRunner* task_runner_; | 56 TaskRunner* task_runner_; |
| 55 FrontendChannel* frontend_channel_; | 57 FrontendChannel* frontend_channel_; |
| 56 | 58 |
| 59 bool current_time_set_for_test_ = false; |
| 60 double current_time_ = 0.0; |
| 61 |
| 57 DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl); | 62 DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl); |
| 58 }; | 63 }; |
| 59 | 64 |
| 60 class SendMessageToBackendExtension : public v8::Extension { | 65 class SendMessageToBackendExtension : public v8::Extension { |
| 61 public: | 66 public: |
| 62 SendMessageToBackendExtension() | 67 SendMessageToBackendExtension() |
| 63 : v8::Extension("v8_inspector/frontend", | 68 : v8::Extension("v8_inspector/frontend", |
| 64 "native function sendMessageToBackend();") {} | 69 "native function sendMessageToBackend();") {} |
| 65 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 70 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 66 v8::Isolate* isolate, v8::Local<v8::String> name); | 71 v8::Isolate* isolate, v8::Local<v8::String> name); |
| 67 | 72 |
| 68 static void set_backend_task_runner(TaskRunner* task_runner) { | 73 static void set_backend_task_runner(TaskRunner* task_runner) { |
| 69 backend_task_runner_ = task_runner; | 74 backend_task_runner_ = task_runner; |
| 70 } | 75 } |
| 71 | 76 |
| 72 private: | 77 private: |
| 73 static void SendMessageToBackend( | 78 static void SendMessageToBackend( |
| 74 const v8::FunctionCallbackInfo<v8::Value>& args); | 79 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 75 | 80 |
| 76 static TaskRunner* backend_task_runner_; | 81 static TaskRunner* backend_task_runner_; |
| 77 }; | 82 }; |
| 78 | 83 |
| 79 #endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | 84 #endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ |
| OLD | NEW |