Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart

Issue 221173007: Properly handle web socket requests to half-initialized servers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart b/sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart
index 6a2d6b09cf66ee87f1ff7eddc83c8afa9dce7d34..63e56fdb38bcb203f3c2f763c46e5e18d5d426b2 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart
@@ -167,25 +167,26 @@ class WebSocketApi {
/// If the asset is not in a directory being served by pub, returns an error:
///
/// example/index.html -> NOT_SERVED error
- Map _pathToUrls(json_rpc.Parameters params) {
+ Future<Map> _pathToUrls(json_rpc.Parameters params) {
var assetPath = params["path"].asString;
var line = params["line"].asIntOr(null);
- var urls = _environment.getUrlsForAssetPath(assetPath);
- if (urls.isEmpty) {
- throw new json_rpc.RpcException(_NOT_SERVED,
- 'Asset path "$assetPath" is not currently being served.');
- }
+ return _environment.getUrlsForAssetPath(assetPath).then((urls) {
+ if (urls.isEmpty) {
+ throw new json_rpc.RpcException(_NOT_SERVED,
+ 'Asset path "$assetPath" is not currently being served.');
+ }
- var result = {"urls": urls.map((url) => url.toString()).toList()};
+ var result = {"urls": urls.map((url) => url.toString()).toList()};
- // Map the line.
- // TODO(rnystrom): Right now, source maps are not supported and it just
- // passes through the original line. This lets the editor start using
- // this API before we've fully implemented it. See #12339 and #16061.
- if (line != null) result["line"] = line;
+ // Map the line.
+ // TODO(rnystrom): Right now, source maps are not supported and it just
+ // passes through the original line. This lets the editor start using
+ // this API before we've fully implemented it. See #12339 and #16061.
+ if (line != null) result["line"] = line;
- return result;
+ return result;
+ });
}
/// Given a relative directory path within the entrypoint package, binds a
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback/old_web_socket_api.dart ('k') | sdk/lib/_internal/pub/test/serve/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698