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

Unified Diff: tools/testing/dart/browser_controller.dart

Issue 16836009: Fixed bug in browser_controller.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/browser_controller.dart
diff --git a/tools/testing/dart/browser_controller.dart b/tools/testing/dart/browser_controller.dart
index 59d4f9b7ae0769b14c06681f2e3790e6f42e1318..2420bb12c7e9c916f46c140bcb740a70de9f161f 100644
--- a/tools/testing/dart/browser_controller.dart
+++ b/tools/testing/dart/browser_controller.dart
@@ -16,12 +16,11 @@ abstract class Browser {
StringBuffer _stderr = new StringBuffer();
StringBuffer _usageLog = new StringBuffer();
// This function is called when the process is closed.
- // This is extracted to an external function so that we can do additional
- // functionality when the process closes (cleanup and call onExit)
- Function _processClosed;
- // This is called after the process is closed, after _processClosed has
- // been called, but before onExit. Subclasses can use this to cleanup
+ Completer _processClosedCompleter = new Completer();
+ // This is called after the process is closed, after _processClosedCompleter
+ // has been called, but before onExit. Subclasses can use this to cleanup
// any browser specific resources (temp directories, profiles, etc)
+ // The function is expected to do it's work synchronously.
Function _cleanup;
/** The version of the browser - normally set when starting a browser */
@@ -40,9 +39,6 @@ abstract class Browser {
*/
String id;
- /** Callback that will be executed when the browser has closed */
- Function onClose;
-
/** Print everything (stdout, stderr, usageLog) whenever we add to it */
bool debugPrint = false;
@@ -99,12 +95,13 @@ abstract class Browser {
browserTerminationFuture = completer.future;
if (process != null) {
- // Make sure we intercept onExit calls and complete.
- _processClosed = () {
- _processClosed = null;
+ _processClosedCompleter.future.then((_) {
process = null;
completer.complete(true);
- };
+ if (_cleanup != null) {
+ _cleanup();
+ }
+ });
if (process.kill(ProcessSignal.SIGKILL)) {
_logEvent("Successfully sent kill signal to process.");
@@ -152,9 +149,7 @@ abstract class Browser {
process.exitCode.then((exitCode) {
_logEvent("Browser closed with exitcode $exitCode");
Future.wait([stdoutDone.future, stderrDone.future]).then((_) {
- if (_processClosed != null) _processClosed();
- if (_cleanup != null) _cleanup();
- if (onClose != null) onClose(exitCode);
+ _processClosedCompleter.complete(exitCode);
});
});
return true;
@@ -256,7 +251,7 @@ class Safari extends Browser {
_logEvent("Got version: $version");
var args = ["'$url'"];
return new Directory('').createTemp().then((userDir) {
- _cleanup = () { userDir.delete(recursive: true); };
+ _cleanup = () { userDir.deleteSync(recursive: true); };
_createLaunchHTML(userDir.path, url);
var args = ["${userDir.path}/launch.html"];
return startBrowser(binary, args);
@@ -292,7 +287,7 @@ class Chrome extends Browser {
_logEvent("Got version: $version");
return new Directory('').createTemp().then((userDir) {
- _cleanup = () { userDir.delete(recursive: true); };
+ _cleanup = () { userDir.deleteSync(recursive: true); };
var args = ["--user-data-dir=${userDir.path}", url,
"--disable-extensions", "--disable-popup-blocking",
"--bwsi", "--no-first-run"];
@@ -409,7 +404,7 @@ class Firefox extends Browser {
return new Directory('').createTemp().then((userDir) {
_createPreferenceFile(userDir.path);
- _cleanup = () { userDir.delete(recursive: true); };
+ _cleanup = () { userDir.deleteSync(recursive: true); };
var args = ["-profile", "${userDir.path}",
"-no-remote", "-new-instance", url];
return startBrowser(binary, args);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698