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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: test/inspector-protocol/inspector-impl.h
diff --git a/test/inspector-protocol/inspector-impl.h b/test/inspector-protocol/inspector-impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..413a2472acceaf6ef717b51ebbf4fe9737860f34
--- /dev/null
+++ b/test/inspector-protocol/inspector-impl.h
@@ -0,0 +1,125 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_
+#define V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_
+
+#include "include/v8-inspector.h"
+#include "include/v8.h"
+#include "src/base/macros.h"
+#include "test/inspector-protocol/task-runner.h"
+
+namespace v8 {
+namespace base {
+class Semaphore;
dgozman 2016/09/27 16:30:36 Include it.
kozy 2016/09/27 17:00:53 Done.
+} // base
+} // v8
+
+class TaskRunner;
dgozman 2016/09/27 16:30:36 Remove.
kozy 2016/09/27 17:00:53 I need this for ChannelImpl constructor.
+
+class ChannelImpl final : public v8_inspector::V8Inspector::Channel {
+ public:
+ ChannelImpl(TaskRunner* frontend_task_runner)
dgozman 2016/09/27 16:30:36 explicit
kozy 2016/09/27 17:00:53 Done.
+ : frontend_task_runner_(frontend_task_runner) {}
+ virtual ~ChannelImpl() {}
+
+ private:
+ void sendProtocolResponse(int callId,
+ const v8_inspector::StringView& message) override {
+ SendMessageToFrontend(message);
+ }
+ void sendProtocolNotification(
+ const v8_inspector::StringView& message) override {
+ SendMessageToFrontend(message);
+ }
+ void flushProtocolNotifications() override {}
+ void SendMessageToFrontend(const v8_inspector::StringView& message);
+
+ TaskRunner* frontend_task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
+};
+
+class InspectorClientImpl : public v8_inspector::V8InspectorClient {
+ public:
+ InspectorClientImpl();
+ virtual ~InspectorClientImpl();
+
+ void connect(ChannelImpl* channel, v8::Local<v8::Context>);
+
+ // V8InspectorClient implementation.
+ v8::Local<v8::Context> ensureDefaultContextInGroup(int) override;
+ double currentTimeMS() override;
+ void runMessageLoopOnPause(int) override;
+ void quitMessageLoopOnPause() override;
+
+ static v8_inspector::V8Inspector* InspectorFromContext(
+ v8::Local<v8::Context> context);
+ static v8_inspector::V8InspectorSession* SessionFromContext(
+ v8::Local<v8::Context> context);
+
+ private:
+ std::unique_ptr<v8_inspector::V8Inspector> inspector_;
+ std::unique_ptr<v8_inspector::V8InspectorSession> session_;
+ v8::Isolate* isolate_;
+ v8::Global<v8::Context> context_;
+
+ DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl);
+};
+
+class ConnectTask : public TaskRunner::Task {
+ public:
+ ConnectTask(InspectorClientImpl* client, ChannelImpl* channel,
+ v8::base::Semaphore* ready_semaphore);
+ virtual ~ConnectTask() {}
+
+ 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
+
+ void Run(v8::Isolate* isolate, const v8::Global<v8::Context>& context);
+
+ private:
+ InspectorClientImpl* client_;
+ ChannelImpl* channel_;
+ v8::base::Semaphore* ready_semaphore_;
+};
+
+class BackendExtension : public v8::Extension {
+ public:
+ BackendExtension()
+ : v8::Extension("v8_inspector/backend",
+ "native function evaluateInFrontend();") {}
+ virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
+ v8::Isolate* isolate, v8::Local<v8::String> name);
+
+ static void set_frontend_task_runner(TaskRunner* task_runner) {
+ frontend_task_runner_ = task_runner;
+ }
+
+ private:
+ static void EvaluateInFrontend(
+ const v8::FunctionCallbackInfo<v8::Value>& args);
+
+ static TaskRunner* frontend_task_runner_;
+};
+
+class FrontendExtension : public v8::Extension {
+ public:
+ FrontendExtension()
+ : v8::Extension("v8_inspector/frontend",
+ "native function sendMessageToBackend();") {}
+ virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
+ v8::Isolate* isolate, v8::Local<v8::String> name);
+
+ static void set_backend_task_runner(TaskRunner* task_runner) {
+ backend_task_runner_ = task_runner;
+ }
+
+ private:
+ static void SendMessageToBackend(
+ const v8::FunctionCallbackInfo<v8::Value>& args);
+
+ static TaskRunner* backend_task_runner_;
+};
+
+#endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698