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

Unified Diff: mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Move code from mojo_patch to proxy.dart 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 side-by-side diff with in-line comments
Download patch
Index: mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart b/mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart
index bd14a06f2141376ad0fbc98b2eee2444b04422b3..c607babb22d60990d494be1dea5f6679d782237e 100644
--- a/mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart
@@ -18,6 +18,10 @@ class _AuthenticationServiceSelectAccountParams extends bindings.Struct {
_AuthenticationServiceSelectAccountParams() : super(kVersions.last.size);
+ _AuthenticationServiceSelectAccountParams.init(
+ bool this.returnLastSelected
+ ) : super(kVersions.last.size);
+
static _AuthenticationServiceSelectAccountParams deserialize(bindings.Message message) {
var decoder = new bindings.Decoder(message);
var result = decode(decoder);
@@ -91,6 +95,11 @@ class AuthenticationServiceSelectAccountResponseParams extends bindings.Struct {
AuthenticationServiceSelectAccountResponseParams() : super(kVersions.last.size);
+ AuthenticationServiceSelectAccountResponseParams.init(
+ String this.username,
+ String this.error
+ ) : super(kVersions.last.size);
+
static AuthenticationServiceSelectAccountResponseParams deserialize(bindings.Message message) {
var decoder = new bindings.Decoder(message);
var result = decode(decoder);
@@ -177,6 +186,11 @@ class _AuthenticationServiceGetOAuth2TokenParams extends bindings.Struct {
_AuthenticationServiceGetOAuth2TokenParams() : super(kVersions.last.size);
+ _AuthenticationServiceGetOAuth2TokenParams.init(
+ String this.username,
+ List<String> this.scopes
+ ) : super(kVersions.last.size);
+
static _AuthenticationServiceGetOAuth2TokenParams deserialize(bindings.Message message) {
var decoder = new bindings.Decoder(message);
var result = decode(decoder);
@@ -278,6 +292,11 @@ class AuthenticationServiceGetOAuth2TokenResponseParams extends bindings.Struct
AuthenticationServiceGetOAuth2TokenResponseParams() : super(kVersions.last.size);
+ AuthenticationServiceGetOAuth2TokenResponseParams.init(
+ String this.token,
+ String this.error
+ ) : super(kVersions.last.size);
+
static AuthenticationServiceGetOAuth2TokenResponseParams deserialize(bindings.Message message) {
var decoder = new bindings.Decoder(message);
var result = decode(decoder);
@@ -363,6 +382,10 @@ class _AuthenticationServiceClearOAuth2TokenParams extends bindings.Struct {
_AuthenticationServiceClearOAuth2TokenParams() : super(kVersions.last.size);
+ _AuthenticationServiceClearOAuth2TokenParams.init(
+ String this.token
+ ) : super(kVersions.last.size);
+
static _AuthenticationServiceClearOAuth2TokenParams deserialize(bindings.Message message) {
var decoder = new bindings.Decoder(message);
var result = decode(decoder);
@@ -435,6 +458,10 @@ class _AuthenticationServiceGetOAuth2DeviceCodeParams extends bindings.Struct {
_AuthenticationServiceGetOAuth2DeviceCodeParams() : super(kVersions.last.size);
+ _AuthenticationServiceGetOAuth2DeviceCodeParams.init(
+ List<String> this.scopes
+ ) : super(kVersions.last.size);
+
static _AuthenticationServiceGetOAuth2DeviceCodeParams deserialize(bindings.Message message) {
var decoder = new bindings.Decoder(message);
var result = decode(decoder);
@@ -525,6 +552,13 @@ class AuthenticationServiceGetOAuth2DeviceCodeResponseParams extends bindings.St
AuthenticationServiceGetOAuth2DeviceCodeResponseParams() : super(kVersions.last.size);
+ AuthenticationServiceGetOAuth2DeviceCodeResponseParams.init(
+ String this.verificationUrl,
+ String this.deviceCode,
+ String this.userCode,
+ String this.error
+ ) : super(kVersions.last.size);
+
static AuthenticationServiceGetOAuth2DeviceCodeResponseParams deserialize(bindings.Message message) {
var decoder = new bindings.Decoder(message);
var result = decode(decoder);
@@ -636,6 +670,10 @@ class _AuthenticationServiceAddAccountParams extends bindings.Struct {
_AuthenticationServiceAddAccountParams() : super(kVersions.last.size);
+ _AuthenticationServiceAddAccountParams.init(
+ String this.deviceCode
+ ) : super(kVersions.last.size);
+
static _AuthenticationServiceAddAccountParams deserialize(bindings.Message message) {
var decoder = new bindings.Decoder(message);
var result = decode(decoder);
@@ -709,6 +747,11 @@ class AuthenticationServiceAddAccountResponseParams extends bindings.Struct {
AuthenticationServiceAddAccountResponseParams() : super(kVersions.last.size);
+ AuthenticationServiceAddAccountResponseParams.init(
+ String this.username,
+ String this.error
+ ) : super(kVersions.last.size);
+
static AuthenticationServiceAddAccountResponseParams deserialize(bindings.Message message) {
var decoder = new bindings.Decoder(message);
var result = decode(decoder);
@@ -792,14 +835,17 @@ const int _authenticationServiceMethodGetOAuth2DeviceCodeName = 3;
const int _authenticationServiceMethodAddAccountName = 4;
class _AuthenticationServiceServiceDescription implements service_describer.ServiceDescription {
- dynamic getTopLevelInterface([Function responseFactory]) =>
- responseFactory(null);
+ void getTopLevelInterface(Function responder) {
+ responder(null);
+ }
- dynamic getTypeDefinition(String typeKey, [Function responseFactory]) =>
- responseFactory(null);
+ void getTypeDefinition(String typeKey, Function responder) {
+ responder(null);
+ }
- dynamic getAllTypeDefinitions([Function responseFactory]) =>
- responseFactory(null);
+ void getAllTypeDefinitions(Function responder) {
+ responder(null);
+ }
}
abstract class AuthenticationService {
@@ -824,11 +870,11 @@ abstract class AuthenticationService {
s.connectToService(url, p, name);
return p;
}
- dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null]);
- dynamic getOAuth2Token(String username,List<String> scopes,[Function responseFactory = null]);
+ void selectAccount(bool returnLastSelected,void callback(String username, String error));
+ void getOAuth2Token(String username,List<String> scopes,void callback(String token, String error));
void clearOAuth2Token(String token);
- dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory = null]);
- dynamic addAccount(String deviceCode,[Function responseFactory = null]);
+ void getOAuth2DeviceCode(List<String> scopes,void callback(String verificationUrl, String deviceCode, String userCode, String error));
+ void addAccount(String deviceCode,void callback(String username, String error));
}
abstract class AuthenticationServiceInterface
@@ -871,18 +917,14 @@ class _AuthenticationServiceProxyControl
proxyError("Expected a message with a valid request Id.");
return;
}
- Completer c = completerMap[message.header.requestId];
- if (c == null) {
+ Function callback = callbackMap[message.header.requestId];
+ if (callback == null) {
proxyError(
"Message had unknown request Id: ${message.header.requestId}");
return;
}
- completerMap.remove(message.header.requestId);
- if (c.isCompleted) {
- proxyError("Response completer already completed");
- return;
- }
- c.complete(r);
+ callbackMap.remove(message.header.requestId);
+ callback(r.username , r.error );
break;
case _authenticationServiceMethodGetOAuth2TokenName:
var r = AuthenticationServiceGetOAuth2TokenResponseParams.deserialize(
@@ -891,18 +933,14 @@ class _AuthenticationServiceProxyControl
proxyError("Expected a message with a valid request Id.");
return;
}
- Completer c = completerMap[message.header.requestId];
- if (c == null) {
+ Function callback = callbackMap[message.header.requestId];
+ if (callback == null) {
proxyError(
"Message had unknown request Id: ${message.header.requestId}");
return;
}
- completerMap.remove(message.header.requestId);
- if (c.isCompleted) {
- proxyError("Response completer already completed");
- return;
- }
- c.complete(r);
+ callbackMap.remove(message.header.requestId);
+ callback(r.token , r.error );
break;
case _authenticationServiceMethodGetOAuth2DeviceCodeName:
var r = AuthenticationServiceGetOAuth2DeviceCodeResponseParams.deserialize(
@@ -911,18 +949,14 @@ class _AuthenticationServiceProxyControl
proxyError("Expected a message with a valid request Id.");
return;
}
- Completer c = completerMap[message.header.requestId];
- if (c == null) {
+ Function callback = callbackMap[message.header.requestId];
+ if (callback == null) {
proxyError(
"Message had unknown request Id: ${message.header.requestId}");
return;
}
- completerMap.remove(message.header.requestId);
- if (c.isCompleted) {
- proxyError("Response completer already completed");
- return;
- }
- c.complete(r);
+ callbackMap.remove(message.header.requestId);
+ callback(r.verificationUrl , r.deviceCode , r.userCode , r.error );
break;
case _authenticationServiceMethodAddAccountName:
var r = AuthenticationServiceAddAccountResponseParams.deserialize(
@@ -931,18 +965,14 @@ class _AuthenticationServiceProxyControl
proxyError("Expected a message with a valid request Id.");
return;
}
- Completer c = completerMap[message.header.requestId];
- if (c == null) {
+ Function callback = callbackMap[message.header.requestId];
+ if (callback == null) {
proxyError(
"Message had unknown request Id: ${message.header.requestId}");
return;
}
- completerMap.remove(message.header.requestId);
- if (c.isCompleted) {
- proxyError("Response completer already completed");
- return;
- }
- c.complete(r);
+ callbackMap.remove(message.header.requestId);
+ callback(r.username , r.error );
break;
default:
proxyError("Unexpected message type: ${message.header.type}");
@@ -985,24 +1015,26 @@ class AuthenticationServiceProxy
}
- dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null]) {
+ void selectAccount(bool returnLastSelected,void callback(String username, String error)) {
var params = new _AuthenticationServiceSelectAccountParams();
params.returnLastSelected = returnLastSelected;
- return ctrl.sendMessageWithRequestId(
+ ctrl.sendMessageWithRequestId(
params,
_authenticationServiceMethodSelectAccountName,
-1,
- bindings.MessageHeader.kMessageExpectsResponse);
+ bindings.MessageHeader.kMessageExpectsResponse,
+ callback);
}
- dynamic getOAuth2Token(String username,List<String> scopes,[Function responseFactory = null]) {
+ void getOAuth2Token(String username,List<String> scopes,void callback(String token, String error)) {
var params = new _AuthenticationServiceGetOAuth2TokenParams();
params.username = username;
params.scopes = scopes;
- return ctrl.sendMessageWithRequestId(
+ ctrl.sendMessageWithRequestId(
params,
_authenticationServiceMethodGetOAuth2TokenName,
-1,
- bindings.MessageHeader.kMessageExpectsResponse);
+ bindings.MessageHeader.kMessageExpectsResponse,
+ callback);
}
void clearOAuth2Token(String token) {
if (!ctrl.isBound) {
@@ -1014,23 +1046,25 @@ class AuthenticationServiceProxy
ctrl.sendMessage(params,
_authenticationServiceMethodClearOAuth2TokenName);
}
- dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory = null]) {
+ void getOAuth2DeviceCode(List<String> scopes,void callback(String verificationUrl, String deviceCode, String userCode, String error)) {
var params = new _AuthenticationServiceGetOAuth2DeviceCodeParams();
params.scopes = scopes;
- return ctrl.sendMessageWithRequestId(
+ ctrl.sendMessageWithRequestId(
params,
_authenticationServiceMethodGetOAuth2DeviceCodeName,
-1,
- bindings.MessageHeader.kMessageExpectsResponse);
+ bindings.MessageHeader.kMessageExpectsResponse,
+ callback);
}
- dynamic addAccount(String deviceCode,[Function responseFactory = null]) {
+ void addAccount(String deviceCode,void callback(String username, String error)) {
var params = new _AuthenticationServiceAddAccountParams();
params.deviceCode = deviceCode;
- return ctrl.sendMessageWithRequestId(
+ ctrl.sendMessageWithRequestId(
params,
_authenticationServiceMethodAddAccountName,
-1,
- bindings.MessageHeader.kMessageExpectsResponse);
+ bindings.MessageHeader.kMessageExpectsResponse,
+ callback);
}
}
@@ -1056,38 +1090,66 @@ class _AuthenticationServiceStubControl
String get serviceName => AuthenticationService.serviceName;
- AuthenticationServiceSelectAccountResponseParams _authenticationServiceSelectAccountResponseParamsFactory(String username, String error) {
- var result = new AuthenticationServiceSelectAccountResponseParams();
- result.username = username;
- result.error = error;
- return result;
- }
- AuthenticationServiceGetOAuth2TokenResponseParams _authenticationServiceGetOAuth2TokenResponseParamsFactory(String token, String error) {
- var result = new AuthenticationServiceGetOAuth2TokenResponseParams();
- result.token = token;
- result.error = error;
- return result;
- }
- AuthenticationServiceGetOAuth2DeviceCodeResponseParams _authenticationServiceGetOAuth2DeviceCodeResponseParamsFactory(String verificationUrl, String deviceCode, String userCode, String error) {
- var result = new AuthenticationServiceGetOAuth2DeviceCodeResponseParams();
- result.verificationUrl = verificationUrl;
- result.deviceCode = deviceCode;
- result.userCode = userCode;
- result.error = error;
- return result;
- }
- AuthenticationServiceAddAccountResponseParams _authenticationServiceAddAccountResponseParamsFactory(String username, String error) {
- var result = new AuthenticationServiceAddAccountResponseParams();
- result.username = username;
- result.error = error;
- return result;
- }
-
- dynamic handleMessage(bindings.ServiceMessage message) {
+ Function _authenticationServiceSelectAccountResponseParamsResponder(
+ int requestId) {
+ return (String username, String error) {
+ var result = new AuthenticationServiceSelectAccountResponseParams();
+ result.username = username;
+ result.error = error;
+ sendResponse(buildResponseWithId(
+ result,
+ _authenticationServiceMethodSelectAccountName,
+ requestId,
+ bindings.MessageHeader.kMessageIsResponse));
+ };
+ }
+ Function _authenticationServiceGetOAuth2TokenResponseParamsResponder(
+ int requestId) {
+ return (String token, String error) {
+ var result = new AuthenticationServiceGetOAuth2TokenResponseParams();
+ result.token = token;
+ result.error = error;
+ sendResponse(buildResponseWithId(
+ result,
+ _authenticationServiceMethodGetOAuth2TokenName,
+ requestId,
+ bindings.MessageHeader.kMessageIsResponse));
+ };
+ }
+ Function _authenticationServiceGetOAuth2DeviceCodeResponseParamsResponder(
+ int requestId) {
+ return (String verificationUrl, String deviceCode, String userCode, String error) {
+ var result = new AuthenticationServiceGetOAuth2DeviceCodeResponseParams();
+ result.verificationUrl = verificationUrl;
+ result.deviceCode = deviceCode;
+ result.userCode = userCode;
+ result.error = error;
+ sendResponse(buildResponseWithId(
+ result,
+ _authenticationServiceMethodGetOAuth2DeviceCodeName,
+ requestId,
+ bindings.MessageHeader.kMessageIsResponse));
+ };
+ }
+ Function _authenticationServiceAddAccountResponseParamsResponder(
+ int requestId) {
+ return (String username, String error) {
+ var result = new AuthenticationServiceAddAccountResponseParams();
+ result.username = username;
+ result.error = error;
+ sendResponse(buildResponseWithId(
+ result,
+ _authenticationServiceMethodAddAccountName,
+ requestId,
+ bindings.MessageHeader.kMessageIsResponse));
+ };
+ }
+
+ void handleMessage(bindings.ServiceMessage message) {
if (bindings.ControlMessageHandler.isControlMessage(message)) {
- return bindings.ControlMessageHandler.handleMessage(this,
- 0,
- message);
+ bindings.ControlMessageHandler.handleMessage(
+ this, 0, message);
+ return;
}
if (_impl == null) {
throw new core.MojoApiError("$this has no implementation set");
@@ -1096,46 +1158,12 @@ class _AuthenticationServiceStubControl
case _authenticationServiceMethodSelectAccountName:
var params = _AuthenticationServiceSelectAccountParams.deserialize(
message.payload);
- var response = _impl.selectAccount(params.returnLastSelected,_authenticationServiceSelectAccountResponseParamsFactory);
- if (response is Future) {
- return response.then((response) {
- if (response != null) {
- return buildResponseWithId(
- response,
- _authenticationServiceMethodSelectAccountName,
- message.header.requestId,
- bindings.MessageHeader.kMessageIsResponse);
- }
- });
- } else if (response != null) {
- return buildResponseWithId(
- response,
- _authenticationServiceMethodSelectAccountName,
- message.header.requestId,
- bindings.MessageHeader.kMessageIsResponse);
- }
+ _impl.selectAccount(params.returnLastSelected, _authenticationServiceSelectAccountResponseParamsResponder(message.header.requestId));
break;
case _authenticationServiceMethodGetOAuth2TokenName:
var params = _AuthenticationServiceGetOAuth2TokenParams.deserialize(
message.payload);
- var response = _impl.getOAuth2Token(params.username,params.scopes,_authenticationServiceGetOAuth2TokenResponseParamsFactory);
- if (response is Future) {
- return response.then((response) {
- if (response != null) {
- return buildResponseWithId(
- response,
- _authenticationServiceMethodGetOAuth2TokenName,
- message.header.requestId,
- bindings.MessageHeader.kMessageIsResponse);
- }
- });
- } else if (response != null) {
- return buildResponseWithId(
- response,
- _authenticationServiceMethodGetOAuth2TokenName,
- message.header.requestId,
- bindings.MessageHeader.kMessageIsResponse);
- }
+ _impl.getOAuth2Token(params.username, params.scopes, _authenticationServiceGetOAuth2TokenResponseParamsResponder(message.header.requestId));
break;
case _authenticationServiceMethodClearOAuth2TokenName:
var params = _AuthenticationServiceClearOAuth2TokenParams.deserialize(
@@ -1145,52 +1173,17 @@ class _AuthenticationServiceStubControl
case _authenticationServiceMethodGetOAuth2DeviceCodeName:
var params = _AuthenticationServiceGetOAuth2DeviceCodeParams.deserialize(
message.payload);
- var response = _impl.getOAuth2DeviceCode(params.scopes,_authenticationServiceGetOAuth2DeviceCodeResponseParamsFactory);
- if (response is Future) {
- return response.then((response) {
- if (response != null) {
- return buildResponseWithId(
- response,
- _authenticationServiceMethodGetOAuth2DeviceCodeName,
- message.header.requestId,
- bindings.MessageHeader.kMessageIsResponse);
- }
- });
- } else if (response != null) {
- return buildResponseWithId(
- response,
- _authenticationServiceMethodGetOAuth2DeviceCodeName,
- message.header.requestId,
- bindings.MessageHeader.kMessageIsResponse);
- }
+ _impl.getOAuth2DeviceCode(params.scopes, _authenticationServiceGetOAuth2DeviceCodeResponseParamsResponder(message.header.requestId));
break;
case _authenticationServiceMethodAddAccountName:
var params = _AuthenticationServiceAddAccountParams.deserialize(
message.payload);
- var response = _impl.addAccount(params.deviceCode,_authenticationServiceAddAccountResponseParamsFactory);
- if (response is Future) {
- return response.then((response) {
- if (response != null) {
- return buildResponseWithId(
- response,
- _authenticationServiceMethodAddAccountName,
- message.header.requestId,
- bindings.MessageHeader.kMessageIsResponse);
- }
- });
- } else if (response != null) {
- return buildResponseWithId(
- response,
- _authenticationServiceMethodAddAccountName,
- message.header.requestId,
- bindings.MessageHeader.kMessageIsResponse);
- }
+ _impl.addAccount(params.deviceCode, _authenticationServiceAddAccountResponseParamsResponder(message.header.requestId));
break;
default:
throw new bindings.MojoCodecError("Unexpected message name");
break;
}
- return null;
}
AuthenticationService get impl => _impl;
@@ -1244,20 +1237,20 @@ class AuthenticationServiceStub
}
- dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null]) {
- return impl.selectAccount(returnLastSelected,responseFactory);
+ void selectAccount(bool returnLastSelected,void callback(String username, String error)) {
+ return impl.selectAccount(returnLastSelected,callback);
}
- dynamic getOAuth2Token(String username,List<String> scopes,[Function responseFactory = null]) {
- return impl.getOAuth2Token(username,scopes,responseFactory);
+ void getOAuth2Token(String username,List<String> scopes,void callback(String token, String error)) {
+ return impl.getOAuth2Token(username,scopes,callback);
}
void clearOAuth2Token(String token) {
return impl.clearOAuth2Token(token);
}
- dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory = null]) {
- return impl.getOAuth2DeviceCode(scopes,responseFactory);
+ void getOAuth2DeviceCode(List<String> scopes,void callback(String verificationUrl, String deviceCode, String userCode, String error)) {
+ return impl.getOAuth2DeviceCode(scopes,callback);
}
- dynamic addAccount(String deviceCode,[Function responseFactory = null]) {
- return impl.addAccount(deviceCode,responseFactory);
+ void addAccount(String deviceCode,void callback(String username, String error)) {
+ return impl.addAccount(deviceCode,callback);
}
}

Powered by Google App Engine
This is Rietveld 408576698