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

Side by Side Diff: mojo/dart/packages/mojo/lib/mojo/application_connector.mojom.dart

Issue 1983453002: Dart: Refactor Stubs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge Created 4 years, 7 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
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 library application_connector_mojom; 5 library application_connector_mojom;
6 import 'dart:async'; 6 import 'dart:async';
7 import 'package:mojo/bindings.dart' as bindings; 7 import 'package:mojo/bindings.dart' as bindings;
8 import 'package:mojo/core.dart' as core; 8 import 'package:mojo/core.dart' as core;
9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer; 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer;
10 import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom ; 10 import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom ;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 dynamic getAllTypeDefinitions([Function responseFactory]) => 191 dynamic getAllTypeDefinitions([Function responseFactory]) =>
192 responseFactory(null); 192 responseFactory(null);
193 } 193 }
194 194
195 abstract class ApplicationConnector { 195 abstract class ApplicationConnector {
196 static const String serviceName = null; 196 static const String serviceName = null;
197 void connectToApplication(String applicationUrl, Object services, Object expos edServices); 197 void connectToApplication(String applicationUrl, Object services, Object expos edServices);
198 void duplicate(Object applicationConnectorRequest); 198 void duplicate(Object applicationConnectorRequest);
199 } 199 }
200 200
201 201 class _ApplicationConnectorProxyControl
202 class _ApplicationConnectorProxyControl extends bindings.ProxyMessageHandler 202 extends bindings.ProxyMessageHandler
203 implements bindings.ProxyControl { 203 implements bindings.ProxyControl {
204 _ApplicationConnectorProxyControl.fromEndpoint( 204 _ApplicationConnectorProxyControl.fromEndpoint(
205 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 205 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
206 206
207 _ApplicationConnectorProxyControl.fromHandle( 207 _ApplicationConnectorProxyControl.fromHandle(
208 core.MojoHandle handle) : super.fromHandle(handle); 208 core.MojoHandle handle) : super.fromHandle(handle);
209 209
210 _ApplicationConnectorProxyControl.unbound() : super.unbound(); 210 _ApplicationConnectorProxyControl.unbound() : super.unbound();
211 211
212 service_describer.ServiceDescription get serviceDescription => 212 service_describer.ServiceDescription get serviceDescription =>
213 new _ApplicationConnectorServiceDescription(); 213 new _ApplicationConnectorServiceDescription();
214 214
215 String get serviceName => ApplicationConnector.serviceName; 215 String get serviceName => ApplicationConnector.serviceName;
216 216
217 @override
218 void handleResponse(bindings.ServiceMessage message) { 217 void handleResponse(bindings.ServiceMessage message) {
219 switch (message.header.type) { 218 switch (message.header.type) {
220 default: 219 default:
221 proxyError("Unexpected message type: ${message.header.type}"); 220 proxyError("Unexpected message type: ${message.header.type}");
222 close(immediate: true); 221 close(immediate: true);
223 break; 222 break;
224 } 223 }
225 } 224 }
226 225
227 @override 226 @override
228 String toString() { 227 String toString() {
229 var superString = super.toString(); 228 var superString = super.toString();
230 return "_ApplicationConnectorProxyControl($superString)"; 229 return "_ApplicationConnectorProxyControl($superString)";
231 } 230 }
232 } 231 }
233 232
234 233 class ApplicationConnectorProxy
235 class ApplicationConnectorProxy extends bindings.Proxy 234 extends bindings.Proxy
236 implements ApplicationConnector { 235 implements ApplicationConnector {
237 ApplicationConnectorProxy.fromEndpoint( 236 ApplicationConnectorProxy.fromEndpoint(
238 core.MojoMessagePipeEndpoint endpoint) 237 core.MojoMessagePipeEndpoint endpoint)
239 : super(new _ApplicationConnectorProxyControl.fromEndpoint(endpoint)); 238 : super(new _ApplicationConnectorProxyControl.fromEndpoint(endpoint));
240 239
241 ApplicationConnectorProxy.fromHandle(core.MojoHandle handle) 240 ApplicationConnectorProxy.fromHandle(core.MojoHandle handle)
242 : super(new _ApplicationConnectorProxyControl.fromHandle(handle)); 241 : super(new _ApplicationConnectorProxyControl.fromHandle(handle));
243 242
244 ApplicationConnectorProxy.unbound() 243 ApplicationConnectorProxy.unbound()
245 : super(new _ApplicationConnectorProxyControl.unbound()); 244 : super(new _ApplicationConnectorProxyControl.unbound());
246 245
(...skipping 28 matching lines...) Expand all
275 ctrl.proxyError("The Proxy is closed."); 274 ctrl.proxyError("The Proxy is closed.");
276 return; 275 return;
277 } 276 }
278 var params = new _ApplicationConnectorDuplicateParams(); 277 var params = new _ApplicationConnectorDuplicateParams();
279 params.applicationConnectorRequest = applicationConnectorRequest; 278 params.applicationConnectorRequest = applicationConnectorRequest;
280 ctrl.sendMessage(params, 279 ctrl.sendMessage(params,
281 _applicationConnectorMethodDuplicateName); 280 _applicationConnectorMethodDuplicateName);
282 } 281 }
283 } 282 }
284 283
285 284 class _ApplicationConnectorStubControl
286 class ApplicationConnectorStub extends bindings.Stub { 285 extends bindings.StubMessageHandler
286 implements bindings.StubControl<ApplicationConnector> {
287 ApplicationConnector _impl; 287 ApplicationConnector _impl;
288 288
289 ApplicationConnectorStub.fromEndpoint( 289 _ApplicationConnectorStubControl.fromEndpoint(
290 core.MojoMessagePipeEndpoint endpoint, [ApplicationConnector impl]) 290 core.MojoMessagePipeEndpoint endpoint, [ApplicationConnector impl])
291 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 291 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
292 _impl = impl; 292 _impl = impl;
293 } 293 }
294 294
295 ApplicationConnectorStub.fromHandle( 295 _ApplicationConnectorStubControl.fromHandle(
296 core.MojoHandle handle, [ApplicationConnector impl]) 296 core.MojoHandle handle, [ApplicationConnector impl])
297 : super.fromHandle(handle, autoBegin: impl != null) { 297 : super.fromHandle(handle, autoBegin: impl != null) {
298 _impl = impl; 298 _impl = impl;
299 } 299 }
300 300
301 ApplicationConnectorStub.unbound([this._impl]) : super.unbound(); 301 _ApplicationConnectorStubControl.unbound([this._impl]) : super.unbound();
302
303 static ApplicationConnectorStub newFromEndpoint(
304 core.MojoMessagePipeEndpoint endpoint) {
305 assert(endpoint.setDescription("For ApplicationConnectorStub"));
306 return new ApplicationConnectorStub.fromEndpoint(endpoint);
307 }
308 302
309 303
310 304
311 dynamic handleMessage(bindings.ServiceMessage message) { 305 dynamic handleMessage(bindings.ServiceMessage message) {
312 if (bindings.ControlMessageHandler.isControlMessage(message)) { 306 if (bindings.ControlMessageHandler.isControlMessage(message)) {
313 return bindings.ControlMessageHandler.handleMessage(this, 307 return bindings.ControlMessageHandler.handleMessage(this,
314 0, 308 0,
315 message); 309 message);
316 } 310 }
317 if (_impl == null) { 311 if (_impl == null) {
(...skipping 29 matching lines...) Expand all
347 } 341 }
348 342
349 @override 343 @override
350 void bind(core.MojoMessagePipeEndpoint endpoint) { 344 void bind(core.MojoMessagePipeEndpoint endpoint) {
351 super.bind(endpoint); 345 super.bind(endpoint);
352 if (!isOpen && (_impl != null)) { 346 if (!isOpen && (_impl != null)) {
353 beginHandlingEvents(); 347 beginHandlingEvents();
354 } 348 }
355 } 349 }
356 350
351 @override
357 String toString() { 352 String toString() {
358 var superString = super.toString(); 353 var superString = super.toString();
359 return "ApplicationConnectorStub($superString)"; 354 return "_ApplicationConnectorStubControl($superString)";
360 } 355 }
361 356
362 int get version => 0; 357 int get version => 0;
363 358
364 static service_describer.ServiceDescription _cachedServiceDescription; 359 static service_describer.ServiceDescription _cachedServiceDescription;
365 static service_describer.ServiceDescription get serviceDescription { 360 static service_describer.ServiceDescription get serviceDescription {
366 if (_cachedServiceDescription == null) { 361 if (_cachedServiceDescription == null) {
367 _cachedServiceDescription = new _ApplicationConnectorServiceDescription(); 362 _cachedServiceDescription = new _ApplicationConnectorServiceDescription();
368 } 363 }
369 return _cachedServiceDescription; 364 return _cachedServiceDescription;
370 } 365 }
371 } 366 }
372 367
368 class ApplicationConnectorStub
369 extends bindings.Stub<ApplicationConnector>
370 implements ApplicationConnector {
371 ApplicationConnectorStub.fromEndpoint(
372 core.MojoMessagePipeEndpoint endpoint, [ApplicationConnector impl])
373 : super(new _ApplicationConnectorStubControl.fromEndpoint(endpoint, impl)) ;
374
375 ApplicationConnectorStub.fromHandle(
376 core.MojoHandle handle, [ApplicationConnector impl])
377 : super(new _ApplicationConnectorStubControl.fromHandle(handle, impl));
378
379 ApplicationConnectorStub.unbound([ApplicationConnector impl])
380 : super(new _ApplicationConnectorStubControl.unbound(impl));
381
382 static ApplicationConnectorStub newFromEndpoint(
383 core.MojoMessagePipeEndpoint endpoint) {
384 assert(endpoint.setDescription("For ApplicationConnectorStub"));
385 return new ApplicationConnectorStub.fromEndpoint(endpoint);
386 }
387
388 static service_describer.ServiceDescription get serviceDescription =>
389 _ApplicationConnectorStubControl.serviceDescription;
390
391
392 void connectToApplication(String applicationUrl, Object services, Object expos edServices) {
393 return impl.connectToApplication(applicationUrl, services, exposedServices);
394 }
395 void duplicate(Object applicationConnectorRequest) {
396 return impl.duplicate(applicationConnectorRequest);
397 }
398 }
399
373 400
374 401
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698