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 21 matching lines...) Expand all Loading... |
32 * @unrestricted | 32 * @unrestricted |
33 */ | 33 */ |
34 Network.HARWriter = class { | 34 Network.HARWriter = class { |
35 /** | 35 /** |
36 * @param {!Common.OutputStream} stream | 36 * @param {!Common.OutputStream} stream |
37 * @param {!Array.<!SDK.NetworkRequest>} requests | 37 * @param {!Array.<!SDK.NetworkRequest>} requests |
38 * @param {!Common.Progress} progress | 38 * @param {!Common.Progress} progress |
39 */ | 39 */ |
40 write(stream, requests, progress) { | 40 write(stream, requests, progress) { |
41 this._stream = stream; | 41 this._stream = stream; |
42 this._harLog = (new SDK.HARLog(requests)).build(); | 42 this._harLog = (new NetworkLog.HARLog(requests)).build(); |
43 this._pendingRequests = 1; // Guard against completing resource transfer be
fore all requests are made. | 43 this._pendingRequests = 1; // Guard against completing resource transfer be
fore all requests are made. |
44 var entries = this._harLog.entries; | 44 var entries = this._harLog.entries; |
45 for (var i = 0; i < entries.length; ++i) { | 45 for (var i = 0; i < entries.length; ++i) { |
46 var content = requests[i].content; | 46 var content = requests[i].content; |
47 if (typeof content === 'undefined' && requests[i].finished) { | 47 if (typeof content === 'undefined' && requests[i].finished) { |
48 ++this._pendingRequests; | 48 ++this._pendingRequests; |
49 requests[i].requestContent().then(this._onContentAvailable.bind(this, en
tries[i], requests[i])); | 49 requests[i].requestContent().then(this._onContentAvailable.bind(this, en
tries[i], requests[i])); |
50 } else if (content !== null) { | 50 } else if (content !== null) { |
51 this._setEntryContent(entries[i], requests[i]); | 51 this._setEntryContent(entries[i], requests[i]); |
52 } | 52 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 this._writeProgress.done(); | 107 this._writeProgress.done(); |
108 return; | 108 return; |
109 } | 109 } |
110 const chunkSize = 100000; | 110 const chunkSize = 100000; |
111 var text = this._text.substring(this._bytesWritten, this._bytesWritten + chu
nkSize); | 111 var text = this._text.substring(this._bytesWritten, this._bytesWritten + chu
nkSize); |
112 this._bytesWritten += text.length; | 112 this._bytesWritten += text.length; |
113 stream.write(text, this._writeNextChunk.bind(this)); | 113 stream.write(text, this._writeNextChunk.bind(this)); |
114 this._writeProgress.setWorked(this._bytesWritten); | 114 this._writeProgress.setWorked(this._bytesWritten); |
115 } | 115 } |
116 }; | 116 }; |
OLD | NEW |