зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1768350 [wpt PR 33984] - Revert "Use mojo_base.mojom.ReadOnlySharedMemoryRegion in device sensors.", a=testonly
Automatic update from web-platform-tests Revert "Use mojo_base.mojom.ReadOnlySharedMemoryRegion in device sensors." This reverts commit 076ef25936e7142c67e21d9295dd92a139164e71. Reason for revert: prereq for reverting https://crrev.com/c/3625893 Original change's description: > Use mojo_base.mojom.ReadOnlySharedMemoryRegion in device sensors. > > Unfortunately, the CL largely relies on using static_cast<const T*> > instead of the safer GetMemoryAs<T> helper, since GetMemoryAs<T> requires > that device::SensorReadingSharedBuffer is trivially copyable. > > Bug: 1306363 > Change-Id: I91d048450bf7ba341065e6175c9928be34e45946 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3621355 > Commit-Queue: Daniel Cheng <dcheng@chromium.org> > Reviewed-by: Reilly Grant <reillyg@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1000672} Bug: 1306363 Change-Id: I10fe4e9eacd16c4016e71410eaa7aa2597a2578b No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3632842 Commit-Queue: Daniel Cheng <dcheng@chromium.org> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Owners-Override: Daniel Cheng <dcheng@chromium.org> Auto-Submit: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#1000750} -- wpt-commits: 4e0796bcd669c3caf123d5a8f4a2d9acf9e12393 wpt-pr: 33984
This commit is contained in:
Родитель
2a245bc080
Коммит
932a7e1334
|
@ -38,7 +38,7 @@ self.GenericSensorTest = (() => {
|
|||
// Class that mocks Sensor interface defined in
|
||||
// https://cs.chromium.org/chromium/src/services/device/public/mojom/sensor.mojom
|
||||
class MockSensor {
|
||||
constructor(sensorRequest, buffer, reportingMode) {
|
||||
constructor(sensorRequest, handle, offset, size, reportingMode) {
|
||||
this.client_ = null;
|
||||
this.startShouldFail_ = false;
|
||||
this.notifyOnReadingChange_ = true;
|
||||
|
@ -51,7 +51,11 @@ self.GenericSensorTest = (() => {
|
|||
// In this mock implementation we use a starting value
|
||||
// and an increment step value that resemble a platform timestamp reasonably enough.
|
||||
this.timestamp_ = window.performance.timeOrigin;
|
||||
this.buffer_ = buffer;
|
||||
let rv = handle.mapBuffer(offset, size);
|
||||
if (rv.result != Mojo.RESULT_OK) {
|
||||
throw new Error("MockSensor(): Failed to map shared buffer");
|
||||
}
|
||||
this.buffer_ = new Float64Array(rv.buffer);
|
||||
this.buffer_.fill(0);
|
||||
this.receiver_ = new SensorReceiver(this);
|
||||
this.receiver_.$.bindHandle(sensorRequest.handle);
|
||||
|
@ -194,22 +198,11 @@ self.GenericSensorTest = (() => {
|
|||
Number(SensorInitParams_READ_BUFFER_SIZE_FOR_TESTS);
|
||||
this.sharedBufferSizeInBytes_ =
|
||||
this.readingSizeInBytes_ * (SensorType.MAX_VALUE + 1);
|
||||
let rv = Mojo.createSharedBuffer(this.sharedBufferSizeInBytes_);
|
||||
if (rv.result != Mojo.RESULT_OK) {
|
||||
throw new Error('MockSensorProvider: Failed to create shared buffer');
|
||||
}
|
||||
const handle = rv.handle;
|
||||
rv = handle.mapBuffer(0, this.sharedBufferSizeInBytes_);
|
||||
const rv = Mojo.createSharedBuffer(this.sharedBufferSizeInBytes_);
|
||||
if (rv.result != Mojo.RESULT_OK) {
|
||||
throw new Error("MockSensorProvider: Failed to map shared buffer");
|
||||
}
|
||||
this.shmemArrayBuffer_ = rv.buffer;
|
||||
rv = handle.duplicateBufferHandle({readOnly: true});
|
||||
if (rv.result != Mojo.RESULT_OK) {
|
||||
throw new Error(
|
||||
'MockSensorProvider: failed to duplicate shared buffer');
|
||||
}
|
||||
this.readOnlySharedBufferHandle_ = rv.handle;
|
||||
this.sharedBufferHandle_ = rv.handle;
|
||||
this.activeSensors_ = new Map();
|
||||
this.resolveFuncs_ = new Map();
|
||||
this.getSensorShouldFail_ = new Map();
|
||||
|
@ -259,19 +252,16 @@ self.GenericSensorTest = (() => {
|
|||
|
||||
const sensor = new SensorRemote();
|
||||
if (!this.activeSensors_.has(type)) {
|
||||
const shmemView = new Float64Array(
|
||||
this.shmemArrayBuffer_, offset,
|
||||
this.readingSizeInBytes_ / Float64Array.BYTES_PER_ELEMENT);
|
||||
const mockSensor = new MockSensor(
|
||||
sensor.$.bindNewPipeAndPassReceiver(), shmemView, reportingMode);
|
||||
sensor.$.bindNewPipeAndPassReceiver(), this.sharedBufferHandle_,
|
||||
offset, this.readingSizeInBytes_, reportingMode);
|
||||
this.activeSensors_.set(type, mockSensor);
|
||||
this.activeSensors_.get(type).client_ = new SensorClientRemote();
|
||||
}
|
||||
|
||||
const rv = this.readOnlySharedBufferHandle_.duplicateBufferHandle(
|
||||
{readOnly: true});
|
||||
const rv = this.sharedBufferHandle_.duplicateBufferHandle();
|
||||
if (rv.result != Mojo.RESULT_OK) {
|
||||
throw new Error('getSensor(): failed to duplicate shared buffer');
|
||||
throw new Error("getSensor(): failed to duplicate Mojo buffer handler");
|
||||
}
|
||||
|
||||
const defaultConfig = { frequency: DEFAULT_FREQUENCY };
|
||||
|
@ -298,7 +288,7 @@ self.GenericSensorTest = (() => {
|
|||
const initParams = {
|
||||
sensor,
|
||||
clientReceiver: client.$.bindNewPipeAndPassReceiver(),
|
||||
memory: {buffer: rv.handle},
|
||||
memory: rv.handle,
|
||||
bufferOffset: BigInt(offset),
|
||||
mode: reportingMode,
|
||||
defaultConfiguration: defaultConfig,
|
||||
|
|
Загрузка…
Ссылка в новой задаче