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..5eb5371e5a2825241a3b53d721e977dba7883896 100644 |
| --- a/mojo/public/js/router.js |
| +++ b/mojo/public/js/router.js |
| @@ -72,6 +72,9 @@ define("mojo/public/js/router", [ |
| }); |
| this.setInterfaceIdNamespaceBit_ = setInterfaceIdNamespaceBit; |
| + // |cachedMessageData| caches infomation about a message, so it can be |
| + // processed later if a client is not yet attached to the target endpoint. |
| + this.cachedMessageData = null; |
| this.controlMessageHandler_ = new PipeControlMessageHandler(this); |
| this.controlMessageProxy_ = new PipeControlMessageProxy(this.connector_); |
| this.nextInterfaceIdValue_ = 1; |
| @@ -132,6 +135,21 @@ define("mojo/public/js/router", [ |
| endpoint.client.notifyError.bind(endpoint.client)); |
| } |
| + if (this.cachedMessageData && interfaceEndpointHandle.id() === |
| + this.cachedMessageData.message.getInterfaceId()) { |
| + timer.createOneShot(0, (function() { |
|
wangjimmy
2017/04/24 19:04:33
TODO(wangjimmy): Check endpoint client still exist
yzshen1
2017/04/24 19:21:49
I hope this could be addressed in this CL, which s
wangjimmy
2017/04/24 21:16:39
Done.
|
| + var ok = interfaceEndpointClient.handleIncomingMessage( |
| + this.cachedMessageData.message, |
| + this.cachedMessageData.messageValidator); |
| + |
| + if (!ok) { |
| + this.handleInvalidIncomingMessage_(); |
| + } |
| + this.cachedMessageData = null; |
| + this.connector_.resumeIncomingMethodCallProcessing(); |
| + }).bind(this)); |
| + } |
| + |
| return endpoint; |
| }; |
| @@ -199,9 +217,10 @@ 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. |
| - return false; |
| + this.cachedMessageData = {message: message, |
| + messageValidator: messageValidator}; |
| + this.connector_.pauseIncomingMethodCallProcessing(); |
| + return true; |
| } |
| ok = endpoint.client.handleIncomingMessage(message, messageValidator); |
| } |