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 <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // of assigned names it's important to do this before trying to name the | 59 // of assigned names it's important to do this before trying to name the |
60 // proxies, which have a less well defined order. | 60 // proxies, which have a less well defined order. |
61 for (to_explore.push(root); !to_explore.empty();) { | 61 for (to_explore.push(root); !to_explore.empty();) { |
62 FrameTreeNode* node = to_explore.top(); | 62 FrameTreeNode* node = to_explore.top(); |
63 to_explore.pop(); | 63 to_explore.pop(); |
64 for (size_t i = node->child_count(); i-- != 0;) { | 64 for (size_t i = node->child_count(); i-- != 0;) { |
65 to_explore.push(node->child_at(i)); | 65 to_explore.push(node->child_at(i)); |
66 } | 66 } |
67 | 67 |
68 RenderFrameHost* pending = node->render_manager()->pending_frame_host(); | 68 RenderFrameHost* pending = node->render_manager()->pending_frame_host(); |
69 RenderFrameHost* spec = | 69 RenderFrameHost* spec = node->render_manager()->speculative_frame_host(); |
70 node->render_manager()->speculative_render_frame_host_.get(); | |
71 if (pending) | 70 if (pending) |
72 legend[GetName(pending->GetSiteInstance())] = pending->GetSiteInstance(); | 71 legend[GetName(pending->GetSiteInstance())] = pending->GetSiteInstance(); |
73 if (spec) | 72 if (spec) |
74 legend[GetName(spec->GetSiteInstance())] = spec->GetSiteInstance(); | 73 legend[GetName(spec->GetSiteInstance())] = spec->GetSiteInstance(); |
75 } | 74 } |
76 | 75 |
77 // Traversal 3: Assign names to the proxies and add them to |legend| too. | 76 // Traversal 3: Assign names to the proxies and add them to |legend| too. |
78 // Typically, only openers should have their names assigned this way. | 77 // Typically, only openers should have their names assigned this way. |
79 for (to_explore.push(root); !to_explore.empty();) { | 78 for (to_explore.push(root); !to_explore.empty();) { |
80 FrameTreeNode* node = to_explore.top(); | 79 FrameTreeNode* node = to_explore.top(); |
81 to_explore.pop(); | 80 to_explore.pop(); |
82 for (size_t i = node->child_count(); i-- != 0;) { | 81 for (size_t i = node->child_count(); i-- != 0;) { |
83 to_explore.push(node->child_at(i)); | 82 to_explore.push(node->child_at(i)); |
84 } | 83 } |
85 | 84 |
86 // Sort the proxies by SiteInstance ID to avoid hash_map ordering. | 85 // Sort the proxies by SiteInstance ID to avoid hash_map ordering. |
87 std::map<int, RenderFrameProxyHost*> sorted_proxy_hosts; | 86 std::map<int, RenderFrameProxyHost*> sorted_proxy_hosts = |
88 for (auto& proxy_pair : node->render_manager()->proxy_hosts_) { | 87 node->render_manager()->GetAllProxyHostsForTesting(); |
89 sorted_proxy_hosts.insert(proxy_pair); | |
90 } | |
91 for (auto& proxy_pair : sorted_proxy_hosts) { | 88 for (auto& proxy_pair : sorted_proxy_hosts) { |
92 RenderFrameProxyHost* proxy = proxy_pair.second; | 89 RenderFrameProxyHost* proxy = proxy_pair.second; |
93 legend[GetName(proxy->GetSiteInstance())] = proxy->GetSiteInstance(); | 90 legend[GetName(proxy->GetSiteInstance())] = proxy->GetSiteInstance(); |
94 } | 91 } |
95 } | 92 } |
96 | 93 |
97 // Traversal 4: Now that all names are assigned, make a big loop to pretty- | 94 // Traversal 4: Now that all names are assigned, make a big loop to pretty- |
98 // print the tree. Each iteration produces exactly one line of format. | 95 // print the tree. Each iteration produces exactly one line of format. |
99 std::string result; | 96 std::string result; |
100 for (to_explore.push(root); !to_explore.empty();) { | 97 for (to_explore.push(root); !to_explore.empty();) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // Prefix one extra space of padding for two reasons. First, this helps the | 131 // Prefix one extra space of padding for two reasons. First, this helps the |
135 // diagram aligns nicely with the legend. Second, this makes it easier to | 132 // diagram aligns nicely with the legend. Second, this makes it easier to |
136 // read the diffs that gtest spits out on EXPECT_EQ failure. | 133 // read the diffs that gtest spits out on EXPECT_EQ failure. |
137 line = " " + line; | 134 line = " " + line; |
138 | 135 |
139 // Summarize the FrameTreeNode's state. Always show the site of the current | 136 // Summarize the FrameTreeNode's state. Always show the site of the current |
140 // RenderFrameHost, and show any exceptional state of the node, like a | 137 // RenderFrameHost, and show any exceptional state of the node, like a |
141 // pending or speculative RenderFrameHost. | 138 // pending or speculative RenderFrameHost. |
142 RenderFrameHost* current = node->render_manager()->current_frame_host(); | 139 RenderFrameHost* current = node->render_manager()->current_frame_host(); |
143 RenderFrameHost* pending = node->render_manager()->pending_frame_host(); | 140 RenderFrameHost* pending = node->render_manager()->pending_frame_host(); |
144 RenderFrameHost* spec = | 141 RenderFrameHost* spec = node->render_manager()->speculative_frame_host(); |
145 node->render_manager()->speculative_render_frame_host_.get(); | |
146 base::StringAppendF(&line, "Site %s", | 142 base::StringAppendF(&line, "Site %s", |
147 GetName(current->GetSiteInstance()).c_str()); | 143 GetName(current->GetSiteInstance()).c_str()); |
148 if (pending) { | 144 if (pending) { |
149 base::StringAppendF(&line, " (%s pending)", | 145 base::StringAppendF(&line, " (%s pending)", |
150 GetName(pending->GetSiteInstance()).c_str()); | 146 GetName(pending->GetSiteInstance()).c_str()); |
151 } | 147 } |
152 if (spec) { | 148 if (spec) { |
153 base::StringAppendF(&line, " (%s speculative)", | 149 base::StringAppendF(&line, " (%s speculative)", |
154 GetName(spec->GetSiteInstance()).c_str()); | 150 GetName(spec->GetSiteInstance()).c_str()); |
155 } | 151 } |
156 | 152 |
157 // Show the SiteInstances of the RenderFrameProxyHosts of this node. | 153 // Show the SiteInstances of the RenderFrameProxyHosts of this node. |
158 if (!node->render_manager()->proxy_hosts_.empty()) { | 154 std::map<int, RenderFrameProxyHost*> sorted_proxy_host_map = |
| 155 node->render_manager()->GetAllProxyHostsForTesting(); |
| 156 if (!sorted_proxy_host_map.empty()) { |
159 // Show a dashed line of variable length before the proxy list. Always at | 157 // Show a dashed line of variable length before the proxy list. Always at |
160 // least two dashes. | 158 // least two dashes. |
161 line.append(" --"); | 159 line.append(" --"); |
162 | 160 |
163 // To make proxy lists align vertically for the first three tree levels, | 161 // To make proxy lists align vertically for the first three tree levels, |
164 // pad with dashes up to a first tab stop at column 19 (which works out to | 162 // pad with dashes up to a first tab stop at column 19 (which works out to |
165 // text editor column 28 in the typical diagram fed to EXPECT_EQ as a | 163 // text editor column 28 in the typical diagram fed to EXPECT_EQ as a |
166 // string literal). Lining the lists up vertically makes differences in | 164 // string literal). Lining the lists up vertically makes differences in |
167 // the proxy sets easier to spot visually. We choose not to use the | 165 // the proxy sets easier to spot visually. We choose not to use the |
168 // *actual* tree height here, because that would make the diagram's | 166 // *actual* tree height here, because that would make the diagram's |
169 // appearance less stable as the tree's shape evolves. | 167 // appearance less stable as the tree's shape evolves. |
170 while (line.length() < 20) { | 168 while (line.length() < 20) { |
171 line.append("-"); | 169 line.append("-"); |
172 } | 170 } |
173 line.append(" proxies for"); | 171 line.append(" proxies for"); |
174 | 172 |
175 // Sort these alphabetically, to avoid hash_map ordering dependency. | 173 // Sort these alphabetically, to avoid hash_map ordering dependency. |
176 std::vector<std::string> sorted_proxy_hosts; | 174 std::vector<std::string> sorted_proxy_hosts; |
177 for (auto& proxy_pair : node->render_manager()->proxy_hosts_) { | 175 for (auto& proxy_pair : sorted_proxy_host_map) { |
178 sorted_proxy_hosts.push_back( | 176 sorted_proxy_hosts.push_back( |
179 GetName(proxy_pair.second->GetSiteInstance())); | 177 GetName(proxy_pair.second->GetSiteInstance())); |
180 } | 178 } |
181 std::sort(sorted_proxy_hosts.begin(), sorted_proxy_hosts.end()); | 179 std::sort(sorted_proxy_hosts.begin(), sorted_proxy_hosts.end()); |
182 for (std::string& proxy_name : sorted_proxy_hosts) { | 180 for (std::string& proxy_name : sorted_proxy_hosts) { |
183 base::StringAppendF(&line, " %s", proxy_name.c_str()); | 181 base::StringAppendF(&line, " %s", proxy_name.c_str()); |
184 } | 182 } |
185 } | 183 } |
186 if (node != root) | 184 if (node != root) |
187 result.append("\n"); | 185 result.append("\n"); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 &did_create_popup); | 232 &did_create_popup); |
235 if (!did_execute_script || !did_create_popup) | 233 if (!did_execute_script || !did_create_popup) |
236 return nullptr; | 234 return nullptr; |
237 | 235 |
238 Shell* new_shell = new_shell_observer.GetShell(); | 236 Shell* new_shell = new_shell_observer.GetShell(); |
239 WaitForLoadStop(new_shell->web_contents()); | 237 WaitForLoadStop(new_shell->web_contents()); |
240 return new_shell; | 238 return new_shell; |
241 } | 239 } |
242 | 240 |
243 } // namespace content | 241 } // namespace content |
OLD | NEW |