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

Unified Diff: mojo/public/js/router.js

Issue 2832303002: Fifo order should be preserved for messages on associated interfaces. (Closed)
Patch Set: Remove timer from closeEndpointHandle. Clean up associated_interface_ptr.html test. Created 3 years, 8 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
« no previous file with comments | « mojo/public/js/connector.js ('k') | third_party/WebKit/LayoutTests/mojo/associated_interface_ptr.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/router.js
diff --git a/mojo/public/js/router.js b/mojo/public/js/router.js
index 401a22278958e0736eb7375bf6f458b7fd0c7d19..dfe7c28b74147deb875a7cadeaad155ca3bde129 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,31 @@ define("mojo/public/js/router", [
endpoint.client.notifyError.bind(endpoint.client));
}
+ if (this.cachedMessageData && interfaceEndpointHandle.id() ===
+ this.cachedMessageData.message.getInterfaceId()) {
+ timer.createOneShot(0, (function() {
+ if (!this.cachedMessageData) {
+ return;
+ }
+
+ var targetEndpoint = this.endpoints_.get(
+ this.cachedMessageData.message.getInterfaceId());
+ // Check that the target endpoint's client still exists.
+ if (targetEndpoint && targetEndpoint.client) {
+ var message = this.cachedMessageData.message;
+ var messageValidator = this.cachedMessageData.messageValidator;
+ this.cachedMessageData = null;
+ this.connector_.resumeIncomingMethodCallProcessing();
+ var ok = endpoint.client.handleIncomingMessage(message,
+ messageValidator);
+
+ if (!ok) {
+ this.handleInvalidIncomingMessage_();
+ }
+ }
+ }).bind(this));
+ }
+
return endpoint;
};
@@ -199,9 +227,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);
}
@@ -290,6 +319,12 @@ define("mojo/public/js/router", [
if (!types.isMasterInterfaceId(interfaceId) || reason) {
this.controlMessageProxy_.notifyPeerEndpointClosed(interfaceId, reason);
}
+
+ if (this.cachedMessageData && interfaceId ===
+ this.cachedMessageData.message.getInterfaceId()) {
+ this.cachedMessageData = null;
+ this.connector_.resumeIncomingMethodCallProcessing();
+ }
};
Router.prototype.updateEndpointStateMayRemove = function(endpoint,
« no previous file with comments | « mojo/public/js/connector.js ('k') | third_party/WebKit/LayoutTests/mojo/associated_interface_ptr.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698