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

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

Issue 257083002: Check BrowsingInstance before swapping prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: creis comments Created 6 years, 7 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/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"
11 #include "content/public/browser/content_browser_client.h" 11 #include "content/public/browser/content_browser_client.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "content/public/common/url_constants.h" 13 #include "content/public/common/url_constants.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 BrowsingInstance::BrowsingInstance(BrowserContext* browser_context) 17 BrowsingInstance::BrowsingInstance(BrowserContext* browser_context)
18 : browser_context_(browser_context) { 18 : browser_context_(browser_context),
19 active_contents_count_(0) {
Charlie Reis 2014/04/29 22:13:51 Minor nit: You're using 0u everywhere else, so per
davidben 2014/04/29 23:02:26 Done.
19 } 20 }
20 21
21 bool BrowsingInstance::HasSiteInstance(const GURL& url) { 22 bool BrowsingInstance::HasSiteInstance(const GURL& url) {
22 std::string site = 23 std::string site =
23 SiteInstanceImpl::GetSiteForURL(browser_context_, url) 24 SiteInstanceImpl::GetSiteForURL(browser_context_, url)
24 .possibly_invalid_spec(); 25 .possibly_invalid_spec();
25 26
26 return site_instance_map_.find(site) != site_instance_map_.end(); 27 return site_instance_map_.find(site) != site_instance_map_.end();
27 } 28 }
28 29
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 if (i != site_instance_map_.end() && i->second == site_instance) { 78 if (i != site_instance_map_.end() && i->second == site_instance) {
78 // Matches, so erase it. 79 // Matches, so erase it.
79 site_instance_map_.erase(i); 80 site_instance_map_.erase(i);
80 } 81 }
81 } 82 }
82 83
83 BrowsingInstance::~BrowsingInstance() { 84 BrowsingInstance::~BrowsingInstance() {
84 // We should only be deleted when all of the SiteInstances that refer to 85 // We should only be deleted when all of the SiteInstances that refer to
85 // us are gone. 86 // us are gone.
86 DCHECK(site_instance_map_.empty()); 87 DCHECK(site_instance_map_.empty());
88 DCHECK_EQ(0u, active_contents_count_);
87 } 89 }
88 90
89 } // namespace content 91 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698