Skip to content

Commit 1c55263

Browse files
committed
refactored classes to and interface names to be more clear
1 parent cd5b810 commit 1c55263

File tree

5 files changed

+52
-44
lines changed

5 files changed

+52
-44
lines changed

dwds/lib/src/dwds_vm_client.dart

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum _NamespacedServiceExtension {
3939
}
4040

4141
/// Common interface for DWDS VM clients.
42-
abstract class IDwdsVmClient {
42+
abstract class DwdsVmClient {
4343
/// The VM service client.
4444
VmService get client;
4545

@@ -52,7 +52,7 @@ final _chromeLogger = Logger('DwdsVmClient');
5252

5353
// A client of the vm service that registers some custom extensions like
5454
// hotRestart.
55-
class DwdsVmClient implements IDwdsVmClient {
55+
class ChromeDwdsVmClient implements DwdsVmClient {
5656
@override
5757
final VmService client;
5858
final StreamController<Map<String, Object>> _requestController;
@@ -66,7 +66,11 @@ class DwdsVmClient implements IDwdsVmClient {
6666
/// Synchronizes hot restarts to avoid races.
6767
final _hotRestartQueue = AtomicQueue();
6868

69-
DwdsVmClient(this.client, this._requestController, this._responseController);
69+
ChromeDwdsVmClient(
70+
this.client,
71+
this._requestController,
72+
this._responseController,
73+
);
7074

7175
@override
7276
Future<void> close() =>
@@ -76,8 +80,8 @@ class DwdsVmClient implements IDwdsVmClient {
7680
await client.dispose();
7781
}();
7882

79-
static Future<DwdsVmClient> create(
80-
DebugService debugService,
83+
static Future<ChromeDwdsVmClient> create(
84+
ChromeDebugService debugService,
8185
DwdsStats dwdsStats,
8286
Uri? ddsUri,
8387
) async {
@@ -118,7 +122,7 @@ class DwdsVmClient implements IDwdsVmClient {
118122
clientCompleter.complete(client);
119123
}
120124

121-
final dwdsVmClient = DwdsVmClient(
125+
final dwdsVmClient = ChromeDwdsVmClient(
122126
client,
123127
requestController,
124128
responseController,
@@ -176,7 +180,7 @@ class DwdsVmClient implements IDwdsVmClient {
176180
static void _setUpVmServerConnection({
177181
required ChromeProxyService chromeProxyService,
178182
required DwdsStats dwdsStats,
179-
required DebugService debugService,
183+
required ChromeDebugService debugService,
180184
required Stream<VmResponse> responseStream,
181185
required StreamSink<VmResponse> responseSink,
182186
required Stream<VmRequest> requestStream,
@@ -276,7 +280,7 @@ class DwdsVmClient implements IDwdsVmClient {
276280
static Future<void> _registerServiceExtensions({
277281
required VmService client,
278282
required ChromeProxyService chromeProxyService,
279-
required DwdsVmClient dwdsVmClient,
283+
required ChromeDwdsVmClient dwdsVmClient,
280284
}) async {
281285
client.registerServiceCallback(
282286
'hotRestart',
@@ -309,7 +313,7 @@ class DwdsVmClient implements IDwdsVmClient {
309313
final _webSocketLogger = Logger('WebSocketDwdsVmClient');
310314

311315
/// WebSocket-based DWDS VM client.
312-
class WebSocketDwdsVmClient implements IDwdsVmClient {
316+
class WebSocketDwdsVmClient implements DwdsVmClient {
313317
@override
314318
final VmService client;
315319
final StreamController<VmRequest> _requestController;

dwds/lib/src/handlers/dev_handler.dart

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class DevHandler {
5959
final AssetReader _assetReader;
6060
final String _hostname;
6161
final _connectedApps = StreamController<AppConnection>.broadcast();
62-
final _servicesByAppId = <String, IAppDebugServices>{};
62+
final _servicesByAppId = <String, AppDebugServices>{};
6363
final _appConnectionByAppId = <String, AppConnection>{};
6464
final Stream<BuildResult> buildResults;
6565
final Future<ChromeConnection> Function() _chromeConnection;
@@ -163,8 +163,8 @@ class DevHandler {
163163
return successfulSends;
164164
}
165165

166-
/// Starts a [DebugService] for local debugging.
167-
Future<DebugService> _startLocalDebugService(
166+
/// Starts a [ChromeDebugService] for local debugging.
167+
Future<ChromeDebugService> _startLocalDebugService(
168168
ChromeConnection chromeConnection,
169169
AppConnection appConnection,
170170
) async {
@@ -224,7 +224,7 @@ class DevHandler {
224224

225225
final webkitDebugger = WebkitDebugger(WipDebugger(tabConnection));
226226

227-
return DebugService.start(
227+
return ChromeDebugService.start(
228228
// We assume the user will connect to the debug service on the same
229229
// machine. This allows consumers of DWDS to provide a `hostname` for
230230
// debugging through the Dart Debug Extension without impacting the local
@@ -264,7 +264,7 @@ class DevHandler {
264264
);
265265
}
266266

267-
Future<IAppDebugServices> loadAppServices(AppConnection appConnection) async {
267+
Future<AppDebugServices> loadAppServices(AppConnection appConnection) async {
268268
final appId = appConnection.request.appId;
269269
var appServices = _servicesByAppId[appId];
270270
if (appServices == null) {
@@ -281,7 +281,7 @@ class DevHandler {
281281
}
282282

283283
/// Creates WebSocket-based app services for hot reload functionality.
284-
Future<IAppDebugServices> _createWebSocketAppServices(
284+
Future<AppDebugServices> _createWebSocketAppServices(
285285
AppConnection appConnection,
286286
) async {
287287
final webSocketDebugService = await WebSocketDebugService.start(
@@ -296,7 +296,7 @@ class DevHandler {
296296
}
297297

298298
/// Creates Chrome-based app services for full debugging capabilities.
299-
Future<IAppDebugServices> _createChromeAppServices(
299+
Future<AppDebugServices> _createChromeAppServices(
300300
AppConnection appConnection,
301301
) async {
302302
final debugService = await _startLocalDebugService(
@@ -308,7 +308,7 @@ class DevHandler {
308308

309309
/// Sets up cleanup handling for Chrome-based services.
310310
void _setupChromeServiceCleanup(
311-
IAppDebugServices appServices,
311+
AppDebugServices appServices,
312312
AppConnection appConnection,
313313
) {
314314
final chromeProxy = appServices.proxyService;
@@ -468,7 +468,7 @@ class DevHandler {
468468
return;
469469
}
470470
final debuggerStart = DateTime.now();
471-
IAppDebugServices appServices;
471+
AppDebugServices appServices;
472472
try {
473473
appServices = await loadAppServices(appConnection);
474474
} catch (_) {
@@ -733,7 +733,7 @@ class DevHandler {
733733

734734
/// Handles reconnection to existing services for web-socket mode.
735735
Future<void> _reconnectToService(
736-
IAppDebugServices services,
736+
AppDebugServices services,
737737
AppConnection? existingConnection,
738738
AppConnection newConnection,
739739
ConnectRequest message,
@@ -846,17 +846,21 @@ class DevHandler {
846846
);
847847
}
848848

849-
Future<IAppDebugServices> _createAppDebugServices(
850-
DebugService debugService,
849+
Future<AppDebugServices> _createAppDebugServices(
850+
ChromeDebugService debugService,
851851
) async {
852852
final dwdsStats = DwdsStats();
853853
Uri? ddsUri;
854854
if (_spawnDds) {
855855
final dds = await debugService.startDartDevelopmentService();
856856
ddsUri = dds.wsUri;
857857
}
858-
final vmClient = await DwdsVmClient.create(debugService, dwdsStats, ddsUri);
859-
final appDebugService = AppDebugServices(
858+
final vmClient = await ChromeDwdsVmClient.create(
859+
debugService,
860+
dwdsStats,
861+
ddsUri,
862+
);
863+
final appDebugService = ChromeAppDebugServices(
860864
debugService,
861865
vmClient,
862866
dwdsStats,
@@ -883,7 +887,7 @@ class DevHandler {
883887
return appDebugService;
884888
}
885889

886-
Future<IAppDebugServices> _createAppDebugServicesWebSocketMode(
890+
Future<AppDebugServices> _createAppDebugServicesWebSocketMode(
887891
WebSocketDebugService webSocketDebugService,
888892
AppConnection appConnection,
889893
) async {
@@ -918,7 +922,7 @@ class DevHandler {
918922
}
919923
}
920924

921-
/// Starts a [DebugService] for Dart Debug Extension.
925+
/// Starts a [ChromeProxyService] for Dart Debug Extension.
922926
void _startExtensionDebugService(ExtensionDebugger extensionDebugger) {
923927
// Waits for a `DevToolsRequest` to be sent from the extension background
924928
// when the extension is clicked.
@@ -965,7 +969,7 @@ class DevHandler {
965969
final debuggerStart = DateTime.now();
966970
var appServices = _servicesByAppId[appId];
967971
if (appServices == null) {
968-
final debugService = await DebugService.start(
972+
final debugService = await ChromeDebugService.start(
969973
_hostname,
970974
extensionDebugger,
971975
executionContext,

dwds/lib/src/services/app_debug_services.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import 'package:dwds/src/services/debug_service.dart';
1010
import 'package:dwds/src/services/proxy_service.dart';
1111

1212
/// Common interface for debug service containers.
13-
abstract class IAppDebugServices {
14-
IDebugService get debugService;
15-
IDwdsVmClient get dwdsVmClient;
13+
abstract class AppDebugServices {
14+
DebugService get debugService;
15+
DwdsVmClient get dwdsVmClient;
1616
DwdsStats? get dwdsStats;
1717
Uri? get ddsUri;
1818
String? get connectedInstanceId;
@@ -22,26 +22,26 @@ abstract class IAppDebugServices {
2222
}
2323

2424
/// Chrome-based debug services container.
25-
class AppDebugServices implements IAppDebugServices {
26-
final DebugService _debugService;
27-
final DwdsVmClient _dwdsVmClient;
25+
class ChromeAppDebugServices implements AppDebugServices {
26+
final ChromeDebugService _debugService;
27+
final ChromeDwdsVmClient _dwdsVmClient;
2828
final DwdsStats _dwdsStats;
2929
final Uri? _ddsUri;
3030
Future<void>? _closed;
3131
String? _connectedInstanceId;
3232

33-
AppDebugServices(
33+
ChromeAppDebugServices(
3434
this._debugService,
3535
this._dwdsVmClient,
3636
this._dwdsStats,
3737
this._ddsUri,
3838
);
3939

4040
@override
41-
DebugService get debugService => _debugService;
41+
ChromeDebugService get debugService => _debugService;
4242

4343
@override
44-
IDwdsVmClient get dwdsVmClient => _dwdsVmClient;
44+
DwdsVmClient get dwdsVmClient => _dwdsVmClient;
4545

4646
@override
4747
DwdsStats get dwdsStats => _dwdsStats;
@@ -65,7 +65,7 @@ class AppDebugServices implements IAppDebugServices {
6565
}
6666

6767
/// WebSocket-based implementation of app debug services.
68-
class WebSocketAppDebugServices implements IAppDebugServices {
68+
class WebSocketAppDebugServices implements AppDebugServices {
6969
final WebSocketDebugService _debugService;
7070
final WebSocketDwdsVmClient _dwdsVmClient;
7171
Future<void>? _closed;
@@ -77,7 +77,7 @@ class WebSocketAppDebugServices implements IAppDebugServices {
7777
WebSocketDebugService get debugService => _debugService;
7878

7979
@override
80-
IDwdsVmClient get dwdsVmClient => _dwdsVmClient;
80+
DwdsVmClient get dwdsVmClient => _dwdsVmClient;
8181

8282
@override
8383
String? get connectedInstanceId => _connectedInstanceId;

dwds/lib/src/services/chrome_proxy_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ class ChromeProxyService extends ProxyService {
15481548

15491549
@override
15501550
Future<void> yieldControlToDDS(String uri) async {
1551-
final canYield = DebugService.yieldControlToDDS(uri);
1551+
final canYield = ChromeDebugService.yieldControlToDDS(uri);
15521552

15531553
if (!canYield) {
15541554
throw RPCError(

dwds/lib/src/services/debug_service.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Future<void> _handleSseConnections(
128128
}
129129

130130
/// Common interface for debug services (Chrome or WebSocket based).
131-
abstract class IDebugService {
131+
abstract class DebugService {
132132
String get hostname;
133133
int get port;
134134
String get uri;
@@ -140,7 +140,7 @@ abstract class IDebugService {
140140
/// A Dart Web Debug Service.
141141
///
142142
/// Creates a [ChromeProxyService] from an existing Chrome instance.
143-
class DebugService implements IDebugService {
143+
class ChromeDebugService implements DebugService {
144144
static String? _ddsUri;
145145

146146
final VmServiceInterface chromeProxyService;
@@ -163,7 +163,7 @@ class DebugService implements IDebugService {
163163
/// All subsequent calls to [close] will return this future.
164164
Future<void>? _closed;
165165

166-
DebugService._(
166+
ChromeDebugService._(
167167
this.chromeProxyService,
168168
this.hostname,
169169
this.port,
@@ -235,7 +235,7 @@ class DebugService implements IDebugService {
235235
return true;
236236
}
237237

238-
static Future<DebugService> start(
238+
static Future<ChromeDebugService> start(
239239
String hostname,
240240
RemoteDebugger remoteDebugger,
241241
ExecutionContext executionContext,
@@ -305,7 +305,7 @@ class DebugService implements IDebugService {
305305
_logger.warning('Error serving requests', e);
306306
emitEvent(DwdsEvent.httpRequestException('DebugService', '$e:$s'));
307307
});
308-
return DebugService._(
308+
return ChromeDebugService._(
309309
chromeProxyService,
310310
server.address.host,
311311
server.port,
@@ -325,7 +325,7 @@ class DebugService implements IDebugService {
325325
typedef SendClientRequest = int Function(Object request);
326326

327327
/// WebSocket-based debug service for web debugging.
328-
class WebSocketDebugService implements IDebugService {
328+
class WebSocketDebugService implements DebugService {
329329
@override
330330
final String hostname;
331331
@override

0 commit comments

Comments
 (0)