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

Side by Side Diff: content/browser/site_instance_impl.cc

Issue 166533002: [wip] Introduce SiteInstanceKeepAlive. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 10 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) 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 #include "content/browser/site_instance_impl.h" 5 #include "content/browser/site_instance_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/browsing_instance.h" 8 #include "content/browser/browsing_instance.h"
9 #include "content/browser/child_process_security_policy_impl.h" 9 #include "content/browser/child_process_security_policy_impl.h"
10 #include "content/browser/frame_host/debug_urls.h" 10 #include "content/browser/frame_host/debug_urls.h"
11 #include "content/browser/renderer_host/render_process_host_impl.h" 11 #include "content/browser/renderer_host/render_process_host_impl.h"
12 #include "content/browser/storage_partition_impl.h" 12 #include "content/browser/storage_partition_impl.h"
13 #include "content/public/browser/content_browser_client.h" 13 #include "content/public/browser/content_browser_client.h"
14 #include "content/public/browser/render_process_host_factory.h" 14 #include "content/public/browser/render_process_host_factory.h"
15 #include "content/public/browser/web_ui_controller_factory.h" 15 #include "content/public/browser/web_ui_controller_factory.h"
16 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
17 #include "content/public/common/url_constants.h" 17 #include "content/public/common/url_constants.h"
18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 SiteInstanceKeepAlive::SiteInstanceKeepAlive(
23 scoped_refptr<SiteInstanceImpl> instance)
24 : instance_(instance) {
25 instance_->increment_active_view_count();
26 instance_->GetProcess()->AddPendingView();
27 }
28
29 SiteInstanceKeepAlive::~SiteInstanceKeepAlive() {
30 instance_->GetProcess()->RemovePendingView();
31 instance_->decrement_active_view_count();
32 }
33
22 const RenderProcessHostFactory* 34 const RenderProcessHostFactory*
23 SiteInstanceImpl::g_render_process_host_factory_ = NULL; 35 SiteInstanceImpl::g_render_process_host_factory_ = NULL;
24 int32 SiteInstanceImpl::next_site_instance_id_ = 1; 36 int32 SiteInstanceImpl::next_site_instance_id_ = 1;
25 37
26 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) 38 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance)
27 : id_(next_site_instance_id_++), 39 : id_(next_site_instance_id_++),
28 active_view_count_(0), 40 active_view_count_(0),
29 browsing_instance_(browsing_instance), 41 browsing_instance_(browsing_instance),
30 process_(NULL), 42 process_(NULL),
31 has_site_(false) { 43 has_site_(false) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 220
209 void SiteInstanceImpl::set_render_process_host_factory( 221 void SiteInstanceImpl::set_render_process_host_factory(
210 const RenderProcessHostFactory* rph_factory) { 222 const RenderProcessHostFactory* rph_factory) {
211 g_render_process_host_factory_ = rph_factory; 223 g_render_process_host_factory_ = rph_factory;
212 } 224 }
213 225
214 BrowserContext* SiteInstanceImpl::GetBrowserContext() const { 226 BrowserContext* SiteInstanceImpl::GetBrowserContext() const {
215 return browsing_instance_->browser_context(); 227 return browsing_instance_->browser_context();
216 } 228 }
217 229
230 scoped_ptr<SiteInstanceKeepAlive> SiteInstanceImpl::AcquireKeepAlive() {
231 return make_scoped_ptr(new SiteInstanceKeepAlive(this));
232 }
233
218 /*static*/ 234 /*static*/
219 SiteInstance* SiteInstance::Create(BrowserContext* browser_context) { 235 SiteInstance* SiteInstance::Create(BrowserContext* browser_context) {
220 return new SiteInstanceImpl(new BrowsingInstance(browser_context)); 236 return new SiteInstanceImpl(new BrowsingInstance(browser_context));
221 } 237 }
222 238
223 /*static*/ 239 /*static*/
224 SiteInstance* SiteInstance::CreateForURL(BrowserContext* browser_context, 240 SiteInstance* SiteInstance::CreateForURL(BrowserContext* browser_context,
225 const GURL& url) { 241 const GURL& url) {
226 // This BrowsingInstance may be deleted if it returns an existing 242 // This BrowsingInstance may be deleted if it returns an existing
227 // SiteInstance. 243 // SiteInstance.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 339 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
324 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || 340 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
325 command_line.HasSwitch(switches::kSitePerProcess)) { 341 command_line.HasSwitch(switches::kSitePerProcess)) {
326 ChildProcessSecurityPolicyImpl* policy = 342 ChildProcessSecurityPolicyImpl* policy =
327 ChildProcessSecurityPolicyImpl::GetInstance(); 343 ChildProcessSecurityPolicyImpl::GetInstance();
328 policy->LockToOrigin(process_->GetID(), site_); 344 policy->LockToOrigin(process_->GetID(), site_);
329 } 345 }
330 } 346 }
331 347
332 } // namespace content 348 } // namespace content
OLDNEW
« content/browser/site_instance_impl.h ('K') | « content/browser/site_instance_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698