Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(945)

Side by Side Diff: content/browser/browsing_instance.h

Issue 11340029: Move remaining files in content\browser to the content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "content/public/browser/browser_context.h" 12 #include "content/public/browser/browser_context.h"
13 13
14 class GURL; 14 class GURL;
15 class SiteInstanceImpl;
16 15
17 namespace content { 16 namespace content {
18 class SiteInstance; 17 class SiteInstance;
19 } 18 class SiteInstanceImpl;
20 19
21 /////////////////////////////////////////////////////////////////////////////// 20 ///////////////////////////////////////////////////////////////////////////////
22 // 21 //
23 // BrowsingInstance class 22 // BrowsingInstance class
24 // 23 //
25 // A browsing instance corresponds to the notion of a "unit of related browsing 24 // A browsing instance corresponds to the notion of a "unit of related browsing
26 // contexts" in the HTML 5 spec. Intuitively, it represents a collection of 25 // contexts" in the HTML 5 spec. Intuitively, it represents a collection of
27 // tabs and frames that can have script connections to each other. In that 26 // tabs and frames that can have script connections to each other. In that
28 // sense, it reflects the user interface, and not the contents of the tabs and 27 // sense, it reflects the user interface, and not the contents of the tabs and
29 // frames. 28 // frames.
(...skipping 19 matching lines...) Expand all
49 // SiteInstance that is part of the same BrowsingInstance, use 48 // SiteInstance that is part of the same BrowsingInstance, use
50 // SiteInstance::GetRelatedSiteInstance. Because of this, 49 // SiteInstance::GetRelatedSiteInstance. Because of this,
51 // BrowsingInstances and SiteInstances are tested together in 50 // BrowsingInstances and SiteInstances are tested together in
52 // site_instance_unittest.cc. 51 // site_instance_unittest.cc.
53 // 52 //
54 /////////////////////////////////////////////////////////////////////////////// 53 ///////////////////////////////////////////////////////////////////////////////
55 class CONTENT_EXPORT BrowsingInstance 54 class CONTENT_EXPORT BrowsingInstance
56 : public base::RefCounted<BrowsingInstance> { 55 : public base::RefCounted<BrowsingInstance> {
57 protected: 56 protected:
58 // Create a new BrowsingInstance. 57 // Create a new BrowsingInstance.
59 explicit BrowsingInstance(content::BrowserContext* context); 58 explicit BrowsingInstance(BrowserContext* context);
60 59
61 // Get the browser context to which this BrowsingInstance belongs. 60 // Get the browser context to which this BrowsingInstance belongs.
62 content::BrowserContext* browser_context() const { return browser_context_; } 61 BrowserContext* browser_context() const { return browser_context_; }
63 62
64 // Returns whether this BrowsingInstance has registered a SiteInstance for 63 // Returns whether this BrowsingInstance has registered a SiteInstance for
65 // the site of the given URL. 64 // the site of the given URL.
66 bool HasSiteInstance(const GURL& url); 65 bool HasSiteInstance(const GURL& url);
67 66
68 // Get the SiteInstance responsible for rendering the given URL. Should 67 // Get the SiteInstance responsible for rendering the given URL. Should
69 // 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
70 // SiteInstance per site. 69 // SiteInstance per site.
71 content::SiteInstance* GetSiteInstanceForURL(const GURL& url); 70 SiteInstance* GetSiteInstanceForURL(const GURL& url);
72 71
73 // 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
74 // another SiteInstance for the same site. 73 // another SiteInstance for the same site.
75 void RegisterSiteInstance(content::SiteInstance* site_instance); 74 void RegisterSiteInstance(SiteInstance* site_instance);
76 75
77 // 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
78 // 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
79 // 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
80 // BrowsingInstance. 79 // BrowsingInstance.
81 void UnregisterSiteInstance(content::SiteInstance* site_instance); 80 void UnregisterSiteInstance(SiteInstance* site_instance);
82 81
83 friend class SiteInstanceImpl; 82 friend class SiteInstanceImpl;
84 friend class content::SiteInstance; 83 friend class SiteInstance;
85 84
86 friend class base::RefCounted<BrowsingInstance>; 85 friend class base::RefCounted<BrowsingInstance>;
87 86
88 // Virtual to allow tests to extend it. 87 // Virtual to allow tests to extend it.
89 virtual ~BrowsingInstance(); 88 virtual ~BrowsingInstance();
90 89
91 private: 90 private:
92 // 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
93 typedef base::hash_map<std::string, content::SiteInstance*> SiteInstanceMap; 92 typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap;
94 93
95 // Common browser context to which all SiteInstances in this BrowsingInstance 94 // Common browser context to which all SiteInstances in this BrowsingInstance
96 // must belong. 95 // must belong.
97 content::BrowserContext* const browser_context_; 96 BrowserContext* const browser_context_;
98 97
99 // 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
100 // 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
101 // obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not 100 // obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not
102 // contain every active SiteInstance, because a race exists where two 101 // contain every active SiteInstance, because a race exists where two
103 // 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.
104 SiteInstanceMap site_instance_map_; 103 SiteInstanceMap site_instance_map_;
105 104
106 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance); 105 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance);
107 }; 106 };
108 107
108 } // namespace content
109
109 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_ 110 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698