Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1182)

Unified Diff: Source/devtools/front_end/TempFile.js

Issue 132993009: Use mock temp file in profiler tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comment Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/HeapSnapshotView.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/TempFile.js
diff --git a/Source/devtools/front_end/TempFile.js b/Source/devtools/front_end/TempFile.js
index d864a4ffe48dfa866a5135b9f8957f12f2f6da6e..2c2bcd4e2b9dd28e2e6b96951038c6eafdda95e5 100644
--- a/Source/devtools/front_end/TempFile.js
+++ b/Source/devtools/front_end/TempFile.js
@@ -182,17 +182,27 @@ WebInspector.TempFile.prototype = {
},
/**
- * @param {!function(?File)} callback
+ * @param {!WebInspector.OutputStream} outputStream
+ * @param {!WebInspector.OutputStreamDelegate} delegate
*/
- getFile: function(callback)
+ writeToOutputSteam: function(outputStream, delegate)
{
+ /**
+ * @param {!File} file
+ * @this {WebInspector.TempFile}
+ */
+ function didGetFile(file)
+ {
+ var reader = new WebInspector.ChunkedFileReader(file, 10*1000*1000, delegate);
+ reader.start(outputStream);
+ }
function didFailToGetFile(error)
{
WebInspector.log("Failed to load temp file: " + error.message,
- WebInspector.ConsoleMessage.MessageLevel.Error);
- callback(null);
+ WebInspector.ConsoleMessage.MessageLevel.Error);
+ outputStream.close();
}
- this._fileEntry.file(callback, didFailToGetFile.bind(this));
+ this._fileEntry.file(didGetFile.bind(this), didFailToGetFile.bind(this));
},
remove: function()
@@ -240,6 +250,8 @@ WebInspector.BufferedTempFileWriter.prototype = {
this._finishCallback = callback;
if (this._isFinished)
callback(this._tempFile);
+ else if (!this._isWriting && !this._chunks.length)
+ this._notifyFinished();
},
_didCreateTempFile: function(tempFile)
@@ -265,8 +277,8 @@ WebInspector.BufferedTempFileWriter.prototype = {
}
var chunk = this._chunks.slice(0, endIndex + 1).join("");
this._chunks.splice(0, endIndex + 1);
- this._tempFile.write(chunk, this._didWriteChunk.bind(this));
this._isWriting = true;
+ this._tempFile.write(chunk, this._didWriteChunk.bind(this));
},
_didWriteChunk: function(success)
« no previous file with comments | « Source/devtools/front_end/HeapSnapshotView.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698