Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: mojo/dart/packages/mojo_services/lib/tracing/trace_provider_registry.mojom.dart

Issue 1948003003: Dart: Wait to handle events on a Stub until it makes sense to do it. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add test Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 impl.requireVersion(requiredVersion); 203 impl.requireVersion(requiredVersion);
204 } 204 }
205 205
206 String toString() { 206 String toString() {
207 return "TraceProviderRegistryProxy($impl)"; 207 return "TraceProviderRegistryProxy($impl)";
208 } 208 }
209 } 209 }
210 210
211 211
212 class TraceProviderRegistryStub extends bindings.Stub { 212 class TraceProviderRegistryStub extends bindings.Stub {
213 TraceProviderRegistry _impl = null; 213 TraceProviderRegistry _impl;
214 214
215 TraceProviderRegistryStub.fromEndpoint( 215 TraceProviderRegistryStub.fromEndpoint(
216 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 216 core.MojoMessagePipeEndpoint endpoint, [TraceProviderRegistry impl])
217 : super.fromEndpoint(endpoint); 217 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
218 _impl = impl;
219 }
218 220
219 TraceProviderRegistryStub.fromHandle(core.MojoHandle handle, [this._impl]) 221 TraceProviderRegistryStub.fromHandle(
220 : super.fromHandle(handle); 222 core.MojoHandle handle, [TraceProviderRegistry impl])
223 : super.fromHandle(handle, autoBegin: impl != null) {
224 _impl = impl;
225 }
221 226
222 TraceProviderRegistryStub.unbound() : super.unbound(); 227 TraceProviderRegistryStub.unbound() : super.unbound();
223 228
224 static TraceProviderRegistryStub newFromEndpoint( 229 static TraceProviderRegistryStub newFromEndpoint(
225 core.MojoMessagePipeEndpoint endpoint) { 230 core.MojoMessagePipeEndpoint endpoint) {
226 assert(endpoint.setDescription("For TraceProviderRegistryStub")); 231 assert(endpoint.setDescription("For TraceProviderRegistryStub"));
227 return new TraceProviderRegistryStub.fromEndpoint(endpoint); 232 return new TraceProviderRegistryStub.fromEndpoint(endpoint);
228 } 233 }
229 234
230 235
231 236
232 dynamic handleMessage(bindings.ServiceMessage message) { 237 dynamic handleMessage(bindings.ServiceMessage message) {
233 if (bindings.ControlMessageHandler.isControlMessage(message)) { 238 if (bindings.ControlMessageHandler.isControlMessage(message)) {
234 return bindings.ControlMessageHandler.handleMessage(this, 239 return bindings.ControlMessageHandler.handleMessage(this,
235 0, 240 0,
236 message); 241 message);
237 } 242 }
238 assert(_impl != null); 243 if (_impl == null) {
244 throw new core.MojoApiError("$this has no implementation set");
245 }
239 switch (message.header.type) { 246 switch (message.header.type) {
240 case _traceProviderRegistryMethodRegisterTraceProviderName: 247 case _traceProviderRegistryMethodRegisterTraceProviderName:
241 var params = _TraceProviderRegistryRegisterTraceProviderParams.deseriali ze( 248 var params = _TraceProviderRegistryRegisterTraceProviderParams.deseriali ze(
242 message.payload); 249 message.payload);
243 _impl.registerTraceProvider(params.traceProvider); 250 _impl.registerTraceProvider(params.traceProvider);
244 break; 251 break;
245 default: 252 default:
246 throw new bindings.MojoCodecError("Unexpected message name"); 253 throw new bindings.MojoCodecError("Unexpected message name");
247 break; 254 break;
248 } 255 }
249 return null; 256 return null;
250 } 257 }
251 258
252 TraceProviderRegistry get impl => _impl; 259 TraceProviderRegistry get impl => _impl;
253 set impl(TraceProviderRegistry d) { 260 set impl(TraceProviderRegistry d) {
254 assert(_impl == null); 261 if (d == null) {
262 throw new core.MojoApiError("$this: Cannot set a null implementation");
263 }
264 if (isBound && (_impl == null)) {
265 beginHandlingEvents();
266 }
255 _impl = d; 267 _impl = d;
256 } 268 }
257 269
270 @override
271 void bind(core.MojoMessagePipeEndpoint endpoint) {
272 super.bind(endpoint);
273 if (!isOpen && (_impl != null)) {
274 beginHandlingEvents();
275 }
276 }
277
258 String toString() { 278 String toString() {
259 var superString = super.toString(); 279 var superString = super.toString();
260 return "TraceProviderRegistryStub($superString)"; 280 return "TraceProviderRegistryStub($superString)";
261 } 281 }
262 282
263 int get version => 0; 283 int get version => 0;
264 284
265 static service_describer.ServiceDescription _cachedServiceDescription; 285 static service_describer.ServiceDescription _cachedServiceDescription;
266 static service_describer.ServiceDescription get serviceDescription { 286 static service_describer.ServiceDescription get serviceDescription {
267 if (_cachedServiceDescription == null) { 287 if (_cachedServiceDescription == null) {
268 _cachedServiceDescription = new _TraceProviderRegistryServiceDescription() ; 288 _cachedServiceDescription = new _TraceProviderRegistryServiceDescription() ;
269 } 289 }
270 return _cachedServiceDescription; 290 return _cachedServiceDescription;
271 } 291 }
272 } 292 }
273 293
274 294
275 295
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698