Chromium Code Reviews| 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)|u ndefined)}>} */ |
|
lushnikov
2016/03/04 05:06:58
null
kozy
2016/03/04 06:13:29
Done.
| |
| 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 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 this._writeNextChunk(); | 294 this._writeNextChunk(); |
| 295 }, | 295 }, |
| 296 | 296 |
| 297 _writeNextChunk: function() | 297 _writeNextChunk: function() |
| 298 { | 298 { |
| 299 // File was deleted while create or write was in-flight. | 299 // File was deleted while create or write was in-flight. |
| 300 if (!this._tempFile) | 300 if (!this._tempFile) |
| 301 return; | 301 return; |
| 302 var chunk = this._chunks.shift(); | 302 var chunk = this._chunks.shift(); |
| 303 this._isWriting = true; | 303 this._isWriting = true; |
| 304 this._tempFile.write(/** @type {!Array.<string>} */(chunk.strings), this ._didWriteChunk.bind(this, chunk.callback)); | 304 this._tempFile.write(/** @type {!Array.<string>} */(chunk.strings), this ._didWriteChunk.bind(this, chunk.callback || null)); |
| 305 }, | 305 }, |
| 306 | 306 |
| 307 /** | 307 /** |
| 308 * @param {?function(number)} callback | 308 * @param {?function(number)} callback |
| 309 * @param {number} size | 309 * @param {number} size |
| 310 */ | 310 */ |
| 311 _didWriteChunk: function(callback, size) | 311 _didWriteChunk: function(callback, size) |
| 312 { | 312 { |
| 313 this._isWriting = false; | 313 this._isWriting = false; |
| 314 if (size === -1) { | 314 if (size === -1) { |
| (...skipping 269 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 |