| // mojo/public/cpp/bindings/tests/idle_tracking_unittest.test-mojom.js is auto generated by mojom_bindings_generator.py, do not edit |
| |
| // Copyright 2014 The Chromium Authors |
| // 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 = 'mojo/public/cpp/bindings/tests/idle_tracking_unittest.test-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('mojo.test.idleTrackingUnittest.mojom'); |
| |
| |
| |
| function TestService_Ping_Params(values) { |
| this.initDefaults_(); |
| this.initFields_(values); |
| } |
| |
| |
| TestService_Ping_Params.prototype.initDefaults_ = function() { |
| }; |
| TestService_Ping_Params.prototype.initFields_ = function(fields) { |
| for(var field in fields) { |
| if (this.hasOwnProperty(field)) |
| this[field] = fields[field]; |
| } |
| }; |
| |
| TestService_Ping_Params.validate = function(messageValidator, offset) { |
| var err; |
| err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize); |
| if (err !== validator.validationError.NONE) |
| return err; |
| |
| var kVersionSizes = [ |
| {version: 0, numBytes: 8} |
| ]; |
| err = messageValidator.validateStructVersion(offset, kVersionSizes); |
| if (err !== validator.validationError.NONE) |
| return err; |
| |
| return validator.validationError.NONE; |
| }; |
| |
| TestService_Ping_Params.encodedSize = codec.kStructHeaderSize + 0; |
| |
| TestService_Ping_Params.decode = function(decoder) { |
| var packed; |
| var val = new TestService_Ping_Params(); |
| var numberOfBytes = decoder.readUint32(); |
| var version = decoder.readUint32(); |
| return val; |
| }; |
| |
| TestService_Ping_Params.encode = function(encoder, val) { |
| var packed; |
| encoder.writeUint32(TestService_Ping_Params.encodedSize); |
| encoder.writeUint32(0); |
| }; |
| function TestService_PingPong_Params(values) { |
| this.initDefaults_(); |
| this.initFields_(values); |
| } |
| |
| |
| TestService_PingPong_Params.prototype.initDefaults_ = function() { |
| }; |
| TestService_PingPong_Params.prototype.initFields_ = function(fields) { |
| for(var field in fields) { |
| if (this.hasOwnProperty(field)) |
| this[field] = fields[field]; |
| } |
| }; |
| |
| TestService_PingPong_Params.validate = function(messageValidator, offset) { |
| var err; |
| err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize); |
| if (err !== validator.validationError.NONE) |
| return err; |
| |
| var kVersionSizes = [ |
| {version: 0, numBytes: 8} |
| ]; |
| err = messageValidator.validateStructVersion(offset, kVersionSizes); |
| if (err !== validator.validationError.NONE) |
| return err; |
| |
| return validator.validationError.NONE; |
| }; |
| |
| TestService_PingPong_Params.encodedSize = codec.kStructHeaderSize + 0; |
| |
| TestService_PingPong_Params.decode = function(decoder) { |
| var packed; |
| var val = new TestService_PingPong_Params(); |
| var numberOfBytes = decoder.readUint32(); |
| var version = decoder.readUint32(); |
| return val; |
| }; |
| |
| TestService_PingPong_Params.encode = function(encoder, val) { |
| var packed; |
| encoder.writeUint32(TestService_PingPong_Params.encodedSize); |
| encoder.writeUint32(0); |
| }; |
| function TestService_PingPong_ResponseParams(values) { |
| this.initDefaults_(); |
| this.initFields_(values); |
| } |
| |
| |
| TestService_PingPong_ResponseParams.prototype.initDefaults_ = function() { |
| }; |
| TestService_PingPong_ResponseParams.prototype.initFields_ = function(fields) { |
| for(var field in fields) { |
| if (this.hasOwnProperty(field)) |
| this[field] = fields[field]; |
| } |
| }; |
| |
| TestService_PingPong_ResponseParams.validate = function(messageValidator, offset) { |
| var err; |
| err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize); |
| if (err !== validator.validationError.NONE) |
| return err; |
| |
| var kVersionSizes = [ |
| {version: 0, numBytes: 8} |
| ]; |
| err = messageValidator.validateStructVersion(offset, kVersionSizes); |
| if (err !== validator.validationError.NONE) |
| return err; |
| |
| return validator.validationError.NONE; |
| }; |
| |
| TestService_PingPong_ResponseParams.encodedSize = codec.kStructHeaderSize + 0; |
| |
| TestService_PingPong_ResponseParams.decode = function(decoder) { |
| var packed; |
| var val = new TestService_PingPong_ResponseParams(); |
| var numberOfBytes = decoder.readUint32(); |
| var version = decoder.readUint32(); |
| return val; |
| }; |
| |
| TestService_PingPong_ResponseParams.encode = function(encoder, val) { |
| var packed; |
| encoder.writeUint32(TestService_PingPong_ResponseParams.encodedSize); |
| encoder.writeUint32(0); |
| }; |
| function TestService_BindKeepAlive_Params(values) { |
| this.initDefaults_(); |
| this.initFields_(values); |
| } |
| |
| |
| TestService_BindKeepAlive_Params.prototype.initDefaults_ = function() { |
| this.receiver = new bindings.InterfaceRequest(); |
| }; |
| TestService_BindKeepAlive_Params.prototype.initFields_ = function(fields) { |
| for(var field in fields) { |
| if (this.hasOwnProperty(field)) |
| this[field] = fields[field]; |
| } |
| }; |
| |
| TestService_BindKeepAlive_Params.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 TestService_BindKeepAlive_Params.receiver |
| err = messageValidator.validateInterfaceRequest(offset + codec.kStructHeaderSize + 0, false) |
| if (err !== validator.validationError.NONE) |
| return err; |
| |
| return validator.validationError.NONE; |
| }; |
| |
| TestService_BindKeepAlive_Params.encodedSize = codec.kStructHeaderSize + 8; |
| |
| TestService_BindKeepAlive_Params.decode = function(decoder) { |
| var packed; |
| var val = new TestService_BindKeepAlive_Params(); |
| var numberOfBytes = decoder.readUint32(); |
| var version = decoder.readUint32(); |
| val.receiver = |
| decoder.decodeStruct(codec.InterfaceRequest); |
| decoder.skip(1); |
| decoder.skip(1); |
| decoder.skip(1); |
| decoder.skip(1); |
| return val; |
| }; |
| |
| TestService_BindKeepAlive_Params.encode = function(encoder, val) { |
| var packed; |
| encoder.writeUint32(TestService_BindKeepAlive_Params.encodedSize); |
| encoder.writeUint32(0); |
| encoder.encodeStruct(codec.InterfaceRequest, val.receiver); |
| encoder.skip(1); |
| encoder.skip(1); |
| encoder.skip(1); |
| encoder.skip(1); |
| }; |
| var kTestService_Ping_Name = 0; |
| var kTestService_PingPong_Name = 1; |
| var kTestService_BindKeepAlive_Name = 2; |
| |
| function TestServicePtr(handleOrPtrInfo) { |
| this.ptr = new bindings.InterfacePtrController(TestService, |
| handleOrPtrInfo); |
| } |
| |
| function TestServiceAssociatedPtr(associatedInterfacePtrInfo) { |
| this.ptr = new associatedBindings.AssociatedInterfacePtrController( |
| TestService, associatedInterfacePtrInfo); |
| } |
| |
| TestServiceAssociatedPtr.prototype = |
| Object.create(TestServicePtr.prototype); |
| TestServiceAssociatedPtr.prototype.constructor = |
| TestServiceAssociatedPtr; |
| |
| function TestServiceProxy(receiver) { |
| this.receiver_ = receiver; |
| } |
| TestServicePtr.prototype.ping = function() { |
| return TestServiceProxy.prototype.ping |
| .apply(this.ptr.getProxy(), arguments); |
| }; |
| |
| TestServiceProxy.prototype.ping = function() { |
| var params_ = new TestService_Ping_Params(); |
| var builder = new codec.MessageV0Builder( |
| kTestService_Ping_Name, |
| codec.align(TestService_Ping_Params.encodedSize)); |
| builder.encodeStruct(TestService_Ping_Params, params_); |
| var message = builder.finish(); |
| this.receiver_.accept(message); |
| }; |
| TestServicePtr.prototype.pingPong = function() { |
| return TestServiceProxy.prototype.pingPong |
| .apply(this.ptr.getProxy(), arguments); |
| }; |
| |
| TestServiceProxy.prototype.pingPong = function() { |
| var params_ = new TestService_PingPong_Params(); |
| return new Promise(function(resolve, reject) { |
| var builder = new codec.MessageV1Builder( |
| kTestService_PingPong_Name, |
| codec.align(TestService_PingPong_Params.encodedSize), |
| codec.kMessageExpectsResponse, 0); |
| builder.encodeStruct(TestService_PingPong_Params, params_); |
| var message = builder.finish(); |
| this.receiver_.acceptAndExpectResponse(message).then(function(message) { |
| var reader = new codec.MessageReader(message); |
| var responseParams = |
| reader.decodeStruct(TestService_PingPong_ResponseParams); |
| resolve(responseParams); |
| }).catch(function(result) { |
| reject(Error("Connection error: " + result)); |
| }); |
| }.bind(this)); |
| }; |
| TestServicePtr.prototype.bindKeepAlive = function() { |
| return TestServiceProxy.prototype.bindKeepAlive |
| .apply(this.ptr.getProxy(), arguments); |
| }; |
| |
| TestServiceProxy.prototype.bindKeepAlive = function(receiver) { |
| var params_ = new TestService_BindKeepAlive_Params(); |
| params_.receiver = receiver; |
| var builder = new codec.MessageV0Builder( |
| kTestService_BindKeepAlive_Name, |
| codec.align(TestService_BindKeepAlive_Params.encodedSize)); |
| builder.encodeStruct(TestService_BindKeepAlive_Params, params_); |
| var message = builder.finish(); |
| this.receiver_.accept(message); |
| }; |
| |
| function TestServiceStub(delegate) { |
| this.delegate_ = delegate; |
| } |
| TestServiceStub.prototype.ping = function() { |
| return this.delegate_ && this.delegate_.ping && this.delegate_.ping(); |
| } |
| TestServiceStub.prototype.pingPong = function() { |
| return this.delegate_ && this.delegate_.pingPong && this.delegate_.pingPong(); |
| } |
| TestServiceStub.prototype.bindKeepAlive = function(receiver) { |
| return this.delegate_ && this.delegate_.bindKeepAlive && this.delegate_.bindKeepAlive(receiver); |
| } |
| |
| TestServiceStub.prototype.accept = function(message) { |
| var reader = new codec.MessageReader(message); |
| switch (reader.messageName) { |
| case kTestService_Ping_Name: |
| var params = reader.decodeStruct(TestService_Ping_Params); |
| this.ping(); |
| return true; |
| case kTestService_BindKeepAlive_Name: |
| var params = reader.decodeStruct(TestService_BindKeepAlive_Params); |
| this.bindKeepAlive(params.receiver); |
| return true; |
| default: |
| return false; |
| } |
| }; |
| |
| TestServiceStub.prototype.acceptWithResponder = |
| function(message, responder) { |
| var reader = new codec.MessageReader(message); |
| switch (reader.messageName) { |
| case kTestService_PingPong_Name: |
| var params = reader.decodeStruct(TestService_PingPong_Params); |
| this.pingPong().then(function(response) { |
| var responseParams = |
| new TestService_PingPong_ResponseParams(); |
| var builder = new codec.MessageV1Builder( |
| kTestService_PingPong_Name, |
| codec.align(TestService_PingPong_ResponseParams.encodedSize), |
| codec.kMessageIsResponse, reader.requestID); |
| builder.encodeStruct(TestService_PingPong_ResponseParams, |
| responseParams); |
| var message = builder.finish(); |
| responder.accept(message); |
| }); |
| return true; |
| default: |
| return false; |
| } |
| }; |
| |
| function validateTestServiceRequest(messageValidator) { |
| var message = messageValidator.message; |
| var paramsClass = null; |
| switch (message.getName()) { |
| case kTestService_Ping_Name: |
| if (!message.expectsResponse() && !message.isResponse()) |
| paramsClass = TestService_Ping_Params; |
| break; |
| case kTestService_PingPong_Name: |
| if (message.expectsResponse()) |
| paramsClass = TestService_PingPong_Params; |
| break; |
| case kTestService_BindKeepAlive_Name: |
| if (!message.expectsResponse() && !message.isResponse()) |
| paramsClass = TestService_BindKeepAlive_Params; |
| break; |
| } |
| if (paramsClass === null) |
| return validator.validationError.NONE; |
| return paramsClass.validate(messageValidator, messageValidator.message.getHeaderNumBytes()); |
| } |
| |
| function validateTestServiceResponse(messageValidator) { |
| var message = messageValidator.message; |
| var paramsClass = null; |
| switch (message.getName()) { |
| case kTestService_PingPong_Name: |
| if (message.isResponse()) |
| paramsClass = TestService_PingPong_ResponseParams; |
| break; |
| } |
| if (paramsClass === null) |
| return validator.validationError.NONE; |
| return paramsClass.validate(messageValidator, messageValidator.message.getHeaderNumBytes()); |
| } |
| |
| var TestService = { |
| name: 'mojo.test.idle_tracking_unittest.mojom.TestService', |
| kVersion: 0, |
| ptrClass: TestServicePtr, |
| proxyClass: TestServiceProxy, |
| stubClass: TestServiceStub, |
| validateRequest: validateTestServiceRequest, |
| validateResponse: validateTestServiceResponse, |
| }; |
| TestServiceStub.prototype.validator = validateTestServiceRequest; |
| TestServiceProxy.prototype.validator = validateTestServiceResponse; |
| |
| function KeepAlivePtr(handleOrPtrInfo) { |
| this.ptr = new bindings.InterfacePtrController(KeepAlive, |
| handleOrPtrInfo); |
| } |
| |
| function KeepAliveAssociatedPtr(associatedInterfacePtrInfo) { |
| this.ptr = new associatedBindings.AssociatedInterfacePtrController( |
| KeepAlive, associatedInterfacePtrInfo); |
| } |
| |
| KeepAliveAssociatedPtr.prototype = |
| Object.create(KeepAlivePtr.prototype); |
| KeepAliveAssociatedPtr.prototype.constructor = |
| KeepAliveAssociatedPtr; |
| |
| function KeepAliveProxy(receiver) { |
| this.receiver_ = receiver; |
| } |
| |
| function KeepAliveStub(delegate) { |
| this.delegate_ = delegate; |
| } |
| |
| KeepAliveStub.prototype.accept = function(message) { |
| var reader = new codec.MessageReader(message); |
| switch (reader.messageName) { |
| default: |
| return false; |
| } |
| }; |
| |
| KeepAliveStub.prototype.acceptWithResponder = |
| function(message, responder) { |
| var reader = new codec.MessageReader(message); |
| switch (reader.messageName) { |
| default: |
| return false; |
| } |
| }; |
| |
| function validateKeepAliveRequest(messageValidator) { |
| return validator.validationError.NONE; |
| } |
| |
| function validateKeepAliveResponse(messageValidator) { |
| return validator.validationError.NONE; |
| } |
| |
| var KeepAlive = { |
| name: 'mojo.test.idle_tracking_unittest.mojom.KeepAlive', |
| kVersion: 0, |
| ptrClass: KeepAlivePtr, |
| proxyClass: KeepAliveProxy, |
| stubClass: KeepAliveStub, |
| validateRequest: validateKeepAliveRequest, |
| validateResponse: null, |
| }; |
| KeepAliveStub.prototype.validator = validateKeepAliveRequest; |
| KeepAliveProxy.prototype.validator = null; |
| exports.TestService = TestService; |
| exports.TestServicePtr = TestServicePtr; |
| exports.TestServiceAssociatedPtr = TestServiceAssociatedPtr; |
| exports.KeepAlive = KeepAlive; |
| exports.KeepAlivePtr = KeepAlivePtr; |
| exports.KeepAliveAssociatedPtr = KeepAliveAssociatedPtr; |
| })(); |