OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> | 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> |
4 * Copyright (C) 2011 Google Inc. All rights reserved. | 4 * Copyright (C) 2011 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 write: function(stream, requests, progress) | 44 write: function(stream, requests, progress) |
45 { | 45 { |
46 this._stream = stream; | 46 this._stream = stream; |
47 this._harLog = (new WebInspector.HARLog(requests)).build(); | 47 this._harLog = (new WebInspector.HARLog(requests)).build(); |
48 this._pendingRequests = 1; // Guard against completing resource transfer
before all requests are made. | 48 this._pendingRequests = 1; // Guard against completing resource transfer
before all requests are made. |
49 var entries = this._harLog.entries; | 49 var entries = this._harLog.entries; |
50 for (var i = 0; i < entries.length; ++i) { | 50 for (var i = 0; i < entries.length; ++i) { |
51 var content = requests[i].content; | 51 var content = requests[i].content; |
52 if (typeof content === "undefined" && requests[i].finished) { | 52 if (typeof content === "undefined" && requests[i].finished) { |
53 ++this._pendingRequests; | 53 ++this._pendingRequests; |
54 requests[i].requestContent(this._onContentAvailable.bind(this, e
ntries[i], requests[i])); | 54 requests[i].requestContent().then(this._onContentAvailable.bind(
this, entries[i], requests[i])); |
55 } else if (content !== null) | 55 } else if (content !== null) |
56 this._setEntryContent(entries[i], requests[i]); | 56 this._setEntryContent(entries[i], requests[i]); |
57 } | 57 } |
58 var compositeProgress = new WebInspector.CompositeProgress(progress); | 58 var compositeProgress = new WebInspector.CompositeProgress(progress); |
59 this._writeProgress = compositeProgress.createSubProgress(); | 59 this._writeProgress = compositeProgress.createSubProgress(); |
60 if (--this._pendingRequests) { | 60 if (--this._pendingRequests) { |
61 this._requestsProgress = compositeProgress.createSubProgress(); | 61 this._requestsProgress = compositeProgress.createSubProgress(); |
62 this._requestsProgress.setTitle(WebInspector.UIString("Collecting co
ntent…")); | 62 this._requestsProgress.setTitle(WebInspector.UIString("Collecting co
ntent…")); |
63 this._requestsProgress.setTotalWork(this._pendingRequests); | 63 this._requestsProgress.setTotalWork(this._pendingRequests); |
64 } else | 64 } else |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 this._writeProgress.done(); | 114 this._writeProgress.done(); |
115 return; | 115 return; |
116 } | 116 } |
117 const chunkSize = 100000; | 117 const chunkSize = 100000; |
118 var text = this._text.substring(this._bytesWritten, this._bytesWritten +
chunkSize); | 118 var text = this._text.substring(this._bytesWritten, this._bytesWritten +
chunkSize); |
119 this._bytesWritten += text.length; | 119 this._bytesWritten += text.length; |
120 stream.write(text, this._writeNextChunk.bind(this)); | 120 stream.write(text, this._writeNextChunk.bind(this)); |
121 this._writeProgress.setWorked(this._bytesWritten); | 121 this._writeProgress.setWorked(this._bytesWritten); |
122 } | 122 } |
123 } | 123 } |
OLD | NEW |