| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 * @interface | 31 * @interface |
| 32 */ | 32 */ |
| 33 WebInspector.Progress = function() {}; | 33 Common.Progress = function() {}; |
| 34 | 34 |
| 35 WebInspector.Progress.prototype = { | 35 Common.Progress.prototype = { |
| 36 /** | 36 /** |
| 37 * @param {number} totalWork | 37 * @param {number} totalWork |
| 38 */ | 38 */ |
| 39 setTotalWork: function(totalWork) {}, | 39 setTotalWork: function(totalWork) {}, |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * @param {string} title | 42 * @param {string} title |
| 43 */ | 43 */ |
| 44 setTitle: function(title) {}, | 44 setTitle: function(title) {}, |
| 45 | 45 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 60 * @return {boolean} | 60 * @return {boolean} |
| 61 */ | 61 */ |
| 62 isCanceled: function() { | 62 isCanceled: function() { |
| 63 return false; | 63 return false; |
| 64 }, | 64 }, |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * @unrestricted | 68 * @unrestricted |
| 69 */ | 69 */ |
| 70 WebInspector.CompositeProgress = class { | 70 Common.CompositeProgress = class { |
| 71 /** | 71 /** |
| 72 * @param {!WebInspector.Progress} parent | 72 * @param {!Common.Progress} parent |
| 73 */ | 73 */ |
| 74 constructor(parent) { | 74 constructor(parent) { |
| 75 this._parent = parent; | 75 this._parent = parent; |
| 76 this._children = []; | 76 this._children = []; |
| 77 this._childrenDone = 0; | 77 this._childrenDone = 0; |
| 78 this._parent.setTotalWork(1); | 78 this._parent.setTotalWork(1); |
| 79 this._parent.setWorked(0); | 79 this._parent.setWorked(0); |
| 80 } | 80 } |
| 81 | 81 |
| 82 _childDone() { | 82 _childDone() { |
| 83 if (++this._childrenDone !== this._children.length) | 83 if (++this._childrenDone !== this._children.length) |
| 84 return; | 84 return; |
| 85 this._parent.done(); | 85 this._parent.done(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @param {number=} weight | 89 * @param {number=} weight |
| 90 * @return {!WebInspector.SubProgress} | 90 * @return {!Common.SubProgress} |
| 91 */ | 91 */ |
| 92 createSubProgress(weight) { | 92 createSubProgress(weight) { |
| 93 var child = new WebInspector.SubProgress(this, weight); | 93 var child = new Common.SubProgress(this, weight); |
| 94 this._children.push(child); | 94 this._children.push(child); |
| 95 return child; | 95 return child; |
| 96 } | 96 } |
| 97 | 97 |
| 98 _update() { | 98 _update() { |
| 99 var totalWeights = 0; | 99 var totalWeights = 0; |
| 100 var done = 0; | 100 var done = 0; |
| 101 | 101 |
| 102 for (var i = 0; i < this._children.length; ++i) { | 102 for (var i = 0; i < this._children.length; ++i) { |
| 103 var child = this._children[i]; | 103 var child = this._children[i]; |
| 104 if (child._totalWork) | 104 if (child._totalWork) |
| 105 done += child._weight * child._worked / child._totalWork; | 105 done += child._weight * child._worked / child._totalWork; |
| 106 totalWeights += child._weight; | 106 totalWeights += child._weight; |
| 107 } | 107 } |
| 108 this._parent.setWorked(done / totalWeights); | 108 this._parent.setWorked(done / totalWeights); |
| 109 } | 109 } |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 /** | 112 /** |
| 113 * @implements {WebInspector.Progress} | 113 * @implements {Common.Progress} |
| 114 * @unrestricted | 114 * @unrestricted |
| 115 */ | 115 */ |
| 116 WebInspector.SubProgress = class { | 116 Common.SubProgress = class { |
| 117 /** | 117 /** |
| 118 * @param {!WebInspector.CompositeProgress} composite | 118 * @param {!Common.CompositeProgress} composite |
| 119 * @param {number=} weight | 119 * @param {number=} weight |
| 120 */ | 120 */ |
| 121 constructor(composite, weight) { | 121 constructor(composite, weight) { |
| 122 this._composite = composite; | 122 this._composite = composite; |
| 123 this._weight = weight || 1; | 123 this._weight = weight || 1; |
| 124 this._worked = 0; | 124 this._worked = 0; |
| 125 } | 125 } |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * @override | 128 * @override |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 /** | 172 /** |
| 173 * @override | 173 * @override |
| 174 * @param {number=} worked | 174 * @param {number=} worked |
| 175 */ | 175 */ |
| 176 worked(worked) { | 176 worked(worked) { |
| 177 this.setWorked(this._worked + (worked || 1)); | 177 this.setWorked(this._worked + (worked || 1)); |
| 178 } | 178 } |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 /** | 181 /** |
| 182 * @implements {WebInspector.Progress} | 182 * @implements {Common.Progress} |
| 183 * @unrestricted | 183 * @unrestricted |
| 184 */ | 184 */ |
| 185 WebInspector.ProgressProxy = class { | 185 Common.ProgressProxy = class { |
| 186 /** | 186 /** |
| 187 * @param {?WebInspector.Progress} delegate | 187 * @param {?Common.Progress} delegate |
| 188 * @param {function()=} doneCallback | 188 * @param {function()=} doneCallback |
| 189 */ | 189 */ |
| 190 constructor(delegate, doneCallback) { | 190 constructor(delegate, doneCallback) { |
| 191 this._delegate = delegate; | 191 this._delegate = delegate; |
| 192 this._doneCallback = doneCallback; | 192 this._doneCallback = doneCallback; |
| 193 } | 193 } |
| 194 | 194 |
| 195 /** | 195 /** |
| 196 * @override | 196 * @override |
| 197 * @return {boolean} | 197 * @return {boolean} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * @override | 242 * @override |
| 243 * @param {number=} worked | 243 * @param {number=} worked |
| 244 */ | 244 */ |
| 245 worked(worked) { | 245 worked(worked) { |
| 246 if (this._delegate) | 246 if (this._delegate) |
| 247 this._delegate.worked(worked); | 247 this._delegate.worked(worked); |
| 248 } | 248 } |
| 249 }; | 249 }; |
| OLD | NEW |