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

Side by Side Diff: third_party/WebKit/LayoutTests/shapedetection/resources/mock-barcodedetection.js

Issue 2590393002: Revert of Mojo JS bindings: switch most usage of "connection"/"router" module to "bindings". (Closed)
Patch Set: Created 3 years, 12 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 "use strict"; 1 "use strict";
2 2
3 let mockBarcodeDetectionReady = define( 3 let mockBarcodeDetectionReady = define(
4 'mockBarcodeDetection', 4 'mockBarcodeDetection',
5 ['third_party/WebKit/public/platform/modules/shapedetection/barcodedetection.m ojom', 5 ['third_party/WebKit/public/platform/modules/shapedetection/barcodedetection.m ojom',
6 'mojo/public/js/bindings', 6 'mojo/public/js/bindings',
7 'mojo/public/js/connection',
7 'mojo/public/js/core', 8 'mojo/public/js/core',
8 'content/public/renderer/frame_interfaces', 9 'content/public/renderer/frame_interfaces',
9 ], (barcodeDetection, bindings, mojo, interfaces) => { 10 ], (barcodeDetection, bindings, connection, mojo, interfaces) => {
10 11
11 class MockBarcodeDetection { 12 class MockBarcodeDetection {
12 constructor() { 13 constructor() {
13 this.bindingSet_ = new bindings.BindingSet(
14 barcodeDetection.BarcodeDetection);
15
16 interfaces.addInterfaceOverrideForTesting( 14 interfaces.addInterfaceOverrideForTesting(
17 barcodeDetection.BarcodeDetection.name, 15 barcodeDetection.BarcodeDetection.name,
18 handle => this.bindingSet_.addBinding(this, handle)); 16 pipe => this.bindToPipe(pipe));
17 }
18
19 bindToPipe(pipe) {
20 this.stub_ = connection.bindHandleToStub(pipe,
21 barcodeDetection.BarcodeDetection );
22 bindings.StubBindings(this.stub_).delegate = this;
19 } 23 }
20 24
21 detect(frame_data, width, height) { 25 detect(frame_data, width, height) {
22 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0); 26 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0);
23 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); 27 this.buffer_data_ = new Uint32Array(receivedStruct.buffer);
24 return Promise.resolve({ 28 return Promise.resolve({
25 results: [ 29 results: [
26 { 30 {
27 raw_value : "cats", 31 raw_value : "cats",
28 bounding_box: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 }, 32 bounding_box: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 },
(...skipping 18 matching lines...) Expand all
47 }); 51 });
48 mojo.unmapBuffer(receivedStruct.buffer); 52 mojo.unmapBuffer(receivedStruct.buffer);
49 } 53 }
50 54
51 getFrameData() { 55 getFrameData() {
52 return this.buffer_data_; 56 return this.buffer_data_;
53 } 57 }
54 } 58 }
55 return new MockBarcodeDetection(); 59 return new MockBarcodeDetection();
56 }); 60 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698