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

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

Issue 2643063002: Refactor Blink's ServiceConnector and add ability to mock in layout tests (Closed)
Patch Set: Fix build Created 3 years, 9 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 2017 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_BLINK_CONNECTOR_JS_WRAPPER_H_
6 #define CONTENT_RENDERER_MOJO_BLINK_CONNECTOR_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 BlinkConnectorImpl;
21
22 // A JS wrapper around blink::Connector that allows connecting to remote
23 // services.
24 class CONTENT_EXPORT BlinkConnectorJsWrapper
25 : public gin::Wrappable<BlinkConnectorJsWrapper> {
26 public:
27 ~BlinkConnectorJsWrapper() override;
28 static gin::Handle<BlinkConnectorJsWrapper> Create(
29 v8::Isolate* isolate,
30 v8::Handle<v8::Context> context,
31 BlinkConnectorImpl* remote_interfaces);
32
33 // gin::Wrappable<BlinkConnectorJsWrapper> overrides.
34 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
35 v8::Isolate* isolate) override;
36
37 // JS interface implementation.
38 void AddOverrideForTesting(const std::string& service_name,
39 const std::string& interface_name,
40 v8::Local<v8::Function> interface_factory);
41 void ClearOverridesForTesting();
42 mojo::Handle BindInterface(const std::string& service_name,
43 const std::string& interface_name);
44
45 static gin::WrapperInfo kWrapperInfo;
46 static const char kModuleName[];
47
48 private:
49 using ScopedJsFactory =
50 v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function>>;
51
52 BlinkConnectorJsWrapper(v8::Isolate* isolate,
53 v8::Handle<v8::Context> context,
54 base::WeakPtr<BlinkConnectorImpl> connector);
55
56 void CallJsFactory(const ScopedJsFactory& factory,
57 mojo::ScopedMessagePipeHandle pipe);
58
59 static void ClearContext(
60 const v8::WeakCallbackInfo<BlinkConnectorJsWrapper>& data);
61
62 v8::Isolate* isolate_;
63 v8::Global<v8::Context> context_;
64 base::WeakPtr<BlinkConnectorImpl> connector_;
65
66 base::WeakPtrFactory<BlinkConnectorJsWrapper> weak_factory_;
67
68 DISALLOW_COPY_AND_ASSIGN(BlinkConnectorJsWrapper);
69 };
70
71 } // namespace content
72
73 #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