summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 01:17:54 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 01:17:54 +0000
commit7a12518454d36fb4ac79431f56106b38cd2482ab (patch)
treeff2fa2bc8761460b9345e0d9c9a1def5a8e5f663 /chrome/browser
parent779c33638f4b10def2d103f4703fa5bf58899aec (diff)
downloadchromium_src-7a12518454d36fb4ac79431f56106b38cd2482ab.zip
chromium_src-7a12518454d36fb4ac79431f56106b38cd2482ab.tar.gz
chromium_src-7a12518454d36fb4ac79431f56106b38cd2482ab.tar.bz2
Make the Blacklist in the URL request context refcounted, since the Profile gets destroyed before the IO thread.
Also some other random misc. cleanup. TBR=darin BUG=none TEST=none Review URL: http://codereview.chromium.org/554140 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37596 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc7
-rw-r--r--chrome/browser/net/chrome_url_request_context.h11
-rw-r--r--chrome/browser/privacy_blacklist/blacklist.h5
-rw-r--r--chrome/browser/profile.cc64
-rw-r--r--chrome/browser/profile.h2
5 files changed, 39 insertions, 50 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 4e9b0ec..7963742 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -740,7 +740,7 @@ bool ChromeURLRequestContext::InterceptCookie(
}
const Blacklist* ChromeURLRequestContext::GetPrivacyBlacklist() const {
- return privacy_blacklist_;
+ return privacy_blacklist_.get();
}
void ChromeURLRequestContext::OnNewExtensions(const std::string& id,
@@ -786,11 +786,6 @@ ChromeURLRequestContext::ChromeURLRequestContext(
is_off_the_record_ = other->is_off_the_record_;
}
-void ChromeURLRequestContext::set_privacy_blacklist(
- const Blacklist* privacy_blacklist) {
- privacy_blacklist_ = privacy_blacklist;
-}
-
void ChromeURLRequestContext::OnAcceptLanguageChange(
const std::string& accept_language) {
CheckCurrentlyOnIOThread();
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index f3d1a14..7c60a56 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -9,6 +9,7 @@
#include "base/linked_ptr.h"
#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/host_zoom_map.h"
+#include "chrome/browser/privacy_blacklist/blacklist.h"
#include "chrome/browser/net/url_request_context_getter.h"
#include "chrome/common/appcache/chrome_appcache_service.h"
#include "chrome/common/extensions/extension.h"
@@ -16,7 +17,6 @@
#include "chrome/common/pref_service.h"
#include "net/url_request/url_request_context.h"
-class Blacklist;
class CommandLine;
class Profile;
@@ -182,7 +182,9 @@ class ChromeURLRequestContext : public URLRequestContext {
void set_host_zoom_map(HostZoomMap* host_zoom_map) {
host_zoom_map_ = host_zoom_map;
}
- void set_privacy_blacklist(const Blacklist* privacy_blacklist);
+ void set_privacy_blacklist(Blacklist* privacy_blacklist) {
+ privacy_blacklist_ = privacy_blacklist;
+ }
void set_appcache_service(ChromeAppCacheService* service) {
appcache_service_ = service;
}
@@ -205,8 +207,7 @@ class ChromeURLRequestContext : public URLRequestContext {
scoped_refptr<ChromeAppCacheService> appcache_service_;
HostContentSettingsMap* host_content_settings_map_;
scoped_refptr<HostZoomMap> host_zoom_map_;
-
- const Blacklist* privacy_blacklist_;
+ scoped_refptr<Blacklist> privacy_blacklist_;
bool is_media_;
bool is_off_the_record_;
@@ -376,7 +377,7 @@ class ChromeURLRequestContextFactory {
FilePath user_script_dir_path_;
HostContentSettingsMap* host_content_settings_map_;
scoped_refptr<HostZoomMap> host_zoom_map_;
- const Blacklist* privacy_blacklist_;
+ scoped_refptr<Blacklist> privacy_blacklist_;
net::TransportSecurityState* transport_security_state_;
scoped_refptr<net::SSLConfigService> ssl_config_service_;
diff --git a/chrome/browser/privacy_blacklist/blacklist.h b/chrome/browser/privacy_blacklist/blacklist.h
index 4101ac57..181b7f0 100644
--- a/chrome/browser/privacy_blacklist/blacklist.h
+++ b/chrome/browser/privacy_blacklist/blacklist.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/linked_ptr.h"
+#include "base/ref_counted.h"
#include "googleurl/src/gurl.h"
#include "net/url_request/url_request.h"
@@ -27,7 +28,7 @@ class PrefService;
// attributes. Each time a resources matches a pattern the filter-attributes
// are used to determine how the browser handles the matching resource.
////////////////////////////////////////////////////////////////////////////////
-class Blacklist {
+class Blacklist : public base::RefCountedThreadSafe<Blacklist> {
public:
class Entry;
class Provider;
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 4e83acd..597b286 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -275,21 +275,18 @@ class OffTheRecordProfileImpl : public Profile,
}
virtual net::TransportSecurityState* GetTransportSecurityState() {
- if (!transport_security_state_.get()) {
- transport_security_state_ =
- new net::TransportSecurityState();
- }
+ if (!transport_security_state_.get())
+ transport_security_state_ = new net::TransportSecurityState();
return transport_security_state_.get();
}
virtual HistoryService* GetHistoryService(ServiceAccessType sat) {
- if (sat == EXPLICIT_ACCESS) {
+ if (sat == EXPLICIT_ACCESS)
return profile_->GetHistoryService(sat);
- } else {
- NOTREACHED() << "This profile is OffTheRecord";
- return NULL;
- }
+
+ NOTREACHED() << "This profile is OffTheRecord";
+ return NULL;
}
virtual HistoryService* GetHistoryServiceWithoutCreating() {
@@ -297,12 +294,11 @@ class OffTheRecordProfileImpl : public Profile,
}
virtual FaviconService* GetFaviconService(ServiceAccessType sat) {
- if (sat == EXPLICIT_ACCESS) {
+ if (sat == EXPLICIT_ACCESS)
return profile_->GetFaviconService(sat);
- } else {
- NOTREACHED() << "This profile is OffTheRecord";
- return NULL;
- }
+
+ NOTREACHED() << "This profile is OffTheRecord";
+ return NULL;
}
virtual SearchVersusNavigateClassifier* GetSearchVersusNavigateClassifier() {
@@ -310,12 +306,11 @@ class OffTheRecordProfileImpl : public Profile,
}
virtual WebDataService* GetWebDataService(ServiceAccessType sat) {
- if (sat == EXPLICIT_ACCESS) {
+ if (sat == EXPLICIT_ACCESS)
return profile_->GetWebDataService(sat);
- } else {
- NOTREACHED() << "This profile is OffTheRecord";
- return NULL;
- }
+
+ NOTREACHED() << "This profile is OffTheRecord";
+ return NULL;
}
virtual WebDataService* GetWebDataServiceWithoutCreating() {
@@ -323,12 +318,11 @@ class OffTheRecordProfileImpl : public Profile,
}
virtual PasswordStore* GetPasswordStore(ServiceAccessType sat) {
- if (sat == EXPLICIT_ACCESS) {
+ if (sat == EXPLICIT_ACCESS)
return profile_->GetPasswordStore(sat);
- } else {
- NOTREACHED() << "This profile is OffTheRecord";
- return NULL;
- }
+
+ NOTREACHED() << "This profile is OffTheRecord";
+ return NULL;
}
virtual PrefService* GetPrefs() {
@@ -361,27 +355,27 @@ class OffTheRecordProfileImpl : public Profile,
}
virtual void InitThemes() {
- GetOriginalProfile()->InitThemes();
+ profile_->InitThemes();
}
virtual void SetTheme(Extension* extension) {
- GetOriginalProfile()->SetTheme(extension);
+ profile_->SetTheme(extension);
}
virtual void SetNativeTheme() {
- GetOriginalProfile()->SetNativeTheme();
+ profile_->SetNativeTheme();
}
virtual void ClearTheme() {
- GetOriginalProfile()->ClearTheme();
+ profile_->ClearTheme();
}
virtual Extension* GetTheme() {
- return GetOriginalProfile()->GetTheme();
+ return profile_->GetTheme();
}
virtual BrowserThemeProvider* GetThemeProvider() {
- return GetOriginalProfile()->GetThemeProvider();
+ return profile_->GetThemeProvider();
}
virtual URLRequestContextGetter* GetRequestContext() {
@@ -403,7 +397,7 @@ class OffTheRecordProfileImpl : public Profile,
}
virtual net::SSLConfigService* GetSSLConfigService() {
- return GetOriginalProfile()->GetSSLConfigService();
+ return profile_->GetSSLConfigService();
}
virtual HostContentSettingsMap* GetHostContentSettingsMap() {
@@ -419,7 +413,7 @@ class OffTheRecordProfileImpl : public Profile,
}
virtual Blacklist* GetPrivacyBlacklist() {
- return GetOriginalProfile()->GetPrivacyBlacklist();
+ return profile_->GetPrivacyBlacklist();
}
virtual SessionService* GetSessionService() {
@@ -457,9 +451,7 @@ class OffTheRecordProfileImpl : public Profile,
}
virtual bool IsSameProfile(Profile* profile) {
- if (profile == static_cast<Profile*>(this))
- return true;
- return profile == profile_;
+ return (profile == this) || (profile == profile_);
}
virtual Time GetStartTime() const {
@@ -984,7 +976,7 @@ Blacklist* ProfileImpl::GetPrivacyBlacklist() {
switches::kEnablePrivacyBlacklists))
return NULL;
if (!privacy_blacklist_.get())
- privacy_blacklist_.reset(new Blacklist(GetPrefs()));
+ privacy_blacklist_ = new Blacklist(GetPrefs());
return privacy_blacklist_.get();
}
diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h
index 6f97fec..1068370 100644
--- a/chrome/browser/profile.h
+++ b/chrome/browser/profile.h
@@ -528,7 +528,7 @@ class ProfileImpl : public Profile,
scoped_ptr<HostContentSettingsMap> host_content_settings_map_;
scoped_refptr<HostZoomMap> host_zoom_map_;
- scoped_ptr<Blacklist> privacy_blacklist_;
+ scoped_refptr<Blacklist> privacy_blacklist_;
scoped_refptr<DownloadManager> download_manager_;
scoped_refptr<HistoryService> history_service_;
scoped_refptr<FaviconService> favicon_service_;