| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #library("drt_updater"); | 5 #library("drt_updater"); |
| 6 | 6 |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 #import("dart:builtin"); | 8 #import("dart:builtin"); |
| 9 | 9 |
| 10 class _DartiumUpdater { | 10 class _DartiumUpdater { |
| 11 String name; | 11 String name; |
| 12 String script; | 12 String script; |
| 13 String option; | 13 String option; |
| 14 | 14 |
| 15 bool isActive = false; | 15 bool isActive = false; |
| 16 bool updated = false; | 16 bool updated = false; |
| 17 List onUpdated; | 17 List onUpdated; |
| 18 | 18 |
| 19 Process _updatingProcess; | 19 Process _updatingProcess; |
| 20 | 20 |
| 21 _DartiumUpdater(this.name, this.script, [this.option = null]); | 21 _DartiumUpdater(this.name, this.script, [this.option = null]); |
| 22 | 22 |
| 23 void update() { | 23 void update() { |
| 24 if (!isActive) { | 24 if (!isActive) { |
| 25 isActive = true; | 25 isActive = true; |
| 26 print('Updating $name.'); | 26 print('Updating $name.'); |
| 27 onUpdated = [() {updated = true;} ]; | 27 onUpdated = [() {updated = true;} ]; |
| 28 _updatingProcess = new Process.start('python', _getUpdateCommand); | 28 _updatingProcess = Process.start('python', _getUpdateCommand); |
| 29 _updatingProcess.onExit = _onUpdatedHandler; | 29 _updatingProcess.onExit = _onUpdatedHandler; |
| 30 _updatingProcess.onError = (error) { | 30 _updatingProcess.onError = (error) { |
| 31 print("Error starting $script process: $error"); | 31 print("Error starting $script process: $error"); |
| 32 _onUpdatedHandler(-1); // Continue anyway. | 32 _onUpdatedHandler(-1); // Continue anyway. |
| 33 }; | 33 }; |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 List<String> get _getUpdateCommand() { | 37 List<String> get _getUpdateCommand() { |
| 38 String scriptPath = new Options().script.replaceAll('\\', '/'); | 38 String scriptPath = new Options().script.replaceAll('\\', '/'); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 66 // Download the default Dartium from Google Storage. | 66 // Download the default Dartium from Google Storage. |
| 67 if (_dartiumUpdater === null) { | 67 if (_dartiumUpdater === null) { |
| 68 _dartiumUpdater = new _DartiumUpdater('Dartium Chrome', 'get_drt.py', | 68 _dartiumUpdater = new _DartiumUpdater('Dartium Chrome', 'get_drt.py', |
| 69 '--dartium'); | 69 '--dartium'); |
| 70 } | 70 } |
| 71 return _dartiumUpdater; | 71 return _dartiumUpdater; |
| 72 } else { | 72 } else { |
| 73 return null; | 73 return null; |
| 74 } | 74 } |
| 75 } | 75 } |
| OLD | NEW |