summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/net_pref_observer.cc26
-rw-r--r--chrome/browser/net/net_pref_observer.h33
2 files changed, 59 insertions, 0 deletions
diff --git a/chrome/browser/net/net_pref_observer.cc b/chrome/browser/net/net_pref_observer.cc
new file mode 100644
index 0000000..f81febf
--- /dev/null
+++ b/chrome/browser/net/net_pref_observer.cc
@@ -0,0 +1,26 @@
+// 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.
+
+#include "chrome/browser/net/net_pref_observer.h"
+
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/net/predictor_api.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/common/pref_names.h"
+
+NetPrefObserver::NetPrefObserver(PrefService* prefs) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ dns_prefetching_enabled_.Init(prefs::kDnsPrefetchingEnabled, prefs, this);
+}
+
+NetPrefObserver::~NetPrefObserver() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+}
+
+void NetPrefObserver::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ chrome_browser_net::EnablePredictor(*dns_prefetching_enabled_);
+}
diff --git a/chrome/browser/net/net_pref_observer.h b/chrome/browser/net/net_pref_observer.h
new file mode 100644
index 0000000..d41e8b7
--- /dev/null
+++ b/chrome/browser/net/net_pref_observer.h
@@ -0,0 +1,33 @@
+// 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.
+
+#ifndef CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_
+#define CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "chrome/browser/prefs/pref_member.h"
+#include "chrome/common/notification_observer.h"
+
+// Monitors network-related preferences for changes and applies them.
+// The supplied PrefService must outlive this NetPrefObserver.
+// Must be used only on the UI thread.
+class NetPrefObserver : public NotificationObserver {
+ public:
+ explicit NetPrefObserver(PrefService* prefs);
+ ~NetPrefObserver();
+
+ // NotificationObserver
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ private:
+ BooleanPrefMember dns_prefetching_enabled_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetPrefObserver);
+};
+
+#endif // CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_
+