| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 /** | 77 /** |
| 78 * @override | 78 * @override |
| 79 * @param {!SDK.Target} target | 79 * @param {!SDK.Target} target |
| 80 * @param {!Array.<!SDK.NetworkRequest>} requests | 80 * @param {!Array.<!SDK.NetworkRequest>} requests |
| 81 * @param {!Audits.AuditRuleResult} result | 81 * @param {!Audits.AuditRuleResult} result |
| 82 * @param {function(?Audits.AuditRuleResult)} callback | 82 * @param {function(?Audits.AuditRuleResult)} callback |
| 83 * @param {!Common.Progress} progress | 83 * @param {!Common.Progress} progress |
| 84 */ | 84 */ |
| 85 doRun(target, requests, result, callback, progress) { | 85 doRun(target, requests, result, callback, progress) { |
| 86 var totalSavings = 0; | 86 var totalSavings = 0; |
| 87 var compressedSize = 0; | |
| 88 var candidateSize = 0; | |
| 89 var summary = result.addChild('', true); | 87 var summary = result.addChild('', true); |
| 90 for (var i = 0, length = requests.length; i < length; ++i) { | 88 for (var i = 0, length = requests.length; i < length; ++i) { |
| 91 var request = requests[i]; | 89 var request = requests[i]; |
| 92 if (request.cached() || request.statusCode === 304) | 90 if (request.cached() || request.statusCode === 304) |
| 93 continue; // Do not test cached resources. | 91 continue; // Do not test cached resources. |
| 94 if (this._shouldCompress(request)) { | 92 if (this._shouldCompress(request)) { |
| 95 var size = request.resourceSize; | 93 var size = request.resourceSize; |
| 96 candidateSize += size; | 94 if (this._isCompressed(request)) |
| 97 if (this._isCompressed(request)) { | |
| 98 compressedSize += size; | |
| 99 continue; | 95 continue; |
| 100 } | |
| 101 var savings = 2 * size / 3; | 96 var savings = 2 * size / 3; |
| 102 totalSavings += savings; | 97 totalSavings += savings; |
| 103 summary.addFormatted('%r could save ~%s', request.url, Number.bytesToStr
ing(savings)); | 98 summary.addFormatted('%r could save ~%s', request.url, Number.bytesToStr
ing(savings)); |
| 104 result.violationCount++; | 99 result.violationCount++; |
| 105 } | 100 } |
| 106 } | 101 } |
| 107 if (!totalSavings) { | 102 if (!totalSavings) { |
| 108 callback(null); | 103 callback(null); |
| 109 return; | 104 return; |
| 110 } | 105 } |
| (...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 Number.bytesToString(cookieBytes)), | 1473 Number.bytesToString(cookieBytes)), |
| 1479 true); | 1474 true); |
| 1480 entry.addURLs(badUrls); | 1475 entry.addURLs(badUrls); |
| 1481 result.violationCount = badUrls.length; | 1476 result.violationCount = badUrls.length; |
| 1482 } | 1477 } |
| 1483 | 1478 |
| 1484 _collectorCallback(matchingResourceData, request, cookie) { | 1479 _collectorCallback(matchingResourceData, request, cookie) { |
| 1485 matchingResourceData[request.url] = (matchingResourceData[request.url] || 0)
+ cookie.size(); | 1480 matchingResourceData[request.url] = (matchingResourceData[request.url] || 0)
+ cookie.size(); |
| 1486 } | 1481 } |
| 1487 }; | 1482 }; |
| OLD | NEW |