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

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

Issue 7464009: Removal of Profile from content part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: browser_context Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
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_RENDERER_HOST_SITE_INSTANCE_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "content/browser/renderer_host/render_process_host.h" 9 #include "content/browser/renderer_host/render_process_host.h"
10 #include "content/common/notification_observer.h" 10 #include "content/common/notification_observer.h"
(...skipping 18 matching lines...) Expand all
29 // BrowsingInstance. 29 // BrowsingInstance.
30 // 30 //
31 // In process-per-site-instance (the current default process model), 31 // In process-per-site-instance (the current default process model),
32 // SiteInstances are created (1) when the user manually creates a new tab 32 // SiteInstances are created (1) when the user manually creates a new tab
33 // (which also creates a new BrowsingInstance), and (2) when the user navigates 33 // (which also creates a new BrowsingInstance), and (2) when the user navigates
34 // across site boundaries (which uses the same BrowsingInstance). If the user 34 // across site boundaries (which uses the same BrowsingInstance). If the user
35 // navigates within a site, or opens links in new tabs within a site, the same 35 // navigates within a site, or opens links in new tabs within a site, the same
36 // SiteInstance is used. 36 // SiteInstance is used.
37 // 37 //
38 // In --process-per-site, we consolidate all SiteInstances for a given site, 38 // In --process-per-site, we consolidate all SiteInstances for a given site,
39 // throughout the entire profile. This ensures that only one process will be 39 // throughout the entire context. This ensures that only one process will be
40 // dedicated to each site. 40 // dedicated to each site.
41 // 41 //
42 // Each NavigationEntry for a TabContents points to the SiteInstance that 42 // Each NavigationEntry for a TabContents points to the SiteInstance that
43 // rendered it. Each RenderViewHost also points to the SiteInstance that it is 43 // rendered it. Each RenderViewHost also points to the SiteInstance that it is
44 // associated with. A SiteInstance keeps track of the number of these 44 // associated with. A SiteInstance keeps track of the number of these
45 // references and deletes itself when the count goes to zero. This means that 45 // references and deletes itself when the count goes to zero. This means that
46 // a SiteInstance is only live as long as it is accessible, either from new 46 // a SiteInstance is only live as long as it is accessible, either from new
47 // tabs with no NavigationEntries or in NavigationEntries in the history. 47 // tabs with no NavigationEntries or in NavigationEntries in the history.
48 // 48 //
49 /////////////////////////////////////////////////////////////////////////////// 49 ///////////////////////////////////////////////////////////////////////////////
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 // Factory method to create a new SiteInstance. This will create a new 113 // Factory method to create a new SiteInstance. This will create a new
114 // new BrowsingInstance, so it should only be used when creating a new tab 114 // new BrowsingInstance, so it should only be used when creating a new tab
115 // from scratch (or similar circumstances). Callers should ensure that 115 // from scratch (or similar circumstances). Callers should ensure that
116 // this SiteInstance becomes ref counted, by storing it in a scoped_refptr. 116 // this SiteInstance becomes ref counted, by storing it in a scoped_refptr.
117 // 117 //
118 // The render process host factory may be NULL. See SiteInstance constructor. 118 // The render process host factory may be NULL. See SiteInstance constructor.
119 // 119 //
120 // TODO(creis): This may be an argument to build a pass_refptr<T> class, as 120 // TODO(creis): This may be an argument to build a pass_refptr<T> class, as
121 // Darin suggests. 121 // Darin suggests.
122 static SiteInstance* CreateSiteInstance(Profile* profile); 122 static SiteInstance* CreateSiteInstance(content::BrowserContext* context);
jam 2011/07/22 16:58:38 browser_context in all this file
123 123
124 // Factory method to get the appropriate SiteInstance for the given URL, in 124 // Factory method to get the appropriate SiteInstance for the given URL, in
125 // a new BrowsingInstance. Use this instead of CreateSiteInstance when you 125 // a new BrowsingInstance. Use this instead of CreateSiteInstance when you
126 // know the URL, since it allows special site grouping rules to be applied 126 // know the URL, since it allows special site grouping rules to be applied
127 // (for example, to group chrome-ui pages into the same instance). 127 // (for example, to group chrome-ui pages into the same instance).
128 static SiteInstance* CreateSiteInstanceForURL(Profile* profile, 128 static SiteInstance* CreateSiteInstanceForURL(
129 const GURL& url); 129 content::BrowserContext* context, const GURL& url);
130 130
131 // Returns the site for the given URL, which includes only the scheme and 131 // Returns the site for the given URL, which includes only the scheme and
132 // registered domain. Returns an empty GURL if the URL has no host. 132 // registered domain. Returns an empty GURL if the URL has no host.
133 static GURL GetSiteForURL(Profile* profile, const GURL& url); 133 static GURL GetSiteForURL(content::BrowserContext* context, const GURL& url);
134 134
135 // Return whether both URLs are part of the same web site, for the purpose of 135 // Return whether both URLs are part of the same web site, for the purpose of
136 // assigning them to processes accordingly. The decision is currently based 136 // assigning them to processes accordingly. The decision is currently based
137 // on the registered domain of the URLs (google.com, bbc.co.uk), as well as 137 // on the registered domain of the URLs (google.com, bbc.co.uk), as well as
138 // the scheme (https, http). This ensures that two pages will be in 138 // the scheme (https, http). This ensures that two pages will be in
139 // the same process if they can communicate with other via JavaScript. 139 // the same process if they can communicate with other via JavaScript.
140 // (e.g., docs.google.com and mail.google.com have DOM access to each other 140 // (e.g., docs.google.com and mail.google.com have DOM access to each other
141 // if they both set their document.domain properties to google.com.) 141 // if they both set their document.domain properties to google.com.)
142 static bool IsSameWebSite(Profile* profile, 142 static bool IsSameWebSite(content::BrowserContext* context,
143 const GURL& url1, const GURL& url2); 143 const GURL& url1, const GURL& url2);
144 144
145 // Returns the renderer type for this URL. 145 // Returns the renderer type for this URL.
146 static RenderProcessHost::Type RendererTypeForURL(const GURL& url); 146 static RenderProcessHost::Type RendererTypeForURL(const GURL& url);
147 147
148 protected: 148 protected:
149 friend class base::RefCounted<SiteInstance>; 149 friend class base::RefCounted<SiteInstance>;
150 friend class BrowsingInstance; 150 friend class BrowsingInstance;
151 151
152 // Virtual to allow tests to extend it. 152 // Virtual to allow tests to extend it.
153 virtual ~SiteInstance(); 153 virtual ~SiteInstance();
154 154
155 // Create a new SiteInstance. Protected to give access to BrowsingInstance 155 // Create a new SiteInstance. Protected to give access to BrowsingInstance
156 // and tests; most callers should use CreateSiteInstance or 156 // and tests; most callers should use CreateSiteInstance or
157 // GetRelatedSiteInstance instead. 157 // GetRelatedSiteInstance instead.
158 explicit SiteInstance(BrowsingInstance* browsing_instance); 158 explicit SiteInstance(BrowsingInstance* browsing_instance);
159 159
160 // Get the effective URL for the given actual URL. 160 // Get the effective URL for the given actual URL.
161 static GURL GetEffectiveURL(Profile* profile, const GURL& url); 161 static GURL GetEffectiveURL(content::BrowserContext* context,
162 const GURL& url);
162 163
163 // Returns the type of renderer process this instance belongs in, for grouping 164 // Returns the type of renderer process this instance belongs in, for grouping
164 // purposes. 165 // purposes.
165 RenderProcessHost::Type GetRendererType(); 166 RenderProcessHost::Type GetRendererType();
166 167
167 private: 168 private:
168 // NotificationObserver implementation. 169 // NotificationObserver implementation.
169 virtual void Observe(int type, 170 virtual void Observe(int type,
170 const NotificationSource& source, 171 const NotificationSource& source,
171 const NotificationDetails& details); 172 const NotificationDetails& details);
(...skipping 27 matching lines...) Expand all
199 // The web site that this SiteInstance is rendering pages for. 200 // The web site that this SiteInstance is rendering pages for.
200 GURL site_; 201 GURL site_;
201 202
202 // Whether SetSite has been called. 203 // Whether SetSite has been called.
203 bool has_site_; 204 bool has_site_;
204 205
205 DISALLOW_COPY_AND_ASSIGN(SiteInstance); 206 DISALLOW_COPY_AND_ASSIGN(SiteInstance);
206 }; 207 };
207 208
208 #endif // CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ 209 #endif // CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698