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_PUBLIC_COMMON_SERVICE_REGISTRY_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ |
6 #define CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ | 6 #define CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "mojo/public/cpp/bindings/interface_ptr.h" | 15 #include "mojo/public/cpp/bindings/interface_ptr.h" |
16 #include "mojo/public/cpp/bindings/interface_request.h" | 16 #include "mojo/public/cpp/bindings/interface_request.h" |
17 #include "mojo/public/cpp/system/core.h" | 17 #include "mojo/public/cpp/system/core.h" |
18 | 18 |
| 19 #if defined(OS_ANDROID) |
| 20 #include <jni.h> |
| 21 #include "base/android/scoped_java_ref.h" |
| 22 #endif |
| 23 |
19 namespace content { | 24 namespace content { |
20 | 25 |
21 // A ServiceRegistry exposes local services that have been added using | 26 // A ServiceRegistry exposes local services that have been added using |
22 // AddService to a paired remote ServiceRegistry and provides local access to | 27 // AddService to a paired remote ServiceRegistry and provides local access to |
23 // services exposed by the remote ServiceRegistry through | 28 // services exposed by the remote ServiceRegistry through |
24 // ConnectToRemoteService. | 29 // ConnectToRemoteService. |
25 class CONTENT_EXPORT ServiceRegistry { | 30 class CONTENT_EXPORT ServiceRegistry { |
26 public: | 31 public: |
27 virtual ~ServiceRegistry() {} | 32 virtual ~ServiceRegistry() {} |
28 | 33 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // for testing. | 70 // for testing. |
66 virtual void AddServiceOverrideForTesting( | 71 virtual void AddServiceOverrideForTesting( |
67 const std::string& service_name, | 72 const std::string& service_name, |
68 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& | 73 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& |
69 service_factory) = 0; | 74 service_factory) = 0; |
70 | 75 |
71 // Removes all local service factories registered | 76 // Removes all local service factories registered |
72 // by AddServiceOverrideForTesting. Used only for testing. | 77 // by AddServiceOverrideForTesting. Used only for testing. |
73 virtual void ClearServiceOverridesForTesting() = 0; | 78 virtual void ClearServiceOverridesForTesting() = 0; |
74 | 79 |
| 80 #if defined(OS_ANDROID) |
| 81 // Returns the corresponding Java object. |
| 82 virtual const base::android::ScopedJavaGlobalRef<jobject>& GetJavaObj() = 0; |
| 83 #endif |
| 84 |
75 private: | 85 private: |
76 template <typename Interface> | 86 template <typename Interface> |
77 static void ForwardToServiceFactory( | 87 static void ForwardToServiceFactory( |
78 const base::Callback<void(mojo::InterfaceRequest<Interface>)> | 88 const base::Callback<void(mojo::InterfaceRequest<Interface>)> |
79 service_factory, | 89 service_factory, |
80 mojo::ScopedMessagePipeHandle handle) { | 90 mojo::ScopedMessagePipeHandle handle) { |
81 service_factory.Run(mojo::MakeRequest<Interface>(std::move(handle))); | 91 service_factory.Run(mojo::MakeRequest<Interface>(std::move(handle))); |
82 } | 92 } |
83 }; | 93 }; |
84 | 94 |
85 } // namespace content | 95 } // namespace content |
86 | 96 |
87 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ | 97 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ |
OLD | NEW |