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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/ResourceUtils.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) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
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 14 matching lines...) Expand all
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 /** 30 /**
31 * @param {string} url 31 * @param {string} url
32 * @return {?SDK.Resource} 32 * @return {?SDK.Resource}
33 */ 33 */
34 Bindings.resourceForURL = function(url) { 34 Bindings.resourceForURL = function(url) {
35 var targets = SDK.targetManager.targets(SDK.Target.Capability.DOM); 35 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel)) {
36 for (var i = 0; i < targets.length; ++i) { 36 var resource = resourceTreeModel.resourceForURL(url);
37 var resource = SDK.ResourceTreeModel.fromTarget(targets[i]).resourceForURL(u rl);
38 if (resource) 37 if (resource)
39 return resource; 38 return resource;
40 } 39 }
41 return null; 40 return null;
42 }; 41 };
43 42
44 /** 43 /**
45 * @param {function(!SDK.Resource)} callback 44 * @param {function(!SDK.Resource)} callback
46 */ 45 */
47 Bindings.forAllResources = function(callback) { 46 Bindings.forAllResources = function(callback) {
48 var targets = SDK.targetManager.targets(SDK.Target.Capability.DOM); 47 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel))
49 for (var i = 0; i < targets.length; ++i) 48 resourceTreeModel.forAllResources(callback);
50 SDK.ResourceTreeModel.fromTarget(targets[i]).forAllResources(callback);
51 }; 49 };
52 50
53 /** 51 /**
54 * @param {string} url 52 * @param {string} url
55 * @return {string} 53 * @return {string}
56 */ 54 */
57 Bindings.displayNameForURL = function(url) { 55 Bindings.displayNameForURL = function(url) {
58 if (!url) 56 if (!url)
59 return ''; 57 return '';
60 58
(...skipping 18 matching lines...) Expand all
79 if (url.startsWith(baseURL)) 77 if (url.startsWith(baseURL))
80 return url.substring(index); 78 return url.substring(index);
81 } 79 }
82 80
83 if (!parsedURL) 81 if (!parsedURL)
84 return url; 82 return url;
85 83
86 var displayName = url.trimURL(parsedURL.host); 84 var displayName = url.trimURL(parsedURL.host);
87 return displayName === '/' ? parsedURL.host + '/' : displayName; 85 return displayName === '/' ? parsedURL.host + '/' : displayName;
88 }; 86 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698