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

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.debug.core/src/com/google/dart/tools/debug/core/pubserve/PubServe.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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 IContainer getWorkingDir() { 129 IContainer getWorkingDir() {
130 return workingDir; 130 return workingDir;
131 } 131 }
132 132
133 boolean isAlive() { 133 boolean isAlive() {
134 return process != null && !isTerminated() && pubConnection != null 134 return process != null && !isTerminated() && pubConnection != null
135 && pubConnection.isConnected(); 135 && pubConnection.isConnected();
136 } 136 }
137 137
138 /** 138 /**
139 * Sends an exit on close command to pub, indicating pub serve should shut dow n when connection is
140 * lost.
141 *
142 * @throws IOException
143 */
144 void sendExitOnCloseCommand() throws IOException {
145 PubCommands command = pubConnection.getCommands();
146 command.exitOnClose();
147 }
148
149 /**
139 * Send a urlToAssetId command to the current pub serve 150 * Send a urlToAssetId command to the current pub serve
140 * 151 *
141 * @param url 152 * @param url
142 * @param callback 153 * @param callback
143 * @throws IOException 154 * @throws IOException
144 */ 155 */
145 void sendGetAssetIdCommand(String url, PubCallback<PubAsset> callback) throws IOException { 156 void sendGetAssetIdCommand(String url, PubCallback<PubAsset> callback) throws IOException {
146 PubCommands command = pubConnection.getCommands(); 157 PubCommands command = pubConnection.getCommands();
147 command.urlToAssetId(url, callback); 158 command.urlToAssetId(url, callback);
148 } 159 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 pubConnection = new PubConnection(new URI(NLS.bind(WEBSOCKET_URL, LOCAL_HOST _ADDR, portNumber))); 231 pubConnection = new PubConnection(new URI(NLS.bind(WEBSOCKET_URL, LOCAL_HOST _ADDR, portNumber)));
221 232
222 pubConnection.addConnectionListener(new PubConnectionListener() { 233 pubConnection.addConnectionListener(new PubConnectionListener() {
223 @Override 234 @Override
224 public void connectionClosed(PubConnection connection) { 235 public void connectionClosed(PubConnection connection) {
225 pubConnection = null; 236 pubConnection = null;
226 } 237 }
227 }); 238 });
228 239
229 pubConnection.connect(); 240 pubConnection.connect();
230 241 sendExitOnCloseCommand();
231 } 242 }
232 243
233 private void copyStream(InputStream in, StringBuilder stringBuilder, boolean t oConsole) { 244 private void copyStream(InputStream in, StringBuilder stringBuilder, boolean t oConsole) {
234 byte[] buffer = new byte[2048]; 245 byte[] buffer = new byte[2048];
235 try { 246 try {
236 int count = in.read(buffer); 247 int count = in.read(buffer);
237 while (count != -1) { 248 while (count != -1) {
238 if (count > 0) { 249 if (count > 0) {
239 String str = new String(buffer, 0, count); 250 String str = new String(buffer, 0, count);
240 stringBuilder.append(str); 251 stringBuilder.append(str);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 315 }
305 316
306 if (isTerminated()) { 317 if (isTerminated()) {
307 return false; 318 return false;
308 } 319 }
309 servedDirs.add(directoryToServe); 320 servedDirs.add(directoryToServe);
310 321
311 return true; 322 return true;
312 } 323 }
313 } 324 }
OLDNEW
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.debug.core/src/com/google/dart/tools/debug/core/pubserve/PubCommands.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698