Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 // Get the browser context to which this BrowsingInstance belongs. | 60 // Get the browser context to which this BrowsingInstance belongs. |
| 61 BrowserContext* browser_context() const { return browser_context_; } | 61 BrowserContext* browser_context() const { return browser_context_; } |
| 62 | 62 |
| 63 // Returns whether this BrowsingInstance has registered a SiteInstance for | 63 // Returns whether this BrowsingInstance has registered a SiteInstance for |
| 64 // the site of the given URL. | 64 // the site of the given URL. |
| 65 bool HasSiteInstance(const GURL& url); | 65 bool HasSiteInstance(const GURL& url); |
| 66 | 66 |
| 67 // Get the SiteInstance responsible for rendering the given URL. Should | 67 // Get the SiteInstance responsible for rendering the given URL. Should |
| 68 // create a new one if necessary, but should not create more than one | 68 // create a new one if necessary, but should not create more than one |
| 69 // SiteInstance per site. | 69 // SiteInstance per site. |
| 70 SiteInstance* GetSiteInstanceForURL(const GURL& url); | 70 SiteInstanceImpl* GetSiteInstanceForURL(const GURL& url); |
|
Matt Perry
2013/04/04 20:54:26
why change these?
Jeffrey Yasskin
2013/04/05 13:14:01
No good reason anymore. I was thinking that I migh
| |
| 71 | 71 |
| 72 // Adds the given SiteInstance to our map, to ensure that we do not create | 72 // Adds the given SiteInstance to our map, to ensure that we do not create |
| 73 // another SiteInstance for the same site. | 73 // another SiteInstance for the same site. |
| 74 void RegisterSiteInstance(SiteInstance* site_instance); | 74 void RegisterSiteInstance(SiteInstanceImpl* site_instance); |
| 75 | 75 |
| 76 // Removes the given SiteInstance from our map, after all references to it | 76 // Removes the given SiteInstance from our map, after all references to it |
| 77 // have been deleted. This means it is safe to create a new SiteInstance | 77 // have been deleted. This means it is safe to create a new SiteInstance |
| 78 // if the user later visits a page from this site, within this | 78 // if the user later visits a page from this site, within this |
| 79 // BrowsingInstance. | 79 // BrowsingInstance. |
| 80 void UnregisterSiteInstance(SiteInstance* site_instance); | 80 void UnregisterSiteInstance(SiteInstanceImpl* site_instance); |
| 81 | 81 |
| 82 friend class SiteInstanceImpl; | 82 friend class SiteInstanceImpl; |
| 83 friend class SiteInstance; | 83 friend class SiteInstance; |
| 84 | 84 |
| 85 friend class base::RefCounted<BrowsingInstance>; | 85 friend class base::RefCounted<BrowsingInstance>; |
| 86 | 86 |
| 87 // Virtual to allow tests to extend it. | 87 // Virtual to allow tests to extend it. |
| 88 virtual ~BrowsingInstance(); | 88 virtual ~BrowsingInstance(); |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 // Map of site to SiteInstance, to ensure we only have one SiteInstance per | 91 // Map of site to SiteInstance, to ensure we only have one SiteInstance per |
| 92 typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap; | 92 typedef base::hash_map<std::string, SiteInstanceImpl*> SiteInstanceMap; |
| 93 | 93 |
| 94 // Common browser context to which all SiteInstances in this BrowsingInstance | 94 // Common browser context to which all SiteInstances in this BrowsingInstance |
| 95 // must belong. | 95 // must belong. |
| 96 BrowserContext* const browser_context_; | 96 BrowserContext* const browser_context_; |
| 97 | 97 |
| 98 // Map of site to SiteInstance, to ensure we only have one SiteInstance per | 98 // Map of site to SiteInstance, to ensure we only have one SiteInstance per |
| 99 // site. The site string should be the possibly_invalid_spec() of a GURL | 99 // site. The site string should be the possibly_invalid_spec() of a GURL |
| 100 // obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not | 100 // obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not |
| 101 // contain every active SiteInstance, because a race exists where two | 101 // contain every active SiteInstance, because a race exists where two |
| 102 // SiteInstances can be assigned to the same site. This is ok in rare cases. | 102 // SiteInstances can be assigned to the same site. This is ok in rare cases. |
| 103 SiteInstanceMap site_instance_map_; | 103 SiteInstanceMap site_instance_map_; |
| 104 | 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance); | 105 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 } // namespace content | 108 } // namespace content |
| 109 | 109 |
| 110 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_ | 110 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_ |
| OLD | NEW |