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

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

Issue 2875793002: Why this CL triggers an OilPan crash.
Patch Set: Created 3 years, 7 months 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
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // A BrowsingInstance is live as long as any SiteInstance has a reference to 45 // A BrowsingInstance is live as long as any SiteInstance has a reference to
46 // it. A SiteInstance is live as long as any NavigationEntry or RenderViewHost 46 // it. A SiteInstance is live as long as any NavigationEntry or RenderViewHost
47 // have references to it. Because both classes are RefCounted, they do not 47 // have references to it. Because both classes are RefCounted, they do not
48 // need to be manually deleted. 48 // need to be manually deleted.
49 // 49 //
50 // BrowsingInstance has no public members, as it is designed to be 50 // BrowsingInstance has no public members, as it is designed to be
51 // visible only from the SiteInstance class. To get a new 51 // visible only from the SiteInstance class. To get a new
52 // SiteInstance that is part of the same BrowsingInstance, use 52 // SiteInstance that is part of the same BrowsingInstance, use
53 // SiteInstance::GetRelatedSiteInstance. Because of this, 53 // SiteInstance::GetRelatedSiteInstance. Because of this,
54 // BrowsingInstances and SiteInstances are tested together in 54 // BrowsingInstances and SiteInstances are tested together in
55 // site_instance_unittest.cc. 55 // site_instance_impl_unittest.cc.
56 // 56 //
57 /////////////////////////////////////////////////////////////////////////////// 57 ///////////////////////////////////////////////////////////////////////////////
58 class CONTENT_EXPORT BrowsingInstance final 58 class CONTENT_EXPORT BrowsingInstance final
59 : public base::RefCounted<BrowsingInstance> { 59 : public base::RefCounted<BrowsingInstance> {
60 private: 60 private:
61 friend class base::RefCounted<BrowsingInstance>; 61 friend class base::RefCounted<BrowsingInstance>;
62 friend class SiteInstanceImpl; 62 friend class SiteInstanceImpl;
63 FRIEND_TEST_ALL_PREFIXES(SiteInstanceTest, OneSiteInstancePerSite); 63 FRIEND_TEST_ALL_PREFIXES(SiteInstanceTest, OneSiteInstancePerSite);
64 FRIEND_TEST_ALL_PREFIXES(SiteInstanceTest, 64 FRIEND_TEST_ALL_PREFIXES(SiteInstanceTest,
65 OneSiteInstancePerSiteInBrowserContext); 65 OneSiteInstancePerSiteInBrowserContext);
66 66
67 // Create a new BrowsingInstance. 67 // Create a new BrowsingInstance.
68 explicit BrowsingInstance(BrowserContext* context); 68 explicit BrowsingInstance(BrowserContext* context);
69 69
70 ~BrowsingInstance(); 70 ~BrowsingInstance();
71 71
72 // Get the browser context to which this BrowsingInstance belongs. 72 // Get the browser context to which this BrowsingInstance belongs.
73 BrowserContext* browser_context() const { return browser_context_; } 73 BrowserContext* browser_context() const { return browser_context_; }
74 74
75 // Get the id of this instance.
76 int browsing_instance_id() const { return browsing_instance_id_; }
77
75 // Returns whether this BrowsingInstance has registered a SiteInstance for 78 // Returns whether this BrowsingInstance has registered a SiteInstance for
76 // the site of the given URL. 79 // the site of the given URL.
77 bool HasSiteInstance(const GURL& url); 80 bool HasSiteInstance(const GURL& url);
78 81
79 // Get the SiteInstance responsible for rendering the given URL. Should 82 // Get the SiteInstance responsible for rendering the given URL. Should
80 // create a new one if necessary, but should not create more than one 83 // create a new one if necessary, but should not create more than one
81 // SiteInstance per site. 84 // SiteInstance per site.
82 scoped_refptr<SiteInstanceImpl> GetSiteInstanceForURL(const GURL& url); 85 scoped_refptr<SiteInstanceImpl> GetSiteInstanceForURL(const GURL& url);
83 86
84 // Returns a SiteInstance that should be used for subframes when an oopif is 87 // Returns a SiteInstance that should be used for subframes when an oopif is
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not 121 // obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not
119 // contain every active SiteInstance, because a race exists where two 122 // contain every active SiteInstance, because a race exists where two
120 // SiteInstances can be assigned to the same site. This is ok in rare cases. 123 // SiteInstances can be assigned to the same site. This is ok in rare cases.
121 // It also does not contain SiteInstances which have not yet been assigned a 124 // It also does not contain SiteInstances which have not yet been assigned a
122 // site, such as about:blank. See NavigatorImpl::ShouldAssignSiteForURL. 125 // site, such as about:blank. See NavigatorImpl::ShouldAssignSiteForURL.
123 SiteInstanceMap site_instance_map_; 126 SiteInstanceMap site_instance_map_;
124 127
125 // Number of WebContentses currently using this BrowsingInstance. 128 // Number of WebContentses currently using this BrowsingInstance.
126 size_t active_contents_count_; 129 size_t active_contents_count_;
127 130
131 // ID of this BrowsingInstance.
132 int browsing_instance_id_;
133
128 SiteInstanceImpl* default_subframe_site_instance_ = nullptr; 134 SiteInstanceImpl* default_subframe_site_instance_ = nullptr;
129 135
130 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance); 136 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance);
131 }; 137 };
132 138
133 } // namespace content 139 } // namespace content
134 140
135 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_ 141 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/process_management_browsertest.cc ('k') | content/browser/browsing_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698