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

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

Issue 3461019: FBTF: Move virtual methods to implementation files. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Win+chromeos+mac fixes Created 10 years, 3 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_BROWSING_INSTANCE_H_ 5 #ifndef CHROME_BROWSER_BROWSING_INSTANCE_H_
6 #define CHROME_BROWSER_BROWSING_INSTANCE_H_ 6 #define CHROME_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/logging.h"
11 #include "base/ref_counted.h" 10 #include "base/ref_counted.h"
12 #include "chrome/browser/profile.h" 11 #include "chrome/browser/profile.h"
13 12
14 class GURL; 13 class GURL;
15 class SiteInstance; 14 class SiteInstance;
16 15
17 /////////////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////////////
18 // 17 //
19 // BrowsingInstance class 18 // BrowsingInstance class
20 // 19 //
(...skipping 28 matching lines...) Expand all
49 // Currently, the BrowsingInstance class is not visible outside of the 48 // Currently, the BrowsingInstance class is not visible outside of the
50 // SiteInstance class. To get a new SiteInstance that is part of the same 49 // SiteInstance class. To get a new SiteInstance that is part of the same
51 // BrowsingInstance, use SiteInstance::GetRelatedSiteInstance. Because of 50 // BrowsingInstance, use SiteInstance::GetRelatedSiteInstance. Because of
52 // this, BrowsingInstances and SiteInstances are tested together in 51 // this, BrowsingInstances and SiteInstances are tested together in
53 // site_instance_unittest.cc. 52 // site_instance_unittest.cc.
54 // 53 //
55 /////////////////////////////////////////////////////////////////////////////// 54 ///////////////////////////////////////////////////////////////////////////////
56 class BrowsingInstance : public base::RefCounted<BrowsingInstance> { 55 class BrowsingInstance : public base::RefCounted<BrowsingInstance> {
57 public: 56 public:
58 // Create a new BrowsingInstance. 57 // Create a new BrowsingInstance.
59 explicit BrowsingInstance(Profile* profile) 58 explicit BrowsingInstance(Profile* profile);
60 : profile_(profile) {
61 }
62 59
63 // Returns whether the process-per-site model is in use (globally or just for 60 // Returns whether the process-per-site model is in use (globally or just for
64 // the given url), in which case we should ensure there is only one 61 // the given url), in which case we should ensure there is only one
65 // SiteInstance per site for the entire profile, not just for this 62 // SiteInstance per site for the entire profile, not just for this
66 // BrowsingInstance. 63 // BrowsingInstance.
67 virtual bool ShouldUseProcessPerSite(const GURL& url); 64 virtual bool ShouldUseProcessPerSite(const GURL& url);
68 65
69 // Get the profile to which this BrowsingInstance belongs. 66 // Get the profile to which this BrowsingInstance belongs.
70 Profile* profile() { return profile_; } 67 Profile* profile() { return profile_; }
71 68
(...skipping 13 matching lines...) Expand all
85 // Removes the given SiteInstance from our map, after all references to it 82 // Removes the given SiteInstance from our map, after all references to it
86 // have been deleted. This means it is safe to create a new SiteInstance 83 // have been deleted. This means it is safe to create a new SiteInstance
87 // if the user later visits a page from this site, within this 84 // if the user later visits a page from this site, within this
88 // BrowsingInstance. 85 // BrowsingInstance.
89 void UnregisterSiteInstance(SiteInstance* site_instance); 86 void UnregisterSiteInstance(SiteInstance* site_instance);
90 87
91 protected: 88 protected:
92 friend class base::RefCounted<BrowsingInstance>; 89 friend class base::RefCounted<BrowsingInstance>;
93 90
94 // Virtual to allow tests to extend it. 91 // Virtual to allow tests to extend it.
95 virtual ~BrowsingInstance() { 92 virtual ~BrowsingInstance();
96 // We should only be deleted when all of the SiteInstances that refer to
97 // us are gone.
98 DCHECK(site_instance_map_.empty());
99 }
100 93
101 private: 94 private:
102 // 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
103 // site. The site string should be the possibly_invalid_spec() of a GURL 96 // site. The site string should be the possibly_invalid_spec() of a GURL
104 // obtained with SiteInstance::GetSiteForURL. 97 // obtained with SiteInstance::GetSiteForURL.
105 typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap; 98 typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap;
106 99
107 // Map of Profile runtime Id to SiteInstanceMap, for use in the 100 // Map of Profile runtime Id to SiteInstanceMap, for use in the
108 // process-per-site model. 101 // process-per-site model.
109 typedef base::hash_map<ProfileId, SiteInstanceMap> ProfileSiteInstanceMap; 102 typedef base::hash_map<ProfileId, SiteInstanceMap> ProfileSiteInstanceMap;
(...skipping 18 matching lines...) Expand all
128 // This field is only used if we are not using process-per-site. 121 // This field is only used if we are not using process-per-site.
129 SiteInstanceMap site_instance_map_; 122 SiteInstanceMap site_instance_map_;
130 123
131 // Global map of Profile to SiteInstanceMap, for process-per-site. 124 // Global map of Profile to SiteInstanceMap, for process-per-site.
132 static ProfileSiteInstanceMap profile_site_instance_map_; 125 static ProfileSiteInstanceMap profile_site_instance_map_;
133 126
134 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance); 127 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance);
135 }; 128 };
136 129
137 #endif // CHROME_BROWSER_BROWSING_INSTANCE_H_ 130 #endif // CHROME_BROWSER_BROWSING_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698