| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 * @param {!WebInspector.Progress} parent | 83 * @param {!WebInspector.Progress} parent |
| 84 * @extends {WebInspector.Object} | 84 * @extends {WebInspector.Object} |
| 85 */ | 85 */ |
| 86 WebInspector.CompositeProgress = function(parent) | 86 WebInspector.CompositeProgress = function(parent) |
| 87 { | 87 { |
| 88 this._parent = parent; | 88 this._parent = parent; |
| 89 this._children = []; | 89 this._children = []; |
| 90 this._childrenDone = 0; | 90 this._childrenDone = 0; |
| 91 this._parent.setTotalWork(1); | 91 this._parent.setTotalWork(1); |
| 92 this._parent.setWorked(0); | 92 this._parent.setWorked(0); |
| 93 // FIXME: there should be no "progress events" |
| 93 parent.addEventListener(WebInspector.Progress.Events.Canceled, this._parentC
anceled.bind(this)); | 94 parent.addEventListener(WebInspector.Progress.Events.Canceled, this._parentC
anceled.bind(this)); |
| 94 } | 95 } |
| 95 | 96 |
| 96 WebInspector.CompositeProgress.prototype = { | 97 WebInspector.CompositeProgress.prototype = { |
| 97 _childDone: function() | 98 _childDone: function() |
| 98 { | 99 { |
| 99 if (++this._childrenDone !== this._children.length) | 100 if (++this._childrenDone !== this._children.length) |
| 100 return; | 101 return; |
| 101 this.dispatchEventToListeners(WebInspector.Progress.Events.Done); | 102 this.dispatchEventToListeners(WebInspector.Progress.Events.Done); |
| 102 this._parent.done(); | 103 this._parent.done(); |
| 103 }, | 104 }, |
| 104 | 105 |
| 105 _parentCanceled: function() | 106 _parentCanceled: function() |
| 106 { | 107 { |
| 108 // FIXME: there should be no "progress events" |
| 107 this.dispatchEventToListeners(WebInspector.Progress.Events.Canceled); | 109 this.dispatchEventToListeners(WebInspector.Progress.Events.Canceled); |
| 108 for (var i = 0; i < this._children.length; ++i) { | 110 for (var i = 0; i < this._children.length; ++i) { |
| 109 this._children[i].dispatchEventToListeners(WebInspector.Progress.Eve
nts.Canceled); | 111 this._children[i].dispatchEventToListeners(WebInspector.Progress.Eve
nts.Canceled); |
| 110 } | 112 } |
| 111 }, | 113 }, |
| 112 | 114 |
| 113 /** | 115 /** |
| 114 * @param {number=} weight | 116 * @param {number=} weight |
| 115 * @return {!WebInspector.SubProgress} | 117 * @return {!WebInspector.SubProgress} |
| 116 */ | 118 */ |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 this._composite._parent.setTitle(title); | 173 this._composite._parent.setTitle(title); |
| 172 }, | 174 }, |
| 173 | 175 |
| 174 /** | 176 /** |
| 175 * @override | 177 * @override |
| 176 */ | 178 */ |
| 177 done: function() | 179 done: function() |
| 178 { | 180 { |
| 179 this.setWorked(this._totalWork); | 181 this.setWorked(this._totalWork); |
| 180 this._composite._childDone(); | 182 this._composite._childDone(); |
| 183 // FIXME: there should be no "progress events" |
| 181 this.dispatchEventToListeners(WebInspector.Progress.Events.Done); | 184 this.dispatchEventToListeners(WebInspector.Progress.Events.Done); |
| 182 }, | 185 }, |
| 183 | 186 |
| 184 /** | 187 /** |
| 185 * @override | 188 * @override |
| 186 * @param {number} totalWork | 189 * @param {number} totalWork |
| 187 */ | 190 */ |
| 188 setTotalWork: function(totalWork) | 191 setTotalWork: function(totalWork) |
| 189 { | 192 { |
| 190 this._totalWork = totalWork; | 193 this._totalWork = totalWork; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 208 * @override | 211 * @override |
| 209 * @param {number=} worked | 212 * @param {number=} worked |
| 210 */ | 213 */ |
| 211 worked: function(worked) | 214 worked: function(worked) |
| 212 { | 215 { |
| 213 this.setWorked(this._worked + (worked || 1)); | 216 this.setWorked(this._worked + (worked || 1)); |
| 214 }, | 217 }, |
| 215 | 218 |
| 216 __proto__: WebInspector.Object.prototype | 219 __proto__: WebInspector.Object.prototype |
| 217 } | 220 } |
| 221 |
| 222 /** |
| 223 * @constructor |
| 224 * @extends {WebInspector.Object} |
| 225 * @implements {WebInspector.Progress} |
| 226 */ |
| 227 WebInspector.ProgressStub = function() |
| 228 { |
| 229 } |
| 230 |
| 231 WebInspector.ProgressStub.prototype = { |
| 232 /** |
| 233 * @override |
| 234 * @return {boolean} |
| 235 */ |
| 236 isCanceled: function() |
| 237 { |
| 238 return false; |
| 239 }, |
| 240 |
| 241 /** |
| 242 * @override |
| 243 * @param {string} title |
| 244 */ |
| 245 setTitle: function(title) |
| 246 { |
| 247 }, |
| 248 |
| 249 /** |
| 250 * @override |
| 251 */ |
| 252 done: function() |
| 253 { |
| 254 }, |
| 255 |
| 256 /** |
| 257 * @override |
| 258 * @param {number} totalWork |
| 259 */ |
| 260 setTotalWork: function(totalWork) |
| 261 { |
| 262 }, |
| 263 |
| 264 /** |
| 265 * @override |
| 266 * @param {number} worked |
| 267 * @param {string=} title |
| 268 */ |
| 269 setWorked: function(worked, title) |
| 270 { |
| 271 }, |
| 272 |
| 273 /** |
| 274 * @override |
| 275 * @param {number=} worked |
| 276 */ |
| 277 worked: function(worked) |
| 278 { |
| 279 }, |
| 280 |
| 281 __proto__: WebInspector.Object.prototype |
| 282 } |
| OLD | NEW |