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

Side by Side Diff: mojo/edk/js/tests/js_to_cpp_tests.js

Issue 2578333002: Mojo JS bindings: BindingSet support. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « mojo/edk/js/tests/interface_ptr_tests.js ('k') | mojo/public/js/bindings.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/edk/js/tests/js_to_cpp_tests', [ 5 define('mojo/edk/js/tests/js_to_cpp_tests', [
6 'console', 6 'console',
7 'mojo/edk/js/tests/js_to_cpp.mojom', 7 'mojo/edk/js/tests/js_to_cpp.mojom',
8 'mojo/public/js/bindings', 8 'mojo/public/js/bindings',
9 'mojo/public/js/connection',
10 'mojo/public/js/connector', 9 'mojo/public/js/connector',
11 'mojo/public/js/core', 10 'mojo/public/js/core',
12 ], function (console, jsToCpp, bindings, connection, connector, core) { 11 ], function (console, jsToCpp, bindings, connector, core) {
13 var retainedJsSide; 12 var retainedJsSide;
14 var retainedJsSideStub; 13 var retainedJsSideStub;
15 var sampleData; 14 var sampleData;
16 var sampleMessage; 15 var sampleMessage;
17 var BAD_VALUE = 13; 16 var BAD_VALUE = 13;
18 var DATA_PIPE_PARAMS = { 17 var DATA_PIPE_PARAMS = {
19 flags: core.CREATE_DATA_PIPE_OPTIONS_FLAG_NONE, 18 flags: core.CREATE_DATA_PIPE_OPTIONS_FLAG_NONE,
20 elementNumBytes: 1, 19 elementNumBytes: 1,
21 capacityNumBytes: 64 20 capacityNumBytes: 64
22 }; 21 };
23 22
24 function JsSideConnection() { 23 function JsSideConnection() {
24 this.binding = new bindings.Binding(jsToCpp.JsSide, this);
25 } 25 }
26 26
27 JsSideConnection.prototype =
28 Object.create(jsToCpp.JsSide.stubClass.prototype);
29
30 JsSideConnection.prototype.setCppSide = function(cppSide) { 27 JsSideConnection.prototype.setCppSide = function(cppSide) {
31 this.cppSide_ = cppSide; 28 this.cppSide_ = cppSide;
32 this.cppSide_.startTest(); 29 this.cppSide_.startTest();
33 }; 30 };
34 31
35 JsSideConnection.prototype.ping = function (arg) { 32 JsSideConnection.prototype.ping = function (arg) {
36 this.cppSide_.pingResponse(); 33 this.cppSide_.pingResponse();
37 }; 34 };
38 35
39 JsSideConnection.prototype.echo = function (numIterations, arg) { 36 JsSideConnection.prototype.echo = function (numIterations, arg) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return function(jsSideRequestHandle) { 210 return function(jsSideRequestHandle) {
214 var i; 211 var i;
215 sampleData = new Uint8Array(DATA_PIPE_PARAMS.capacityNumBytes); 212 sampleData = new Uint8Array(DATA_PIPE_PARAMS.capacityNumBytes);
216 for (i = 0; i < sampleData.length; ++i) { 213 for (i = 0; i < sampleData.length; ++i) {
217 sampleData[i] = i; 214 sampleData[i] = i;
218 } 215 }
219 sampleMessage = new Uint8Array(DATA_PIPE_PARAMS.capacityNumBytes); 216 sampleMessage = new Uint8Array(DATA_PIPE_PARAMS.capacityNumBytes);
220 for (i = 0; i < sampleMessage.length; ++i) { 217 for (i = 0; i < sampleMessage.length; ++i) {
221 sampleMessage[i] = 255 - i; 218 sampleMessage[i] = 255 - i;
222 } 219 }
223 retainedJsSideStub =
224 connection.bindHandleToStub(jsSideRequestHandle, jsToCpp.JsSide);
225 retainedJsSide = new JsSideConnection; 220 retainedJsSide = new JsSideConnection;
226 bindings.StubBindings(retainedJsSideStub).delegate = retainedJsSide; 221 retainedJsSide.binding.bind(jsSideRequestHandle);
227 }; 222 };
228 }); 223 });
OLDNEW
« no previous file with comments | « mojo/edk/js/tests/interface_ptr_tests.js ('k') | mojo/public/js/bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698