OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 set resourceSize(x) | 243 set resourceSize(x) |
244 { | 244 { |
245 this._resourceSize = x; | 245 this._resourceSize = x; |
246 }, | 246 }, |
247 | 247 |
248 /** | 248 /** |
249 * @return {number} | 249 * @return {number} |
250 */ | 250 */ |
251 get transferSize() | 251 get transferSize() |
252 { | 252 { |
253 if (typeof this._transferSize === "number") | 253 return this._transferSize || 0; |
254 return this._transferSize; | |
255 if (this.statusCode === 304) // Not modified | |
256 return this.responseHeadersSize; | |
257 if (this._cached) | |
258 return 0; | |
259 // If we did not receive actual transfer size from network | |
260 // stack, we prefer using Content-Length over resourceSize as | |
261 // resourceSize may differ from actual transfer size if platform's | |
262 // network stack performed decoding (e.g. gzip decompression). | |
263 // The Content-Length, though, is expected to come from raw | |
264 // response headers and will reflect actual transfer length. | |
265 // This won't work for chunked content encoding, so fall back to | |
266 // resourceSize when we don't have Content-Length. This still won't | |
267 // work for chunks with non-trivial encodings. We need a way to | |
268 // get actual transfer size from the network stack. | |
269 var bodySize = Number(this.responseHeaderValue("Content-Length") || this
.resourceSize); | |
270 return this.responseHeadersSize + bodySize; | |
271 }, | 254 }, |
272 | 255 |
273 /** | 256 /** |
274 * @param {number} x | 257 * @param {number} x |
275 */ | 258 */ |
276 increaseTransferSize: function(x) | 259 increaseTransferSize: function(x) |
277 { | 260 { |
278 this._transferSize = (this._transferSize || 0) + x; | 261 this._transferSize = (this._transferSize || 0) + x; |
279 }, | 262 }, |
280 | 263 |
281 /** | 264 /** |
| 265 * @param {number} x |
| 266 */ |
| 267 setTransferSize: function(x) |
| 268 { |
| 269 this._transferSize = x; |
| 270 }, |
| 271 |
| 272 /** |
282 * @return {boolean} | 273 * @return {boolean} |
283 */ | 274 */ |
284 get finished() | 275 get finished() |
285 { | 276 { |
286 return this._finished; | 277 return this._finished; |
287 }, | 278 }, |
288 | 279 |
289 set finished(x) | 280 set finished(x) |
290 { | 281 { |
291 if (this._finished === x) | 282 if (this._finished === x) |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 */ | 968 */ |
978 _pushFrame: function(frameOrError) | 969 _pushFrame: function(frameOrError) |
979 { | 970 { |
980 if (this._frames.length >= 100) | 971 if (this._frames.length >= 100) |
981 this._frames.splice(0, 10); | 972 this._frames.splice(0, 10); |
982 this._frames.push(frameOrError); | 973 this._frames.push(frameOrError); |
983 }, | 974 }, |
984 | 975 |
985 __proto__: WebInspector.Object.prototype | 976 __proto__: WebInspector.Object.prototype |
986 } | 977 } |
OLD | NEW |