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

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

Issue 241223002: Start using RenderFrameProxyHost objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar fixes. Created 6 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) 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"
(...skipping 12 matching lines...) Expand all
23 SiteInstanceImpl::g_render_process_host_factory_ = NULL; 23 SiteInstanceImpl::g_render_process_host_factory_ = NULL;
24 int32 SiteInstanceImpl::next_site_instance_id_ = 1; 24 int32 SiteInstanceImpl::next_site_instance_id_ = 1;
25 25
26 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) 26 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance)
27 : id_(next_site_instance_id_++), 27 : id_(next_site_instance_id_++),
28 active_view_count_(0), 28 active_view_count_(0),
29 browsing_instance_(browsing_instance), 29 browsing_instance_(browsing_instance),
30 process_(NULL), 30 process_(NULL),
31 has_site_(false) { 31 has_site_(false) {
32 DCHECK(browsing_instance); 32 DCHECK(browsing_instance);
33 LOG(ERROR) << "SI::SI[" << this << "]:"
34 << " id:" << id_;
33 } 35 }
34 36
35 SiteInstanceImpl::~SiteInstanceImpl() { 37 SiteInstanceImpl::~SiteInstanceImpl() {
36 GetContentClient()->browser()->SiteInstanceDeleting(this); 38 GetContentClient()->browser()->SiteInstanceDeleting(this);
37 39
38 if (process_) 40 if (process_)
39 process_->RemoveObserver(this); 41 process_->RemoveObserver(this);
40 42
41 // Now that no one is referencing us, we can safely remove ourselves from 43 // Now that no one is referencing us, we can safely remove ourselves from
42 // the BrowsingInstance. Any future visits to a page from this site 44 // the BrowsingInstance. Any future visits to a page from this site
43 // (within the same BrowsingInstance) can safely create a new SiteInstance. 45 // (within the same BrowsingInstance) can safely create a new SiteInstance.
44 if (has_site_) 46 if (has_site_)
45 browsing_instance_->UnregisterSiteInstance( 47 browsing_instance_->UnregisterSiteInstance(
46 static_cast<SiteInstance*>(this)); 48 static_cast<SiteInstance*>(this));
49 LOG(ERROR) << "SI::~SI[" << this << "]:"
50 << " id:" << id_;
47 } 51 }
48 52
49 int32 SiteInstanceImpl::GetId() { 53 int32 SiteInstanceImpl::GetId() {
50 return id_; 54 return id_;
51 } 55 }
52 56
53 bool SiteInstanceImpl::HasProcess() const { 57 bool SiteInstanceImpl::HasProcess() const {
54 if (process_ != NULL) 58 if (process_ != NULL)
55 return true; 59 return true;
56 60
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // be fixed, but until then, we should still not set the site of a 141 // be fixed, but until then, we should still not set the site of a
138 // SiteInstance more than once. 142 // SiteInstance more than once.
139 DCHECK(!has_site_); 143 DCHECK(!has_site_);
140 144
141 // Remember that this SiteInstance has been used to load a URL, even if the 145 // Remember that this SiteInstance has been used to load a URL, even if the
142 // URL is invalid. 146 // URL is invalid.
143 has_site_ = true; 147 has_site_ = true;
144 BrowserContext* browser_context = browsing_instance_->browser_context(); 148 BrowserContext* browser_context = browsing_instance_->browser_context();
145 site_ = GetSiteForURL(browser_context, url); 149 site_ = GetSiteForURL(browser_context, url);
146 150
151 LOG(ERROR) << "SI::SI[" << this << "]:"
152 << " site:" << site_;
153
147 // Now that we have a site, register it with the BrowsingInstance. This 154 // Now that we have a site, register it with the BrowsingInstance. This
148 // ensures that we won't create another SiteInstance for this site within 155 // ensures that we won't create another SiteInstance for this site within
149 // the same BrowsingInstance, because all same-site pages within a 156 // the same BrowsingInstance, because all same-site pages within a
150 // BrowsingInstance can script each other. 157 // BrowsingInstance can script each other.
151 browsing_instance_->RegisterSiteInstance(this); 158 browsing_instance_->RegisterSiteInstance(this);
152 159
153 if (process_) { 160 if (process_) {
154 LockToOrigin(); 161 LockToOrigin();
155 162
156 // Ensure the process is registered for this site if necessary. 163 // Ensure the process is registered for this site if necessary.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 339 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
333 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || 340 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
334 command_line.HasSwitch(switches::kSitePerProcess)) { 341 command_line.HasSwitch(switches::kSitePerProcess)) {
335 ChildProcessSecurityPolicyImpl* policy = 342 ChildProcessSecurityPolicyImpl* policy =
336 ChildProcessSecurityPolicyImpl::GetInstance(); 343 ChildProcessSecurityPolicyImpl::GetInstance();
337 policy->LockToOrigin(process_->GetID(), site_); 344 policy->LockToOrigin(process_->GetID(), site_);
338 } 345 }
339 } 346 }
340 347
341 } // namespace content 348 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698