Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: test/inspector-protocol/inspector-impl.h

Issue 2368393003: [inspector] added inspector test runner [part 2] (Closed)
Patch Set: added missing microtask scope Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "test/inspector-protocol/task-runner.h"
12
13 namespace v8 {
14 namespace base {
15 class Semaphore;
dgozman 2016/09/27 16:30:36 Include it.
kozy 2016/09/27 17:00:53 Done.
16 } // base
17 } // v8
18
19 class TaskRunner;
dgozman 2016/09/27 16:30:36 Remove.
kozy 2016/09/27 17:00:53 I need this for ChannelImpl constructor.
20
21 class ChannelImpl final : public v8_inspector::V8Inspector::Channel {
22 public:
23 ChannelImpl(TaskRunner* frontend_task_runner)
dgozman 2016/09/27 16:30:36 explicit
kozy 2016/09/27 17:00:53 Done.
24 : frontend_task_runner_(frontend_task_runner) {}
25 virtual ~ChannelImpl() {}
26
27 private:
28 void sendProtocolResponse(int callId,
29 const v8_inspector::StringView& message) override {
30 SendMessageToFrontend(message);
31 }
32 void sendProtocolNotification(
33 const v8_inspector::StringView& message) override {
34 SendMessageToFrontend(message);
35 }
36 void flushProtocolNotifications() override {}
37 void SendMessageToFrontend(const v8_inspector::StringView& message);
38
39 TaskRunner* frontend_task_runner_;
40
41 DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
42 };
43
44 class InspectorClientImpl : public v8_inspector::V8InspectorClient {
45 public:
46 InspectorClientImpl();
47 virtual ~InspectorClientImpl();
48
49 void connect(ChannelImpl* channel, v8::Local<v8::Context>);
50
51 // V8InspectorClient implementation.
52 v8::Local<v8::Context> ensureDefaultContextInGroup(int) override;
53 double currentTimeMS() override;
54 void runMessageLoopOnPause(int) override;
55 void quitMessageLoopOnPause() override;
56
57 static v8_inspector::V8Inspector* InspectorFromContext(
58 v8::Local<v8::Context> context);
59 static v8_inspector::V8InspectorSession* SessionFromContext(
60 v8::Local<v8::Context> context);
61
62 private:
63 std::unique_ptr<v8_inspector::V8Inspector> inspector_;
64 std::unique_ptr<v8_inspector::V8InspectorSession> session_;
65 v8::Isolate* isolate_;
66 v8::Global<v8::Context> context_;
67
68 DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl);
69 };
70
71 class ConnectTask : public TaskRunner::Task {
72 public:
73 ConnectTask(InspectorClientImpl* client, ChannelImpl* channel,
74 v8::base::Semaphore* ready_semaphore);
75 virtual ~ConnectTask() {}
76
77 bool is_protocol_task() { return true; }
dgozman 2016/09/27 16:30:36 is_inspector_task
kozy 2016/09/27 17:00:53 Changed in https://codereview.chromium.org/2361623
78
79 void Run(v8::Isolate* isolate, const v8::Global<v8::Context>& context);
80
81 private:
82 InspectorClientImpl* client_;
83 ChannelImpl* channel_;
84 v8::base::Semaphore* ready_semaphore_;
85 };
86
87 class BackendExtension : public v8::Extension {
88 public:
89 BackendExtension()
90 : v8::Extension("v8_inspector/backend",
91 "native function evaluateInFrontend();") {}
92 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
93 v8::Isolate* isolate, v8::Local<v8::String> name);
94
95 static void set_frontend_task_runner(TaskRunner* task_runner) {
96 frontend_task_runner_ = task_runner;
97 }
98
99 private:
100 static void EvaluateInFrontend(
101 const v8::FunctionCallbackInfo<v8::Value>& args);
102
103 static TaskRunner* frontend_task_runner_;
104 };
105
106 class FrontendExtension : public v8::Extension {
107 public:
108 FrontendExtension()
109 : v8::Extension("v8_inspector/frontend",
110 "native function sendMessageToBackend();") {}
111 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
112 v8::Isolate* isolate, v8::Local<v8::String> name);
113
114 static void set_backend_task_runner(TaskRunner* task_runner) {
115 backend_task_runner_ = task_runner;
116 }
117
118 private:
119 static void SendMessageToBackend(
120 const v8::FunctionCallbackInfo<v8::Value>& args);
121
122 static TaskRunner* backend_task_runner_;
123 };
124
125 #endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698