Chromium Code Reviews| Index: mojo/public/js/router.js |
| diff --git a/mojo/public/js/router.js b/mojo/public/js/router.js |
| index 401a22278958e0736eb7375bf6f458b7fd0c7d19..b86daae43a969f2698e5d495bda4dd710ab09c4c 100644 |
| --- a/mojo/public/js/router.js |
| +++ b/mojo/public/js/router.js |
| @@ -72,6 +72,7 @@ define("mojo/public/js/router", [ |
| }); |
| this.setInterfaceIdNamespaceBit_ = setInterfaceIdNamespaceBit; |
| + this.cachedMessageData = null; |
|
yzshen1
2017/04/24 17:30:46
nit: Please consider commenting on the meaning of
wangjimmy
2017/04/24 19:03:35
Done.
|
| this.controlMessageHandler_ = new PipeControlMessageHandler(this); |
| this.controlMessageProxy_ = new PipeControlMessageProxy(this.connector_); |
| this.nextInterfaceIdValue_ = 1; |
| @@ -132,6 +133,18 @@ define("mojo/public/js/router", [ |
| endpoint.client.notifyError.bind(endpoint.client)); |
| } |
| + if (this.cachedMessageData && interfaceEndpointHandle.id() === |
| + this.cachedMessageData.message.getInterfaceId()) { |
| + var ok = interfaceEndpointClient.handleIncomingMessage( |
|
yzshen1
2017/04/24 17:30:45
We are not supposed to call it synchronously. Beca
wangjimmy
2017/04/24 19:03:35
Done.
|
| + this.cachedMessageData.message, |
| + this.cachedMessageData.messageValidator); |
| + |
| + if (!ok) { |
| + this.handleInvalidIncomingMessage_(); |
| + } |
| + this.connector_.resumeIncomingMethodCallProcessing(); |
| + } |
| + |
| return endpoint; |
| }; |
| @@ -199,8 +212,9 @@ define("mojo/public/js/router", [ |
| if (!endpoint.client) { |
| // We need to wait until a client is attached in order to dispatch |
| // further messages. |
| - // TODO(wangjimmy): Cache the message and send when the appropriate |
| - // endpoint client is attached. |
| + this.cachedMessageData = {message: message, |
| + messageValidator: messageValidator}; |
| + this.connector_.pauseIncomingMethodCallProcessing(); |
| return false; |
|
yzshen1
2017/04/24 17:30:45
I think we should return "true" to mean "the messa
wangjimmy
2017/04/24 19:03:35
Done.
|
| } |
| ok = endpoint.client.handleIncomingMessage(message, messageValidator); |