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

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