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

Side by Side Diff: content/test/content_browser_test_utils_internal.cc

Issue 1245903004: Switch RenderFrameHostManager to use RenderProcessHostObserver, remove NOTIFICATION_RENDERER_PROCES… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 // 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Traversal 3: Assign names to the proxies and add them to |legend| too. 77 // Traversal 3: Assign names to the proxies and add them to |legend| too.
78 // Typically, only openers should have their names assigned this way. 78 // Typically, only openers should have their names assigned this way.
79 for (to_explore.push(root); !to_explore.empty();) { 79 for (to_explore.push(root); !to_explore.empty();) {
80 FrameTreeNode* node = to_explore.top(); 80 FrameTreeNode* node = to_explore.top();
81 to_explore.pop(); 81 to_explore.pop();
82 for (size_t i = node->child_count(); i-- != 0;) { 82 for (size_t i = node->child_count(); i-- != 0;) {
83 to_explore.push(node->child_at(i)); 83 to_explore.push(node->child_at(i));
84 } 84 }
85 85
86 // Sort the proxies by SiteInstance ID to avoid hash_map ordering. 86 // Sort the proxies by SiteInstance ID to avoid hash_map ordering.
87 std::map<int, RenderFrameProxyHost*> sorted_proxy_hosts; 87 std::map<int, RenderFrameProxyHost*> sorted_proxy_hosts =
88 for (auto& proxy_pair : node->render_manager()->proxy_hosts_) { 88 node->render_manager()->GetAllProxyHostsForTesting();
89 sorted_proxy_hosts.insert(proxy_pair);
90 }
91 for (auto& proxy_pair : sorted_proxy_hosts) { 89 for (auto& proxy_pair : sorted_proxy_hosts) {
92 RenderFrameProxyHost* proxy = proxy_pair.second; 90 RenderFrameProxyHost* proxy = proxy_pair.second;
93 legend[GetName(proxy->GetSiteInstance())] = proxy->GetSiteInstance(); 91 legend[GetName(proxy->GetSiteInstance())] = proxy->GetSiteInstance();
94 } 92 }
95 } 93 }
96 94
97 // Traversal 4: Now that all names are assigned, make a big loop to pretty- 95 // 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. 96 // print the tree. Each iteration produces exactly one line of format.
99 std::string result; 97 std::string result;
100 for (to_explore.push(root); !to_explore.empty();) { 98 for (to_explore.push(root); !to_explore.empty();) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (pending) { 146 if (pending) {
149 base::StringAppendF(&line, " (%s pending)", 147 base::StringAppendF(&line, " (%s pending)",
150 GetName(pending->GetSiteInstance()).c_str()); 148 GetName(pending->GetSiteInstance()).c_str());
151 } 149 }
152 if (spec) { 150 if (spec) {
153 base::StringAppendF(&line, " (%s speculative)", 151 base::StringAppendF(&line, " (%s speculative)",
154 GetName(spec->GetSiteInstance()).c_str()); 152 GetName(spec->GetSiteInstance()).c_str());
155 } 153 }
156 154
157 // Show the SiteInstances of the RenderFrameProxyHosts of this node. 155 // Show the SiteInstances of the RenderFrameProxyHosts of this node.
158 if (!node->render_manager()->proxy_hosts_.empty()) { 156 std::map<int, RenderFrameProxyHost*> sorted_proxy_host_map =
157 node->render_manager()->GetAllProxyHostsForTesting();
158 if (!sorted_proxy_host_map.empty()) {
159 // Show a dashed line of variable length before the proxy list. Always at 159 // Show a dashed line of variable length before the proxy list. Always at
160 // least two dashes. 160 // least two dashes.
161 line.append(" --"); 161 line.append(" --");
162 162
163 // To make proxy lists align vertically for the first three tree levels, 163 // 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 164 // 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 165 // 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 166 // string literal). Lining the lists up vertically makes differences in
167 // the proxy sets easier to spot visually. We choose not to use the 167 // 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 168 // *actual* tree height here, because that would make the diagram's
169 // appearance less stable as the tree's shape evolves. 169 // appearance less stable as the tree's shape evolves.
170 while (line.length() < 20) { 170 while (line.length() < 20) {
171 line.append("-"); 171 line.append("-");
172 } 172 }
173 line.append(" proxies for"); 173 line.append(" proxies for");
174 174
175 // Sort these alphabetically, to avoid hash_map ordering dependency. 175 // Sort these alphabetically, to avoid hash_map ordering dependency.
176 std::vector<std::string> sorted_proxy_hosts; 176 std::vector<std::string> sorted_proxy_hosts;
177 for (auto& proxy_pair : node->render_manager()->proxy_hosts_) { 177 for (auto& proxy_pair : sorted_proxy_host_map) {
178 sorted_proxy_hosts.push_back( 178 sorted_proxy_hosts.push_back(
179 GetName(proxy_pair.second->GetSiteInstance())); 179 GetName(proxy_pair.second->GetSiteInstance()));
180 } 180 }
181 std::sort(sorted_proxy_hosts.begin(), sorted_proxy_hosts.end()); 181 std::sort(sorted_proxy_hosts.begin(), sorted_proxy_hosts.end());
182 for (std::string& proxy_name : sorted_proxy_hosts) { 182 for (std::string& proxy_name : sorted_proxy_hosts) {
183 base::StringAppendF(&line, " %s", proxy_name.c_str()); 183 base::StringAppendF(&line, " %s", proxy_name.c_str());
184 } 184 }
185 } 185 }
186 if (node != root) 186 if (node != root)
187 result.append("\n"); 187 result.append("\n");
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 &did_create_popup); 234 &did_create_popup);
235 if (!did_execute_script || !did_create_popup) 235 if (!did_execute_script || !did_create_popup)
236 return nullptr; 236 return nullptr;
237 237
238 Shell* new_shell = new_shell_observer.GetShell(); 238 Shell* new_shell = new_shell_observer.GetShell();
239 WaitForLoadStop(new_shell->web_contents()); 239 WaitForLoadStop(new_shell->web_contents());
240 return new_shell; 240 return new_shell;
241 } 241 }
242 242
243 } // namespace content 243 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698