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; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 void registerTraceProvider(Object traceProvider); |
100 } | 100 } |
101 | 101 |
102 | 102 |
103 class _TraceProviderRegistryProxyImpl extends bindings.Proxy { | 103 class _TraceProviderRegistryProxyControl extends bindings.ProxyMessageHandler |
104 _TraceProviderRegistryProxyImpl.fromEndpoint( | 104 implements bindings.ProxyControl { |
| 105 _TraceProviderRegistryProxyControl.fromEndpoint( |
105 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 106 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
106 | 107 |
107 _TraceProviderRegistryProxyImpl.fromHandle(core.MojoHandle handle) : | 108 _TraceProviderRegistryProxyControl.fromHandle( |
108 super.fromHandle(handle); | 109 core.MojoHandle handle) : super.fromHandle(handle); |
109 | 110 |
110 _TraceProviderRegistryProxyImpl.unbound() : super.unbound(); | 111 _TraceProviderRegistryProxyControl.unbound() : super.unbound(); |
111 | |
112 static _TraceProviderRegistryProxyImpl newFromEndpoint( | |
113 core.MojoMessagePipeEndpoint endpoint) { | |
114 assert(endpoint.setDescription("For _TraceProviderRegistryProxyImpl")); | |
115 return new _TraceProviderRegistryProxyImpl.fromEndpoint(endpoint); | |
116 } | |
117 | 112 |
118 service_describer.ServiceDescription get serviceDescription => | 113 service_describer.ServiceDescription get serviceDescription => |
119 new _TraceProviderRegistryServiceDescription(); | 114 new _TraceProviderRegistryServiceDescription(); |
120 | 115 |
| 116 String get serviceName => TraceProviderRegistry.serviceName; |
| 117 |
| 118 @override |
121 void handleResponse(bindings.ServiceMessage message) { | 119 void handleResponse(bindings.ServiceMessage message) { |
122 switch (message.header.type) { | 120 switch (message.header.type) { |
123 default: | 121 default: |
124 proxyError("Unexpected message type: ${message.header.type}"); | 122 proxyError("Unexpected message type: ${message.header.type}"); |
125 close(immediate: true); | 123 close(immediate: true); |
126 break; | 124 break; |
127 } | 125 } |
128 } | 126 } |
129 | 127 |
| 128 @override |
130 String toString() { | 129 String toString() { |
131 var superString = super.toString(); | 130 var superString = super.toString(); |
132 return "_TraceProviderRegistryProxyImpl($superString)"; | 131 return "_TraceProviderRegistryProxyControl($superString)"; |
133 } | 132 } |
134 } | 133 } |
135 | 134 |
136 | 135 |
137 class _TraceProviderRegistryProxyCalls implements TraceProviderRegistry { | 136 class TraceProviderRegistryProxy extends bindings.Proxy |
138 _TraceProviderRegistryProxyImpl _proxyImpl; | 137 implements TraceProviderRegistry { |
| 138 TraceProviderRegistryProxy.fromEndpoint( |
| 139 core.MojoMessagePipeEndpoint endpoint) |
| 140 : super(new _TraceProviderRegistryProxyControl.fromEndpoint(endpoint)); |
139 | 141 |
140 _TraceProviderRegistryProxyCalls(this._proxyImpl); | 142 TraceProviderRegistryProxy.fromHandle(core.MojoHandle handle) |
141 void registerTraceProvider(Object traceProvider) { | 143 : super(new _TraceProviderRegistryProxyControl.fromHandle(handle)); |
142 if (!_proxyImpl.isBound) { | |
143 _proxyImpl.proxyError("The Proxy is closed."); | |
144 return; | |
145 } | |
146 var params = new _TraceProviderRegistryRegisterTraceProviderParams(); | |
147 params.traceProvider = traceProvider; | |
148 _proxyImpl.sendMessage(params, _traceProviderRegistryMethodRegisterTracePr
oviderName); | |
149 } | |
150 } | |
151 | 144 |
| 145 TraceProviderRegistryProxy.unbound() |
| 146 : super(new _TraceProviderRegistryProxyControl.unbound()); |
152 | 147 |
153 class TraceProviderRegistryProxy implements bindings.ProxyBase { | 148 static TraceProviderRegistryProxy newFromEndpoint( |
154 final bindings.Proxy impl; | 149 core.MojoMessagePipeEndpoint endpoint) { |
155 TraceProviderRegistry ptr; | 150 assert(endpoint.setDescription("For TraceProviderRegistryProxy")); |
156 | 151 return new TraceProviderRegistryProxy.fromEndpoint(endpoint); |
157 TraceProviderRegistryProxy(_TraceProviderRegistryProxyImpl proxyImpl) : | |
158 impl = proxyImpl, | |
159 ptr = new _TraceProviderRegistryProxyCalls(proxyImpl); | |
160 | |
161 TraceProviderRegistryProxy.fromEndpoint( | |
162 core.MojoMessagePipeEndpoint endpoint) : | |
163 impl = new _TraceProviderRegistryProxyImpl.fromEndpoint(endpoint) { | |
164 ptr = new _TraceProviderRegistryProxyCalls(impl); | |
165 } | |
166 | |
167 TraceProviderRegistryProxy.fromHandle(core.MojoHandle handle) : | |
168 impl = new _TraceProviderRegistryProxyImpl.fromHandle(handle) { | |
169 ptr = new _TraceProviderRegistryProxyCalls(impl); | |
170 } | |
171 | |
172 TraceProviderRegistryProxy.unbound() : | |
173 impl = new _TraceProviderRegistryProxyImpl.unbound() { | |
174 ptr = new _TraceProviderRegistryProxyCalls(impl); | |
175 } | 152 } |
176 | 153 |
177 factory TraceProviderRegistryProxy.connectToService( | 154 factory TraceProviderRegistryProxy.connectToService( |
178 bindings.ServiceConnector s, String url, [String serviceName]) { | 155 bindings.ServiceConnector s, String url, [String serviceName]) { |
179 TraceProviderRegistryProxy p = new TraceProviderRegistryProxy.unbound(); | 156 TraceProviderRegistryProxy p = new TraceProviderRegistryProxy.unbound(); |
180 s.connectToService(url, p, serviceName); | 157 s.connectToService(url, p, serviceName); |
181 return p; | 158 return p; |
182 } | 159 } |
183 | 160 |
184 static TraceProviderRegistryProxy newFromEndpoint( | |
185 core.MojoMessagePipeEndpoint endpoint) { | |
186 assert(endpoint.setDescription("For TraceProviderRegistryProxy")); | |
187 return new TraceProviderRegistryProxy.fromEndpoint(endpoint); | |
188 } | |
189 | 161 |
190 String get serviceName => TraceProviderRegistry.serviceName; | 162 void registerTraceProvider(Object traceProvider) { |
191 | 163 if (!ctrl.isBound) { |
192 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 164 ctrl.proxyError("The Proxy is closed."); |
193 | 165 return; |
194 Future responseOrError(Future f) => impl.responseOrError(f); | 166 } |
195 | 167 var params = new _TraceProviderRegistryRegisterTraceProviderParams(); |
196 Future get errorFuture => impl.errorFuture; | 168 params.traceProvider = traceProvider; |
197 | 169 ctrl.sendMessage(params, |
198 int get version => impl.version; | 170 _traceProviderRegistryMethodRegisterTraceProviderName); |
199 | |
200 Future<int> queryVersion() => impl.queryVersion(); | |
201 | |
202 void requireVersion(int requiredVersion) { | |
203 impl.requireVersion(requiredVersion); | |
204 } | |
205 | |
206 String toString() { | |
207 return "TraceProviderRegistryProxy($impl)"; | |
208 } | 171 } |
209 } | 172 } |
210 | 173 |
211 | 174 |
212 class TraceProviderRegistryStub extends bindings.Stub { | 175 class TraceProviderRegistryStub extends bindings.Stub { |
213 TraceProviderRegistry _impl; | 176 TraceProviderRegistry _impl; |
214 | 177 |
215 TraceProviderRegistryStub.fromEndpoint( | 178 TraceProviderRegistryStub.fromEndpoint( |
216 core.MojoMessagePipeEndpoint endpoint, [TraceProviderRegistry impl]) | 179 core.MojoMessagePipeEndpoint endpoint, [TraceProviderRegistry impl]) |
217 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 180 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 static service_describer.ServiceDescription get serviceDescription { | 249 static service_describer.ServiceDescription get serviceDescription { |
287 if (_cachedServiceDescription == null) { | 250 if (_cachedServiceDescription == null) { |
288 _cachedServiceDescription = new _TraceProviderRegistryServiceDescription()
; | 251 _cachedServiceDescription = new _TraceProviderRegistryServiceDescription()
; |
289 } | 252 } |
290 return _cachedServiceDescription; | 253 return _cachedServiceDescription; |
291 } | 254 } |
292 } | 255 } |
293 | 256 |
294 | 257 |
295 | 258 |
OLD | NEW |