OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_SERVICE_REGISTRY_JS_WRAPPER_H_ | 5 #ifndef CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ |
6 #define CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ | 6 #define CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_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/handle.h" | 15 #include "mojo/public/cpp/system/core.h" |
16 | |
17 namespace v8 { | |
18 class Isolate; | |
19 } | |
20 | 16 |
21 namespace content { | 17 namespace content { |
22 | 18 |
23 class ServiceRegistry; | 19 class ServiceRegistry; |
24 | 20 |
25 // A JS wrapper around ServiceRegistry that allows connecting to remote | 21 // A JS wrapper around ServiceRegistry that allows connecting to remote |
26 // services. | 22 // services. |
27 class CONTENT_EXPORT ServiceRegistryJsWrapper | 23 class CONTENT_EXPORT ServiceRegistryJsWrapper |
28 : public gin::Wrappable<ServiceRegistryJsWrapper> { | 24 : public gin::Wrappable<ServiceRegistryJsWrapper> { |
29 public: | 25 public: |
30 ~ServiceRegistryJsWrapper() override; | 26 ~ServiceRegistryJsWrapper() override; |
31 static gin::Handle<ServiceRegistryJsWrapper> Create( | 27 static gin::Handle<ServiceRegistryJsWrapper> Create( |
32 v8::Isolate* isolate, | 28 v8::Isolate* isolate, |
33 ServiceRegistry* service_registry); | 29 ServiceRegistry* service_registry); |
34 | 30 |
35 // gin::Wrappable<ServiceRegistryJsWrapper> overrides. | 31 // gin::Wrappable<ServiceRegistryJsWrapper> overrides. |
36 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 32 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
37 v8::Isolate* isolate) override; | 33 v8::Isolate* isolate) override; |
38 | 34 |
39 // JS interface implementation. | 35 // JS interface implementation. |
40 void AddServiceOverrideForTesting(const std::string& service_name, | |
41 v8::Local<v8::Function> service_factory); | |
42 mojo::Handle ConnectToService(const std::string& service_name); | 36 mojo::Handle ConnectToService(const std::string& service_name); |
43 | 37 |
44 static gin::WrapperInfo kWrapperInfo; | 38 static gin::WrapperInfo kWrapperInfo; |
45 static const char kModuleName[]; | 39 static const char kModuleName[]; |
46 | 40 |
47 private: | 41 private: |
48 explicit ServiceRegistryJsWrapper( | 42 explicit ServiceRegistryJsWrapper( |
49 base::WeakPtr<ServiceRegistry> service_registry); | 43 base::WeakPtr<ServiceRegistry> service_registry); |
50 | 44 |
51 base::WeakPtr<ServiceRegistry> service_registry_; | 45 base::WeakPtr<ServiceRegistry> service_registry_; |
52 | 46 |
53 DISALLOW_COPY_AND_ASSIGN(ServiceRegistryJsWrapper); | 47 DISALLOW_COPY_AND_ASSIGN(ServiceRegistryJsWrapper); |
54 }; | 48 }; |
55 | 49 |
56 } // namespace content | 50 } // namespace content |
57 | 51 |
58 #endif // CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ | 52 #endif // CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ |
OLD | NEW |