OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_BROWSER_BROWSING_INSTANCE_H_ | 5 #ifndef CONTENT_BROWSER_BROWSING_INSTANCE_H_ |
6 #define CONTENT_BROWSER_BROWSING_INSTANCE_H_ | 6 #define CONTENT_BROWSER_BROWSING_INSTANCE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "chrome/browser/profiles/profile.h" | |
12 | 11 |
13 class GURL; | 12 class GURL; |
| 13 class Profile; |
14 class SiteInstance; | 14 class SiteInstance; |
15 | 15 |
16 /////////////////////////////////////////////////////////////////////////////// | 16 /////////////////////////////////////////////////////////////////////////////// |
17 // | 17 // |
18 // BrowsingInstance class | 18 // BrowsingInstance class |
19 // | 19 // |
20 // A browsing instance corresponds to the notion of a "unit of related browsing | 20 // A browsing instance corresponds to the notion of a "unit of related browsing |
21 // contexts" in the HTML 5 spec. Intuitively, it represents a collection of | 21 // contexts" in the HTML 5 spec. Intuitively, it represents a collection of |
22 // tabs and frames that can have script connections to each other. In that | 22 // tabs and frames that can have script connections to each other. In that |
23 // sense, it reflects the user interface, and not the contents of the tabs and | 23 // sense, it reflects the user interface, and not the contents of the tabs and |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 void UnregisterSiteInstance(SiteInstance* site_instance); | 86 void UnregisterSiteInstance(SiteInstance* site_instance); |
87 | 87 |
88 protected: | 88 protected: |
89 friend class base::RefCounted<BrowsingInstance>; | 89 friend class base::RefCounted<BrowsingInstance>; |
90 | 90 |
91 // Virtual to allow tests to extend it. | 91 // Virtual to allow tests to extend it. |
92 virtual ~BrowsingInstance(); | 92 virtual ~BrowsingInstance(); |
93 | 93 |
94 private: | 94 private: |
95 // Map of site to SiteInstance, to ensure we only have one SiteInstance per | 95 // Map of site to SiteInstance, to ensure we only have one SiteInstance per |
96 // site. The site string should be the possibly_invalid_spec() of a GURL | |
97 // obtained with SiteInstance::GetSiteForURL. | |
98 typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap; | 96 typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap; |
99 | 97 |
100 // Map of Profile runtime Id to SiteInstanceMap, for use in the | 98 // Map of Profile to SiteInstanceMap, for use in the process-per-site model. |
101 // process-per-site model. | 99 // process-per-site model. |
102 typedef base::hash_map<ProfileId, SiteInstanceMap> ProfileSiteInstanceMap; | 100 typedef base::hash_map<Profile*, SiteInstanceMap> ProfileSiteInstanceMap; |
103 | 101 |
104 // Returns a pointer to the relevant SiteInstanceMap for this object. If the | 102 // Returns a pointer to the relevant SiteInstanceMap for this object. If the |
105 // process-per-site model is in use, or if process-per-site-instance is in | 103 // process-per-site model is in use, or if process-per-site-instance is in |
106 // use and |url| matches a site for which we always use one process (e.g., | 104 // use and |url| matches a site for which we always use one process (e.g., |
107 // the new tab page), then this returns the SiteInstanceMap for the entire | 105 // the new tab page), then this returns the SiteInstanceMap for the entire |
108 // profile. If not, this returns the BrowsingInstance's own private | 106 // profile. If not, this returns the BrowsingInstance's own private |
109 // SiteInstanceMap. | 107 // SiteInstanceMap. |
110 SiteInstanceMap* GetSiteInstanceMap(Profile* profile, const GURL& url); | 108 SiteInstanceMap* GetSiteInstanceMap(Profile* profile, const GURL& url); |
111 | 109 |
112 // Utility routine which removes the passed SiteInstance from the passed | 110 // Utility routine which removes the passed SiteInstance from the passed |
(...skipping 13 matching lines...) Expand all Loading... |
126 // This field is only used if we are not using process-per-site. | 124 // This field is only used if we are not using process-per-site. |
127 SiteInstanceMap site_instance_map_; | 125 SiteInstanceMap site_instance_map_; |
128 | 126 |
129 // Global map of Profile to SiteInstanceMap, for process-per-site. | 127 // Global map of Profile to SiteInstanceMap, for process-per-site. |
130 static ProfileSiteInstanceMap profile_site_instance_map_; | 128 static ProfileSiteInstanceMap profile_site_instance_map_; |
131 | 129 |
132 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance); | 130 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance); |
133 }; | 131 }; |
134 | 132 |
135 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_ | 133 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_ |
OLD | NEW |