@@ -226,14 +226,13 @@ class DevHandler {
226226 );
227227 }
228228
229- Future <AppDebugServices > loadAppServices (
230- AppConnection appConnection, DwdsStats dwdsStats) async {
229+ Future <AppDebugServices > loadAppServices (AppConnection appConnection) async {
231230 var appId = appConnection.request.appId;
232231 if (_servicesByAppId[appId] == null ) {
233232 var debugService = await _startLocalDebugService (
234233 await _chromeConnection (), appConnection);
235234 var appServices = await _createAppDebugServices (
236- appConnection.request.appId, debugService, dwdsStats );
235+ appConnection.request.appId, debugService);
237236 unawaited (appServices.chromeProxyService.remoteDebugger.onClose.first
238237 .whenComplete (() async {
239238 await appServices.close ();
@@ -329,11 +328,10 @@ class DevHandler {
329328 'Otherwise check the docs for the tool you are using.' ))));
330329 return ;
331330 }
332-
333- var dwdsStats = DwdsStats (DateTime .now ());
331+ var debuggerStart = DateTime .now ();
334332 AppDebugServices appServices;
335333 try {
336- appServices = await loadAppServices (appConnection, dwdsStats );
334+ appServices = await loadAppServices (appConnection);
337335 } catch (_) {
338336 var error = 'Unable to connect debug services to your '
339337 'application. Most likely this means you are trying to '
@@ -374,7 +372,10 @@ class DevHandler {
374372 ..promptExtension = false ))));
375373
376374 appServices.connectedInstanceId = appConnection.request.instanceId;
377- dwdsStats.devToolsStart = DateTime .now ();
375+ appServices.dwdsStats.updateLoadTime (
376+ debuggerStart: debuggerStart,
377+ devToolsStart: DateTime .now (),
378+ );
378379 await _launchDevTools (
379380 appServices.chromeProxyService.remoteDebugger,
380381 _constructDevToolsUri (appServices.debugService.uri,
@@ -448,12 +449,14 @@ class DevHandler {
448449 }
449450
450451 Future <AppDebugServices > _createAppDebugServices (
451- String appId, DebugService debugService, DwdsStats dwdsStats) async {
452+ String appId, DebugService debugService) async {
453+ var dwdsStats = DwdsStats ();
452454 var webdevClient = await DwdsVmClient .create (debugService, dwdsStats);
453455 if (_spawnDds) {
454456 await debugService.startDartDevelopmentService ();
455457 }
456- var appDebugService = AppDebugServices (debugService, webdevClient);
458+ var appDebugService =
459+ AppDebugServices (debugService, webdevClient, dwdsStats);
457460 var encodedUri = await debugService.encodedUri;
458461 _logger.info ('Debug service listening on $encodedUri \n ' );
459462 await appDebugService.chromeProxyService.remoteDebugger
@@ -477,7 +480,6 @@ class DevHandler {
477480 // Waits for a `DevToolsRequest` to be sent from the extension background
478481 // when the extension is clicked.
479482 extensionDebugger.devToolsRequestStream.listen ((devToolsRequest) async {
480- var dwdsStats = DwdsStats (DateTime .now ());
481483 var connection = _appConnectionByAppId[devToolsRequest.appId];
482484 if (connection == null ) {
483485 // TODO(grouma) - Ideally we surface this warning to the extension so
@@ -486,6 +488,7 @@ class DevHandler {
486488 'Not connected to an app with id: ${devToolsRequest .appId }' );
487489 return ;
488490 }
491+ var debuggerStart = DateTime .now ();
489492 var appId = devToolsRequest.appId;
490493 if (_servicesByAppId[appId] == null ) {
491494 var debugService = await DebugService .start (
@@ -510,7 +513,6 @@ class DevHandler {
510513 var appServices = await _createAppDebugServices (
511514 devToolsRequest.appId,
512515 debugService,
513- dwdsStats,
514516 );
515517 var encodedUri = await debugService.encodedUri;
516518 extensionDebugger.sendEvent ('dwds.encodedUri' , encodedUri);
@@ -525,8 +527,8 @@ class DevHandler {
525527 extensionDebugConnections.add (DebugConnection (appServices));
526528 _servicesByAppId[appId] = appServices;
527529 }
528- final encodedUri = await _servicesByAppId[appId].debugService.encodedUri ;
529- dwdsStats.devToolsStart = DateTime . now () ;
530+ final appServices = _servicesByAppId[appId];
531+ final encodedUri = await appServices.debugService.encodedUri ;
530532
531533 // If we only want the URI, this means we are embedding Dart DevTools in
532534 // Chrome DevTools. Therefore return early.
@@ -538,11 +540,12 @@ class DevHandler {
538540 extensionDebugger.sendEvent ('dwds.devtoolsUri' , devToolsUri);
539541 return ;
540542 }
541-
542543 final devToolsUri = _constructDevToolsUri (
543544 encodedUri,
544545 ideQueryParam: 'DebugExtension' ,
545546 );
547+ appServices.dwdsStats.updateLoadTime (
548+ debuggerStart: debuggerStart, devToolsStart: DateTime .now ());
546549 await _launchDevTools (extensionDebugger, devToolsUri);
547550 });
548551 }
0 commit comments