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

Side by Side Diff: mojo/public/dart/src/application.dart

Issue 1060193002: Provide mechanism to close immediately to Dart bindings (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « mojo/dart/test/validation_test.dart ('k') | mojo/public/dart/src/application_connection.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of application; 5 part of application;
6 6
7 class _ApplicationImpl implements application_mojom.Application { 7 class _ApplicationImpl implements application_mojom.Application {
8 application_mojom.ApplicationStub _stub; 8 application_mojom.ApplicationStub _stub;
9 shell_mojom.ShellProxy shell; 9 shell_mojom.ShellProxy shell;
10 Application _application; 10 Application _application;
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 @override 36 @override
37 void acceptConnection(String requestorUrl, ServiceProviderStub services, 37 void acceptConnection(String requestorUrl, ServiceProviderStub services,
38 bindings.ProxyBase exposedServices, String resolvedUrl) => _application 38 bindings.ProxyBase exposedServices, String resolvedUrl) => _application
39 ._acceptConnection(requestorUrl, services, exposedServices, resolvedUrl); 39 ._acceptConnection(requestorUrl, services, exposedServices, resolvedUrl);
40 40
41 @override 41 @override
42 void requestQuit() => _application._requestQuitAndClose(); 42 void requestQuit() => _application._requestQuitAndClose();
43 43
44 Future close({bool nodefer: false}) { 44 Future close({bool immediate: false}) {
45 if (shell != null) shell.close(); 45 if (shell != null) {
46 return _stub.close(); 46 shell.close(immediate: immediate);
47 }
48 return _stub.close(immediate: immediate);
47 } 49 }
48 } 50 }
49 51
50 // TODO(zra): Better documentation and examples. 52 // TODO(zra): Better documentation and examples.
51 // To implement, do the following: 53 // To implement, do the following:
52 // - Optionally override initialize() to process command-line args. 54 // - Optionally override initialize() to process command-line args.
53 // - Optionally override acceptConnection() if services are to be provided. 55 // - Optionally override acceptConnection() if services are to be provided.
54 // - Optionally override close() to clean up application resources. 56 // - Optionally override close() to clean up application resources.
55 abstract class Application { 57 abstract class Application {
56 _ApplicationImpl _applicationImpl; 58 _ApplicationImpl _applicationImpl;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 requestQuit(); 99 requestQuit();
98 close(); 100 close();
99 } 101 }
100 102
101 void _errorHandler() { 103 void _errorHandler() {
102 close().then((_) { 104 close().then((_) {
103 if (onError != null) onError(); 105 if (onError != null) onError();
104 }); 106 });
105 } 107 }
106 108
107 Future close() { 109 Future close({bool immediate: false}) {
108 assert(_applicationImpl != null); 110 assert(_applicationImpl != null);
109 _applicationConnections.forEach((c) => c.close()); 111 _applicationConnections.forEach((c) => c.close(immediate: immediate));
110 _applicationConnections.clear(); 112 _applicationConnections.clear();
111 return _applicationImpl.close(); 113 return _applicationImpl.close(immediate: immediate);
112 } 114 }
113 115
114 // This method closes all the application connections. Used during apptesting. 116 // This method closes all the application connections. Used during apptesting.
115 void resetConnections() { 117 void resetConnections() {
116 assert(_applicationImpl != null); 118 assert(_applicationImpl != null);
117 _applicationConnections.forEach((c) => c.close()); 119 _applicationConnections.forEach((c) => c.close());
118 _applicationConnections.clear(); 120 _applicationConnections.clear();
119 } 121 }
120 122
121 void _acceptConnection(String requestorUrl, ServiceProviderStub services, 123 void _acceptConnection(String requestorUrl, ServiceProviderStub services,
122 ServiceProviderProxy exposedServices, String resolvedUrl) { 124 ServiceProviderProxy exposedServices, String resolvedUrl) {
123 var connection = new ApplicationConnection(services, exposedServices); 125 var connection = new ApplicationConnection(services, exposedServices);
124 _applicationConnections.add(connection); 126 _applicationConnections.add(connection);
125 acceptConnection(requestorUrl, resolvedUrl, connection); 127 acceptConnection(requestorUrl, resolvedUrl, connection);
126 } 128 }
127 129
128 // Override this method to provide services on |connection|. 130 // Override this method to provide services on |connection|.
129 void acceptConnection(String requestorUrl, String resolvedUrl, 131 void acceptConnection(String requestorUrl, String resolvedUrl,
130 ApplicationConnection connection) {} 132 ApplicationConnection connection) {}
131 } 133 }
OLDNEW
« no previous file with comments | « mojo/dart/test/validation_test.dart ('k') | mojo/public/dart/src/application_connection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698