Unverified Commit 4add01ab authored by Ben Konyi's avatar Ben Konyi Committed by GitHub

Reland "Enable caching of CPU samples collected at application startup (#89600)" (#98769)

This reverts commit ac3c4435.
parent 50c47209
......@@ -17,6 +17,7 @@ Future<dds.DartDevelopmentService> Function(
bool enableAuthCodes,
bool ipv6,
Uri? serviceUri,
List<String> cachedUserTags,
}) ddsLauncherCallback = dds.DartDevelopmentService.startDartDevelopmentService;
/// Helper class to launch a [dds.DartDevelopmentService]. Allows for us to
......@@ -36,6 +37,7 @@ class DartDevelopmentService {
int? hostPort,
bool? ipv6,
bool? disableServiceAuthCodes,
bool cacheStartupProfile = false,
}) async {
final Uri ddsUri = Uri(
scheme: 'http',
......@@ -52,6 +54,8 @@ class DartDevelopmentService {
serviceUri: ddsUri,
enableAuthCodes: disableServiceAuthCodes != true,
ipv6: ipv6 == true,
// Enables caching of CPU samples collected during application startup.
cachedUserTags: cacheStartupProfile ? const <String>['AppStartUp'] : const <String>[],
);
unawaited(_ddsInstance?.done.whenComplete(() {
if (!_completer.isCompleted) {
......
......@@ -63,6 +63,7 @@ Future<void> _kDefaultDartDevelopmentServiceStarter(
ipv6: true,
disableServiceAuthCodes: disableServiceAuthCodes,
logger: globals.logger,
cacheStartupProfile: true,
);
}
......
......@@ -267,6 +267,7 @@ class FlutterDevice {
ipv6: ipv6,
disableServiceAuthCodes: disableServiceAuthCodes,
logger: globals.logger,
cacheStartupProfile: true,
);
} on dds.DartDevelopmentServiceException catch (e, st) {
if (!allowExistingDdsInstance ||
......
......@@ -798,6 +798,7 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
int hostPort,
bool ipv6,
bool disableServiceAuthCodes,
bool cacheStartupProfile = false,
}) async {}
@override
......
......@@ -590,6 +590,7 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
int hostPort,
bool ipv6,
bool disableServiceAuthCodes,
bool cacheStartupProfile = false,
}) async {
started = true;
}
......
......@@ -944,6 +944,7 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
int hostPort,
bool ipv6,
bool disableServiceAuthCodes,
bool cacheStartupProfile = false,
}) async {}
@override
......
......@@ -1892,11 +1892,12 @@ flutter:
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri}) {
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags}) {
expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isTrue);
expect(ipv6, isFalse);
expect(serviceUri, Uri(scheme: 'http', host: '127.0.0.1', port: 0));
expect(cachedUserTags, <String>['AppStartUp']);
throw FakeDartDevelopmentServiceException(message:
'Existing VM service clients prevent DDS from taking control.',
);
......@@ -1939,11 +1940,12 @@ flutter:
final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService();
final Completer<void>done = Completer<void>();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri}) async {
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags}) async {
expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isFalse);
expect(ipv6, isTrue);
expect(serviceUri, Uri(scheme: 'http', host: '::1', port: 0));
expect(cachedUserTags, <String>['AppStartUp']);
done.complete();
return null;
};
......@@ -1970,11 +1972,12 @@ flutter:
// See https://github.com/flutter/flutter/issues/72385 for context.
final FakeDevice device = FakeDevice()
..dds = DartDevelopmentService();
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri}) {
ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List<String> cachedUserTags}) {
expect(uri, Uri(scheme: 'foo', host: 'bar'));
expect(enableAuthCodes, isTrue);
expect(ipv6, isFalse);
expect(serviceUri, Uri(scheme: 'http', host: '127.0.0.1', port: 0));
expect(cachedUserTags, <String>['AppStartUp']);
throw FakeDartDevelopmentServiceException(message: 'No URI');
};
final TestFlutterDevice flutterDevice = TestFlutterDevice(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment