| 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 <map> |
| 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/site_instance.h" | 14 #include "content/public/browser/site_instance.h" |
| 14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 15 | 16 |
| 16 // Collects information for a browsing instance assuming some alternate | 17 // Collects information for a browsing instance assuming some alternate |
| 17 // isolation scenario. | 18 // isolation scenario. |
| 18 struct ScenarioBrowsingInstanceInfo { | 19 struct ScenarioBrowsingInstanceInfo { |
| 19 ScenarioBrowsingInstanceInfo(); | 20 ScenarioBrowsingInstanceInfo(); |
| 20 ScenarioBrowsingInstanceInfo(const ScenarioBrowsingInstanceInfo& other); | 21 ScenarioBrowsingInstanceInfo(const ScenarioBrowsingInstanceInfo& other); |
| 21 ~ScenarioBrowsingInstanceInfo(); | 22 ~ScenarioBrowsingInstanceInfo(); |
| 22 | 23 |
| 23 std::set<GURL> sites; | 24 std::set<GURL> sites; |
| 24 }; | 25 }; |
| 25 using ScenarioBrowsingInstanceMap = | 26 using ScenarioBrowsingInstanceMap = |
| 26 base::hash_map<int32_t, ScenarioBrowsingInstanceInfo>; | 27 std::map<int32_t, ScenarioBrowsingInstanceInfo>; |
| 27 | 28 |
| 28 // Collects metrics about an actual browsing instance in the current session. | 29 // Collects metrics about an actual browsing instance in the current session. |
| 29 struct BrowsingInstanceInfo { | 30 struct BrowsingInstanceInfo { |
| 30 BrowsingInstanceInfo(); | 31 BrowsingInstanceInfo(); |
| 31 BrowsingInstanceInfo(const BrowsingInstanceInfo& other); | 32 BrowsingInstanceInfo(const BrowsingInstanceInfo& other); |
| 32 ~BrowsingInstanceInfo(); | 33 ~BrowsingInstanceInfo(); |
| 33 | 34 |
| 34 std::set<content::SiteInstance*> site_instances; | 35 std::set<content::SiteInstance*> site_instances; |
| 35 int proxy_count = 0; | 36 int proxy_count = 0; |
| 36 }; | 37 }; |
| 37 using BrowsingInstanceMap = | 38 using BrowsingInstanceMap = |
| 38 base::hash_map<content::SiteInstance*, BrowsingInstanceInfo>; | 39 std::map<content::SiteInstance*, BrowsingInstanceInfo>; |
| 39 | 40 |
| 40 // This enum represents various alternative process model policies that we want | 41 // This enum represents various alternative process model policies that we want |
| 41 // to evaluate. We'll estimate the process cost of each scenario. | 42 // to evaluate. We'll estimate the process cost of each scenario. |
| 42 enum IsolationScenarioType { | 43 enum IsolationScenarioType { |
| 43 ISOLATE_NOTHING, | 44 ISOLATE_NOTHING, |
| 44 ISOLATE_ALL_SITES, | 45 ISOLATE_ALL_SITES, |
| 45 ISOLATE_HTTPS_SITES, | 46 ISOLATE_HTTPS_SITES, |
| 46 ISOLATE_EXTENSIONS, | 47 ISOLATE_EXTENSIONS, |
| 47 ISOLATION_SCENARIO_LAST = ISOLATE_EXTENSIONS | 48 ISOLATION_SCENARIO_LAST = ISOLATE_EXTENSIONS |
| 48 }; | 49 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 73 // first SiteInstance we see in a BrowsingInstance is designated as the | 74 // first SiteInstance we see in a BrowsingInstance is designated as the |
| 74 // 'primary' SiteInstance, and becomes the key of this map. | 75 // 'primary' SiteInstance, and becomes the key of this map. |
| 75 BrowsingInstanceMap browsing_instances; | 76 BrowsingInstanceMap browsing_instances; |
| 76 | 77 |
| 77 // A count of all RenderFrameHosts, which are in a different SiteInstance from | 78 // A count of all RenderFrameHosts, which are in a different SiteInstance from |
| 78 // their parents. | 79 // their parents. |
| 79 int out_of_process_frames = 0; | 80 int out_of_process_frames = 0; |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 // Maps a BrowserContext to information about the sites it contains. | 83 // Maps a BrowserContext to information about the sites it contains. |
| 83 typedef base::hash_map<content::BrowserContext*, SiteData> | 84 typedef std::map<content::BrowserContext*, SiteData> BrowserContextSiteDataMap; |
| 84 BrowserContextSiteDataMap; | |
| 85 | 85 |
| 86 class SiteDetails { | 86 class SiteDetails { |
| 87 public: | 87 public: |
| 88 // Collect information about all committed sites in the given WebContents | 88 // Collect information about all committed sites in the given WebContents |
| 89 // on the UI thread. | 89 // on the UI thread. |
| 90 static void CollectSiteInfo(content::WebContents* contents, | 90 static void CollectSiteInfo(content::WebContents* contents, |
| 91 SiteData* site_data); | 91 SiteData* site_data); |
| 92 | 92 |
| 93 // Updates the global histograms for tracking memory usage. | 93 // Updates the global histograms for tracking memory usage. |
| 94 static void UpdateHistograms(const BrowserContextSiteDataMap& site_data_map, | 94 static void UpdateHistograms(const BrowserContextSiteDataMap& site_data_map, |
| 95 int all_renderer_process_count, | 95 int all_renderer_process_count, |
| 96 int non_renderer_process_count); | 96 int non_renderer_process_count); |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 // Never needs to be constructed. | 99 // Never needs to be constructed. |
| 100 SiteDetails(); | 100 SiteDetails(); |
| 101 ~SiteDetails(); | 101 ~SiteDetails(); |
| 102 | 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(SiteDetails); | 103 DISALLOW_COPY_AND_ASSIGN(SiteDetails); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 #endif // CHROME_BROWSER_SITE_DETAILS_H_ | 106 #endif // CHROME_BROWSER_SITE_DETAILS_H_ |
| OLD | NEW |