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

Side by Side Diff: mojo/public/js/associated_bindings.js

Issue 2844133003: Add associated binding set. Add associated_binding.html layout test. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 define("mojo/public/js/associated_bindings", [ 5 define("mojo/public/js/associated_bindings", [
6 "mojo/public/js/bindings",
6 "mojo/public/js/core", 7 "mojo/public/js/core",
7 "mojo/public/js/interface_types", 8 "mojo/public/js/interface_types",
8 "mojo/public/js/lib/interface_endpoint_client", 9 "mojo/public/js/lib/interface_endpoint_client",
9 "mojo/public/js/lib/interface_endpoint_handle", 10 "mojo/public/js/lib/interface_endpoint_handle",
10 ], function(core, types, interfaceEndpointClient, interfaceEndpointHandle) { 11 ], function(bindings, core, types, interfaceEndpointClient,
12 interfaceEndpointHandle) {
11 13
12 var InterfaceEndpointClient = interfaceEndpointClient.InterfaceEndpointClient; 14 var InterfaceEndpointClient = interfaceEndpointClient.InterfaceEndpointClient;
13 15
14 // --------------------------------------------------------------------------- 16 // ---------------------------------------------------------------------------
15 17
16 function makeRequest(associatedInterfacePtrInfo) { 18 function makeRequest(associatedInterfacePtrInfo) {
17 var {handle0, handle1} = 19 var {handle0, handle1} =
18 interfaceEndpointHandle.createPairPendingAssociation(); 20 interfaceEndpointHandle.createPairPendingAssociation();
19 21
20 associatedInterfacePtrInfo.interfaceEndpointHandle = handle0; 22 associatedInterfacePtrInfo.interfaceEndpointHandle = handle0;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (!this.isBound()) { 225 if (!this.isBound()) {
224 return new types.AssociatedInterfaceRequest(null); 226 return new types.AssociatedInterfaceRequest(null);
225 } 227 }
226 228
227 var result = new types.AssociatedInterfaceRequest( 229 var result = new types.AssociatedInterfaceRequest(
228 this.interfaceEndpointClient_.passHandle()); 230 this.interfaceEndpointClient_.passHandle());
229 this.close(); 231 this.close();
230 return result; 232 return result;
231 }; 233 };
232 234
235 // ---------------------------------------------------------------------------
236
237 function AssociatedBindingSetEntry(associatedBindingSet, interfaceType, impl,
yzshen1 2017/04/27 17:28:38 For function definition, please either fit all par
wangjimmy 2017/04/27 20:26:49 Done.
238 associatedInterfaceRequest, bindingId) {
239 this.associatedBindingSet_ = associatedBindingSet;
240 this.bindingId_ = bindingId;
241 this.associatedBinding_ = new AssociatedBinding(interfaceType, impl,
242 associatedInterfaceRequest);
243
244 this.associatedBinding_.setConnectionErrorHandler(function(reason) {
245 this.associatedBindingSet_.onConnectionError(bindingId, reason);
246 }.bind(this));
247 }
248
249 AssociatedBindingSetEntry.prototype.close = function() {
250 this.associatedBinding_.close();
251 };
252
253 function AssociatedBindingSet(interfaceType) {
254 this.interfaceType_ = interfaceType;
255 this.nextBindingId_ = 0;
256 this.bindings_ = new Map();
257 this.errorHandler_ = null;
258 }
259
260 AssociatedBindingSet.prototype = Object.create(
261 bindings.BindingSet.prototype);
262
263 AssociatedBindingSet.prototype.addBinding = function(impl,
yzshen1 2017/04/27 17:28:38 Could we design BindingSetBase/BindingSetEntry to
wangjimmy 2017/04/27 20:26:49 Done.
264 associatedInterfaceRequest) {
265 this.bindings_.set(
266 this.nextBindingId_,
267 new AssociatedBindingSetEntry(this, this.interfaceType_, impl,
268 associatedInterfaceRequest, this.nextBindingId_));
269 ++this.nextBindingId_;
270 };
271
272 AssociatedBindingSet.prototype.constructor = AssociatedBindingSet;
273
233 var exports = {}; 274 var exports = {};
234 exports.AssociatedInterfacePtrInfo = types.AssociatedInterfacePtrInfo; 275 exports.AssociatedInterfacePtrInfo = types.AssociatedInterfacePtrInfo;
235 exports.AssociatedInterfaceRequest = types.AssociatedInterfaceRequest; 276 exports.AssociatedInterfaceRequest = types.AssociatedInterfaceRequest;
236 exports.makeRequest = makeRequest; 277 exports.makeRequest = makeRequest;
237 exports.AssociatedInterfacePtrController = AssociatedInterfacePtrController; 278 exports.AssociatedInterfacePtrController = AssociatedInterfacePtrController;
238 exports.AssociatedBinding = AssociatedBinding; 279 exports.AssociatedBinding = AssociatedBinding;
280 exports.AssociatedBindingSet = AssociatedBindingSet;
239 281
240 return exports; 282 return exports;
241 }); 283 });
OLDNEW
« no previous file with comments | « no previous file | mojo/public/js/bindings.js » ('j') | third_party/WebKit/LayoutTests/mojo/associated_binding.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698