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

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

Issue 2368393003: [inspector] added inspector test runner [part 2] (Closed)
Patch Set: addressed comments 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 "src/base/platform/platform.h"
12 #include "test/inspector-protocol/task-runner.h"
13
14 class TaskRunner;
15
16 class ChannelImpl final : public v8_inspector::V8Inspector::Channel {
17 public:
18 explicit ChannelImpl(TaskRunner* frontend_task_runner)
19 : frontend_task_runner_(frontend_task_runner) {}
20 virtual ~ChannelImpl() {}
21
22 private:
23 void sendProtocolResponse(int callId,
24 const v8_inspector::StringView& message) override {
25 SendMessageToFrontend(message);
26 }
27 void sendProtocolNotification(
28 const v8_inspector::StringView& message) override {
29 SendMessageToFrontend(message);
30 }
31 void flushProtocolNotifications() override {}
32 void SendMessageToFrontend(const v8_inspector::StringView& message);
33
34 TaskRunner* frontend_task_runner_;
35
36 DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
37 };
38
39 class InspectorClientImpl : public v8_inspector::V8InspectorClient {
40 public:
41 InspectorClientImpl();
42 virtual ~InspectorClientImpl();
43
44 void connect(ChannelImpl* channel, v8::Local<v8::Context>);
45
46 // V8InspectorClient implementation.
47 v8::Local<v8::Context> ensureDefaultContextInGroup(int) override;
48 double currentTimeMS() override;
49 void runMessageLoopOnPause(int) override;
50 void quitMessageLoopOnPause() override;
51
52 static v8_inspector::V8Inspector* InspectorFromContext(
53 v8::Local<v8::Context> context);
54 static v8_inspector::V8InspectorSession* SessionFromContext(
55 v8::Local<v8::Context> context);
56
57 private:
58 std::unique_ptr<v8_inspector::V8Inspector> inspector_;
59 std::unique_ptr<v8_inspector::V8InspectorSession> session_;
60 v8::Isolate* isolate_;
61 v8::Global<v8::Context> context_;
62
63 DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl);
64 };
65
66 class ConnectTask : public TaskRunner::Task {
dgozman 2016/09/27 18:41:20 We can remove this and ChannelImpl from header and
kozy 2016/09/27 19:31:22 Done.
67 public:
68 ConnectTask(InspectorClientImpl* client, ChannelImpl* channel,
69 v8::base::Semaphore* ready_semaphore);
70 virtual ~ConnectTask() {}
71
72 bool is_inspector_task() final { return true; }
73
74 void Run(v8::Isolate* isolate, const v8::Global<v8::Context>& context);
75
76 private:
77 InspectorClientImpl* client_;
78 ChannelImpl* channel_;
79 v8::base::Semaphore* ready_semaphore_;
80 };
81
82 class FrontendExtension : public v8::Extension {
83 public:
84 FrontendExtension()
85 : v8::Extension("v8_inspector/frontend",
86 "native function sendMessageToBackend();") {}
87 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
88 v8::Isolate* isolate, v8::Local<v8::String> name);
89
90 static void set_backend_task_runner(TaskRunner* task_runner) {
91 backend_task_runner_ = task_runner;
92 }
93
94 private:
95 static void SendMessageToBackend(
96 const v8::FunctionCallbackInfo<v8::Value>& args);
97
98 static TaskRunner* backend_task_runner_;
99 };
100
101 #endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698