| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 library audio_server_mojom; | 5 library trace_provider_registry_mojom; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'package:mojo/bindings.dart' as bindings; | 7 import 'package:mojo/bindings.dart' as bindings; |
| 8 import 'package:mojo/core.dart' as core; | 8 import 'package:mojo/core.dart' as core; |
| 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
| 10 import 'package:mojo_services/mojo/media/audio_track.mojom.dart' as audio_track_
mojom; | 10 import 'package:mojo_services/tracing/tracing.mojom.dart' as tracing_mojom; |
| 11 | 11 |
| 12 | 12 |
| 13 | 13 |
| 14 class _AudioServerCreateTrackParams extends bindings.Struct { | 14 class _TraceProviderRegistryRegisterTraceProviderParams extends bindings.Struct
{ |
| 15 static const List<bindings.StructDataHeader> kVersions = const [ | 15 static const List<bindings.StructDataHeader> kVersions = const [ |
| 16 const bindings.StructDataHeader(16, 0) | 16 const bindings.StructDataHeader(16, 0) |
| 17 ]; | 17 ]; |
| 18 Object track = null; | 18 Object traceProvider = null; |
| 19 | 19 |
| 20 _AudioServerCreateTrackParams() : super(kVersions.last.size); | 20 _TraceProviderRegistryRegisterTraceProviderParams() : super(kVersions.last.siz
e); |
| 21 | 21 |
| 22 static _AudioServerCreateTrackParams deserialize(bindings.Message message) { | 22 static _TraceProviderRegistryRegisterTraceProviderParams deserialize(bindings.
Message message) { |
| 23 var decoder = new bindings.Decoder(message); | 23 var decoder = new bindings.Decoder(message); |
| 24 var result = decode(decoder); | 24 var result = decode(decoder); |
| 25 if (decoder.excessHandles != null) { | 25 if (decoder.excessHandles != null) { |
| 26 decoder.excessHandles.forEach((h) => h.close()); | 26 decoder.excessHandles.forEach((h) => h.close()); |
| 27 } | 27 } |
| 28 return result; | 28 return result; |
| 29 } | 29 } |
| 30 | 30 |
| 31 static _AudioServerCreateTrackParams decode(bindings.Decoder decoder0) { | 31 static _TraceProviderRegistryRegisterTraceProviderParams decode(bindings.Decod
er decoder0) { |
| 32 if (decoder0 == null) { | 32 if (decoder0 == null) { |
| 33 return null; | 33 return null; |
| 34 } | 34 } |
| 35 _AudioServerCreateTrackParams result = new _AudioServerCreateTrackParams(); | 35 _TraceProviderRegistryRegisterTraceProviderParams result = new _TraceProvide
rRegistryRegisterTraceProviderParams(); |
| 36 | 36 |
| 37 var mainDataHeader = decoder0.decodeStructDataHeader(); | 37 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 38 if (mainDataHeader.version <= kVersions.last.version) { | 38 if (mainDataHeader.version <= kVersions.last.version) { |
| 39 // Scan in reverse order to optimize for more recent versions. | 39 // Scan in reverse order to optimize for more recent versions. |
| 40 for (int i = kVersions.length - 1; i >= 0; --i) { | 40 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 41 if (mainDataHeader.version >= kVersions[i].version) { | 41 if (mainDataHeader.version >= kVersions[i].version) { |
| 42 if (mainDataHeader.size == kVersions[i].size) { | 42 if (mainDataHeader.size == kVersions[i].size) { |
| 43 // Found a match. | 43 // Found a match. |
| 44 break; | 44 break; |
| 45 } | 45 } |
| 46 throw new bindings.MojoCodecError( | 46 throw new bindings.MojoCodecError( |
| 47 'Header size doesn\'t correspond to known version size.'); | 47 'Header size doesn\'t correspond to known version size.'); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 } else if (mainDataHeader.size < kVersions.last.size) { | 50 } else if (mainDataHeader.size < kVersions.last.size) { |
| 51 throw new bindings.MojoCodecError( | 51 throw new bindings.MojoCodecError( |
| 52 'Message newer than the last known version cannot be shorter than ' | 52 'Message newer than the last known version cannot be shorter than ' |
| 53 'required by the last known version.'); | 53 'required by the last known version.'); |
| 54 } | 54 } |
| 55 if (mainDataHeader.version >= 0) { | 55 if (mainDataHeader.version >= 0) { |
| 56 | 56 |
| 57 result.track = decoder0.decodeInterfaceRequest(8, false, audio_track_mojom
.AudioTrackStub.newFromEndpoint); | 57 result.traceProvider = decoder0.decodeServiceInterface(8, false, tracing_m
ojom.TraceProviderProxy.newFromEndpoint); |
| 58 } | 58 } |
| 59 return result; | 59 return result; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void encode(bindings.Encoder encoder) { | 62 void encode(bindings.Encoder encoder) { |
| 63 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); | 63 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 64 try { | 64 try { |
| 65 encoder0.encodeInterfaceRequest(track, 8, false); | 65 encoder0.encodeInterface(traceProvider, 8, false); |
| 66 } on bindings.MojoCodecError catch(e) { | 66 } on bindings.MojoCodecError catch(e) { |
| 67 e.message = "Error encountered while encoding field " | 67 e.message = "Error encountered while encoding field " |
| 68 "track of struct _AudioServerCreateTrackParams: $e"; | 68 "traceProvider of struct _TraceProviderRegistryRegisterTraceProviderPa
rams: $e"; |
| 69 rethrow; | 69 rethrow; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 String toString() { | 73 String toString() { |
| 74 return "_AudioServerCreateTrackParams(" | 74 return "_TraceProviderRegistryRegisterTraceProviderParams(" |
| 75 "track: $track" ")"; | 75 "traceProvider: $traceProvider" ")"; |
| 76 } | 76 } |
| 77 | 77 |
| 78 Map toJson() { | 78 Map toJson() { |
| 79 throw new bindings.MojoCodecError( | 79 throw new bindings.MojoCodecError( |
| 80 'Object containing handles cannot be encoded to JSON.'); | 80 'Object containing handles cannot be encoded to JSON.'); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 const int _audioServerMethodCreateTrackName = 0; | 84 const int _traceProviderRegistryMethodRegisterTraceProviderName = 0; |
| 85 | 85 |
| 86 class _AudioServerServiceDescription implements service_describer.ServiceDescrip
tion { | 86 class _TraceProviderRegistryServiceDescription implements service_describer.Serv
iceDescription { |
| 87 dynamic getTopLevelInterface([Function responseFactory]) => | 87 dynamic getTopLevelInterface([Function responseFactory]) => |
| 88 responseFactory(null); | 88 responseFactory(null); |
| 89 | 89 |
| 90 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 90 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => |
| 91 responseFactory(null); | 91 responseFactory(null); |
| 92 | 92 |
| 93 dynamic getAllTypeDefinitions([Function responseFactory]) => | 93 dynamic getAllTypeDefinitions([Function responseFactory]) => |
| 94 responseFactory(null); | 94 responseFactory(null); |
| 95 } | 95 } |
| 96 | 96 |
| 97 abstract class AudioServer { | 97 abstract class TraceProviderRegistry { |
| 98 static const String serviceName = "mojo::media::AudioServer"; | 98 static const String serviceName = "tracing.TraceProviderRegistry"; |
| 99 void createTrack(Object track); | 99 void registerTraceProvider(Object traceProvider); |
| 100 } | 100 } |
| 101 | 101 |
| 102 | 102 |
| 103 class _AudioServerProxyImpl extends bindings.Proxy { | 103 class _TraceProviderRegistryProxyImpl extends bindings.Proxy { |
| 104 _AudioServerProxyImpl.fromEndpoint( | 104 _TraceProviderRegistryProxyImpl.fromEndpoint( |
| 105 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 105 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 106 | 106 |
| 107 _AudioServerProxyImpl.fromHandle(core.MojoHandle handle) : | 107 _TraceProviderRegistryProxyImpl.fromHandle(core.MojoHandle handle) : |
| 108 super.fromHandle(handle); | 108 super.fromHandle(handle); |
| 109 | 109 |
| 110 _AudioServerProxyImpl.unbound() : super.unbound(); | 110 _TraceProviderRegistryProxyImpl.unbound() : super.unbound(); |
| 111 | 111 |
| 112 static _AudioServerProxyImpl newFromEndpoint( | 112 static _TraceProviderRegistryProxyImpl newFromEndpoint( |
| 113 core.MojoMessagePipeEndpoint endpoint) { | 113 core.MojoMessagePipeEndpoint endpoint) { |
| 114 assert(endpoint.setDescription("For _AudioServerProxyImpl")); | 114 assert(endpoint.setDescription("For _TraceProviderRegistryProxyImpl")); |
| 115 return new _AudioServerProxyImpl.fromEndpoint(endpoint); | 115 return new _TraceProviderRegistryProxyImpl.fromEndpoint(endpoint); |
| 116 } | 116 } |
| 117 | 117 |
| 118 service_describer.ServiceDescription get serviceDescription => | 118 service_describer.ServiceDescription get serviceDescription => |
| 119 new _AudioServerServiceDescription(); | 119 new _TraceProviderRegistryServiceDescription(); |
| 120 | 120 |
| 121 void handleResponse(bindings.ServiceMessage message) { | 121 void handleResponse(bindings.ServiceMessage message) { |
| 122 switch (message.header.type) { | 122 switch (message.header.type) { |
| 123 default: | 123 default: |
| 124 proxyError("Unexpected message type: ${message.header.type}"); | 124 proxyError("Unexpected message type: ${message.header.type}"); |
| 125 close(immediate: true); | 125 close(immediate: true); |
| 126 break; | 126 break; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 String toString() { | 130 String toString() { |
| 131 var superString = super.toString(); | 131 var superString = super.toString(); |
| 132 return "_AudioServerProxyImpl($superString)"; | 132 return "_TraceProviderRegistryProxyImpl($superString)"; |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 class _AudioServerProxyCalls implements AudioServer { | 137 class _TraceProviderRegistryProxyCalls implements TraceProviderRegistry { |
| 138 _AudioServerProxyImpl _proxyImpl; | 138 _TraceProviderRegistryProxyImpl _proxyImpl; |
| 139 | 139 |
| 140 _AudioServerProxyCalls(this._proxyImpl); | 140 _TraceProviderRegistryProxyCalls(this._proxyImpl); |
| 141 void createTrack(Object track) { | 141 void registerTraceProvider(Object traceProvider) { |
| 142 if (!_proxyImpl.isBound) { | 142 if (!_proxyImpl.isBound) { |
| 143 _proxyImpl.proxyError("The Proxy is closed."); | 143 _proxyImpl.proxyError("The Proxy is closed."); |
| 144 return; | 144 return; |
| 145 } | 145 } |
| 146 var params = new _AudioServerCreateTrackParams(); | 146 var params = new _TraceProviderRegistryRegisterTraceProviderParams(); |
| 147 params.track = track; | 147 params.traceProvider = traceProvider; |
| 148 _proxyImpl.sendMessage(params, _audioServerMethodCreateTrackName); | 148 _proxyImpl.sendMessage(params, _traceProviderRegistryMethodRegisterTracePr
oviderName); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 class AudioServerProxy implements bindings.ProxyBase { | 153 class TraceProviderRegistryProxy implements bindings.ProxyBase { |
| 154 final bindings.Proxy impl; | 154 final bindings.Proxy impl; |
| 155 AudioServer ptr; | 155 TraceProviderRegistry ptr; |
| 156 | 156 |
| 157 AudioServerProxy(_AudioServerProxyImpl proxyImpl) : | 157 TraceProviderRegistryProxy(_TraceProviderRegistryProxyImpl proxyImpl) : |
| 158 impl = proxyImpl, | 158 impl = proxyImpl, |
| 159 ptr = new _AudioServerProxyCalls(proxyImpl); | 159 ptr = new _TraceProviderRegistryProxyCalls(proxyImpl); |
| 160 | 160 |
| 161 AudioServerProxy.fromEndpoint( | 161 TraceProviderRegistryProxy.fromEndpoint( |
| 162 core.MojoMessagePipeEndpoint endpoint) : | 162 core.MojoMessagePipeEndpoint endpoint) : |
| 163 impl = new _AudioServerProxyImpl.fromEndpoint(endpoint) { | 163 impl = new _TraceProviderRegistryProxyImpl.fromEndpoint(endpoint) { |
| 164 ptr = new _AudioServerProxyCalls(impl); | 164 ptr = new _TraceProviderRegistryProxyCalls(impl); |
| 165 } | 165 } |
| 166 | 166 |
| 167 AudioServerProxy.fromHandle(core.MojoHandle handle) : | 167 TraceProviderRegistryProxy.fromHandle(core.MojoHandle handle) : |
| 168 impl = new _AudioServerProxyImpl.fromHandle(handle) { | 168 impl = new _TraceProviderRegistryProxyImpl.fromHandle(handle) { |
| 169 ptr = new _AudioServerProxyCalls(impl); | 169 ptr = new _TraceProviderRegistryProxyCalls(impl); |
| 170 } | 170 } |
| 171 | 171 |
| 172 AudioServerProxy.unbound() : | 172 TraceProviderRegistryProxy.unbound() : |
| 173 impl = new _AudioServerProxyImpl.unbound() { | 173 impl = new _TraceProviderRegistryProxyImpl.unbound() { |
| 174 ptr = new _AudioServerProxyCalls(impl); | 174 ptr = new _TraceProviderRegistryProxyCalls(impl); |
| 175 } | 175 } |
| 176 | 176 |
| 177 factory AudioServerProxy.connectToService( | 177 factory TraceProviderRegistryProxy.connectToService( |
| 178 bindings.ServiceConnector s, String url, [String serviceName]) { | 178 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 179 AudioServerProxy p = new AudioServerProxy.unbound(); | 179 TraceProviderRegistryProxy p = new TraceProviderRegistryProxy.unbound(); |
| 180 s.connectToService(url, p, serviceName); | 180 s.connectToService(url, p, serviceName); |
| 181 return p; | 181 return p; |
| 182 } | 182 } |
| 183 | 183 |
| 184 static AudioServerProxy newFromEndpoint( | 184 static TraceProviderRegistryProxy newFromEndpoint( |
| 185 core.MojoMessagePipeEndpoint endpoint) { | 185 core.MojoMessagePipeEndpoint endpoint) { |
| 186 assert(endpoint.setDescription("For AudioServerProxy")); | 186 assert(endpoint.setDescription("For TraceProviderRegistryProxy")); |
| 187 return new AudioServerProxy.fromEndpoint(endpoint); | 187 return new TraceProviderRegistryProxy.fromEndpoint(endpoint); |
| 188 } | 188 } |
| 189 | 189 |
| 190 String get serviceName => AudioServer.serviceName; | 190 String get serviceName => TraceProviderRegistry.serviceName; |
| 191 | 191 |
| 192 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 192 Future close({bool immediate: false}) => impl.close(immediate: immediate); |
| 193 | 193 |
| 194 Future responseOrError(Future f) => impl.responseOrError(f); | 194 Future responseOrError(Future f) => impl.responseOrError(f); |
| 195 | 195 |
| 196 Future get errorFuture => impl.errorFuture; | 196 Future get errorFuture => impl.errorFuture; |
| 197 | 197 |
| 198 int get version => impl.version; | 198 int get version => impl.version; |
| 199 | 199 |
| 200 Future<int> queryVersion() => impl.queryVersion(); | 200 Future<int> queryVersion() => impl.queryVersion(); |
| 201 | 201 |
| 202 void requireVersion(int requiredVersion) { | 202 void requireVersion(int requiredVersion) { |
| 203 impl.requireVersion(requiredVersion); | 203 impl.requireVersion(requiredVersion); |
| 204 } | 204 } |
| 205 | 205 |
| 206 String toString() { | 206 String toString() { |
| 207 return "AudioServerProxy($impl)"; | 207 return "TraceProviderRegistryProxy($impl)"; |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 class AudioServerStub extends bindings.Stub { | 212 class TraceProviderRegistryStub extends bindings.Stub { |
| 213 AudioServer _impl = null; | 213 TraceProviderRegistry _impl = null; |
| 214 | 214 |
| 215 AudioServerStub.fromEndpoint( | 215 TraceProviderRegistryStub.fromEndpoint( |
| 216 core.MojoMessagePipeEndpoint endpoint, [this._impl]) | 216 core.MojoMessagePipeEndpoint endpoint, [this._impl]) |
| 217 : super.fromEndpoint(endpoint); | 217 : super.fromEndpoint(endpoint); |
| 218 | 218 |
| 219 AudioServerStub.fromHandle(core.MojoHandle handle, [this._impl]) | 219 TraceProviderRegistryStub.fromHandle(core.MojoHandle handle, [this._impl]) |
| 220 : super.fromHandle(handle); | 220 : super.fromHandle(handle); |
| 221 | 221 |
| 222 AudioServerStub.unbound() : super.unbound(); | 222 TraceProviderRegistryStub.unbound() : super.unbound(); |
| 223 | 223 |
| 224 static AudioServerStub newFromEndpoint( | 224 static TraceProviderRegistryStub newFromEndpoint( |
| 225 core.MojoMessagePipeEndpoint endpoint) { | 225 core.MojoMessagePipeEndpoint endpoint) { |
| 226 assert(endpoint.setDescription("For AudioServerStub")); | 226 assert(endpoint.setDescription("For TraceProviderRegistryStub")); |
| 227 return new AudioServerStub.fromEndpoint(endpoint); | 227 return new TraceProviderRegistryStub.fromEndpoint(endpoint); |
| 228 } | 228 } |
| 229 | 229 |
| 230 | 230 |
| 231 | 231 |
| 232 dynamic handleMessage(bindings.ServiceMessage message) { | 232 dynamic handleMessage(bindings.ServiceMessage message) { |
| 233 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 233 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 234 return bindings.ControlMessageHandler.handleMessage(this, | 234 return bindings.ControlMessageHandler.handleMessage(this, |
| 235 0, | 235 0, |
| 236 message); | 236 message); |
| 237 } | 237 } |
| 238 assert(_impl != null); | 238 assert(_impl != null); |
| 239 switch (message.header.type) { | 239 switch (message.header.type) { |
| 240 case _audioServerMethodCreateTrackName: | 240 case _traceProviderRegistryMethodRegisterTraceProviderName: |
| 241 var params = _AudioServerCreateTrackParams.deserialize( | 241 var params = _TraceProviderRegistryRegisterTraceProviderParams.deseriali
ze( |
| 242 message.payload); | 242 message.payload); |
| 243 _impl.createTrack(params.track); | 243 _impl.registerTraceProvider(params.traceProvider); |
| 244 break; | 244 break; |
| 245 default: | 245 default: |
| 246 throw new bindings.MojoCodecError("Unexpected message name"); | 246 throw new bindings.MojoCodecError("Unexpected message name"); |
| 247 break; | 247 break; |
| 248 } | 248 } |
| 249 return null; | 249 return null; |
| 250 } | 250 } |
| 251 | 251 |
| 252 AudioServer get impl => _impl; | 252 TraceProviderRegistry get impl => _impl; |
| 253 set impl(AudioServer d) { | 253 set impl(TraceProviderRegistry d) { |
| 254 assert(_impl == null); | 254 assert(_impl == null); |
| 255 _impl = d; | 255 _impl = d; |
| 256 } | 256 } |
| 257 | 257 |
| 258 String toString() { | 258 String toString() { |
| 259 var superString = super.toString(); | 259 var superString = super.toString(); |
| 260 return "AudioServerStub($superString)"; | 260 return "TraceProviderRegistryStub($superString)"; |
| 261 } | 261 } |
| 262 | 262 |
| 263 int get version => 0; | 263 int get version => 0; |
| 264 | 264 |
| 265 static service_describer.ServiceDescription _cachedServiceDescription; | 265 static service_describer.ServiceDescription _cachedServiceDescription; |
| 266 static service_describer.ServiceDescription get serviceDescription { | 266 static service_describer.ServiceDescription get serviceDescription { |
| 267 if (_cachedServiceDescription == null) { | 267 if (_cachedServiceDescription == null) { |
| 268 _cachedServiceDescription = new _AudioServerServiceDescription(); | 268 _cachedServiceDescription = new _TraceProviderRegistryServiceDescription()
; |
| 269 } | 269 } |
| 270 return _cachedServiceDescription; | 270 return _cachedServiceDescription; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 | 274 |
| 275 | 275 |
| OLD | NEW |