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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import org.chromium.base.annotations.CalledByNative; | 7 import org.chromium.base.annotations.CalledByNative; |
8 import org.chromium.base.annotations.JNINamespace; | 8 import org.chromium.base.annotations.JNINamespace; |
9 import org.chromium.mojo.bindings.Interface; | 9 import org.chromium.mojo.bindings.Interface; |
10 import org.chromium.mojo.bindings.Interface.Proxy; | 10 import org.chromium.mojo.bindings.Interface.Proxy; |
11 import org.chromium.mojo.bindings.InterfaceRequest; | 11 import org.chromium.mojo.bindings.InterfaceRequest; |
12 import org.chromium.mojo.system.Core; | 12 import org.chromium.mojo.system.Core; |
13 import org.chromium.mojo.system.MessagePipeHandle; | 13 import org.chromium.mojo.system.MessagePipeHandle; |
14 import org.chromium.mojo.system.impl.CoreImpl; | 14 import org.chromium.mojo.system.impl.CoreImpl; |
15 | 15 |
16 /** | 16 /** |
17 * Java wrapper over Mojo ServiceRegistry held by the browser. | 17 * Java wrapper over Mojo ServiceRegistry held by the browser. |
18 */ | 18 */ |
19 @JNINamespace("content") | 19 @JNINamespace("content") |
20 public class ServiceRegistry { | 20 public class ServiceRegistry { |
21 | 21 |
22 interface ImplementationFactory<I extends Interface> { | 22 /** |
| 23 * The interface that a factory should implement. |
| 24 */ |
| 25 public interface ImplementationFactory<I extends Interface> { |
23 I createImpl(); | 26 I createImpl(); |
24 } | 27 } |
25 | 28 |
26 <I extends Interface, P extends Proxy> void addService( | 29 /** |
| 30 * Adds a service factory. |
| 31 * |
| 32 * @param manager The interface manager. |
| 33 * @param factory The service factory. |
| 34 */ |
| 35 public <I extends Interface, P extends Proxy> void addService( |
27 Interface.Manager<I, P> manager, ImplementationFactory<I> factory) { | 36 Interface.Manager<I, P> manager, ImplementationFactory<I> factory) { |
28 nativeAddService(mNativeServiceRegistryAndroid, manager, factory, manage
r.getName()); | 37 nativeAddService(mNativeServiceRegistryAndroid, manager, factory, manage
r.getName()); |
29 } | 38 } |
30 | 39 |
31 <I extends Interface, P extends Proxy> void removeService( | 40 <I extends Interface, P extends Proxy> void removeService( |
32 Interface.Manager<I, P> manager) { | 41 Interface.Manager<I, P> manager) { |
33 nativeRemoveService(mNativeServiceRegistryAndroid, manager.getName()); | 42 nativeRemoveService(mNativeServiceRegistryAndroid, manager.getName()); |
34 } | 43 } |
35 | 44 |
36 <I extends Interface, P extends Proxy> void connectToRemoteService( | 45 <I extends Interface, P extends Proxy> void connectToRemoteService( |
(...skipping 30 matching lines...) Expand all Loading... |
67 MessagePipeHandle handle = mCore.acquireNativeHandle(nativeHandle).toMes
sagePipeHandle(); | 76 MessagePipeHandle handle = mCore.acquireNativeHandle(nativeHandle).toMes
sagePipeHandle(); |
68 manager.bind(factory.createImpl(), handle); | 77 manager.bind(factory.createImpl(), handle); |
69 } | 78 } |
70 | 79 |
71 private native void nativeAddService(long nativeServiceRegistryAndroid, | 80 private native void nativeAddService(long nativeServiceRegistryAndroid, |
72 Interface.Manager manager, ImplementationFactory factory, String nam
e); | 81 Interface.Manager manager, ImplementationFactory factory, String nam
e); |
73 private native void nativeRemoveService(long nativeServiceRegistryAndroid, S
tring name); | 82 private native void nativeRemoveService(long nativeServiceRegistryAndroid, S
tring name); |
74 private native void nativeConnectToRemoteService(long nativeServiceRegistryA
ndroid, String name, | 83 private native void nativeConnectToRemoteService(long nativeServiceRegistryA
ndroid, String name, |
75 int handle); | 84 int handle); |
76 } | 85 } |
OLD | NEW |