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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/audits/AuditRules.js

Issue 2782773002: [DevTools] Remove SDKModels' fromTarget methods (Closed)
Patch Set: addressed review comments Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 946
947 /** 947 /**
948 * @override 948 * @override
949 * @param {!SDK.Target} target 949 * @param {!SDK.Target} target
950 * @param {!Array.<!SDK.NetworkRequest>} requests 950 * @param {!Array.<!SDK.NetworkRequest>} requests
951 * @param {!Audits.AuditRuleResult} result 951 * @param {!Audits.AuditRuleResult} result
952 * @param {function(?Audits.AuditRuleResult)} callback 952 * @param {function(?Audits.AuditRuleResult)} callback
953 * @param {!Common.Progress} progress 953 * @param {!Common.Progress} progress
954 */ 954 */
955 doRun(target, requests, result, callback, progress) { 955 doRun(target, requests, result, callback, progress) {
956 var domModel = SDK.DOMModel.fromTarget(target); 956 var domModel = target.model(SDK.DOMModel);
957 if (!domModel) { 957 if (!domModel) {
958 callback(null); 958 callback(null);
959 return; 959 return;
960 } 960 }
961 961
962 function evalCallback(evalResult) { 962 function evalCallback(evalResult) {
963 if (progress.isCanceled()) { 963 if (progress.isCanceled()) {
964 callback(null); 964 callback(null);
965 return; 965 return;
966 } 966 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 1057
1058 /** 1058 /**
1059 * @override 1059 * @override
1060 * @param {!SDK.Target} target 1060 * @param {!SDK.Target} target
1061 * @param {!Array.<!SDK.NetworkRequest>} requests 1061 * @param {!Array.<!SDK.NetworkRequest>} requests
1062 * @param {!Audits.AuditRuleResult} result 1062 * @param {!Audits.AuditRuleResult} result
1063 * @param {function(?Audits.AuditRuleResult)} callback 1063 * @param {function(?Audits.AuditRuleResult)} callback
1064 * @param {!Common.Progress} progress 1064 * @param {!Common.Progress} progress
1065 */ 1065 */
1066 doRun(target, requests, result, callback, progress) { 1066 doRun(target, requests, result, callback, progress) {
1067 var domModel = SDK.DOMModel.fromTarget(target); 1067 var domModel = target.model(SDK.DOMModel);
1068 if (!domModel) { 1068 if (!domModel) {
1069 callback(null); 1069 callback(null);
1070 return; 1070 return;
1071 } 1071 }
1072 1072
1073 function evalCallback(resultValue) { 1073 function evalCallback(resultValue) {
1074 if (progress.isCanceled()) { 1074 if (progress.isCanceled()) {
1075 callback(null); 1075 callback(null);
1076 return; 1076 return;
1077 } 1077 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 if (progress.isCanceled()) { 1308 if (progress.isCanceled()) {
1309 callback(result); 1309 callback(result);
1310 return; 1310 return;
1311 } 1311 }
1312 1312
1313 self.processCookies(receivedCookies, requests, result); 1313 self.processCookies(receivedCookies, requests, result);
1314 callback(result); 1314 callback(result);
1315 } 1315 }
1316 1316
1317 const nonDataUrls = requests.map(r => r.url()).filter(url => url && url.asPa rsedURL()); 1317 const nonDataUrls = requests.map(r => r.url()).filter(url => url && url.asPa rsedURL());
1318 SDK.CookieModel.fromTarget(target).getCookiesAsync(nonDataUrls, resultCallba ck); 1318 var cookieModel = target.model(SDK.CookieModel);
1319 if (cookieModel)
1320 cookieModel.getCookiesAsync(nonDataUrls, resultCallback);
1321 else
1322 callback(result);
1319 } 1323 }
1320 1324
1321 mapResourceCookies(requestsByDomain, allCookies, callback) { 1325 mapResourceCookies(requestsByDomain, allCookies, callback) {
1322 for (var i = 0; i < allCookies.length; ++i) { 1326 for (var i = 0; i < allCookies.length; ++i) {
1323 for (var requestDomain in requestsByDomain) { 1327 for (var requestDomain in requestsByDomain) {
1324 if (SDK.CookieModel.cookieDomainMatchesResourceDomain(allCookies[i].doma in(), requestDomain)) 1328 if (SDK.CookieModel.cookieDomainMatchesResourceDomain(allCookies[i].doma in(), requestDomain))
1325 this._callbackForResourceCookiePairs(requestsByDomain[requestDomain], allCookies[i], callback); 1329 this._callbackForResourceCookiePairs(requestsByDomain[requestDomain], allCookies[i], callback);
1326 } 1330 }
1327 } 1331 }
1328 } 1332 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 1487
1484 /** 1488 /**
1485 * @param {!Object<string, number>} matchingResourceData 1489 * @param {!Object<string, number>} matchingResourceData
1486 * @param {!SDK.NetworkRequest} request 1490 * @param {!SDK.NetworkRequest} request
1487 * @param {!SDK.Cookie} cookie 1491 * @param {!SDK.Cookie} cookie
1488 */ 1492 */
1489 _collectorCallback(matchingResourceData, request, cookie) { 1493 _collectorCallback(matchingResourceData, request, cookie) {
1490 matchingResourceData[request.url()] = (matchingResourceData[request.url()] | | 0) + cookie.size(); 1494 matchingResourceData[request.url()] = (matchingResourceData[request.url()] | | 0) + cookie.size();
1491 } 1495 }
1492 }; 1496 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698