This source file includes following definitions.
- CollectSiteInfo
- UpdateHistograms
#include "chrome/browser/site_details.h"
#include "base/metrics/histogram.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
using content::BrowserThread;
using content::RenderProcessHost;
using content::SiteInstance;
using content::WebContents;
SiteData::SiteData() {}
SiteData::~SiteData() {}
SiteDetails::SiteDetails() {}
SiteDetails::~SiteDetails() {}
void SiteDetails::CollectSiteInfo(WebContents* contents,
SiteData* site_data) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
content::BrowserContext* browser_context = contents->GetBrowserContext();
SiteInstance* instance = contents->GetSiteInstance();
SiteInstance* primary = NULL;
for (size_t i = 0; i < site_data->instances.size(); ++i) {
if (instance->IsRelatedSiteInstance(site_data->instances[i])) {
primary = site_data->instances[i];
break;
}
}
if (!primary) {
primary = instance;
site_data->instances.push_back(instance);
}
std::set<GURL> sites_in_tab = contents->GetSitesInTab();
for (std::set<GURL>::iterator iter = sites_in_tab.begin();
iter != sites_in_tab.end(); ++iter) {
if (iter->is_empty())
continue;
if (RenderProcessHost::ShouldUseProcessPerSite(browser_context, *iter) &&
site_data->sites.find(*iter) != site_data->sites.end()) {
continue;
}
site_data->sites.insert(*iter);
site_data->instance_site_map[primary->GetId()].insert(*iter);
GURL https_site = iter->SchemeIs("http") ? GURL("http://") : *iter;
site_data->https_sites.insert(https_site);
site_data->instance_https_site_map[primary->GetId()].insert(https_site);
}
}
void SiteDetails::UpdateHistograms(
const BrowserContextSiteDataMap& site_data_map,
int all_renderer_process_count,
int non_renderer_process_count) {
int process_limit = RenderProcessHost::GetMaxRendererProcessCount();
int num_sites = 0;
int num_https_sites = 0;
int num_browsing_instances = 0;
int num_isolated_site_instances = 0;
int num_isolated_https_site_instances = 0;
for (BrowserContextSiteDataMap::const_iterator i = site_data_map.begin();
i != site_data_map.end(); ++i) {
num_sites += i->second.sites.size();
num_https_sites += i->second.https_sites.size();
num_browsing_instances += i->second.instance_site_map.size();
for (BrowsingInstanceSiteMap::const_iterator iter =
i->second.instance_site_map.begin();
iter != i->second.instance_site_map.end(); ++iter) {
num_isolated_site_instances += iter->second.size();
}
for (BrowsingInstanceSiteMap::const_iterator iter =
i->second.instance_https_site_map.begin();
iter != i->second.instance_https_site_map.end(); ++iter) {
num_isolated_https_site_instances += iter->second.size();
}
}
int process_count_lower_bound = num_sites;
int process_count_upper_bound = num_sites + process_limit - 1;
int process_count_estimate = std::min(
num_isolated_site_instances, process_count_upper_bound);
int process_count_https_lower_bound = num_https_sites;
int process_count_https_upper_bound = num_https_sites + process_limit - 1;
int process_count_https_estimate = std::min(
num_isolated_https_site_instances, process_count_https_upper_bound);
UMA_HISTOGRAM_COUNTS_100("SiteIsolation.CurrentRendererProcessCount",
all_renderer_process_count);
UMA_HISTOGRAM_COUNTS_100(
"SiteIsolation.BrowsingInstanceCount",
num_browsing_instances);
UMA_HISTOGRAM_COUNTS_100(
"SiteIsolation.IsolateAllSitesProcessCountNoLimit",
num_isolated_site_instances);
UMA_HISTOGRAM_COUNTS_100(
"SiteIsolation.IsolateAllSitesProcessCountLowerBound",
process_count_lower_bound);
UMA_HISTOGRAM_COUNTS_100(
"SiteIsolation.IsolateAllSitesProcessCountEstimate",
process_count_estimate);
UMA_HISTOGRAM_COUNTS_100(
"SiteIsolation.IsolateHttpsSitesProcessCountNoLimit",
num_isolated_https_site_instances);
UMA_HISTOGRAM_COUNTS_100(
"SiteIsolation.IsolateHttpsSitesProcessCountLowerBound",
process_count_https_lower_bound);
UMA_HISTOGRAM_COUNTS_100(
"SiteIsolation.IsolateHttpsSitesProcessCountEstimate",
process_count_https_estimate);
UMA_HISTOGRAM_COUNTS_100(
"SiteIsolation.IsolateAllSitesTotalProcessCountEstimate",
process_count_estimate + non_renderer_process_count);
UMA_HISTOGRAM_COUNTS_100(
"SiteIsolation.IsolateHttpsSitesTotalProcessCountEstimate",
process_count_https_estimate + non_renderer_process_count);
}