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 #ifndef CHROME_BROWSER_SITE_DETAILS_H_ | 5 #ifndef CHROME_BROWSER_SITE_DETAILS_H_ |
6 #define CHROME_BROWSER_SITE_DETAILS_H_ | 6 #define CHROME_BROWSER_SITE_DETAILS_H_ |
7 | 7 |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
10 #include "content/public/browser/site_instance.h" | 10 #include "content/public/browser/site_instance.h" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 | 12 |
13 // Maps an ID representing each BrowsingInstance to a set of site URLs. | 13 // Maps an ID representing each BrowsingInstance to a set of site URLs. |
14 typedef base::hash_map<int32, std::set<GURL> > BrowsingInstanceSiteMap; | 14 typedef base::hash_map<int32, std::set<GURL>> BrowsingInstanceSiteMap; |
15 | |
16 // This enum represents various alternative process model policies that we want | |
17 // to evaluate. We'll estimate the process cost of each scenario. | |
18 enum IsolationScenarioType { | |
19 ISOLATE_ALL_SITES, | |
20 ISOLATE_HTTPS_SITES, | |
21 ISOLATE_EXTENSIONS, | |
22 ISOLATION_SCENARIO_LAST = ISOLATE_EXTENSIONS | |
23 }; | |
24 | |
25 // Contains the state required to estimate the process count under a particular | |
26 // process model. We have one of these per IsolationScenarioType. | |
27 struct IsolationScenario { | |
28 IsolationScenario(); | |
29 ~IsolationScenario(); | |
30 | |
31 void CollectSiteInfoForScenario(content::SiteInstance* primary, | |
32 const GURL& site); | |
33 void GetProcessCountEstimate(); | |
34 void GetProcessCountLowerBound(); | |
35 | |
36 IsolationScenarioType policy; | |
37 std::set<GURL> sites; | |
38 BrowsingInstanceSiteMap browsing_instance_site_map; | |
39 }; | |
15 | 40 |
16 // Information about the sites and SiteInstances in each BrowsingInstance, for | 41 // Information about the sites and SiteInstances in each BrowsingInstance, for |
17 // use in estimating the number of processes needed for various process models. | 42 // use in estimating the number of processes needed for various process models. |
18 struct SiteData { | 43 struct SiteData { |
19 SiteData(); | 44 SiteData(); |
20 ~SiteData(); | 45 ~SiteData(); |
21 | 46 |
22 std::set<GURL> sites; | 47 // One IsolationScenario object per IsolationScenarioType. |
23 std::set<GURL> https_sites; | 48 IsolationScenario scenarios[ISOLATION_SCENARIO_LAST + 1]; |
49 | |
50 // Global list of all SiteInstances, used for de-duping related instances. | |
24 std::vector<content::SiteInstance*> instances; | 51 std::vector<content::SiteInstance*> instances; |
25 BrowsingInstanceSiteMap instance_site_map; | |
26 BrowsingInstanceSiteMap instance_https_site_map; | |
27 }; | 52 }; |
28 | 53 |
29 // Maps a BrowserContext to information about the SiteInstances it contains. | 54 // Maps a BrowserContext to information about the sites it contains. |
nasko
2015/09/04 22:19:43
Why not SiteInstances?
ncarter (slow)
2015/09/10 19:08:58
Because SiteInstances reflect the active process m
| |
30 typedef base::hash_map<content::BrowserContext*, SiteData> | 55 typedef base::hash_map<content::BrowserContext*, SiteData> |
31 BrowserContextSiteDataMap; | 56 BrowserContextSiteDataMap; |
32 | 57 |
33 class SiteDetails { | 58 class SiteDetails { |
34 public: | 59 public: |
35 // Collect information about all committed sites in the given WebContents | 60 // Collect information about all committed sites in the given WebContents |
36 // on the UI thread. | 61 // on the UI thread. |
37 static void CollectSiteInfo(content::WebContents* contents, | 62 static void CollectSiteInfo(content::WebContents* contents, |
38 SiteData* site_data); | 63 SiteData* site_data); |
39 | 64 |
40 // Updates the global histograms for tracking memory usage. | 65 // Updates the global histograms for tracking memory usage. |
41 static void UpdateHistograms(const BrowserContextSiteDataMap& site_data_map, | 66 static void UpdateHistograms(const BrowserContextSiteDataMap& site_data_map, |
42 int all_renderer_process_count, | 67 int all_renderer_process_count, |
43 int non_renderer_process_count); | 68 int non_renderer_process_count); |
44 | 69 |
45 private: | 70 private: |
46 // Never needs to be constructed. | 71 // Never needs to be constructed. |
47 SiteDetails(); | 72 SiteDetails(); |
48 ~SiteDetails(); | 73 ~SiteDetails(); |
49 | 74 |
50 DISALLOW_COPY_AND_ASSIGN(SiteDetails); | 75 DISALLOW_COPY_AND_ASSIGN(SiteDetails); |
51 }; | 76 }; |
52 | 77 |
53 #endif // CHROME_BROWSER_SITE_DETAILS_H_ | 78 #endif // CHROME_BROWSER_SITE_DETAILS_H_ |
OLD | NEW |