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

Side by Side Diff: content/renderer/mojo/service_registry_js_wrapper.h

Issue 2079943002: Change RenderFrame to use InterfaceRegistry et al. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a2
Patch Set: . Created 4 years, 6 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 2014 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_SERVICE_REGISTRY_JS_WRAPPER_H_
6 #define CONTENT_RENDERER_MOJO_SERVICE_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 content {
19
20 class ServiceRegistry;
21
22 // A JS wrapper around ServiceRegistry that allows connecting to remote
23 // services.
24 class CONTENT_EXPORT ServiceRegistryJsWrapper
25 : public gin::Wrappable<ServiceRegistryJsWrapper> {
26 public:
27 ~ServiceRegistryJsWrapper() override;
28 static gin::Handle<ServiceRegistryJsWrapper> Create(
29 v8::Isolate* isolate,
30 v8::Handle<v8::Context> context,
31 ServiceRegistry* service_registry);
32
33 // gin::Wrappable<ServiceRegistryJsWrapper> overrides.
34 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
35 v8::Isolate* isolate) override;
36
37 // JS interface implementation.
38 void AddServiceOverrideForTesting(const std::string& service_name,
39 v8::Local<v8::Function> service_factory);
40 void ClearServiceOverridesForTesting();
41 mojo::Handle ConnectToService(const std::string& service_name);
42
43 static gin::WrapperInfo kWrapperInfo;
44 static const char kPerFrameModuleName[];
45 static const char kPerProcessModuleName[];
46
47 private:
48 using ScopedJsFactory =
49 v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function>>;
50
51 ServiceRegistryJsWrapper(v8::Isolate* isolate,
52 v8::Handle<v8::Context> context,
53 base::WeakPtr<ServiceRegistry> service_registry);
54
55 void CallJsFactory(const ScopedJsFactory& factory,
56 mojo::ScopedMessagePipeHandle pipe);
57
58 static void ClearContext(
59 const v8::WeakCallbackInfo<ServiceRegistryJsWrapper>& data);
60
61 v8::Isolate* isolate_;
62 v8::Global<v8::Context> context_;
63 base::WeakPtr<ServiceRegistry> service_registry_;
64
65 base::WeakPtrFactory<ServiceRegistryJsWrapper> weak_factory_;
66
67 DISALLOW_COPY_AND_ASSIGN(ServiceRegistryJsWrapper);
68 };
69
70 } // namespace content
71
72 #endif // CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_
OLDNEW
« no previous file with comments | « content/renderer/mojo/interface_provider_js_wrapper.cc ('k') | content/renderer/mojo/service_registry_js_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698