mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 22:28:59 +02:00
Automatic update from web-platform-tests Refactor device_manager.mojom This CL will allow us to avoid including device_manager.mojom in web_usb_service.mojom, which will in turn all us to use file.mojom in DeviceManager without needing to add it to third_party/blink/web_tests/external/wpt/resources/chromium/ See also https://chromium-review.googlesource.com/c/chromium/src/+/1350417 Change-Id: Ib838c3b2321f62e9c66b927891481c96c12bbcdc Bug: 891381 Reviewed-on: https://chromium-review.googlesource.com/c/1396009 Reviewed-by: Reilly Grant <reillyg@chromium.org> Reviewed-by: Dominick Ng <dominickn@chromium.org> Commit-Queue: Fergus Dall <sidereal@google.com> Cr-Commit-Position: refs/heads/master@{#620603} -- wpt-commits: ba3622aa0057c5e58a3a014e370e165328617a55 wpt-pr: 14732
79 lines
No EOL
2 KiB
JavaScript
79 lines
No EOL
2 KiB
JavaScript
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
'use strict';
|
|
|
|
(function() {
|
|
var mojomId = 'url/mojom/url.mojom';
|
|
if (mojo.internal.isMojomLoaded(mojomId)) {
|
|
console.warn('The following mojom is loaded multiple times: ' + mojomId);
|
|
return;
|
|
}
|
|
mojo.internal.markMojomLoaded(mojomId);
|
|
var bindings = mojo;
|
|
var associatedBindings = mojo;
|
|
var codec = mojo.internal;
|
|
var validator = mojo.internal;
|
|
|
|
var exports = mojo.internal.exposeNamespace('url.mojom');
|
|
|
|
|
|
|
|
function Url(values) {
|
|
this.initDefaults_();
|
|
this.initFields_(values);
|
|
}
|
|
|
|
|
|
Url.prototype.initDefaults_ = function() {
|
|
this.url = null;
|
|
};
|
|
Url.prototype.initFields_ = function(fields) {
|
|
for(var field in fields) {
|
|
if (this.hasOwnProperty(field))
|
|
this[field] = fields[field];
|
|
}
|
|
};
|
|
|
|
Url.validate = function(messageValidator, offset) {
|
|
var err;
|
|
err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
|
|
if (err !== validator.validationError.NONE)
|
|
return err;
|
|
|
|
var kVersionSizes = [
|
|
{version: 0, numBytes: 16}
|
|
];
|
|
err = messageValidator.validateStructVersion(offset, kVersionSizes);
|
|
if (err !== validator.validationError.NONE)
|
|
return err;
|
|
|
|
|
|
// validate Url.url
|
|
err = messageValidator.validateStringPointer(offset + codec.kStructHeaderSize + 0, false)
|
|
if (err !== validator.validationError.NONE)
|
|
return err;
|
|
|
|
return validator.validationError.NONE;
|
|
};
|
|
|
|
Url.encodedSize = codec.kStructHeaderSize + 8;
|
|
|
|
Url.decode = function(decoder) {
|
|
var packed;
|
|
var val = new Url();
|
|
var numberOfBytes = decoder.readUint32();
|
|
var version = decoder.readUint32();
|
|
val.url = decoder.decodeStruct(codec.String);
|
|
return val;
|
|
};
|
|
|
|
Url.encode = function(encoder, val) {
|
|
var packed;
|
|
encoder.writeUint32(Url.encodedSize);
|
|
encoder.writeUint32(0);
|
|
encoder.encodeStruct(codec.String, val.url);
|
|
};
|
|
exports.Url = Url;
|
|
})(); |