Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library services.refactoring.progress_monitor; | |
| 6 | |
| 7 | |
| 8 /** | |
| 9 * A [ProgressMonitor] which ignores interactions. | |
| 10 */ | |
| 11 class NullProgressMonitor implements ProgressMonitor { | |
|
Brian Wilkerson
2014/08/11 16:27:47
I don't understand the value of a progress monitor
scheglov
2014/08/11 18:06:25
Good point.
We don't need it / not useful in Dart.
| |
| 12 @override | |
| 13 bool get isCanceled => false; | |
| 14 | |
| 15 @override | |
| 16 void beginTask(String name, int totalWork) { | |
| 17 } | |
| 18 | |
| 19 @override | |
| 20 void done() { | |
| 21 } | |
| 22 | |
| 23 @override | |
| 24 void internalWorked(double work) { | |
| 25 } | |
| 26 | |
| 27 @override | |
| 28 void setCanceled() { | |
| 29 } | |
| 30 | |
| 31 @override | |
| 32 void subTask(String name) { | |
| 33 } | |
| 34 | |
| 35 @override | |
| 36 void worked(int work) { | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 | |
| 41 /** | |
| 42 * This exception is thrown when the user cancels a long-running operation. | |
| 43 */ | |
| 44 class OperationCanceledException { | |
| 45 final String message; | |
| 46 OperationCanceledException([this.message = '']); | |
| 47 String toString() => "OperationCanceledException: $message"; | |
| 48 } | |
| 49 | |
| 50 | |
| 51 /** | |
| 52 * An interface for monitoring the progress of an activity. | |
| 53 * Its methods are invoked by code that performs the activity. | |
| 54 */ | |
| 55 abstract class ProgressMonitor { | |
| 56 /** | |
| 57 * Returns whether cancelation of current operation has been requested. | |
| 58 * | |
| 59 * Long-running operations should poll to see if cancelation has been | |
| 60 * requested. | |
| 61 */ | |
| 62 bool get isCanceled; | |
| 63 | |
| 64 /** | |
| 65 * Notifies that the main task is beginning. | |
| 66 * | |
| 67 * This must only be called once on a given progress monitor instance. | |
| 68 */ | |
| 69 void beginTask(String name, int totalWork); | |
| 70 | |
| 71 /** | |
| 72 * Notifies that the main task is completed. | |
| 73 * | |
| 74 * This must only be called once on a given progress monitor instance. | |
| 75 */ | |
| 76 void done(); | |
| 77 | |
| 78 /** | |
| 79 * Internal method to handle scaling correctly. | |
| 80 * | |
| 81 * This method must not be called by a client. | |
| 82 * | |
| 83 * Clients should always use the method [worked]. | |
| 84 * | |
| 85 * [work] - the amount of work done. | |
| 86 */ | |
| 87 void internalWorked(double work); | |
| 88 | |
| 89 /** | |
| 90 * Sets the cancel state to the given value. | |
| 91 */ | |
| 92 void setCanceled(); | |
| 93 | |
| 94 /** | |
| 95 * Notifies that a subtask of the main task is beginning. | |
| 96 * | |
| 97 * Subtasks are optional; the main task might not have subtasks. | |
| 98 * | |
| 99 * [name] - the name (or description) of the subtask. | |
| 100 */ | |
| 101 void subTask(String name); | |
| 102 | |
| 103 /** | |
| 104 * Notifies that a given number of work unit of the main task has been | |
| 105 * completed. | |
| 106 * | |
| 107 * Note that this amount represents an installment, as opposed to a cumulative | |
| 108 * amount of work done to date. | |
| 109 * | |
| 110 * [work] - a non-negative number of work units just completed. | |
| 111 */ | |
| 112 void worked(int work); | |
| 113 } | |
| OLD | NEW |