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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 }; | 23 }; |
24 using ScenarioBrowsingInstanceMap = | 24 using ScenarioBrowsingInstanceMap = |
25 base::hash_map<int32_t, ScenarioBrowsingInstanceInfo>; | 25 base::hash_map<int32_t, ScenarioBrowsingInstanceInfo>; |
26 | 26 |
27 // Collects metrics about an actual browsing instance in the current session. | 27 // Collects metrics about an actual browsing instance in the current session. |
28 struct BrowsingInstanceInfo { | 28 struct BrowsingInstanceInfo { |
29 BrowsingInstanceInfo(); | 29 BrowsingInstanceInfo(); |
30 ~BrowsingInstanceInfo(); | 30 ~BrowsingInstanceInfo(); |
31 | 31 |
32 std::set<content::SiteInstance*> site_instances; | 32 std::set<content::SiteInstance*> site_instances; |
| 33 int proxy_count = 0; |
33 }; | 34 }; |
34 using BrowsingInstanceMap = | 35 using BrowsingInstanceMap = |
35 base::hash_map<content::SiteInstance*, BrowsingInstanceInfo>; | 36 base::hash_map<content::SiteInstance*, BrowsingInstanceInfo>; |
36 | 37 |
37 // This enum represents various alternative process model policies that we want | 38 // This enum represents various alternative process model policies that we want |
38 // to evaluate. We'll estimate the process cost of each scenario. | 39 // to evaluate. We'll estimate the process cost of each scenario. |
39 enum IsolationScenarioType { | 40 enum IsolationScenarioType { |
40 ISOLATE_NOTHING, | 41 ISOLATE_NOTHING, |
41 ISOLATE_ALL_SITES, | 42 ISOLATE_ALL_SITES, |
42 ISOLATE_HTTPS_SITES, | 43 ISOLATE_HTTPS_SITES, |
43 ISOLATE_EXTENSIONS, | 44 ISOLATE_EXTENSIONS, |
44 ISOLATION_SCENARIO_LAST = ISOLATE_EXTENSIONS | 45 ISOLATION_SCENARIO_LAST = ISOLATE_EXTENSIONS |
45 }; | 46 }; |
46 | 47 |
47 // Contains the state required to estimate the process count under a particular | 48 // Contains the state required to estimate the process count under a particular |
48 // process model. We have one of these per IsolationScenarioType. | 49 // process model. We have one of these per IsolationScenarioType. |
49 struct IsolationScenario { | 50 struct IsolationScenario { |
50 IsolationScenario(); | 51 IsolationScenario(); |
51 ~IsolationScenario(); | 52 ~IsolationScenario(); |
52 | 53 |
53 IsolationScenarioType policy; | 54 IsolationScenarioType policy = ISOLATE_NOTHING; |
54 std::set<GURL> all_sites; | 55 std::set<GURL> all_sites; |
55 ScenarioBrowsingInstanceMap browsing_instances; | 56 ScenarioBrowsingInstanceMap browsing_instances; |
56 }; | 57 }; |
57 | 58 |
58 // Information about the sites and SiteInstances in each BrowsingInstance, for | 59 // Information about the sites and SiteInstances in each BrowsingInstance, for |
59 // use in estimating the number of processes needed for various process models. | 60 // use in estimating the number of processes needed for various process models. |
60 struct SiteData { | 61 struct SiteData { |
61 SiteData(); | 62 SiteData(); |
62 ~SiteData(); | 63 ~SiteData(); |
63 | 64 |
64 // One IsolationScenario object per IsolationScenarioType. | 65 // One IsolationScenario object per IsolationScenarioType. |
65 IsolationScenario scenarios[ISOLATION_SCENARIO_LAST + 1]; | 66 IsolationScenario scenarios[ISOLATION_SCENARIO_LAST + 1]; |
66 | 67 |
67 // This map groups related SiteInstances together into BrowsingInstances. The | 68 // This map groups related SiteInstances together into BrowsingInstances. The |
68 // first SiteInstance we see in a BrowsingInstance is designated as the | 69 // first SiteInstance we see in a BrowsingInstance is designated as the |
69 // 'primary' SiteInstance, and becomes the key of this map. | 70 // 'primary' SiteInstance, and becomes the key of this map. |
70 BrowsingInstanceMap browsing_instances; | 71 BrowsingInstanceMap browsing_instances; |
71 | 72 |
72 // A count of all RenderFrameHosts, which are in a different SiteInstance from | 73 // A count of all RenderFrameHosts, which are in a different SiteInstance from |
73 // their parents. | 74 // their parents. |
74 int out_of_process_frames; | 75 int out_of_process_frames = 0; |
75 }; | 76 }; |
76 | 77 |
77 // Maps a BrowserContext to information about the sites it contains. | 78 // Maps a BrowserContext to information about the sites it contains. |
78 typedef base::hash_map<content::BrowserContext*, SiteData> | 79 typedef base::hash_map<content::BrowserContext*, SiteData> |
79 BrowserContextSiteDataMap; | 80 BrowserContextSiteDataMap; |
80 | 81 |
81 class SiteDetails { | 82 class SiteDetails { |
82 public: | 83 public: |
83 // Collect information about all committed sites in the given WebContents | 84 // Collect information about all committed sites in the given WebContents |
84 // on the UI thread. | 85 // on the UI thread. |
85 static void CollectSiteInfo(content::WebContents* contents, | 86 static void CollectSiteInfo(content::WebContents* contents, |
86 SiteData* site_data); | 87 SiteData* site_data); |
87 | 88 |
88 // Updates the global histograms for tracking memory usage. | 89 // Updates the global histograms for tracking memory usage. |
89 static void UpdateHistograms(const BrowserContextSiteDataMap& site_data_map, | 90 static void UpdateHistograms(const BrowserContextSiteDataMap& site_data_map, |
90 int all_renderer_process_count, | 91 int all_renderer_process_count, |
91 int non_renderer_process_count); | 92 int non_renderer_process_count); |
92 | 93 |
93 private: | 94 private: |
94 // Never needs to be constructed. | 95 // Never needs to be constructed. |
95 SiteDetails(); | 96 SiteDetails(); |
96 ~SiteDetails(); | 97 ~SiteDetails(); |
97 | 98 |
98 DISALLOW_COPY_AND_ASSIGN(SiteDetails); | 99 DISALLOW_COPY_AND_ASSIGN(SiteDetails); |
99 }; | 100 }; |
100 | 101 |
101 #endif // CHROME_BROWSER_SITE_DETAILS_H_ | 102 #endif // CHROME_BROWSER_SITE_DETAILS_H_ |
OLD | NEW |