Index: chrome/browser/site_details.cc |
diff --git a/chrome/browser/site_details.cc b/chrome/browser/site_details.cc |
index b38c389d48a8e4ba1d3d3250f95511803f2d728f..04acae206195f0ee6c99602c3027106edb1f6454 100644 |
--- a/chrome/browser/site_details.cc |
+++ b/chrome/browser/site_details.cc |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/site_details.h" |
+#include "base/containers/hash_tables.h" |
ncarter (slow)
2015/12/02 18:16:49
This #include belongs in the .h file.
nasko
2015/12/02 19:06:56
Done.
|
#include "base/metrics/histogram.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/render_frame_host.h" |
@@ -105,11 +106,36 @@ void CollectForScenario(std::map<RenderFrameHost*, GURL>* frame_urls, |
(*frame_urls)[frame] = site; |
} |
+content::SiteInstance* DeterminePrimarySiteInstance( |
+ content::SiteInstance* instance, |
+ SiteData* site_data) { |
+ // Find the BrowsingInstance this WebContents belongs to by iterating over |
+ // the "primary" SiteInstances of each BrowsingInstance we've seen so far. |
+ SiteInstance* primary = nullptr; |
+ for (auto& already_collected_instance : site_data->instances) { |
+ if (instance->IsRelatedSiteInstance(already_collected_instance.first)) { |
+ primary = already_collected_instance.first; |
+ already_collected_instance.second.insert(instance); |
+ break; |
ncarter (slow)
2015/12/02 18:16:49
Just return here. That'll let you get rid of the |
nasko
2015/12/02 19:06:56
Done.
|
+ } |
+ } |
+ if (!primary) { |
+ // Remember this as the "primary" SiteInstance of a new BrowsingInstance. |
+ primary = instance; |
+ site_data->instances.insert( |
+ std::make_pair(instance, std::set<SiteInstance*>())); |
ncarter (slow)
2015/12/02 18:16:49
Shouldn't the new std::set contain |instance| init
nasko
2015/12/02 19:06:56
Acknowledged.
|
+ } |
+ |
+ return primary; |
+} |
+ |
void CollectCurrentSnapshot(SiteData* site_data, RenderFrameHost* frame) { |
if (frame->GetParent()) { |
if (frame->GetSiteInstance() != frame->GetParent()->GetSiteInstance()) |
site_data->out_of_process_frames++; |
} |
+ |
+ DeterminePrimarySiteInstance(frame->GetSiteInstance(), site_data); |
ncarter (slow)
2015/12/02 18:16:49
We've already determined the primary site instance
nasko
2015/12/02 19:06:56
Unfortunately not. Due to crbug.com/522302 not all
|
} |
} // namespace |
@@ -132,21 +158,8 @@ SiteDetails::~SiteDetails() {} |
void SiteDetails::CollectSiteInfo(WebContents* contents, |
SiteData* site_data) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
- // Find the BrowsingInstance this WebContents belongs to by iterating over |
- // the "primary" SiteInstances of each BrowsingInstance we've seen so far. |
- SiteInstance* instance = contents->GetSiteInstance(); |
- SiteInstance* primary = NULL; |
- for (SiteInstance* already_collected_instance : site_data->instances) { |
- if (instance->IsRelatedSiteInstance(already_collected_instance)) { |
- primary = already_collected_instance; |
- break; |
- } |
- } |
- if (!primary) { |
- // Remember this as the "primary" SiteInstance of a new BrowsingInstance. |
- primary = instance; |
- site_data->instances.push_back(instance); |
- } |
+ SiteInstance* primary = |
+ DeterminePrimarySiteInstance(contents->GetSiteInstance(), site_data); |
// Now keep track of how many sites we have in this BrowsingInstance (and |
// overall), including sites in iframes. |
@@ -185,6 +198,10 @@ void SiteDetails::UpdateHistograms( |
} |
num_browsing_instances += i->second.scenarios[ISOLATE_ALL_SITES] |
.browsing_instance_site_map.size(); |
+ for (const auto& site : i->second.instances) { |
+ UMA_HISTOGRAM_COUNTS_100("SiteIsolation.SiteInstancesPerBrowsingInstance", |
+ site.second.size()); |
+ } |
num_oopifs += i->second.out_of_process_frames; |
} |