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

Unified Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 3304015: Use PrefChangeRegistrar everywhere (Closed)
Patch Set: final version for commit Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/chrome_url_request_context.cc
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index c9271d91072fe80a354d669bd99be60fd72ad12c..88f8ee0e685a629b62d94a51278e62e68aafe8c3 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -526,8 +526,7 @@ ChromeURLRequestContext* FactoryForMedia::Create() {
ChromeURLRequestContextGetter::ChromeURLRequestContextGetter(
Profile* profile,
ChromeURLRequestContextFactory* factory)
- : prefs_(NULL),
- factory_(factory),
+ : factory_(factory),
url_request_context_(NULL) {
DCHECK(factory);
@@ -539,7 +538,7 @@ ChromeURLRequestContextGetter::ChromeURLRequestContextGetter(
ChromeURLRequestContextGetter::~ChromeURLRequestContextGetter() {
CheckCurrentlyOnIOThread();
- DCHECK(!prefs_) << "Probably didn't call CleanupOnUIThread";
+ DCHECK(registrar_.IsEmpty()) << "Probably didn't call CleanupOnUIThread";
// Either we already transformed the factory into a URLRequestContext, or
// we still have a pending factory.
@@ -652,13 +651,8 @@ ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(
void ChromeURLRequestContextGetter::CleanupOnUIThread() {
CheckCurrentlyOnMainThread();
-
- if (prefs_) {
- // Unregister for pref notifications.
- prefs_->RemovePrefObserver(prefs::kAcceptLanguages, this);
- prefs_->RemovePrefObserver(prefs::kDefaultCharset, this);
- prefs_ = NULL;
- }
+ // Unregister for pref notifications.
+ registrar_.RemoveAll();
}
void ChromeURLRequestContextGetter::OnNewExtensions(
@@ -710,10 +704,9 @@ void ChromeURLRequestContextGetter::Observe(
void ChromeURLRequestContextGetter::RegisterPrefsObserver(Profile* profile) {
CheckCurrentlyOnMainThread();
- prefs_ = profile->GetPrefs();
-
- prefs_->AddPrefObserver(prefs::kAcceptLanguages, this);
- prefs_->AddPrefObserver(prefs::kDefaultCharset, this);
+ registrar_.Init(profile->GetPrefs());
+ registrar_.Add(prefs::kAcceptLanguages, this);
+ registrar_.Add(prefs::kDefaultCharset, this);
}
// static
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.h ('k') | chrome/browser/notifications/desktop_notification_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698