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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium 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 CONTENT_RENDERER_MOJO_INTERFACE_REGISTRY_JS_WRAPPER_H_
6 #define CONTENT_RENDERER_MOJO_INTERFACE_REGISTRY_JS_WRAPPER_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "content/common/content_export.h"
12 #include "gin/handle.h"
13 #include "gin/object_template_builder.h"
14 #include "gin/wrappable.h"
15 #include "mojo/public/cpp/system/message_pipe.h"
16 #include "v8/include/v8.h"
17
18 namespace shell {
19 class InterfaceRegistry;
20 }
21
22 namespace content {
23
24 // A JS wrapper around shell::InterfaceRegistry that allows connecting to
25 // remote services.
26 class CONTENT_EXPORT InterfaceRegistryJsWrapper
27 : public gin::Wrappable<InterfaceRegistryJsWrapper> {
28 public:
29 ~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.
30 static gin::Handle<InterfaceRegistryJsWrapper> Create(
31 v8::Isolate* isolate,
32 v8::Handle<v8::Context> context,
33 shell::InterfaceRegistry* interface_registry);
34
35 // gin::Wrappable<InterfaceRegistryJsWrapper> overrides.
36 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
37 v8::Isolate* isolate) override;
38
39 // JS interface implementation.
40 mojo::Handle GetLocalInterfaceForTesting(const std::string& interface_name);
41
42 static gin::WrapperInfo kWrapperInfo;
43 static const char kPerFrameModuleName[];
44 static const char kPerProcessModuleName[];
45
46 private:
47 using ScopedJsFactory =
48 v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function>>;
49
50 InterfaceRegistryJsWrapper(
51 v8::Isolate* isolate,
52 v8::Handle<v8::Context> context,
53 base::WeakPtr<shell::InterfaceRegistry> interface_registry);
54
55 void CallJsFactory(const ScopedJsFactory& factory,
56 mojo::ScopedMessagePipeHandle pipe);
57
58 static void ClearContext(
59 const v8::WeakCallbackInfo<InterfaceRegistryJsWrapper>& data);
60
61 v8::Isolate* isolate_;
62 v8::Global<v8::Context> context_;
63 base::WeakPtr<shell::InterfaceRegistry> interface_registry_;
64
65 base::WeakPtrFactory<InterfaceRegistryJsWrapper> weak_factory_;
66
67 DISALLOW_COPY_AND_ASSIGN(InterfaceRegistryJsWrapper);
68 };
69
70 } // namespace content
71
72 #endif // CONTENT_RENDERER_MOJO_INTERFACE_REGISTRY_JS_WRAPPER_H_
OLDNEW
« 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