@@ -431,7 +431,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
431431 int ? column,
432432 }) async {
433433 await isInitialized;
434- _checkIsolate ('addBreakpoint' , isolateId);
434+ checkIsolate ('addBreakpoint' , isolateId);
435435 return (await debuggerFuture).addBreakpoint (scriptId, line, column: column);
436436 }
437437
@@ -459,7 +459,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
459459 int ? column,
460460 }) async {
461461 await isInitialized;
462- _checkIsolate ('addBreakpointWithScriptUri' , isolateId);
462+ checkIsolate ('addBreakpointWithScriptUri' , isolateId);
463463 if (Uri .parse (scriptUri).scheme == 'dart' ) {
464464 // TODO(annagrin): Support setting breakpoints in dart SDK locations.
465465 // Issue: https://github.com/dart-lang/webdev/issues/1584
@@ -503,7 +503,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
503503 }) async {
504504 await isInitialized;
505505 isolateId ?? = inspector.isolate.id;
506- _checkIsolate ('callServiceExtension' , isolateId);
506+ checkIsolate ('callServiceExtension' , isolateId);
507507 args ?? = < String , String > {};
508508 final stringArgs = args.map (
509509 (k, v) => MapEntry (
@@ -640,7 +640,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
640640 final evaluator = _expressionEvaluator;
641641 if (evaluator != null ) {
642642 await isCompilerInitialized;
643- _checkIsolate ('evaluate' , isolateId);
643+ checkIsolate ('evaluate' , isolateId);
644644
645645 late Obj object;
646646 try {
@@ -730,7 +730,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
730730 final evaluator = _expressionEvaluator;
731731 if (evaluator != null ) {
732732 await isCompilerInitialized;
733- _checkIsolate ('evaluateInFrame' , isolateId);
733+ checkIsolate ('evaluateInFrame' , isolateId);
734734
735735 return await _getEvaluationResult (
736736 isolateId,
@@ -751,18 +751,6 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
751751 }, (result) => DwdsEvent .evaluateInFrame (expression, result));
752752 }
753753
754- @override
755- Future <Isolate > getIsolate (String isolateId) =>
756- wrapInErrorHandlerAsync ('getIsolate' , () => _getIsolate (isolateId));
757-
758- Future <Isolate > _getIsolate (String isolateId) {
759- return captureElapsedTime (() async {
760- await isInitialized;
761- _checkIsolate ('getIsolate' , isolateId);
762- return inspector.isolate;
763- }, (result) => DwdsEvent .getIsolate ());
764- }
765-
766754 @override
767755 Future <MemoryUsage > getMemoryUsage (String isolateId) =>
768756 wrapInErrorHandlerAsync (
@@ -772,7 +760,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
772760
773761 Future <MemoryUsage > _getMemoryUsage (String isolateId) async {
774762 await isInitialized;
775- _checkIsolate ('getMemoryUsage' , isolateId);
763+ checkIsolate ('getMemoryUsage' , isolateId);
776764 return inspector.getMemoryUsage ();
777765 }
778766
@@ -799,22 +787,10 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
799787 int ? count,
800788 }) async {
801789 await isInitialized;
802- _checkIsolate ('getObject' , isolateId);
790+ checkIsolate ('getObject' , isolateId);
803791 return inspector.getObject (objectId, offset: offset, count: count);
804792 }
805793
806- @override
807- Future <ScriptList > getScripts (String isolateId) =>
808- wrapInErrorHandlerAsync ('getScripts' , () => _getScripts (isolateId));
809-
810- Future <ScriptList > _getScripts (String isolateId) {
811- return captureElapsedTime (() async {
812- await isInitialized;
813- _checkIsolate ('getScripts' , isolateId);
814- return inspector.getScripts ();
815- }, (result) => DwdsEvent .getScripts ());
816- }
817-
818794 @override
819795 Future <SourceReport > getSourceReport (
820796 String isolateId,
@@ -840,7 +816,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
840816 }) {
841817 return captureElapsedTime (() async {
842818 await isInitialized;
843- _checkIsolate ('getSourceReport' , isolateId);
819+ checkIsolate ('getSourceReport' , isolateId);
844820 return await inspector.getSourceReport (reports, scriptId: scriptId);
845821 }, (result) => DwdsEvent .getSourceReport ());
846822 }
@@ -867,20 +843,10 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
867843 Future <Stack > _getStack (String isolateId, {int ? limit}) async {
868844 await isInitialized;
869845 await isStarted;
870- _checkIsolate ('getStack' , isolateId);
846+ checkIsolate ('getStack' , isolateId);
871847 return (await debuggerFuture).getStack (limit: limit);
872848 }
873849
874- @override
875- Future <VM > getVM () => wrapInErrorHandlerAsync ('getVM' , _getVM);
876-
877- Future <VM > _getVM () {
878- return captureElapsedTime (() async {
879- await isInitialized;
880- return vm;
881- }, (result) => DwdsEvent .getVM ());
882- }
883-
884850 @override
885851 Future <Response > invoke (
886852 String isolateId,
@@ -906,7 +872,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
906872 List argumentIds,
907873 ) async {
908874 await isInitialized;
909- _checkIsolate ('invoke' , isolateId);
875+ checkIsolate ('invoke' , isolateId);
910876 final remote = await inspector.invoke (targetId, selector, argumentIds);
911877 return _instanceRef (remote);
912878 }
@@ -968,52 +934,10 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
968934 required bool internalPause,
969935 }) async {
970936 await isInitialized;
971- _checkIsolate ('pause' , isolateId);
937+ checkIsolate ('pause' , isolateId);
972938 return (await debuggerFuture).pause (internalPause: internalPause);
973939 }
974940
975- // Note: Ignore the optional local parameter, when it is set to `true` the
976- // request is intercepted and handled by DDS.
977- @override
978- Future <UriList > lookupResolvedPackageUris (
979- String isolateId,
980- List <String > uris, {
981- bool ? local,
982- }) => wrapInErrorHandlerAsync (
983- 'lookupResolvedPackageUris' ,
984- () => _lookupResolvedPackageUris (isolateId, uris),
985- );
986-
987- Future <UriList > _lookupResolvedPackageUris (
988- String isolateId,
989- List <String > uris,
990- ) async {
991- await isInitialized;
992- _checkIsolate ('lookupResolvedPackageUris' , isolateId);
993- return UriList (uris: uris.map (DartUri .toResolvedUri).toList ());
994- }
995-
996- @override
997- Future <UriList > lookupPackageUris (String isolateId, List <String > uris) =>
998- wrapInErrorHandlerAsync (
999- 'lookupPackageUris' ,
1000- () => _lookupPackageUris (isolateId, uris),
1001- );
1002-
1003- Future <UriList > _lookupPackageUris (
1004- String isolateId,
1005- List <String > uris,
1006- ) async {
1007- await isInitialized;
1008- _checkIsolate ('lookupPackageUris' , isolateId);
1009- return UriList (uris: uris.map (DartUri .toPackageUri).toList ());
1010- }
1011-
1012- @override
1013- Future <Success > registerService (String service, String alias) {
1014- return rpcNotSupportedFuture ('registerService' );
1015- }
1016-
1017941 @override
1018942 Future <ReloadReport > reloadSources (
1019943 String isolateId, {
@@ -1023,7 +947,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
1023947 String ? packagesUri,
1024948 }) async {
1025949 await isInitialized;
1026- _checkIsolate ('reloadSources' , isolateId);
950+ checkIsolate ('reloadSources' , isolateId);
1027951
1028952 ReloadReport getFailedReloadReport (String error) =>
1029953 _ReloadReportWithMetadata (success: false )
@@ -1141,7 +1065,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
11411065 String breakpointId,
11421066 ) async {
11431067 await isInitialized;
1144- _checkIsolate ('removeBreakpoint' , isolateId);
1068+ checkIsolate ('removeBreakpoint' , isolateId);
11451069 return (await debuggerFuture).removeBreakpoint (breakpointId);
11461070 }
11471071
@@ -1168,7 +1092,7 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
11681092 await captureElapsedTime (() async {
11691093 await isInitialized;
11701094 await isStarted;
1171- _checkIsolate ('resume' , isolateId);
1095+ checkIsolate ('resume' , isolateId);
11721096 final debugger = await debuggerFuture;
11731097 return await debugger.resume (step: step, frameIndex: frameIndex);
11741098 }, (result) => DwdsEvent .resume (step));
@@ -1213,76 +1137,12 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
12131137 String ? exceptionPauseMode,
12141138 }) async {
12151139 await isInitialized;
1216- _checkIsolate ('setIsolatePauseMode' , isolateId);
1140+ checkIsolate ('setIsolatePauseMode' , isolateId);
12171141 return (await debuggerFuture).setExceptionPauseMode (
12181142 exceptionPauseMode ?? ExceptionPauseMode .kNone,
12191143 );
12201144 }
12211145
1222- @override
1223- Future <Success > setFlag (String name, String value) =>
1224- wrapInErrorHandlerAsync ('setFlag' , () => _setFlag (name, value));
1225-
1226- Future <Success > _setFlag (String name, String value) async {
1227- if (! currentVmServiceFlags.containsKey (name)) {
1228- return rpcNotSupportedFuture ('setFlag' );
1229- }
1230-
1231- assert (value == 'true' || value == 'false' );
1232- currentVmServiceFlags[name] = value == 'true' ;
1233-
1234- return Success ();
1235- }
1236-
1237- @override
1238- Future <Success > setLibraryDebuggable (
1239- String isolateId,
1240- String libraryId,
1241- bool isDebuggable,
1242- ) {
1243- return rpcNotSupportedFuture ('setLibraryDebuggable' );
1244- }
1245-
1246- @override
1247- Future <Success > setName (String isolateId, String name) =>
1248- wrapInErrorHandlerAsync ('setName' , () => _setName (isolateId, name));
1249-
1250- Future <Success > _setName (String isolateId, String name) async {
1251- await isInitialized;
1252- _checkIsolate ('setName' , isolateId);
1253- inspector.isolate.name = name;
1254- return Success ();
1255- }
1256-
1257- @override
1258- Future <Success > setVMName (String name) =>
1259- wrapInErrorHandlerAsync ('setVMName' , () => _setVMName (name));
1260-
1261- Future <Success > _setVMName (String name) async {
1262- vm.name = name;
1263- streamNotify (
1264- 'VM' ,
1265- Event (
1266- kind: EventKind .kVMUpdate,
1267- timestamp: DateTime .now ().millisecondsSinceEpoch,
1268- // We are not guaranteed to have an isolate at this point in time.
1269- isolate: null ,
1270- )..vm = toVMRef (vm),
1271- );
1272- return Success ();
1273- }
1274-
1275- @override
1276- Future <Success > streamListen (String streamId) =>
1277- wrapInErrorHandlerAsync ('streamListen' , () => _streamListen (streamId));
1278-
1279- Future <Success > _streamListen (String streamId) async {
1280- // TODO: This should return an error if the stream is already being listened
1281- // to.
1282- onEvent (streamId);
1283- return Success ();
1284- }
1285-
12861146 /// Returns a streamController that listens for console logs from chrome and
12871147 /// adds all events passing [filter] to the stream.
12881148 StreamController <Event > _chromeConsoleStreamController (
@@ -1345,57 +1205,20 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
13451205 return controller;
13461206 }
13471207
1348- /// Parses the [BatchedDebugEvents] and emits corresponding Dart VM Service
1349- /// protocol [Event] s.
1350- @override
1351- void parseBatchedDebugEvents (BatchedDebugEvents debugEvents) {
1352- for (final debugEvent in debugEvents.events) {
1353- parseDebugEvent (debugEvent);
1354- }
1355- }
1356-
13571208 /// Parses the [DebugEvent] and emits a corresponding Dart VM Service
13581209 /// protocol [Event] .
13591210 @override
13601211 void parseDebugEvent (DebugEvent debugEvent) {
13611212 if (terminatingIsolates) return ;
1362- if (! isIsolateRunning) return ;
1363- final isolateRef = inspector.isolateRef;
1364-
1365- streamNotify (
1366- EventStreams .kExtension,
1367- Event (
1368- kind: EventKind .kExtension,
1369- timestamp: DateTime .now ().millisecondsSinceEpoch,
1370- isolate: isolateRef,
1371- )
1372- ..extensionKind = debugEvent.kind
1373- ..extensionData = ExtensionData .parse (
1374- jsonDecode (debugEvent.eventData) as Map <String , dynamic >,
1375- ),
1376- );
1213+ super .parseDebugEvent (debugEvent);
13771214 }
13781215
13791216 /// Parses the [RegisterEvent] and emits a corresponding Dart VM Service
13801217 /// protocol [Event] .
13811218 @override
13821219 void parseRegisterEvent (RegisterEvent registerEvent) {
13831220 if (terminatingIsolates) return ;
1384- if (! isIsolateRunning) return ;
1385-
1386- final isolate = inspector.isolate;
1387- final isolateRef = inspector.isolateRef;
1388- final service = registerEvent.eventData;
1389- isolate.extensionRPCs? .add (service);
1390-
1391- streamNotify (
1392- EventStreams .kIsolate,
1393- Event (
1394- kind: EventKind .kServiceExtensionAdded,
1395- timestamp: DateTime .now ().millisecondsSinceEpoch,
1396- isolate: isolateRef,
1397- )..extensionRPC = service,
1398- );
1221+ super .parseRegisterEvent (registerEvent);
13991222 }
14001223
14011224 /// Listens for chrome console events and handles the ones we care about.
@@ -1519,31 +1342,6 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {
15191342 final instance = obj == null ? null : await inspector.instanceRefFor (obj);
15201343 return instance ?? ChromeAppInstanceHelper .kNullInstanceRef;
15211344 }
1522-
1523- /// Validate that isolateId matches the current isolate we're connected to and
1524- /// return that isolate.
1525- ///
1526- /// This is useful to call at the beginning of API methods that are passed an
1527- /// isolate id.
1528- Isolate _checkIsolate (String methodName, String ? isolateId) {
1529- final currentIsolateId = inspector.isolate.id;
1530- if (currentIsolateId == null ) {
1531- throw StateError ('No running isolate ID' );
1532- }
1533- if (isolateId != currentIsolateId) {
1534- _throwSentinel (
1535- methodName,
1536- SentinelKind .kCollected,
1537- 'Unrecognized isolateId: $isolateId ' ,
1538- );
1539- }
1540- return inspector.isolate;
1541- }
1542-
1543- static Never _throwSentinel (String method, String kind, String message) {
1544- final data = < String , String > {'kind' : kind, 'valueAsString' : message};
1545- throw SentinelException .parse (method, data);
1546- }
15471345}
15481346
15491347// The default `ReloadReport`'s `toJson` only emits the type and success of the
0 commit comments