| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 /** | 229 /** |
| 230 * @constructor | 230 * @constructor |
| 231 * @param {string} dirPath | 231 * @param {string} dirPath |
| 232 * @param {string} name | 232 * @param {string} name |
| 233 */ | 233 */ |
| 234 WebInspector.DeferredTempFile = function(dirPath, name) | 234 WebInspector.DeferredTempFile = function(dirPath, name) |
| 235 { | 235 { |
| 236 /** @type {!Array.<!{strings: !Array.<string>, callback: function(number)}>}
*/ | 236 /** @type {!Array.<!{strings: !Array.<string>, callback: ?function(number)}>
} */ |
| 237 this._chunks = []; | 237 this._chunks = []; |
| 238 this._tempFile = null; | 238 this._tempFile = null; |
| 239 this._isWriting = false; | 239 this._isWriting = false; |
| 240 this._finishCallback = null; | 240 this._finishCallback = null; |
| 241 this._finishedWriting = false; | 241 this._finishedWriting = false; |
| 242 this._callsPendingOpen = []; | 242 this._callsPendingOpen = []; |
| 243 this._pendingReads = []; | 243 this._pendingReads = []; |
| 244 WebInspector.TempFile.create(dirPath, name) | 244 WebInspector.TempFile.create(dirPath, name) |
| 245 .then(this._didCreateTempFile.bind(this), this._failedToCreateTempFile.b
ind(this)); | 245 .then(this._didCreateTempFile.bind(this), this._failedToCreateTempFile.b
ind(this)); |
| 246 } | 246 } |
| 247 | 247 |
| 248 WebInspector.DeferredTempFile.prototype = { | 248 WebInspector.DeferredTempFile.prototype = { |
| 249 /** | 249 /** |
| 250 * @param {!Array.<string>} strings | 250 * @param {!Array.<string>} strings |
| 251 * @param {function(number)=} callback | 251 * @param {function(number)=} callback |
| 252 */ | 252 */ |
| 253 write: function(strings, callback) | 253 write: function(strings, callback) |
| 254 { | 254 { |
| 255 if (this._finishCallback) | 255 if (this._finishCallback) |
| 256 throw new Error("No writes are allowed after close."); | 256 throw new Error("No writes are allowed after close."); |
| 257 this._chunks.push({strings: strings, callback: callback}); | 257 this._chunks.push({strings: strings, callback: callback || null}); |
| 258 if (this._tempFile && !this._isWriting) | 258 if (this._tempFile && !this._isWriting) |
| 259 this._writeNextChunk(); | 259 this._writeNextChunk(); |
| 260 }, | 260 }, |
| 261 | 261 |
| 262 /** | 262 /** |
| 263 * @param {function(?WebInspector.TempFile)} callback | 263 * @param {function(?WebInspector.TempFile)} callback |
| 264 */ | 264 */ |
| 265 finishWriting: function(callback) | 265 finishWriting: function(callback) |
| 266 { | 266 { |
| 267 this._finishCallback = callback; | 267 this._finishCallback = callback; |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 584 |
| 585 /** | 585 /** |
| 586 * @param {!WebInspector.OutputStream} outputStream | 586 * @param {!WebInspector.OutputStream} outputStream |
| 587 * @param {!WebInspector.OutputStreamDelegate} delegate | 587 * @param {!WebInspector.OutputStreamDelegate} delegate |
| 588 */ | 588 */ |
| 589 writeToStream: function(outputStream, delegate) | 589 writeToStream: function(outputStream, delegate) |
| 590 { | 590 { |
| 591 this._file.copyToOutputStream(outputStream, delegate); | 591 this._file.copyToOutputStream(outputStream, delegate); |
| 592 } | 592 } |
| 593 } | 593 } |
| OLD | NEW |