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

Side by Side Diff: chrome/browser/site_details.cc

Issue 1674873002: SiteDetailsBrowserTest: prepare to add proxy information (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@uma
Patch Set: thestig's fixes Created 4 years, 10 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
« no previous file with comments | « chrome/browser/site_details.h ('k') | chrome/browser/site_details_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/site_details.h" 5 #include "chrome/browser/site_details.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/render_frame_host.h" 9 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 registry->enabled_extensions().GetExtensionOrAppByURL(site); 51 registry->enabled_extensions().GetExtensionOrAppByURL(site);
52 return extension && !extension->is_hosted_app(); 52 return extension && !extension->is_hosted_app();
53 #endif 53 #endif
54 } 54 }
55 } 55 }
56 NOTREACHED(); 56 NOTREACHED();
57 return true; 57 return true;
58 } 58 }
59 59
60 content::SiteInstance* DeterminePrimarySiteInstance( 60 content::SiteInstance* DeterminePrimarySiteInstance(
61 content::SiteInstance* instance, 61 content::SiteInstance* site_instance,
62 SiteData* site_data) { 62 SiteData* site_data) {
63 // Find the BrowsingInstance this WebContents belongs to by iterating over 63 // Find the BrowsingInstance this WebContents belongs to by iterating over
64 // the "primary" SiteInstances of each BrowsingInstance we've seen so far. 64 // the "primary" SiteInstances of each BrowsingInstance we've seen so far.
65 for (auto& existing_site_instance : site_data->instances) { 65 for (auto& entry : site_data->browsing_instances) {
66 if (instance->IsRelatedSiteInstance(existing_site_instance.first)) { 66 BrowsingInstanceInfo* browsing_instance = &entry.second;
67 existing_site_instance.second.insert(instance); 67 content::SiteInstance* primary_for_browsing_instance = entry.first;
68 return existing_site_instance.first; 68
69 if (site_instance->IsRelatedSiteInstance(primary_for_browsing_instance)) {
70 browsing_instance->site_instances.insert(site_instance);
71 return primary_for_browsing_instance;
69 } 72 }
70 } 73 }
71 74
72 // Add |instance| as the "primary" SiteInstance of a new BrowsingInstance. 75 // Add |instance| as the "primary" SiteInstance of a new BrowsingInstance.
73 site_data->instances[instance].clear(); 76 BrowsingInstanceInfo* browsing_instance =
74 site_data->instances[instance].insert(instance); 77 &site_data->browsing_instances[site_instance];
78 browsing_instance->site_instances.insert(site_instance);
75 79
76 return instance; 80 return site_instance;
77 } 81 }
78 82
79 } // namespace 83 } // namespace
80 84
85 ScenarioBrowsingInstanceInfo::ScenarioBrowsingInstanceInfo() {}
86
87 ScenarioBrowsingInstanceInfo::~ScenarioBrowsingInstanceInfo() {}
88
89 BrowsingInstanceInfo::BrowsingInstanceInfo() {}
90
91 BrowsingInstanceInfo::~BrowsingInstanceInfo() {}
92
81 IsolationScenario::IsolationScenario() : policy(ISOLATE_ALL_SITES) {} 93 IsolationScenario::IsolationScenario() : policy(ISOLATE_ALL_SITES) {}
82 94
83 IsolationScenario::~IsolationScenario() {} 95 IsolationScenario::~IsolationScenario() {}
84 96
85 SiteData::SiteData() : out_of_process_frames(0) { 97 SiteData::SiteData() : out_of_process_frames(0) {
86 for (int i = 0; i <= ISOLATION_SCENARIO_LAST; i++) 98 for (int i = 0; i <= ISOLATION_SCENARIO_LAST; i++)
87 scenarios[i].policy = static_cast<IsolationScenarioType>(i); 99 scenarios[i].policy = static_cast<IsolationScenarioType>(i);
88 } 100 }
89 101
90 SiteData::~SiteData() {} 102 SiteData::~SiteData() {}
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 RenderProcessHost::ShouldUseProcessPerSite(context, site); 140 RenderProcessHost::ShouldUseProcessPerSite(context, site);
129 141
130 // If we don't need a dedicated process, and aren't living in a process- 142 // If we don't need a dedicated process, and aren't living in a process-
131 // per-site process, we are nothing special: collapse our URL to a dummy 143 // per-site process, we are nothing special: collapse our URL to a dummy
132 // site. 144 // site.
133 if (!process_per_site && !should_isolate) 145 if (!process_per_site && !should_isolate)
134 site = GURL("http://"); 146 site = GURL("http://");
135 147
136 // We model process-per-site by only inserting those sites into the first 148 // We model process-per-site by only inserting those sites into the first
137 // browsing instance in which they appear. 149 // browsing instance in which they appear.
138 if (scenario.sites.insert(site).second || !process_per_site) 150 if (scenario.all_sites.insert(site).second || !process_per_site)
139 scenario.browsing_instance_site_map[primary->GetId()].insert(site); 151 scenario.browsing_instances[primary->GetId()].sites.insert(site);
140 152
141 // Record our result in |frame_urls| for use by children. 153 // Record our result in |frame_urls| for use by children.
142 frame_urls[frame] = site; 154 frame_urls[frame] = site;
143 } 155 }
144 } 156 }
145 157
146 for (RenderFrameHost* frame : contents->GetAllFrames()) { 158 for (RenderFrameHost* frame : contents->GetAllFrames()) {
147 if (frame->GetParent()) { 159 if (frame->GetParent()) {
148 if (frame->GetSiteInstance() != frame->GetParent()->GetSiteInstance()) 160 if (frame->GetSiteInstance() != frame->GetParent()->GetSiteInstance())
149 site_data->out_of_process_frames++; 161 site_data->out_of_process_frames++;
150 } 162 }
151 DeterminePrimarySiteInstance(frame->GetSiteInstance(), site_data); 163 DeterminePrimarySiteInstance(frame->GetSiteInstance(), site_data);
152 } 164 }
153 } 165 }
154 166
155 void SiteDetails::UpdateHistograms( 167 void SiteDetails::UpdateHistograms(
156 const BrowserContextSiteDataMap& site_data_map, 168 const BrowserContextSiteDataMap& site_data_map,
157 int all_renderer_process_count, 169 int all_renderer_process_count,
158 int non_renderer_process_count) { 170 int non_renderer_process_count) {
159 // Reports a set of site-based process metrics to UMA. 171 // Reports a set of site-based process metrics to UMA.
160 int process_limit = RenderProcessHost::GetMaxRendererProcessCount(); 172 int process_limit = RenderProcessHost::GetMaxRendererProcessCount();
161 173
162 // Sum the number of sites and SiteInstances in each BrowserContext and 174 // Sum the number of sites and SiteInstances in each BrowserContext and
163 // the total number of out-of-process iframes. 175 // the total number of out-of-process iframes.
164 int num_sites[ISOLATION_SCENARIO_LAST + 1] = {}; 176 int num_sites[ISOLATION_SCENARIO_LAST + 1] = {};
165 int num_isolated_site_instances[ISOLATION_SCENARIO_LAST + 1] = {}; 177 int num_isolated_site_instances[ISOLATION_SCENARIO_LAST + 1] = {};
166 int num_browsing_instances = 0; 178 int num_browsing_instances = 0;
167 int num_oopifs = 0; 179 int num_oopifs = 0;
168 for (BrowserContextSiteDataMap::const_iterator i = site_data_map.begin(); 180 for (auto& site_data_map_entry : site_data_map) {
169 i != site_data_map.end(); ++i) { 181 const SiteData& site_data = site_data_map_entry.second;
170 for (const IsolationScenario& scenario : i->second.scenarios) { 182 for (const IsolationScenario& scenario : site_data.scenarios) {
171 num_sites[scenario.policy] += scenario.sites.size(); 183 num_sites[scenario.policy] += scenario.all_sites.size();
172 for (auto& browsing_instance : scenario.browsing_instance_site_map) { 184 for (auto& entry : scenario.browsing_instances) {
185 const ScenarioBrowsingInstanceInfo& scenario_browsing_instance_info =
186 entry.second;
173 num_isolated_site_instances[scenario.policy] += 187 num_isolated_site_instances[scenario.policy] +=
174 browsing_instance.second.size(); 188 scenario_browsing_instance_info.sites.size();
175 } 189 }
176 } 190 }
177 num_browsing_instances += i->second.scenarios[ISOLATE_ALL_SITES] 191 for (const auto& entry : site_data.browsing_instances) {
178 .browsing_instance_site_map.size(); 192 const BrowsingInstanceInfo& browsing_instance_info = entry.second;
179 for (const auto& site_instance : i->second.instances) {
180 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.SiteInstancesPerBrowsingInstance", 193 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.SiteInstancesPerBrowsingInstance",
181 site_instance.second.size()); 194 browsing_instance_info.site_instances.size());
182 } 195 }
183 num_oopifs += i->second.out_of_process_frames; 196 num_browsing_instances += site_data.browsing_instances.size();
197 num_oopifs += site_data.out_of_process_frames;
184 } 198 }
185 199
186 // Predict the number of processes needed when isolating all sites, when 200 // Predict the number of processes needed when isolating all sites, when
187 // isolating only HTTPS sites, and when isolating extensions. 201 // isolating only HTTPS sites, and when isolating extensions.
188 int process_count_lower_bound[ISOLATION_SCENARIO_LAST + 1]; 202 int process_count_lower_bound[ISOLATION_SCENARIO_LAST + 1];
189 int process_count_upper_bound[ISOLATION_SCENARIO_LAST + 1]; 203 int process_count_upper_bound[ISOLATION_SCENARIO_LAST + 1];
190 int process_count_estimate[ISOLATION_SCENARIO_LAST + 1]; 204 int process_count_estimate[ISOLATION_SCENARIO_LAST + 1];
191 for (int policy = 0; policy <= ISOLATION_SCENARIO_LAST; policy++) { 205 for (int policy = 0; policy <= ISOLATION_SCENARIO_LAST; policy++) {
192 process_count_lower_bound[policy] = num_sites[policy]; 206 process_count_lower_bound[policy] = num_sites[policy];
193 process_count_upper_bound[policy] = num_sites[policy] + process_limit - 1; 207 process_count_upper_bound[policy] = num_sites[policy] + process_limit - 1;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 UMA_HISTOGRAM_COUNTS_100( 259 UMA_HISTOGRAM_COUNTS_100(
246 "SiteIsolation.IsolateExtensionsProcessCountLowerBound", 260 "SiteIsolation.IsolateExtensionsProcessCountLowerBound",
247 process_count_lower_bound[ISOLATE_EXTENSIONS]); 261 process_count_lower_bound[ISOLATE_EXTENSIONS]);
248 UMA_HISTOGRAM_COUNTS_100( 262 UMA_HISTOGRAM_COUNTS_100(
249 "SiteIsolation.IsolateExtensionsProcessCountEstimate", 263 "SiteIsolation.IsolateExtensionsProcessCountEstimate",
250 process_count_estimate[ISOLATE_EXTENSIONS]); 264 process_count_estimate[ISOLATE_EXTENSIONS]);
251 UMA_HISTOGRAM_COUNTS_100( 265 UMA_HISTOGRAM_COUNTS_100(
252 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate", 266 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate",
253 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count); 267 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count);
254 } 268 }
OLDNEW
« no previous file with comments | « chrome/browser/site_details.h ('k') | chrome/browser/site_details_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698