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

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.debug.core/src/com/google/dart/tools/debug/core/pubserve/PubCommands.java

Issue 330123005: fix for pub serve to be terminated when editor is closed (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014, the Dart project authors. 2 * Copyright (c) 2014, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 14 matching lines...) Expand all
25 * A class to encapsulate the available pub protocol commands. 25 * A class to encapsulate the available pub protocol commands.
26 */ 26 */
27 public class PubCommands { 27 public class PubCommands {
28 private PubConnection connection; 28 private PubConnection connection;
29 29
30 protected PubCommands(PubConnection connection) { 30 protected PubCommands(PubConnection connection) {
31 this.connection = connection; 31 this.connection = connection;
32 } 32 }
33 33
34 /** 34 /**
35 * Sends a message to pub to indicate that it should shutdown when connection is closed. There is
36 * no result returned by pub.
37 *
38 * @throws IOException
39 */
40 public void exitOnClose() throws IOException {
41 // {"method": "exitOnClose"}
42
43 try {
44 JSONObject request = new JSONObject();
45
46 request.put("jsonrpc", "2.0");
47
48 request.put("method", "exitOnClose");
49
50 connection.sendRequest(request, null);
51 } catch (JSONException exception) {
52 throw new IOException(exception);
53 }
54 }
55
56 /**
35 * Given an asset ID, returns the relative URI path that asset would be served at. 57 * Given an asset ID, returns the relative URI path that asset would be served at.
36 * 58 *
37 * @param path 59 * @param path
38 * @param callback 60 * @param callback
39 * @throws IOException 61 * @throws IOException
40 */ 62 */
41 public void pathToUrl(String path, final PubCallback<String> callback) throws IOException { 63 public void pathToUrl(String path, final PubCallback<String> callback) throws IOException {
42 // { "method": "pathToUrls", "path": "web/index.html" } 64 // { "method": "pathToUrls", "path": "web/index.html" }
43 // ==>{ "urls": ["http://localhost:8080/index.html"] } 65 // ==>{ "urls": ["http://localhost:8080/index.html"] }
44 66
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 private PubResult<PubAsset> convertUrlToAssetResult(JSONObject obj) throws JSO NException { 183 private PubResult<PubAsset> convertUrlToAssetResult(JSONObject obj) throws JSO NException {
162 PubResult<PubAsset> result = PubResult.createFrom(obj); 184 PubResult<PubAsset> result = PubResult.createFrom(obj);
163 if (obj.has("result")) { 185 if (obj.has("result")) {
164 JSONObject resObj = (JSONObject) obj.get("result"); 186 JSONObject resObj = (JSONObject) obj.get("result");
165 result.setResult(PubAsset.createFrom(resObj)); 187 result.setResult(PubAsset.createFrom(resObj));
166 } 188 }
167 return result; 189 return result;
168 } 190 }
169 191
170 } 192 }
OLDNEW
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.tools.debug.core/src/com/google/dart/tools/debug/core/pubserve/PubServe.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698