summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 09:32:44 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 09:32:44 +0000
commitdd8300719cd3d8514b59f5b182100c238a59abe1 (patch)
tree24919743ef089f040a4071b207d3887eb0ae7418 /chrome/browser/net
parent82b39cbbab422e8a5f696d14c7b3546c98a05fe4 (diff)
downloadchromium_src-dd8300719cd3d8514b59f5b182100c238a59abe1.zip
chromium_src-dd8300719cd3d8514b59f5b182100c238a59abe1.tar.gz
chromium_src-dd8300719cd3d8514b59f5b182100c238a59abe1.tar.bz2
Support dynamic policy refresh for DNS prefetching.
BUG=55423 TEST=none Review URL: http://codereview.chromium.org/3542005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61490 0039d316-1c4b-4281-b951-d872f2087c98
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_
+