| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @interface | 32 * @interface |
| 33 */ | 33 */ |
| 34 WebInspector.Progress = function() | 34 WebInspector.Progress = function() |
| 35 { | 35 { |
| 36 } | 36 }; |
| 37 | 37 |
| 38 WebInspector.Progress.prototype = { | 38 WebInspector.Progress.prototype = { |
| 39 /** | 39 /** |
| 40 * @param {number} totalWork | 40 * @param {number} totalWork |
| 41 */ | 41 */ |
| 42 setTotalWork: function(totalWork) { }, | 42 setTotalWork: function(totalWork) { }, |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * @param {string} title | 45 * @param {string} title |
| 46 */ | 46 */ |
| 47 setTitle: function(title) { }, | 47 setTitle: function(title) { }, |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * @param {number} worked | 50 * @param {number} worked |
| 51 * @param {string=} title | 51 * @param {string=} title |
| 52 */ | 52 */ |
| 53 setWorked: function(worked, title) { }, | 53 setWorked: function(worked, title) { }, |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * @param {number=} worked | 56 * @param {number=} worked |
| 57 */ | 57 */ |
| 58 worked: function(worked) { }, | 58 worked: function(worked) { }, |
| 59 | 59 |
| 60 done: function() { }, | 60 done: function() { }, |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @return {boolean} | 63 * @return {boolean} |
| 64 */ | 64 */ |
| 65 isCanceled: function() { return false; }, | 65 isCanceled: function() { return false; }, |
| 66 } | 66 }; |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * @constructor | 69 * @constructor |
| 70 * @param {!WebInspector.Progress} parent | 70 * @param {!WebInspector.Progress} parent |
| 71 */ | 71 */ |
| 72 WebInspector.CompositeProgress = function(parent) | 72 WebInspector.CompositeProgress = function(parent) |
| 73 { | 73 { |
| 74 this._parent = parent; | 74 this._parent = parent; |
| 75 this._children = []; | 75 this._children = []; |
| 76 this._childrenDone = 0; | 76 this._childrenDone = 0; |
| 77 this._parent.setTotalWork(1); | 77 this._parent.setTotalWork(1); |
| 78 this._parent.setWorked(0); | 78 this._parent.setWorked(0); |
| 79 } | 79 }; |
| 80 | 80 |
| 81 WebInspector.CompositeProgress.prototype = { | 81 WebInspector.CompositeProgress.prototype = { |
| 82 _childDone: function() | 82 _childDone: function() |
| 83 { | 83 { |
| 84 if (++this._childrenDone !== this._children.length) | 84 if (++this._childrenDone !== this._children.length) |
| 85 return; | 85 return; |
| 86 this._parent.done(); | 86 this._parent.done(); |
| 87 }, | 87 }, |
| 88 | 88 |
| 89 /** | 89 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 103 var done = 0; | 103 var done = 0; |
| 104 | 104 |
| 105 for (var i = 0; i < this._children.length; ++i) { | 105 for (var i = 0; i < this._children.length; ++i) { |
| 106 var child = this._children[i]; | 106 var child = this._children[i]; |
| 107 if (child._totalWork) | 107 if (child._totalWork) |
| 108 done += child._weight * child._worked / child._totalWork; | 108 done += child._weight * child._worked / child._totalWork; |
| 109 totalWeights += child._weight; | 109 totalWeights += child._weight; |
| 110 } | 110 } |
| 111 this._parent.setWorked(done / totalWeights); | 111 this._parent.setWorked(done / totalWeights); |
| 112 } | 112 } |
| 113 } | 113 }; |
| 114 | 114 |
| 115 /** | 115 /** |
| 116 * @constructor | 116 * @constructor |
| 117 * @implements {WebInspector.Progress} | 117 * @implements {WebInspector.Progress} |
| 118 * @param {!WebInspector.CompositeProgress} composite | 118 * @param {!WebInspector.CompositeProgress} composite |
| 119 * @param {number=} weight | 119 * @param {number=} weight |
| 120 */ | 120 */ |
| 121 WebInspector.SubProgress = function(composite, weight) | 121 WebInspector.SubProgress = function(composite, weight) |
| 122 { | 122 { |
| 123 this._composite = composite; | 123 this._composite = composite; |
| 124 this._weight = weight || 1; | 124 this._weight = weight || 1; |
| 125 this._worked = 0; | 125 this._worked = 0; |
| 126 } | 126 }; |
| 127 | 127 |
| 128 WebInspector.SubProgress.prototype = { | 128 WebInspector.SubProgress.prototype = { |
| 129 /** | 129 /** |
| 130 * @override | 130 * @override |
| 131 * @return {boolean} | 131 * @return {boolean} |
| 132 */ | 132 */ |
| 133 isCanceled: function() | 133 isCanceled: function() |
| 134 { | 134 { |
| 135 return this._composite._parent.isCanceled(); | 135 return this._composite._parent.isCanceled(); |
| 136 }, | 136 }, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 }, | 177 }, |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * @override | 180 * @override |
| 181 * @param {number=} worked | 181 * @param {number=} worked |
| 182 */ | 182 */ |
| 183 worked: function(worked) | 183 worked: function(worked) |
| 184 { | 184 { |
| 185 this.setWorked(this._worked + (worked || 1)); | 185 this.setWorked(this._worked + (worked || 1)); |
| 186 } | 186 } |
| 187 } | 187 }; |
| 188 | 188 |
| 189 /** | 189 /** |
| 190 * @constructor | 190 * @constructor |
| 191 * @implements {WebInspector.Progress} | 191 * @implements {WebInspector.Progress} |
| 192 * @param {?WebInspector.Progress} delegate | 192 * @param {?WebInspector.Progress} delegate |
| 193 * @param {function()=} doneCallback | 193 * @param {function()=} doneCallback |
| 194 */ | 194 */ |
| 195 WebInspector.ProgressProxy = function(delegate, doneCallback) | 195 WebInspector.ProgressProxy = function(delegate, doneCallback) |
| 196 { | 196 { |
| 197 this._delegate = delegate; | 197 this._delegate = delegate; |
| 198 this._doneCallback = doneCallback; | 198 this._doneCallback = doneCallback; |
| 199 } | 199 }; |
| 200 | 200 |
| 201 WebInspector.ProgressProxy.prototype = { | 201 WebInspector.ProgressProxy.prototype = { |
| 202 /** | 202 /** |
| 203 * @override | 203 * @override |
| 204 * @return {boolean} | 204 * @return {boolean} |
| 205 */ | 205 */ |
| 206 isCanceled: function() | 206 isCanceled: function() |
| 207 { | 207 { |
| 208 return this._delegate ? this._delegate.isCanceled() : false; | 208 return this._delegate ? this._delegate.isCanceled() : false; |
| 209 }, | 209 }, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 /** | 253 /** |
| 254 * @override | 254 * @override |
| 255 * @param {number=} worked | 255 * @param {number=} worked |
| 256 */ | 256 */ |
| 257 worked: function(worked) | 257 worked: function(worked) |
| 258 { | 258 { |
| 259 if (this._delegate) | 259 if (this._delegate) |
| 260 this._delegate.worked(worked); | 260 this._delegate.worked(worked); |
| 261 } | 261 } |
| 262 } | 262 }; |
| OLD | NEW |