OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/test/content_browser_test_utils_internal.h" | 5 #include "content/test/content_browser_test_utils_internal.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Traversal 3: Assign names to the proxies and add them to |legend| too. | 80 // Traversal 3: Assign names to the proxies and add them to |legend| too. |
81 // Typically, only openers should have their names assigned this way. | 81 // Typically, only openers should have their names assigned this way. |
82 for (to_explore.push(root); !to_explore.empty();) { | 82 for (to_explore.push(root); !to_explore.empty();) { |
83 FrameTreeNode* node = to_explore.top(); | 83 FrameTreeNode* node = to_explore.top(); |
84 to_explore.pop(); | 84 to_explore.pop(); |
85 for (size_t i = node->child_count(); i-- != 0;) { | 85 for (size_t i = node->child_count(); i-- != 0;) { |
86 to_explore.push(node->child_at(i)); | 86 to_explore.push(node->child_at(i)); |
87 } | 87 } |
88 | 88 |
89 // Sort the proxies by SiteInstance ID to avoid hash_map ordering. | 89 // Sort the proxies by SiteInstance ID to avoid hash_map ordering. |
90 std::map<int, RenderFrameProxyHost*> sorted_proxy_hosts = | 90 std::vector<SiteInstance*> site_instances; |
91 node->render_manager()->GetAllProxyHostsForTesting(); | 91 for (const auto& proxy_pair : node->render_manager()->GetAllProxyHosts()) |
92 for (auto& proxy_pair : sorted_proxy_hosts) { | 92 site_instances.push_back(proxy_pair.second->GetSiteInstance()); |
93 RenderFrameProxyHost* proxy = proxy_pair.second; | 93 std::sort(site_instances.begin(), site_instances.end(), |
94 legend[GetName(proxy->GetSiteInstance())] = proxy->GetSiteInstance(); | 94 [](const SiteInstance* lhs, const SiteInstance* rhs) { |
95 } | 95 return lhs->GetId() < rhs->GetId(); |
| 96 }); |
| 97 |
| 98 for (SiteInstance* site_instance : site_instances) |
| 99 legend[GetName(site_instance)] = site_instance; |
96 } | 100 } |
97 | 101 |
98 // Traversal 4: Now that all names are assigned, make a big loop to pretty- | 102 // Traversal 4: Now that all names are assigned, make a big loop to pretty- |
99 // print the tree. Each iteration produces exactly one line of format. | 103 // print the tree. Each iteration produces exactly one line of format. |
100 std::string result; | 104 std::string result; |
101 for (to_explore.push(root); !to_explore.empty();) { | 105 for (to_explore.push(root); !to_explore.empty();) { |
102 FrameTreeNode* node = to_explore.top(); | 106 FrameTreeNode* node = to_explore.top(); |
103 to_explore.pop(); | 107 to_explore.pop(); |
104 for (size_t i = node->child_count(); i-- != 0;) { | 108 for (size_t i = node->child_count(); i-- != 0;) { |
105 to_explore.push(node->child_at(i)); | 109 to_explore.push(node->child_at(i)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 if (pending) { | 152 if (pending) { |
149 base::StringAppendF(&line, " (%s pending)", | 153 base::StringAppendF(&line, " (%s pending)", |
150 GetName(pending->GetSiteInstance()).c_str()); | 154 GetName(pending->GetSiteInstance()).c_str()); |
151 } | 155 } |
152 if (spec) { | 156 if (spec) { |
153 base::StringAppendF(&line, " (%s speculative)", | 157 base::StringAppendF(&line, " (%s speculative)", |
154 GetName(spec->GetSiteInstance()).c_str()); | 158 GetName(spec->GetSiteInstance()).c_str()); |
155 } | 159 } |
156 | 160 |
157 // Show the SiteInstances of the RenderFrameProxyHosts of this node. | 161 // Show the SiteInstances of the RenderFrameProxyHosts of this node. |
158 std::map<int, RenderFrameProxyHost*> sorted_proxy_host_map = | 162 const auto& proxy_host_map = node->render_manager()->GetAllProxyHosts(); |
159 node->render_manager()->GetAllProxyHostsForTesting(); | 163 if (!proxy_host_map.empty()) { |
160 if (!sorted_proxy_host_map.empty()) { | |
161 // Show a dashed line of variable length before the proxy list. Always at | 164 // Show a dashed line of variable length before the proxy list. Always at |
162 // least two dashes. | 165 // least two dashes. |
163 line.append(" --"); | 166 line.append(" --"); |
164 | 167 |
165 // To make proxy lists align vertically for the first three tree levels, | 168 // To make proxy lists align vertically for the first three tree levels, |
166 // pad with dashes up to a first tab stop at column 19 (which works out to | 169 // pad with dashes up to a first tab stop at column 19 (which works out to |
167 // text editor column 28 in the typical diagram fed to EXPECT_EQ as a | 170 // text editor column 28 in the typical diagram fed to EXPECT_EQ as a |
168 // string literal). Lining the lists up vertically makes differences in | 171 // string literal). Lining the lists up vertically makes differences in |
169 // the proxy sets easier to spot visually. We choose not to use the | 172 // the proxy sets easier to spot visually. We choose not to use the |
170 // *actual* tree height here, because that would make the diagram's | 173 // *actual* tree height here, because that would make the diagram's |
171 // appearance less stable as the tree's shape evolves. | 174 // appearance less stable as the tree's shape evolves. |
172 while (line.length() < 20) { | 175 while (line.length() < 20) { |
173 line.append("-"); | 176 line.append("-"); |
174 } | 177 } |
175 line.append(" proxies for"); | 178 line.append(" proxies for"); |
176 | 179 |
177 // Sort these alphabetically, to avoid hash_map ordering dependency. | 180 // Sort these alphabetically, to avoid hash_map ordering dependency. |
178 std::vector<std::string> sorted_proxy_hosts; | 181 std::vector<std::string> sorted_proxy_hosts; |
179 for (auto& proxy_pair : sorted_proxy_host_map) { | 182 for (const auto& proxy_pair : proxy_host_map) { |
180 sorted_proxy_hosts.push_back( | 183 sorted_proxy_hosts.push_back( |
181 GetName(proxy_pair.second->GetSiteInstance())); | 184 GetName(proxy_pair.second->GetSiteInstance())); |
182 } | 185 } |
183 std::sort(sorted_proxy_hosts.begin(), sorted_proxy_hosts.end()); | 186 std::sort(sorted_proxy_hosts.begin(), sorted_proxy_hosts.end()); |
184 for (std::string& proxy_name : sorted_proxy_hosts) { | 187 for (std::string& proxy_name : sorted_proxy_hosts) { |
185 base::StringAppendF(&line, " %s", proxy_name.c_str()); | 188 base::StringAppendF(&line, " %s", proxy_name.c_str()); |
186 } | 189 } |
187 } | 190 } |
188 if (node != root) | 191 if (node != root) |
189 result.append("\n"); | 192 result.append("\n"); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 content::ResourceContext* resource_context, | 266 content::ResourceContext* resource_context, |
264 content::AppCacheService* appcache_service, | 267 content::AppCacheService* appcache_service, |
265 ResourceType resource_type, | 268 ResourceType resource_type, |
266 ScopedVector<content::ResourceThrottle>* throttles) { | 269 ScopedVector<content::ResourceThrottle>* throttles) { |
267 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 270 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
268 if (request->url() == url_) | 271 if (request->url() == url_) |
269 throttles->push_back(new HttpRequestStallThrottle); | 272 throttles->push_back(new HttpRequestStallThrottle); |
270 } | 273 } |
271 | 274 |
272 } // namespace content | 275 } // namespace content |
OLD | NEW |