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

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

Issue 883843002: Update mojo sdk to rev 126532ce21c5c3c55a1e1693731411cb60169efd (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to adapt to roll Created 5 years, 11 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
new file mode 100644
index 0000000000000000000000000000000000000000..fcd22442c343ad6f6edb2723afdf15a4d9121d42
--- /dev/null
+++ b/third_party/mojo/src/mojo/public/dart/src/application.dart
@@ -0,0 +1,100 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+part of application;
+
+class ApplicationImpl implements application.ApplicationStub {
+ shell_mojom.ShellProxy shell;
+ Application _application;
+
+ ApplicationImpl(this._application);
+
+ void initialize(shell_mojom.ShellProxy shellProxy, List<String> args) {
+ assert(shell == null);
+ shell = shellProxy;
+ _application.initialize(args);
+ }
+
+ void acceptConnection(
+ String requestorUrl,
+ service_provider.ServiceProviderStub services,
+ service_provider.ServiceProviderProxy exposedServices) =>
+ _application._acceptConnection(requestorUrl, services, exposedServices);
+
+ void close() => shell.close();
+}
+
+// TODO(zra): Better documentation and examples.
+// To implement, provide a stubFactoryClosure() that returns a function
+// that takes a MojoMessagePipeEndpoint and returns a Stub that provides the
+// Application's services. The function may return null if the Application
+// provides no services. Optionally override initialize() when needed. Call
+// listen() on a newly created Application to begin providing services. Call
+// connectToService() to request services from the Shell. Calling close()
+// closes connections to any requested ServiceProviders and the Shell.
+abstract class Application {
+ application.ApplicationStub _applicationStub;
+ ApplicationImpl _applicationImpl;
+ List<service_provider.ServiceProviderProxy> _proxies;
+
+ Application(core.MojoMessagePipeEndpoint endpoint) {
+ _proxies = [];
+ _applicationImpl = new ApplicationImpl(this);
+ _applicationStub = new application.ApplicationStub(endpoint)
+ ..delegate = _applicationImpl;
+ }
+
+ Application.fromHandle(core.MojoHandle appHandle) {
+ _proxies = [];
+ _applicationImpl = new ApplicationImpl(this);
+ _applicationStub = new application.ApplicationStub.fromHandle(appHandle)
+ ..delegate = _applicationImpl;
+ }
+
+ Function stubFactoryClosure();
+
+ void initialize(List<String> args) {}
+
+ void connectToService(String url, bindings.Proxy proxy) {
+ assert(!proxy.isBound);
+ var endpoint = _connectToServiceHelper(url, proxy.name);
+ proxy.bind(endpoint);
+ }
+
+ listen() => _applicationStub.listen();
+
+ void close() {
+ assert(_proxies != null);
+ assert(_applicationImpl != null);
+ _proxies.forEach((c) => c.close());
+ _proxies.clear();
+ _applicationImpl.close();
+ }
+
+ void _acceptConnection(
+ String requestorUrl,
+ service_provider.ServiceProviderStub services,
+ service_provider.ServiceProviderProxy exposedServices) {
+ var closure = stubFactoryClosure();
+ if (closure != null) {
+ var serviceProvider = new ServiceProvider(closure);
+ services.delegate = serviceProvider;
+ services.listen();
+ }
+ }
+
+ core.MojoMessagePipeEndpoint _connectToServiceHelper(
+ String url, String service) {
+ var applicationPipe = new core.MojoMessagePipe();
+ var proxyEndpoint = applicationPipe.endpoints[0];
+ var applicationEndpoint = applicationPipe.endpoints[1];
+ var serviceProviderProxy =
+ new service_provider.ServiceProviderProxy.unbound();
+ _applicationImpl.shell.callConnectToApplication(
+ url, serviceProviderProxy, null);
+ serviceProviderProxy.callConnectToService(service, applicationEndpoint);
+ _proxies.add(serviceProviderProxy);
+ return proxyEndpoint;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698