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

Unified Diff: sky/shell/org/domokit/sky/shell/JavaServiceProvider.java

Issue 969753003: Make it possible for SkyShell embedders to register services (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: sky/shell/org/domokit/sky/shell/JavaServiceProvider.java
diff --git a/sky/shell/org/domokit/sky/shell/JavaServiceProvider.java b/sky/shell/org/domokit/sky/shell/JavaServiceProvider.java
index bda18c83fb39c4b3012b96107640781a501bcb5e..47996f466501af32a7b34491439d90694d96bdaa 100644
--- a/sky/shell/org/domokit/sky/shell/JavaServiceProvider.java
+++ b/sky/shell/org/domokit/sky/shell/JavaServiceProvider.java
@@ -12,14 +12,10 @@ import org.chromium.mojo.system.Core;
import org.chromium.mojo.system.MessagePipeHandle;
import org.chromium.mojo.system.MojoException;
import org.chromium.mojo.system.impl.CoreImpl;
-import org.chromium.mojom.mojo.NetworkService;
import org.chromium.mojom.mojo.ServiceProvider;
-import org.chromium.mojom.sensors.SensorService;
-import org.domokit.oknet.NetworkServiceImpl;
-import org.domokit.sensors.SensorServiceImpl;
/**
- * A class to intialize the network.
+ * A collection of services implemented in Java.
**/
@JNINamespace("sky::shell")
public class JavaServiceProvider implements ServiceProvider {
@@ -49,13 +45,11 @@ public class JavaServiceProvider implements ServiceProvider {
@Override
public void connectToService(String interfaceName, MessagePipeHandle pipe) {
- if (interfaceName.equals(NetworkService.MANAGER.getName())) {
- new NetworkServiceImpl(mContext, mCore, pipe);
- return;
- } else if (interfaceName.equals(SensorService.MANAGER.getName())) {
- new SensorServiceImpl(mContext, mCore, pipe);
+ ServiceFactory factory = ServiceRegistry.SHARED.get(interfaceName);
+ if (factory == null) {
+ pipe.close();
return;
}
- pipe.close();
+ factory.connectToService(mContext, mCore, pipe);
}
}

Powered by Google App Engine
This is Rietveld 408576698