| 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 trace_provider_registry_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/tracing/tracing.mojom.dart' as tracing_mojom; | 10 import 'package:mojo_services/tracing/tracing.mojom.dart' as tracing_mojom; |
| 11 | 11 |
| 12 | 12 |
| 13 | 13 |
| 14 class _TraceProviderRegistryRegisterTraceProviderParams 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 traceProvider = null; | 18 tracing_mojom.TraceProviderInterface traceProvider = null; |
| 19 | 19 |
| 20 _TraceProviderRegistryRegisterTraceProviderParams() : super(kVersions.last.siz
e); | 20 _TraceProviderRegistryRegisterTraceProviderParams() : super(kVersions.last.siz
e); |
| 21 | 21 |
| 22 static _TraceProviderRegistryRegisterTraceProviderParams 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; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 TraceProviderRegistry { | 97 abstract class TraceProviderRegistry { |
| 98 static const String serviceName = "tracing.TraceProviderRegistry"; | 98 static const String serviceName = "tracing.TraceProviderRegistry"; |
| 99 void registerTraceProvider(Object traceProvider); | 99 |
| 100 static service_describer.ServiceDescription _cachedServiceDescription; |
| 101 static service_describer.ServiceDescription get serviceDescription { |
| 102 if (_cachedServiceDescription == null) { |
| 103 _cachedServiceDescription = new _TraceProviderRegistryServiceDescription()
; |
| 104 } |
| 105 return _cachedServiceDescription; |
| 106 } |
| 107 |
| 108 static TraceProviderRegistryProxy connectToService( |
| 109 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 110 TraceProviderRegistryProxy p = new TraceProviderRegistryProxy.unbound(); |
| 111 String name = serviceName ?? TraceProviderRegistry.serviceName; |
| 112 if ((name == null) || name.isEmpty) { |
| 113 throw new core.MojoApiError( |
| 114 "If an interface has no ServiceName, then one must be provided."); |
| 115 } |
| 116 s.connectToService(url, p, name); |
| 117 return p; |
| 118 } |
| 119 void registerTraceProvider(tracing_mojom.TraceProviderInterface traceProvider)
; |
| 120 } |
| 121 |
| 122 abstract class TraceProviderRegistryInterface |
| 123 implements bindings.MojoInterface<TraceProviderRegistry>, |
| 124 TraceProviderRegistry { |
| 125 factory TraceProviderRegistryInterface([TraceProviderRegistry impl]) => |
| 126 new TraceProviderRegistryStub.unbound(impl); |
| 127 factory TraceProviderRegistryInterface.fromEndpoint( |
| 128 core.MojoMessagePipeEndpoint endpoint, |
| 129 [TraceProviderRegistry impl]) => |
| 130 new TraceProviderRegistryStub.fromEndpoint(endpoint, impl); |
| 131 } |
| 132 |
| 133 abstract class TraceProviderRegistryInterfaceRequest |
| 134 implements bindings.MojoInterface<TraceProviderRegistry>, |
| 135 TraceProviderRegistry { |
| 136 factory TraceProviderRegistryInterfaceRequest() => |
| 137 new TraceProviderRegistryProxy.unbound(); |
| 100 } | 138 } |
| 101 | 139 |
| 102 class _TraceProviderRegistryProxyControl | 140 class _TraceProviderRegistryProxyControl |
| 103 extends bindings.ProxyMessageHandler | 141 extends bindings.ProxyMessageHandler |
| 104 implements bindings.ProxyControl { | 142 implements bindings.ProxyControl<TraceProviderRegistry> { |
| 105 _TraceProviderRegistryProxyControl.fromEndpoint( | 143 _TraceProviderRegistryProxyControl.fromEndpoint( |
| 106 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 144 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 107 | 145 |
| 108 _TraceProviderRegistryProxyControl.fromHandle( | 146 _TraceProviderRegistryProxyControl.fromHandle( |
| 109 core.MojoHandle handle) : super.fromHandle(handle); | 147 core.MojoHandle handle) : super.fromHandle(handle); |
| 110 | 148 |
| 111 _TraceProviderRegistryProxyControl.unbound() : super.unbound(); | 149 _TraceProviderRegistryProxyControl.unbound() : super.unbound(); |
| 112 | 150 |
| 113 service_describer.ServiceDescription get serviceDescription => | |
| 114 new _TraceProviderRegistryServiceDescription(); | |
| 115 | |
| 116 String get serviceName => TraceProviderRegistry.serviceName; | 151 String get serviceName => TraceProviderRegistry.serviceName; |
| 117 | 152 |
| 118 void handleResponse(bindings.ServiceMessage message) { | 153 void handleResponse(bindings.ServiceMessage message) { |
| 119 switch (message.header.type) { | 154 switch (message.header.type) { |
| 120 default: | 155 default: |
| 121 proxyError("Unexpected message type: ${message.header.type}"); | 156 proxyError("Unexpected message type: ${message.header.type}"); |
| 122 close(immediate: true); | 157 close(immediate: true); |
| 123 break; | 158 break; |
| 124 } | 159 } |
| 125 } | 160 } |
| 126 | 161 |
| 162 TraceProviderRegistry get impl => null; |
| 163 set impl(TraceProviderRegistry _) { |
| 164 throw new core.MojoApiError("The impl of a Proxy cannot be set."); |
| 165 } |
| 166 |
| 127 @override | 167 @override |
| 128 String toString() { | 168 String toString() { |
| 129 var superString = super.toString(); | 169 var superString = super.toString(); |
| 130 return "_TraceProviderRegistryProxyControl($superString)"; | 170 return "_TraceProviderRegistryProxyControl($superString)"; |
| 131 } | 171 } |
| 132 } | 172 } |
| 133 | 173 |
| 134 class TraceProviderRegistryProxy | 174 class TraceProviderRegistryProxy |
| 135 extends bindings.Proxy | 175 extends bindings.Proxy<TraceProviderRegistry> |
| 136 implements TraceProviderRegistry { | 176 implements TraceProviderRegistry, |
| 177 TraceProviderRegistryInterface, |
| 178 TraceProviderRegistryInterfaceRequest { |
| 137 TraceProviderRegistryProxy.fromEndpoint( | 179 TraceProviderRegistryProxy.fromEndpoint( |
| 138 core.MojoMessagePipeEndpoint endpoint) | 180 core.MojoMessagePipeEndpoint endpoint) |
| 139 : super(new _TraceProviderRegistryProxyControl.fromEndpoint(endpoint)); | 181 : super(new _TraceProviderRegistryProxyControl.fromEndpoint(endpoint)); |
| 140 | 182 |
| 141 TraceProviderRegistryProxy.fromHandle(core.MojoHandle handle) | 183 TraceProviderRegistryProxy.fromHandle(core.MojoHandle handle) |
| 142 : super(new _TraceProviderRegistryProxyControl.fromHandle(handle)); | 184 : super(new _TraceProviderRegistryProxyControl.fromHandle(handle)); |
| 143 | 185 |
| 144 TraceProviderRegistryProxy.unbound() | 186 TraceProviderRegistryProxy.unbound() |
| 145 : super(new _TraceProviderRegistryProxyControl.unbound()); | 187 : super(new _TraceProviderRegistryProxyControl.unbound()); |
| 146 | 188 |
| 147 static TraceProviderRegistryProxy newFromEndpoint( | 189 static TraceProviderRegistryProxy newFromEndpoint( |
| 148 core.MojoMessagePipeEndpoint endpoint) { | 190 core.MojoMessagePipeEndpoint endpoint) { |
| 149 assert(endpoint.setDescription("For TraceProviderRegistryProxy")); | 191 assert(endpoint.setDescription("For TraceProviderRegistryProxy")); |
| 150 return new TraceProviderRegistryProxy.fromEndpoint(endpoint); | 192 return new TraceProviderRegistryProxy.fromEndpoint(endpoint); |
| 151 } | 193 } |
| 152 | 194 |
| 153 factory TraceProviderRegistryProxy.connectToService( | |
| 154 bindings.ServiceConnector s, String url, [String serviceName]) { | |
| 155 TraceProviderRegistryProxy p = new TraceProviderRegistryProxy.unbound(); | |
| 156 s.connectToService(url, p, serviceName); | |
| 157 return p; | |
| 158 } | |
| 159 | 195 |
| 160 | 196 void registerTraceProvider(tracing_mojom.TraceProviderInterface traceProvider)
{ |
| 161 void registerTraceProvider(Object traceProvider) { | |
| 162 if (!ctrl.isBound) { | 197 if (!ctrl.isBound) { |
| 163 ctrl.proxyError("The Proxy is closed."); | 198 ctrl.proxyError("The Proxy is closed."); |
| 164 return; | 199 return; |
| 165 } | 200 } |
| 166 var params = new _TraceProviderRegistryRegisterTraceProviderParams(); | 201 var params = new _TraceProviderRegistryRegisterTraceProviderParams(); |
| 167 params.traceProvider = traceProvider; | 202 params.traceProvider = traceProvider; |
| 168 ctrl.sendMessage(params, | 203 ctrl.sendMessage(params, |
| 169 _traceProviderRegistryMethodRegisterTraceProviderName); | 204 _traceProviderRegistryMethodRegisterTraceProviderName); |
| 170 } | 205 } |
| 171 } | 206 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 182 } | 217 } |
| 183 | 218 |
| 184 _TraceProviderRegistryStubControl.fromHandle( | 219 _TraceProviderRegistryStubControl.fromHandle( |
| 185 core.MojoHandle handle, [TraceProviderRegistry impl]) | 220 core.MojoHandle handle, [TraceProviderRegistry impl]) |
| 186 : super.fromHandle(handle, autoBegin: impl != null) { | 221 : super.fromHandle(handle, autoBegin: impl != null) { |
| 187 _impl = impl; | 222 _impl = impl; |
| 188 } | 223 } |
| 189 | 224 |
| 190 _TraceProviderRegistryStubControl.unbound([this._impl]) : super.unbound(); | 225 _TraceProviderRegistryStubControl.unbound([this._impl]) : super.unbound(); |
| 191 | 226 |
| 227 String get serviceName => TraceProviderRegistry.serviceName; |
| 228 |
| 192 | 229 |
| 193 | 230 |
| 194 dynamic handleMessage(bindings.ServiceMessage message) { | 231 dynamic handleMessage(bindings.ServiceMessage message) { |
| 195 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 232 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 196 return bindings.ControlMessageHandler.handleMessage(this, | 233 return bindings.ControlMessageHandler.handleMessage(this, |
| 197 0, | 234 0, |
| 198 message); | 235 message); |
| 199 } | 236 } |
| 200 if (_impl == null) { | 237 if (_impl == null) { |
| 201 throw new core.MojoApiError("$this has no implementation set"); | 238 throw new core.MojoApiError("$this has no implementation set"); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 232 } | 269 } |
| 233 } | 270 } |
| 234 | 271 |
| 235 @override | 272 @override |
| 236 String toString() { | 273 String toString() { |
| 237 var superString = super.toString(); | 274 var superString = super.toString(); |
| 238 return "_TraceProviderRegistryStubControl($superString)"; | 275 return "_TraceProviderRegistryStubControl($superString)"; |
| 239 } | 276 } |
| 240 | 277 |
| 241 int get version => 0; | 278 int get version => 0; |
| 242 | |
| 243 static service_describer.ServiceDescription _cachedServiceDescription; | |
| 244 static service_describer.ServiceDescription get serviceDescription { | |
| 245 if (_cachedServiceDescription == null) { | |
| 246 _cachedServiceDescription = new _TraceProviderRegistryServiceDescription()
; | |
| 247 } | |
| 248 return _cachedServiceDescription; | |
| 249 } | |
| 250 } | 279 } |
| 251 | 280 |
| 252 class TraceProviderRegistryStub | 281 class TraceProviderRegistryStub |
| 253 extends bindings.Stub<TraceProviderRegistry> | 282 extends bindings.Stub<TraceProviderRegistry> |
| 254 implements TraceProviderRegistry { | 283 implements TraceProviderRegistry, |
| 284 TraceProviderRegistryInterface, |
| 285 TraceProviderRegistryInterfaceRequest { |
| 286 TraceProviderRegistryStub.unbound([TraceProviderRegistry impl]) |
| 287 : super(new _TraceProviderRegistryStubControl.unbound(impl)); |
| 288 |
| 255 TraceProviderRegistryStub.fromEndpoint( | 289 TraceProviderRegistryStub.fromEndpoint( |
| 256 core.MojoMessagePipeEndpoint endpoint, [TraceProviderRegistry impl]) | 290 core.MojoMessagePipeEndpoint endpoint, [TraceProviderRegistry impl]) |
| 257 : super(new _TraceProviderRegistryStubControl.fromEndpoint(endpoint, impl)
); | 291 : super(new _TraceProviderRegistryStubControl.fromEndpoint(endpoint, impl)
); |
| 258 | 292 |
| 259 TraceProviderRegistryStub.fromHandle( | 293 TraceProviderRegistryStub.fromHandle( |
| 260 core.MojoHandle handle, [TraceProviderRegistry impl]) | 294 core.MojoHandle handle, [TraceProviderRegistry impl]) |
| 261 : super(new _TraceProviderRegistryStubControl.fromHandle(handle, impl)); | 295 : super(new _TraceProviderRegistryStubControl.fromHandle(handle, impl)); |
| 262 | 296 |
| 263 TraceProviderRegistryStub.unbound([TraceProviderRegistry impl]) | |
| 264 : super(new _TraceProviderRegistryStubControl.unbound(impl)); | |
| 265 | |
| 266 static TraceProviderRegistryStub newFromEndpoint( | 297 static TraceProviderRegistryStub newFromEndpoint( |
| 267 core.MojoMessagePipeEndpoint endpoint) { | 298 core.MojoMessagePipeEndpoint endpoint) { |
| 268 assert(endpoint.setDescription("For TraceProviderRegistryStub")); | 299 assert(endpoint.setDescription("For TraceProviderRegistryStub")); |
| 269 return new TraceProviderRegistryStub.fromEndpoint(endpoint); | 300 return new TraceProviderRegistryStub.fromEndpoint(endpoint); |
| 270 } | 301 } |
| 271 | 302 |
| 272 static service_describer.ServiceDescription get serviceDescription => | |
| 273 _TraceProviderRegistryStubControl.serviceDescription; | |
| 274 | 303 |
| 275 | 304 void registerTraceProvider(tracing_mojom.TraceProviderInterface traceProvider)
{ |
| 276 void registerTraceProvider(Object traceProvider) { | |
| 277 return impl.registerTraceProvider(traceProvider); | 305 return impl.registerTraceProvider(traceProvider); |
| 278 } | 306 } |
| 279 } | 307 } |
| 280 | 308 |
| 281 | 309 |
| 282 | 310 |
| OLD | NEW |