Skip to content

Removed tabConnection from ChromeProxyService. #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dwds/lib/src/connections/debug_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class DebugConnection {
final _onDoneCompleter = Completer();

DebugConnection(this._appDebugServices) {
_appDebugServices.chromeProxyService.tabConnection.onClose.first.then((_) {
_appDebugServices.chromeProxyService.wipDebugger.connection.onClose.first
.then((_) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] consider using whenComplete

close();
});
}
Expand All @@ -33,7 +34,7 @@ class DebugConnection {

Future<void> close() async {
if (!_onDoneCompleter.isCompleted) _onDoneCompleter.complete();
await _appDebugServices.chromeProxyService.tabConnection.close();
await _appDebugServices.chromeProxyService.wipDebugger.connection.close();
await _appDebugServices.close();
}

Expand Down
10 changes: 5 additions & 5 deletions dwds/lib/src/dwds_vm_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DwdsVmClient {

client.registerServiceCallback('hotRestart', (request) async {
await _removeBreakpointsAndResume(client);
var response = await chromeProxyService.tabConnection.runtime.sendCommand(
var response = await chromeProxyService.wipDebugger.sendCommand(
'Runtime.evaluate',
params: {'expression': r'$dartHotRestart();', 'awaitPromise': true});
var exceptionDetails = response.result['exceptionDetails'];
Expand All @@ -59,17 +59,17 @@ class DwdsVmClient {
await client.registerService('hotRestart', 'DWDS fullReload');

client.registerServiceCallback('fullReload', (_) async {
await chromeProxyService.tabConnection.page.enable();
await chromeProxyService.wipDebugger.connection.page.enable();
// TODO: use built in `page.reload` once it works,
// https://github.com/google/webkit_inspection_protocol.dart/issues/44
await chromeProxyService.tabConnection.sendCommand('Page.reload');
await chromeProxyService.wipDebugger.sendCommand('Page.reload');
return {'result': Success().toJson()};
});
await client.registerService('fullReload', 'DWDS');

client.registerServiceCallback('ext.dwds.screenshot', (_) async {
await chromeProxyService.tabConnection.page.enable();
var response = await chromeProxyService.tabConnection.page
await chromeProxyService.wipDebugger.connection.page.enable();
var response = await chromeProxyService.wipDebugger
.sendCommand('Page.captureScreenshot');
return {'result': response.result};
});
Expand Down
15 changes: 8 additions & 7 deletions dwds/lib/src/handlers/dev_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class DevHandler {
// If you load the same app in a different tab then we need to throw
// away our old services and start new ones.
if (!(await _isCorrectTab(message.instanceId,
appServices.chromeProxyService.tabConnection))) {
appServices.chromeProxyService.wipDebugger.connection))) {
unawaited(appServices.close());
unawaited(_servicesByAppId.remove(message.appId));
appServices =
Expand All @@ -173,8 +173,8 @@ class DevHandler {
serializers.serialize(DevToolsResponse((b) => b..success = true))));

appServices.connectedInstanceId = message.instanceId;
await appServices.chromeProxyService.tabConnection
.sendCommand('Target.createTarget', {
await appServices.chromeProxyService.wipDebugger
.sendCommand('Target.createTarget', params: {
'newWindow': true,
'url': 'http://${_devTools.hostname}:${_devTools.port}'
'/?hide=none&uri=${appServices.debugService.wsUri}',
Expand All @@ -193,8 +193,8 @@ class DevHandler {
if (services != null && services.connectedInstanceId == null) {
// Re-connect to the previous instance if its in the same tab,
// otherwise do nothing for now.
if (await _isCorrectTab(
message.instanceId, services.chromeProxyService.tabConnection)) {
if (await _isCorrectTab(message.instanceId,
services.chromeProxyService.wipDebugger.connection)) {
services.connectedInstanceId = message.instanceId;
await services.chromeProxyService.createIsolate();
}
Expand Down Expand Up @@ -241,8 +241,9 @@ class DevHandler {
var webdevClient = await DwdsVmClient.create(debugService);
var appServices = AppDebugServices(debugService, webdevClient);

unawaited(
appServices.chromeProxyService.tabConnection.onClose.first.then((_) {
unawaited(appServices
.chromeProxyService.wipDebugger.connection.onClose.first
.then((_) {
appServices.close();
_servicesByAppId.remove(appId);
_logWriter(
Expand Down
24 changes: 9 additions & 15 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ class ChromeProxyService implements VmServiceInterface {
/// The actual chrome tab running this app.
final ChromeTab _tab;

/// The connection with the chrome debug service for the tab.
// TODO(grouma) - This should be class private.
final WipConnection tabConnection;

final WipDebugger _wipDebugger;
final WipDebugger wipDebugger;

final AssetHandler _assetHandler;

Expand All @@ -61,9 +57,8 @@ class ChromeProxyService implements VmServiceInterface {
ChromeProxyService._(
this._vm,
this._tab,
this.tabConnection,
this._assetHandler,
this._wipDebugger,
this.wipDebugger,
);

static Future<ChromeProxyService> create(
Expand Down Expand Up @@ -98,8 +93,7 @@ class ChromeProxyService implements VmServiceInterface {
..name = 'ChromeDebugProxy'
..startTime = DateTime.now().millisecondsSinceEpoch
..version = Platform.version;
var service = ChromeProxyService._(
vm, appTab, tabConnection, assetHandler, wipDebugger);
var service = ChromeProxyService._(vm, appTab, assetHandler, wipDebugger);
await service._initialize();
await service.createIsolate();
return service;
Expand All @@ -108,7 +102,7 @@ class ChromeProxyService implements VmServiceInterface {
Future<Null> _initialize() async {
_debugger = await Debugger.create(
_assetHandler,
tabConnection,
wipDebugger.connection,
_streamNotify,
_appInspectorProvider,
uri,
Expand All @@ -130,7 +124,7 @@ class ChromeProxyService implements VmServiceInterface {
}

_inspector = await AppInspector.initialize(
_wipDebugger,
wipDebugger,
_assetHandler,
_debugger,
uri,
Expand Down Expand Up @@ -215,7 +209,7 @@ class ChromeProxyService implements VmServiceInterface {
require("dart_sdk").developer.invokeExtension(
"$method", JSON.stringify(${jsonEncode(stringArgs)}));
''';
var response = await _wipDebugger.sendCommand('Runtime.evaluate', params: {
var response = await wipDebugger.sendCommand('Runtime.evaluate', params: {
'expression': expression,
'awaitPromise': true,
});
Expand Down Expand Up @@ -478,7 +472,7 @@ require("dart_sdk").developer.invokeExtension(
exceptionsSubscription?.cancel();
}, onListen: () {
chromeConsoleSubscription =
tabConnection.runtime.onConsoleAPICalled.listen((e) {
wipDebugger.connection.runtime.onConsoleAPICalled.listen((e) {
var isolate = _inspector?.isolate;
if (isolate == null) return;
if (!filter(e)) return;
Expand All @@ -493,7 +487,7 @@ require("dart_sdk").developer.invokeExtension(
});
if (includeExceptions) {
exceptionsSubscription =
tabConnection.runtime.onExceptionThrown.listen((e) {
wipDebugger.connection.runtime.onExceptionThrown.listen((e) {
var isolate = _inspector?.isolate;
if (isolate == null) return;
controller.add(Event()
Expand All @@ -509,7 +503,7 @@ require("dart_sdk").developer.invokeExtension(

/// Listens for chrome console events and handles the ones we care about.
void _setUpChromeConsoleListeners(IsolateRef isolateRef) {
_consoleSubscription = tabConnection.runtime.onConsoleAPICalled
_consoleSubscription = wipDebugger.connection.runtime.onConsoleAPICalled
.listen((ConsoleAPIEvent event) {
var isolate = _inspector?.isolate;
if (isolate == null) return;
Expand Down