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

Unified Diff: content/renderer/mojo/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/renderer/BUILD.gn ('k') | content/renderer/mojo/interface_registry_js_wrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/mojo/interface_registry_js_wrapper.h
diff --git a/content/renderer/mojo/interface_registry_js_wrapper.h b/content/renderer/mojo/interface_registry_js_wrapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..eeac6bf0e56f39cd12038b1e9e3f712eb26ec5e1
--- /dev/null
+++ b/content/renderer/mojo/interface_registry_js_wrapper.h
@@ -0,0 +1,72 @@
+// 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_RENDERER_MOJO_INTERFACE_REGISTRY_JS_WRAPPER_H_
+#define CONTENT_RENDERER_MOJO_INTERFACE_REGISTRY_JS_WRAPPER_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "content/common/content_export.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
+// remote services.
+class CONTENT_EXPORT InterfaceRegistryJsWrapper
+ : public gin::Wrappable<InterfaceRegistryJsWrapper> {
+ public:
+ ~InterfaceRegistryJsWrapper() override;
jochen (gone - plz use gerrit) 2016/10/10 12:36:03 should be private
Sam McNally 2016/10/11 00:10:13 Done.
+ 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);
+
+ 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_RENDERER_MOJO_INTERFACE_REGISTRY_JS_WRAPPER_H_
« no previous file with comments | « content/renderer/BUILD.gn ('k') | content/renderer/mojo/interface_registry_js_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698