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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart

Issue 1948003003: Dart: Wait to handle events on a Stub until it makes sense to do it. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add test 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 authentication_mojom; 5 library authentication_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 10
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 impl.requireVersion(requiredVersion); 1032 impl.requireVersion(requiredVersion);
1033 } 1033 }
1034 1034
1035 String toString() { 1035 String toString() {
1036 return "AuthenticationServiceProxy($impl)"; 1036 return "AuthenticationServiceProxy($impl)";
1037 } 1037 }
1038 } 1038 }
1039 1039
1040 1040
1041 class AuthenticationServiceStub extends bindings.Stub { 1041 class AuthenticationServiceStub extends bindings.Stub {
1042 AuthenticationService _impl = null; 1042 AuthenticationService _impl;
1043 1043
1044 AuthenticationServiceStub.fromEndpoint( 1044 AuthenticationServiceStub.fromEndpoint(
1045 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 1045 core.MojoMessagePipeEndpoint endpoint, [AuthenticationService impl])
1046 : super.fromEndpoint(endpoint); 1046 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
1047 _impl = impl;
1048 }
1047 1049
1048 AuthenticationServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) 1050 AuthenticationServiceStub.fromHandle(
1049 : super.fromHandle(handle); 1051 core.MojoHandle handle, [AuthenticationService impl])
1052 : super.fromHandle(handle, autoBegin: impl != null) {
1053 _impl = impl;
1054 }
1050 1055
1051 AuthenticationServiceStub.unbound() : super.unbound(); 1056 AuthenticationServiceStub.unbound() : super.unbound();
1052 1057
1053 static AuthenticationServiceStub newFromEndpoint( 1058 static AuthenticationServiceStub newFromEndpoint(
1054 core.MojoMessagePipeEndpoint endpoint) { 1059 core.MojoMessagePipeEndpoint endpoint) {
1055 assert(endpoint.setDescription("For AuthenticationServiceStub")); 1060 assert(endpoint.setDescription("For AuthenticationServiceStub"));
1056 return new AuthenticationServiceStub.fromEndpoint(endpoint); 1061 return new AuthenticationServiceStub.fromEndpoint(endpoint);
1057 } 1062 }
1058 1063
1059 1064
(...skipping 23 matching lines...) Expand all
1083 result.error = error; 1088 result.error = error;
1084 return result; 1089 return result;
1085 } 1090 }
1086 1091
1087 dynamic handleMessage(bindings.ServiceMessage message) { 1092 dynamic handleMessage(bindings.ServiceMessage message) {
1088 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1093 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1089 return bindings.ControlMessageHandler.handleMessage(this, 1094 return bindings.ControlMessageHandler.handleMessage(this,
1090 0, 1095 0,
1091 message); 1096 message);
1092 } 1097 }
1093 assert(_impl != null); 1098 if (_impl == null) {
1099 throw new core.MojoApiError("$this has no implementation set");
1100 }
1094 switch (message.header.type) { 1101 switch (message.header.type) {
1095 case _authenticationServiceMethodSelectAccountName: 1102 case _authenticationServiceMethodSelectAccountName:
1096 var params = _AuthenticationServiceSelectAccountParams.deserialize( 1103 var params = _AuthenticationServiceSelectAccountParams.deserialize(
1097 message.payload); 1104 message.payload);
1098 var response = _impl.selectAccount(params.returnLastSelected,_authentica tionServiceSelectAccountResponseParamsFactory); 1105 var response = _impl.selectAccount(params.returnLastSelected,_authentica tionServiceSelectAccountResponseParamsFactory);
1099 if (response is Future) { 1106 if (response is Future) {
1100 return response.then((response) { 1107 return response.then((response) {
1101 if (response != null) { 1108 if (response != null) {
1102 return buildResponseWithId( 1109 return buildResponseWithId(
1103 response, 1110 response,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 break; 1194 break;
1188 default: 1195 default:
1189 throw new bindings.MojoCodecError("Unexpected message name"); 1196 throw new bindings.MojoCodecError("Unexpected message name");
1190 break; 1197 break;
1191 } 1198 }
1192 return null; 1199 return null;
1193 } 1200 }
1194 1201
1195 AuthenticationService get impl => _impl; 1202 AuthenticationService get impl => _impl;
1196 set impl(AuthenticationService d) { 1203 set impl(AuthenticationService d) {
1197 assert(_impl == null); 1204 if (d == null) {
1205 throw new core.MojoApiError("$this: Cannot set a null implementation");
1206 }
1207 if (isBound && (_impl == null)) {
1208 beginHandlingEvents();
1209 }
1198 _impl = d; 1210 _impl = d;
1199 } 1211 }
1200 1212
1213 @override
1214 void bind(core.MojoMessagePipeEndpoint endpoint) {
1215 super.bind(endpoint);
1216 if (!isOpen && (_impl != null)) {
1217 beginHandlingEvents();
1218 }
1219 }
1220
1201 String toString() { 1221 String toString() {
1202 var superString = super.toString(); 1222 var superString = super.toString();
1203 return "AuthenticationServiceStub($superString)"; 1223 return "AuthenticationServiceStub($superString)";
1204 } 1224 }
1205 1225
1206 int get version => 0; 1226 int get version => 0;
1207 1227
1208 static service_describer.ServiceDescription _cachedServiceDescription; 1228 static service_describer.ServiceDescription _cachedServiceDescription;
1209 static service_describer.ServiceDescription get serviceDescription { 1229 static service_describer.ServiceDescription get serviceDescription {
1210 if (_cachedServiceDescription == null) { 1230 if (_cachedServiceDescription == null) {
1211 _cachedServiceDescription = new _AuthenticationServiceServiceDescription() ; 1231 _cachedServiceDescription = new _AuthenticationServiceServiceDescription() ;
1212 } 1232 }
1213 return _cachedServiceDescription; 1233 return _cachedServiceDescription;
1214 } 1234 }
1215 } 1235 }
1216 1236
1217 1237
1218 1238
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698