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

Unified Diff: third_party/mojo/src/mojo/public/dart/src/application.dart

Issue 954643002: Update mojo sdk to rev 3d23dae011859a2aae49f1d1adde705c8e85d819 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use run_renderer_in_process() 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: third_party/mojo/src/mojo/public/dart/src/application.dart
diff --git a/third_party/mojo/src/mojo/public/dart/src/application.dart b/third_party/mojo/src/mojo/public/dart/src/application.dart
index e5b9d4b73f3b9e13654aa3f5d5175ff3c66c73c1..4be554df1bee1800fdcaaa4981e5e607a6a2ee12 100644
--- a/third_party/mojo/src/mojo/public/dart/src/application.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/application.dart
@@ -19,16 +19,17 @@ class _ApplicationImpl extends application_mojom.Application {
super.delegate = this;
}
- void initialize(shell_mojom.ShellProxy shellProxy, List<String> args) {
+ void initialize(
+ shell_mojom.ShellProxy shellProxy, List<String> args, String url) {
assert(shell == null);
shell = shellProxy;
- _application.initialize(args);
+ _application.initialize(args, url);
}
void acceptConnection(
String requestorUrl,
- service_provider.ServiceProviderStub services,
- service_provider.ServiceProviderProxy exposedServices) =>
+ ServiceProviderStub services,
+ ServiceProviderProxy exposedServices) =>
_application._acceptConnection(requestorUrl, services, exposedServices);
void requestQuit() => _application._requestQuitAndClose();
@@ -36,72 +37,46 @@ class _ApplicationImpl extends application_mojom.Application {
void close({bool nodefer: false}) => shell.close();
}
-// ApplicationConnection represents a single outgoing connection to another app.
-class ApplicationConnection {
- // ServiceProvider used to obtain services from the remote application.
- service_provider.ServiceProviderProxy serviceProvider;
-
- ApplicationConnection(this.serviceProvider);
-
- // Obtains a service from the remote application.
- void connectToService(bindings.Proxy proxy) {
- assert(!proxy.isBound);
- var applicationPipe = new core.MojoMessagePipe();
- var proxyEndpoint = applicationPipe.endpoints[0];
- var applicationEndpoint = applicationPipe.endpoints[1];
- proxy.bind(proxyEndpoint);
- serviceProvider.connectToService(proxy.name, applicationEndpoint);
- }
-}
-
// TODO(zra): Better documentation and examples.
// To implement, do the following:
+// - Optionally override initialize() to process command-line args.
// - Optionally override acceptConnection() if services are to be provided.
-// The override should assign a factory function to the passed in
-// ServiceProvider's |factory| field, and then call listen on the
-// ServiceProvider. The factory function should take a MojoMessagePipeEndpoint
-// and return an object that implements the requested interface.
-// - Optionally override initialize() where needed.
-// - Optionally override requestClose() to clean up state specific to your
-// application.
-// To use an Application:
-// - Call listen() on a newly created Application to begin providing services.
-// - Call connectToService() to request services from the Shell.
-// - Call close() to close connections to any requested ServiceProviders and the
-// Shell.
+// - Optionally override close() to clean up application resources.
abstract class Application {
_ApplicationImpl _applicationImpl;
List<ApplicationConnection> _applicationConnections;
- List<ServiceProvider> _serviceProviders;
Application(core.MojoMessagePipeEndpoint endpoint) {
_applicationConnections = [];
- _serviceProviders = [];
_applicationImpl = new _ApplicationImpl(this, endpoint);
}
Application.fromHandle(core.MojoHandle appHandle) {
_applicationConnections = [];
- _serviceProviders = [];
_applicationImpl = new _ApplicationImpl.fromHandle(this, appHandle);
}
- void initialize(List<String> args) {}
+ void initialize(List<String> args, String url) {}
- // Establishes a connection to the app at |url|.
+ // TODO(skydart): This is a temporary fix to allow sky application to consume
+ // mojo services. Do not use for any other purpose.
+ void initializeFromShellProxy(shell_mojom.ShellProxy shellProxy,
+ List<String> args, String url) {
+ _applicationImpl.initialize(shellProxy, args, url);
+ }
+
+ // Returns a connection to the app at |url|.
ApplicationConnection connectToApplication(String url) {
- var serviceProviderProxy =
- new service_provider.ServiceProviderProxy.unbound();
- // TODO: Need to expose ServiceProvider for local services.
- _applicationImpl.shell.connectToApplication(
- url, serviceProviderProxy, null);
- var applicationConnection = new ApplicationConnection(serviceProviderProxy);
- _applicationConnections.add(applicationConnection);
- return applicationConnection;
+ var proxy = new ServiceProviderProxy.unbound();
+ var stub = new ServiceProviderStub.unbound();
+ _applicationImpl.shell.connectToApplication(url, proxy, stub);
+ var connection = new ApplicationConnection(stub, proxy);
+ _applicationConnections.add(connection);
+ return connection;
}
void connectToService(String url, bindings.Proxy proxy) {
- connectToApplication(url).connectToService(proxy);
+ connectToApplication(url).requestService(proxy);
}
void requestQuit() {}
@@ -115,21 +90,23 @@ abstract class Application {
void close() {
assert(_applicationImpl != null);
- _applicationConnections.forEach((c) => c.serviceProvider.close());
+ _applicationConnections.forEach((c) => c.close());
_applicationConnections.clear();
- _serviceProviders.forEach((sp) => sp.close());
- _serviceProviders.clear();
_applicationImpl.close();
}
void _acceptConnection(
String requestorUrl,
- service_provider.ServiceProviderStub services,
- service_provider.ServiceProviderProxy exposedServices) {
- var serviceProvider = new ServiceProvider(services, exposedServices);
- _serviceProviders.add(serviceProvider);
- acceptConnection(requestorUrl, serviceProvider);
+ ServiceProviderStub services,
+ ServiceProviderProxy exposedServices) {
+ var connection = new ApplicationConnection(services, exposedServices);
+ _applicationConnections.add(connection);
+ acceptConnection(requestorUrl, connection);
}
- void acceptConnection(String requestorUrl, ServiceProvider serviceProvider) {}
+ // Override this method to provide services on |connection|.
+ // If you provide at least one service or set fallbackServiceProvider,
+ // then you must invoke connection.listen().
+ void acceptConnection(String requestorUrl, ApplicationConnection connection) {
+ }
}
« no previous file with comments | « third_party/mojo/src/mojo/public/dart/rules.gni ('k') | third_party/mojo/src/mojo/public/dart/src/application_connection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698