Index: third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js |
diff --git a/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js b/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js |
index 262145feca1793baebf1d93189cdde29be69e497..03f32d9418ec51e827ddf52841cb44a74f8de4da 100644 |
--- a/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js |
+++ b/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js |
@@ -21,10 +21,9 @@ function sensor_mocks(mojo) { |
return define('Generic Sensor API mocks', [ |
'mojo/public/js/core', |
'mojo/public/js/bindings', |
- 'mojo/public/js/connection', |
'device/generic_sensor/public/interfaces/sensor_provider.mojom', |
'device/generic_sensor/public/interfaces/sensor.mojom', |
- ], (core, bindings, connection, sensor_provider, sensor) => { |
+ ], (core, bindings, sensor_provider, sensor) => { |
// Helper function that returns resolved promise with result. |
function sensorResponse(success) { |
@@ -33,9 +32,8 @@ function sensor_mocks(mojo) { |
// Class that mocks Sensor interface defined in sensor.mojom |
class MockSensor { |
- constructor(stub, handle, offset, size, reportingMode) { |
+ constructor(sensorRequest, handle, offset, size, reportingMode) { |
this.client_ = null; |
- this.stub_ = stub; |
this.expects_modified_reading_ = false; |
this.start_should_fail_ = false; |
this.reporting_mode_ = reportingMode; |
@@ -52,10 +50,11 @@ function sensor_mocks(mojo) { |
this.buffer_array_ = rv.buffer; |
this.buffer_ = new Float64Array(this.buffer_array_); |
this.resetBuffer(); |
- bindings.StubBindings(this.stub_).delegate = this; |
- bindings.StubBindings(this.stub_).connectionErrorHandler = () => { |
+ this.binding_ = new bindings.Binding(sensor.Sensor, this, |
+ sensorRequest); |
+ this.binding_.setConnectionErrorHandler(() => { |
this.reset(); |
- }; |
+ }); |
} |
// Returns default configuration. |
@@ -137,7 +136,7 @@ function sensor_mocks(mojo) { |
this.resetBuffer(); |
core.unmapBuffer(this.buffer_array_); |
this.buffer_array_ = null; |
- bindings.StubBindings(this.stub_).close(); |
+ this.binding_.close(); |
} |
// Zeroes shared buffer. |
@@ -241,6 +240,8 @@ function sensor_mocks(mojo) { |
this.resolve_func_ = null; |
this.is_continuous_ = false; |
this.max_frequency_ = 60; |
+ this.binding_ = new bindings.Binding(sensor_provider.SensorProvider, |
+ this); |
} |
// Returns initialized Sensor proxy to the client. |
@@ -258,8 +259,7 @@ function sensor_mocks(mojo) { |
} |
if (this.active_sensor_ == null) { |
- var stub = connection.bindHandleToStub(request.handle, sensor.Sensor); |
- let mockSensor = new MockSensor(stub, this.shared_buffer_handle_, |
+ let mockSensor = new MockSensor(request, this.shared_buffer_handle_, |
offset, this.reading_size_in_bytes_, reporting_mode); |
this.active_sensor_ = mockSensor; |
} |
@@ -285,21 +285,17 @@ function sensor_mocks(mojo) { |
this.resolve_func_(this.active_sensor_); |
} |
- var client_request = new bindings.InterfaceRequest( |
- connection.bindProxy(proxy => { |
- this.active_sensor_.client_ = proxy; |
- }, sensor.SensorClient)); |
- return getSensorResponse(init_params, client_request); |
+ this.active_sensor_.client_ = new sensor.SensorClientPtr(); |
+ return getSensorResponse( |
+ init_params, bindings.makeRequest(this.active_sensor_.client_)); |
} |
// Binds object to mojo message pipe |
bindToPipe(pipe) { |
- this.stub_ = connection.bindHandleToStub( |
- pipe, sensor_provider.SensorProvider); |
- bindings.StubBindings(this.stub_).delegate = this; |
- bindings.StubBindings(this.stub_).connectionErrorHandler = () => { |
+ this.binding_.bind(pipe); |
+ this.binding_.setConnectionErrorHandler(() => { |
this.reset(); |
- }; |
+ }); |
} |
// Mock functions |
@@ -315,8 +311,7 @@ function sensor_mocks(mojo) { |
this.resolve_func_ = null; |
this.max_frequency_ = 60; |
this.is_continuous_ = false; |
- if (this.stub_) |
- bindings.StubBindings(this.stub_).close(); |
+ this.binding_.close(); |
} |
// Sets flag that forces mock SensorProvider to fail when getSensor() is |