Chromium Code Reviews| Index: mojo/public/js/lib/interface_endpoint_handle.js |
| diff --git a/mojo/public/js/lib/interface_endpoint_handle.js b/mojo/public/js/lib/interface_endpoint_handle.js |
| index f48b89ba85c71a372fd8d03c119a578fa8425cc8..d0f267ba59bfc2e77a8fe9e5f4979e9f8c136913 100644 |
| --- a/mojo/public/js/lib/interface_endpoint_handle.js |
| +++ b/mojo/public/js/lib/interface_endpoint_handle.js |
| @@ -92,6 +92,20 @@ define("mojo/public/js/lib/interface_endpoint_handle", [ |
| } |
| }; |
| + State.prototype.notifyAssociation = function(interfaceId, |
| + peerGroupController) { |
|
yzshen1
2017/04/19 21:11:34
nit: please align "peerGroupController" with "inte
wangjimmy
2017/04/20 15:36:44
Done.
|
| + var cachedPeerState = this.peerState_; |
| + this.peerState_ = null; |
| + |
| + this.pendingAssociation = false; |
| + |
| + if (cachedPeerState) { |
| + cachedPeerState.onAssociated(interfaceId, peerGroupController); |
| + return true; |
| + } |
| + return false; |
| + }; |
| + |
| State.prototype.onAssociated = function(interfaceId, |
| associatedGroupController) { |
| if (!this.pendingAssociation) { |
| @@ -117,6 +131,14 @@ define("mojo/public/js/lib/interface_endpoint_handle", [ |
| AssociationEvent.PEER_CLOSED_BEFORE_ASSOCIATION); |
| }; |
| + function createPairPendingAssociation() { |
| + var handle0 = new InterfaceEndpointHandle(); |
| + var handle1 = new InterfaceEndpointHandle(); |
| + handle0.state_.initPendingState(handle1.state_); |
| + handle1.state_.initPendingState(handle0.state_); |
| + return {handle0: handle0, handle1: handle1}; |
| + } |
| + |
| function InterfaceEndpointHandle(interfaceId, associatedGroupController) { |
| this.state_ = new State(interfaceId, associatedGroupController); |
| } |
| @@ -146,13 +168,20 @@ define("mojo/public/js/lib/interface_endpoint_handle", [ |
| this.state_.setAssociationEventHandler(handler); |
| }; |
| + InterfaceEndpointHandle.prototype.notifyAssociation = function(interfaceId, |
| + peerGroupController) { |
| + return this.state_.notifyAssociation(interfaceId, peerGroupController); |
| + }; |
| + |
| InterfaceEndpointHandle.prototype.reset = function(reason) { |
| this.state_.close(reason); |
| this.state_ = new State(); |
| }; |
| var exports = {}; |
| + exports.AssociationEvent = AssociationEvent; |
| exports.InterfaceEndpointHandle = InterfaceEndpointHandle; |
| + exports.createPairPendingAssociation = createPairPendingAssociation; |
| return exports; |
| }); |