Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 | 98 |
| 99 // We model process-per-site by only inserting those sites into the first | 99 // We model process-per-site by only inserting those sites into the first |
| 100 // browsing instance in which they appear. | 100 // browsing instance in which they appear. |
| 101 if (scenario->sites.insert(site).second || !process_per_site) | 101 if (scenario->sites.insert(site).second || !process_per_site) |
| 102 scenario->browsing_instance_site_map[primary->GetId()].insert(site); | 102 scenario->browsing_instance_site_map[primary->GetId()].insert(site); |
| 103 | 103 |
| 104 // Record our result in |frame_urls| for use by children. | 104 // Record our result in |frame_urls| for use by children. |
| 105 (*frame_urls)[frame] = site; | 105 (*frame_urls)[frame] = site; |
| 106 } | 106 } |
| 107 | 107 |
| 108 void CollectCurrentSnapshot(SiteData* site_data, RenderFrameHost* frame) { | |
| 109 if (frame->GetParent()) { | |
| 110 if (frame->GetSiteInstance() != frame->GetParent()->GetSiteInstance()) | |
| 111 site_data->out_of_process_frames.insert(frame); | |
| 112 } | |
| 113 } | |
| 114 | |
| 108 } // namespace | 115 } // namespace |
| 109 | 116 |
| 110 IsolationScenario::IsolationScenario() : policy(ISOLATE_ALL_SITES) {} | 117 IsolationScenario::IsolationScenario() : policy(ISOLATE_ALL_SITES) {} |
| 111 | 118 |
| 112 IsolationScenario::~IsolationScenario() {} | 119 IsolationScenario::~IsolationScenario() {} |
| 113 | 120 |
| 114 SiteData::SiteData() { | 121 SiteData::SiteData() { |
| 115 for (int i = 0; i <= ISOLATION_SCENARIO_LAST; i++) | 122 for (int i = 0; i <= ISOLATION_SCENARIO_LAST; i++) |
| 116 scenarios[i].policy = static_cast<IsolationScenarioType>(i); | 123 scenarios[i].policy = static_cast<IsolationScenarioType>(i); |
| 117 } | 124 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 142 } | 149 } |
| 143 | 150 |
| 144 // Now keep track of how many sites we have in this BrowsingInstance (and | 151 // Now keep track of how many sites we have in this BrowsingInstance (and |
| 145 // overall), including sites in iframes. | 152 // overall), including sites in iframes. |
| 146 for (IsolationScenario& scenario : site_data->scenarios) { | 153 for (IsolationScenario& scenario : site_data->scenarios) { |
| 147 std::map<RenderFrameHost*, GURL> memo; | 154 std::map<RenderFrameHost*, GURL> memo; |
| 148 contents->ForEachFrame( | 155 contents->ForEachFrame( |
| 149 base::Bind(&CollectForScenario, base::Unretained(&memo), | 156 base::Bind(&CollectForScenario, base::Unretained(&memo), |
| 150 base::Unretained(primary), base::Unretained(&scenario))); | 157 base::Unretained(primary), base::Unretained(&scenario))); |
| 151 } | 158 } |
| 159 | |
| 160 contents->ForEachFrame( | |
| 161 base::Bind(&CollectCurrentSnapshot, base::Unretained(site_data))); | |
| 152 } | 162 } |
| 153 | 163 |
| 154 void SiteDetails::UpdateHistograms( | 164 void SiteDetails::UpdateHistograms( |
| 155 const BrowserContextSiteDataMap& site_data_map, | 165 const BrowserContextSiteDataMap& site_data_map, |
| 156 int all_renderer_process_count, | 166 int all_renderer_process_count, |
| 157 int non_renderer_process_count) { | 167 int non_renderer_process_count) { |
| 158 // Reports a set of site-based process metrics to UMA. | 168 // Reports a set of site-based process metrics to UMA. |
| 159 int process_limit = RenderProcessHost::GetMaxRendererProcessCount(); | 169 int process_limit = RenderProcessHost::GetMaxRendererProcessCount(); |
| 160 | 170 |
| 161 // Sum the number of sites and SiteInstances in each BrowserContext. | 171 // Sum the number of sites and SiteInstances in each BrowserContext and |
| 172 // the total number of out-of-process iframes. | |
| 162 int num_sites[ISOLATION_SCENARIO_LAST + 1] = {}; | 173 int num_sites[ISOLATION_SCENARIO_LAST + 1] = {}; |
| 163 int num_isolated_site_instances[ISOLATION_SCENARIO_LAST + 1] = {}; | 174 int num_isolated_site_instances[ISOLATION_SCENARIO_LAST + 1] = {}; |
| 164 int num_browsing_instances = 0; | 175 int num_browsing_instances = 0; |
| 176 int num_oopifs = 0; | |
| 165 for (BrowserContextSiteDataMap::const_iterator i = site_data_map.begin(); | 177 for (BrowserContextSiteDataMap::const_iterator i = site_data_map.begin(); |
| 166 i != site_data_map.end(); ++i) { | 178 i != site_data_map.end(); ++i) { |
| 167 for (const IsolationScenario& scenario : i->second.scenarios) { | 179 for (const IsolationScenario& scenario : i->second.scenarios) { |
| 168 num_sites[scenario.policy] += scenario.sites.size(); | 180 num_sites[scenario.policy] += scenario.sites.size(); |
| 169 for (auto& browsing_instance : scenario.browsing_instance_site_map) { | 181 for (auto& browsing_instance : scenario.browsing_instance_site_map) { |
| 170 num_isolated_site_instances[scenario.policy] += | 182 num_isolated_site_instances[scenario.policy] += |
| 171 browsing_instance.second.size(); | 183 browsing_instance.second.size(); |
| 172 } | 184 } |
| 173 } | 185 } |
| 174 num_browsing_instances += i->second.scenarios[ISOLATE_ALL_SITES] | 186 num_browsing_instances += i->second.scenarios[ISOLATE_ALL_SITES] |
| 175 .browsing_instance_site_map.size(); | 187 .browsing_instance_site_map.size(); |
| 188 num_oopifs += i->second.out_of_process_frames.size(); | |
|
ncarter (slow)
2015/11/18 17:48:14
It doesn't look like you ever actually iterate ove
nasko
2015/11/18 18:32:58
Done.
| |
| 176 } | 189 } |
| 177 | 190 |
| 178 // Predict the number of processes needed when isolating all sites, when | 191 // Predict the number of processes needed when isolating all sites, when |
| 179 // isolating only HTTPS sites, and when isolating extensions. | 192 // isolating only HTTPS sites, and when isolating extensions. |
| 180 int process_count_lower_bound[ISOLATION_SCENARIO_LAST + 1]; | 193 int process_count_lower_bound[ISOLATION_SCENARIO_LAST + 1]; |
| 181 int process_count_upper_bound[ISOLATION_SCENARIO_LAST + 1]; | 194 int process_count_upper_bound[ISOLATION_SCENARIO_LAST + 1]; |
| 182 int process_count_estimate[ISOLATION_SCENARIO_LAST + 1]; | 195 int process_count_estimate[ISOLATION_SCENARIO_LAST + 1]; |
| 183 for (int policy = 0; policy <= ISOLATION_SCENARIO_LAST; policy++) { | 196 for (int policy = 0; policy <= ISOLATION_SCENARIO_LAST; policy++) { |
| 184 process_count_lower_bound[policy] = num_sites[policy]; | 197 process_count_lower_bound[policy] = num_sites[policy]; |
| 185 process_count_upper_bound[policy] = num_sites[policy] + process_limit - 1; | 198 process_count_upper_bound[policy] = num_sites[policy] + process_limit - 1; |
| 186 process_count_estimate[policy] = std::min( | 199 process_count_estimate[policy] = std::min( |
| 187 num_isolated_site_instances[policy], process_count_upper_bound[policy]); | 200 num_isolated_site_instances[policy], process_count_upper_bound[policy]); |
| 188 } | 201 } |
| 189 | 202 |
| 190 // Just renderer process count: | 203 // Just renderer process count: |
| 191 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.CurrentRendererProcessCount", | 204 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.CurrentRendererProcessCount", |
| 192 all_renderer_process_count); | 205 all_renderer_process_count); |
| 193 UMA_HISTOGRAM_COUNTS_100( | 206 UMA_HISTOGRAM_COUNTS_100( |
| 194 "SiteIsolation.BrowsingInstanceCount", | 207 "SiteIsolation.BrowsingInstanceCount", |
| 195 num_browsing_instances); | 208 num_browsing_instances); |
| 209 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.OutOfProcessIframes", num_oopifs); | |
| 196 | 210 |
| 197 // ISOLATE_NOTHING metrics. | 211 // ISOLATE_NOTHING metrics. |
| 198 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountNoLimit", | 212 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountNoLimit", |
| 199 num_isolated_site_instances[ISOLATE_NOTHING]); | 213 num_isolated_site_instances[ISOLATE_NOTHING]); |
| 200 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountLowerBound", | 214 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountLowerBound", |
| 201 process_count_lower_bound[ISOLATE_NOTHING]); | 215 process_count_lower_bound[ISOLATE_NOTHING]); |
| 202 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountEstimate", | 216 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountEstimate", |
| 203 process_count_estimate[ISOLATE_NOTHING]); | 217 process_count_estimate[ISOLATE_NOTHING]); |
| 204 UMA_HISTOGRAM_COUNTS_100( | 218 UMA_HISTOGRAM_COUNTS_100( |
| 205 "SiteIsolation.IsolateNothingTotalProcessCountEstimate", | 219 "SiteIsolation.IsolateNothingTotalProcessCountEstimate", |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 236 UMA_HISTOGRAM_COUNTS_100( | 250 UMA_HISTOGRAM_COUNTS_100( |
| 237 "SiteIsolation.IsolateExtensionsProcessCountLowerBound", | 251 "SiteIsolation.IsolateExtensionsProcessCountLowerBound", |
| 238 process_count_lower_bound[ISOLATE_EXTENSIONS]); | 252 process_count_lower_bound[ISOLATE_EXTENSIONS]); |
| 239 UMA_HISTOGRAM_COUNTS_100( | 253 UMA_HISTOGRAM_COUNTS_100( |
| 240 "SiteIsolation.IsolateExtensionsProcessCountEstimate", | 254 "SiteIsolation.IsolateExtensionsProcessCountEstimate", |
| 241 process_count_estimate[ISOLATE_EXTENSIONS]); | 255 process_count_estimate[ISOLATE_EXTENSIONS]); |
| 242 UMA_HISTOGRAM_COUNTS_100( | 256 UMA_HISTOGRAM_COUNTS_100( |
| 243 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate", | 257 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate", |
| 244 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count); | 258 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count); |
| 245 } | 259 } |
| OLD | NEW |