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

Unified Diff: content/shell/renderer/layout_test/interface_registry_js_wrapper.h

Issue 2402293002: Add a Javascript wrapper for InterfaceRegistry. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/BUILD.gn ('k') | content/shell/renderer/layout_test/interface_registry_js_wrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/layout_test/interface_registry_js_wrapper.h
diff --git a/content/shell/renderer/layout_test/interface_registry_js_wrapper.h b/content/shell/renderer/layout_test/interface_registry_js_wrapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..57498a6d47b5aa9ab0fb8211b9b994a7d351f60f
--- /dev/null
+++ b/content/shell/renderer/layout_test/interface_registry_js_wrapper.h
@@ -0,0 +1,71 @@
+// Copyright 2016 The Chromium 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 CONTENT_SHELL_RENDERER_LAYOUT_TEST_INTERFACE_REGISTRY_JS_WRAPPER_H_
+#define CONTENT_SHELL_RENDERER_LAYOUT_TEST_INTERFACE_REGISTRY_JS_WRAPPER_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "gin/handle.h"
+#include "gin/object_template_builder.h"
+#include "gin/wrappable.h"
+#include "mojo/public/cpp/system/message_pipe.h"
+#include "v8/include/v8.h"
+
+namespace shell {
+class InterfaceRegistry;
+}
+
+namespace content {
+
+// A JS wrapper around shell::InterfaceRegistry that allows connecting to
+// interfaces exposed by the renderer for testing.
+class InterfaceRegistryJsWrapper
+ : public gin::Wrappable<InterfaceRegistryJsWrapper> {
+ public:
+ static gin::Handle<InterfaceRegistryJsWrapper> Create(
+ v8::Isolate* isolate,
+ v8::Handle<v8::Context> context,
+ shell::InterfaceRegistry* interface_registry);
+
+ // gin::Wrappable<InterfaceRegistryJsWrapper> overrides.
+ gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
+ v8::Isolate* isolate) override;
+
+ // JS interface implementation.
+ mojo::Handle GetLocalInterfaceForTesting(const std::string& interface_name);
+
+ static gin::WrapperInfo kWrapperInfo;
+ static const char kPerFrameModuleName[];
+ static const char kPerProcessModuleName[];
+
+ private:
+ using ScopedJsFactory =
+ v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function>>;
+
+ InterfaceRegistryJsWrapper(
+ v8::Isolate* isolate,
+ v8::Handle<v8::Context> context,
+ base::WeakPtr<shell::InterfaceRegistry> interface_registry);
+ ~InterfaceRegistryJsWrapper() override;
+
+ void CallJsFactory(const ScopedJsFactory& factory,
+ mojo::ScopedMessagePipeHandle pipe);
+
+ static void ClearContext(
+ const v8::WeakCallbackInfo<InterfaceRegistryJsWrapper>& data);
+
+ v8::Isolate* isolate_;
+ v8::Global<v8::Context> context_;
+ base::WeakPtr<shell::InterfaceRegistry> interface_registry_;
+
+ base::WeakPtrFactory<InterfaceRegistryJsWrapper> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(InterfaceRegistryJsWrapper);
+};
+
+} // namespace content
+
+#endif // CONTENT_SHELL_RENDERER_LAYOUT_TEST_INTERFACE_REGISTRY_JS_WRAPPER_H_
« no previous file with comments | « content/shell/BUILD.gn ('k') | content/shell/renderer/layout_test/interface_registry_js_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698