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

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

Issue 2775483003: Use public Service Manager Connector API in Blink (Closed)
Patch Set: . Created 3 years, 8 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MOJO_BLINK_CONNECTOR_JS_WRAPPER_H_ 5 #ifndef CONTENT_RENDERER_MOJO_BLINK_CONNECTOR_JS_WRAPPER_H_
6 #define CONTENT_RENDERER_MOJO_BLINK_CONNECTOR_JS_WRAPPER_H_ 6 #define CONTENT_RENDERER_MOJO_BLINK_CONNECTOR_JS_WRAPPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "gin/handle.h" 12 #include "gin/handle.h"
13 #include "gin/object_template_builder.h" 13 #include "gin/object_template_builder.h"
14 #include "gin/wrappable.h" 14 #include "gin/wrappable.h"
15 #include "mojo/public/cpp/system/message_pipe.h" 15 #include "mojo/public/cpp/system/message_pipe.h"
16 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
17 17
18 namespace service_manager {
19 class Connector;
20 }
21
18 namespace content { 22 namespace content {
19 23
20 class BlinkConnectorImpl; 24 // A JS wrapper around service_manager::Connector that allows connecting to
21 25 // remote services.
22 // A JS wrapper around blink::Connector that allows connecting to remote
23 // services.
24 class CONTENT_EXPORT BlinkConnectorJsWrapper 26 class CONTENT_EXPORT BlinkConnectorJsWrapper
25 : public gin::Wrappable<BlinkConnectorJsWrapper> { 27 : public gin::Wrappable<BlinkConnectorJsWrapper> {
26 public: 28 public:
27 ~BlinkConnectorJsWrapper() override; 29 ~BlinkConnectorJsWrapper() override;
28 static gin::Handle<BlinkConnectorJsWrapper> Create( 30 static gin::Handle<BlinkConnectorJsWrapper> Create(
29 v8::Isolate* isolate, 31 v8::Isolate* isolate,
30 v8::Handle<v8::Context> context, 32 v8::Handle<v8::Context> context,
31 BlinkConnectorImpl* remote_interfaces); 33 service_manager::Connector* remote_interfaces);
32 34
33 // gin::Wrappable<BlinkConnectorJsWrapper> overrides. 35 // gin::Wrappable<BlinkConnectorJsWrapper> overrides.
34 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( 36 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
35 v8::Isolate* isolate) override; 37 v8::Isolate* isolate) override;
36 38
37 // JS interface implementation. 39 // JS interface implementation.
38 void AddOverrideForTesting(const std::string& service_name, 40 void AddOverrideForTesting(const std::string& service_name,
39 const std::string& interface_name, 41 const std::string& interface_name,
40 v8::Local<v8::Function> interface_factory); 42 v8::Local<v8::Function> interface_factory);
41 void ClearOverridesForTesting(); 43 void ClearOverridesForTesting();
42 mojo::Handle BindInterface(const std::string& service_name, 44 mojo::Handle BindInterface(const std::string& service_name,
43 const std::string& interface_name); 45 const std::string& interface_name);
44 46
45 static gin::WrapperInfo kWrapperInfo; 47 static gin::WrapperInfo kWrapperInfo;
46 static const char kModuleName[]; 48 static const char kModuleName[];
47 49
48 private: 50 private:
49 using ScopedJsFactory = 51 using ScopedJsFactory =
50 v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function>>; 52 v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function>>;
51 53
52 BlinkConnectorJsWrapper(v8::Isolate* isolate, 54 BlinkConnectorJsWrapper(v8::Isolate* isolate,
53 v8::Handle<v8::Context> context, 55 v8::Handle<v8::Context> context,
54 base::WeakPtr<BlinkConnectorImpl> connector); 56 base::WeakPtr<service_manager::Connector> connector);
55 57
56 void CallJsFactory(const ScopedJsFactory& factory, 58 void CallJsFactory(const ScopedJsFactory& factory,
57 mojo::ScopedMessagePipeHandle pipe); 59 mojo::ScopedMessagePipeHandle pipe);
58 60
59 static void ClearContext( 61 static void ClearContext(
60 const v8::WeakCallbackInfo<BlinkConnectorJsWrapper>& data); 62 const v8::WeakCallbackInfo<BlinkConnectorJsWrapper>& data);
61 63
62 v8::Isolate* isolate_; 64 v8::Isolate* isolate_;
63 v8::Global<v8::Context> context_; 65 v8::Global<v8::Context> context_;
64 base::WeakPtr<BlinkConnectorImpl> connector_; 66 base::WeakPtr<service_manager::Connector> connector_;
65 67
66 base::WeakPtrFactory<BlinkConnectorJsWrapper> weak_factory_; 68 base::WeakPtrFactory<BlinkConnectorJsWrapper> weak_factory_;
67 69
68 DISALLOW_COPY_AND_ASSIGN(BlinkConnectorJsWrapper); 70 DISALLOW_COPY_AND_ASSIGN(BlinkConnectorJsWrapper);
69 }; 71 };
70 72
71 } // namespace content 73 } // namespace content
72 74
73 #endif // CONTENT_RENDERER_MOJO_BLINK_CONNECTOR_JS_WRAPPER_H_ 75 #endif // CONTENT_RENDERER_MOJO_BLINK_CONNECTOR_JS_WRAPPER_H_
OLDNEW
« no previous file with comments | « content/renderer/mojo/blink_connector_impl_unittest.cc ('k') | content/renderer/mojo/blink_connector_js_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698