OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import '../../util/io.dart'; | 9 import '../../util/io.dart'; |
10 import '../../utils.dart'; | 10 import '../../utils.dart'; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 /// Returns the full URL of the remote debugger for the host page. | 98 /// Returns the full URL of the remote debugger for the host page. |
99 /// | 99 /// |
100 /// This takes the base remote debugger URL (which points to a browser-wide | 100 /// This takes the base remote debugger URL (which points to a browser-wide |
101 /// page) and uses its JSON API to find the resolved URL for debugging the | 101 /// page) and uses its JSON API to find the resolved URL for debugging the |
102 /// host page. | 102 /// host page. |
103 static Future<Uri> _getRemoteDebuggerUrl(Uri base) async { | 103 static Future<Uri> _getRemoteDebuggerUrl(Uri base) async { |
104 try { | 104 try { |
105 var client = new HttpClient(); | 105 var client = new HttpClient(); |
106 var request = await client.getUrl(base.resolve("/json/list")); | 106 var request = await client.getUrl(base.resolve("/json/list")); |
107 var response = await request.close(); | 107 var response = await request.close(); |
108 var json = await JSON.fuse(UTF8).decoder.bind(response).single; | 108 var json = await JSON.fuse(UTF8).decoder.bind(response).single as List; |
nweiz
2016/06/20 20:51:36
Why doesn't this complain about calling operator [
kevmoo
2016/06/20 20:57:49
You get Object out of the fused decoder, which is
| |
109 return base.resolve(json.first["devtoolsFrontendUrl"]); | 109 return base.resolve(json.first["devtoolsFrontendUrl"]); |
110 } catch (_) { | 110 } catch (_) { |
111 // If we fail to talk to the remote debugger protocol, give up and return | 111 // If we fail to talk to the remote debugger protocol, give up and return |
112 // the raw URL rather than crashing. | 112 // the raw URL rather than crashing. |
113 return base; | 113 return base; |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 ContentShell._(Future<Process> startBrowser(), this.observatoryUrl, | 117 ContentShell._(Future<Process> startBrowser(), this.observatoryUrl, |
118 this.remoteDebuggerUrl) | 118 this.remoteDebuggerUrl) |
119 : super(startBrowser); | 119 : super(startBrowser); |
120 | 120 |
121 /// Return the default executable for the current operating system. | 121 /// Return the default executable for the current operating system. |
122 static String _defaultExecutable() => | 122 static String _defaultExecutable() => |
123 Platform.isWindows ? "content_shell.exe" : "content_shell"; | 123 Platform.isWindows ? "content_shell.exe" : "content_shell"; |
124 } | 124 } |
OLD | NEW |