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

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

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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
« no previous file with comments | « content/browser/browser_thread_impl.cc ('k') | content/browser/cert_store_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browsing_instance.h" 5 #include "content/browser/browsing_instance.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/browser/site_instance_impl.h" 9 #include "content/browser/site_instance_impl.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 27 matching lines...) Expand all
38 38
39 // No current SiteInstance for this site, so let's create one. 39 // No current SiteInstance for this site, so let's create one.
40 SiteInstanceImpl* instance = new SiteInstanceImpl(this); 40 SiteInstanceImpl* instance = new SiteInstanceImpl(this);
41 41
42 // Set the site of this new SiteInstance, which will register it with us. 42 // Set the site of this new SiteInstance, which will register it with us.
43 instance->SetSite(url); 43 instance->SetSite(url);
44 return instance; 44 return instance;
45 } 45 }
46 46
47 void BrowsingInstance::RegisterSiteInstance(SiteInstance* site_instance) { 47 void BrowsingInstance::RegisterSiteInstance(SiteInstance* site_instance) {
48 DCHECK(static_cast<SiteInstanceImpl*>(site_instance)-> 48 DCHECK(static_cast<SiteInstanceImpl*>(site_instance)
49 browsing_instance_ == this); 49 ->browsing_instance_.get() ==
50 this);
50 DCHECK(static_cast<SiteInstanceImpl*>(site_instance)->HasSite()); 51 DCHECK(static_cast<SiteInstanceImpl*>(site_instance)->HasSite());
51 std::string site = site_instance->GetSiteURL().possibly_invalid_spec(); 52 std::string site = site_instance->GetSiteURL().possibly_invalid_spec();
52 53
53 // Only register if we don't have a SiteInstance for this site already. 54 // Only register if we don't have a SiteInstance for this site already.
54 // It's possible to have two SiteInstances point to the same site if two 55 // It's possible to have two SiteInstances point to the same site if two
55 // tabs are navigated there at the same time. (We don't call SetSite or 56 // tabs are navigated there at the same time. (We don't call SetSite or
56 // register them until DidNavigate.) If there is a previously existing 57 // register them until DidNavigate.) If there is a previously existing
57 // SiteInstance for this site, we just won't register the new one. 58 // SiteInstance for this site, we just won't register the new one.
58 SiteInstanceMap::iterator i = site_instance_map_.find(site); 59 SiteInstanceMap::iterator i = site_instance_map_.find(site);
59 if (i == site_instance_map_.end()) { 60 if (i == site_instance_map_.end()) {
60 // Not previously registered, so register it. 61 // Not previously registered, so register it.
61 site_instance_map_[site] = site_instance; 62 site_instance_map_[site] = site_instance;
62 } 63 }
63 } 64 }
64 65
65 void BrowsingInstance::UnregisterSiteInstance(SiteInstance* site_instance) { 66 void BrowsingInstance::UnregisterSiteInstance(SiteInstance* site_instance) {
66 DCHECK(static_cast<SiteInstanceImpl*>(site_instance)-> 67 DCHECK(static_cast<SiteInstanceImpl*>(site_instance)
67 browsing_instance_ == this); 68 ->browsing_instance_.get() ==
69 this);
68 DCHECK(static_cast<SiteInstanceImpl*>(site_instance)->HasSite()); 70 DCHECK(static_cast<SiteInstanceImpl*>(site_instance)->HasSite());
69 std::string site = site_instance->GetSiteURL().possibly_invalid_spec(); 71 std::string site = site_instance->GetSiteURL().possibly_invalid_spec();
70 72
71 // Only unregister the SiteInstance if it is the same one that is registered 73 // Only unregister the SiteInstance if it is the same one that is registered
72 // for the site. (It might have been an unregistered SiteInstance. See the 74 // for the site. (It might have been an unregistered SiteInstance. See the
73 // comments in RegisterSiteInstance.) 75 // comments in RegisterSiteInstance.)
74 SiteInstanceMap::iterator i = site_instance_map_.find(site); 76 SiteInstanceMap::iterator i = site_instance_map_.find(site);
75 if (i != site_instance_map_.end() && i->second == site_instance) { 77 if (i != site_instance_map_.end() && i->second == site_instance) {
76 // Matches, so erase it. 78 // Matches, so erase it.
77 site_instance_map_.erase(i); 79 site_instance_map_.erase(i);
78 } 80 }
79 } 81 }
80 82
81 BrowsingInstance::~BrowsingInstance() { 83 BrowsingInstance::~BrowsingInstance() {
82 // We should only be deleted when all of the SiteInstances that refer to 84 // We should only be deleted when all of the SiteInstances that refer to
83 // us are gone. 85 // us are gone.
84 DCHECK(site_instance_map_.empty()); 86 DCHECK(site_instance_map_.empty());
85 } 87 }
86 88
87 } // namespace content 89 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_thread_impl.cc ('k') | content/browser/cert_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698