blob: 5ab75ff34cb5e6875e5786f6df65ae0eb5116b5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// 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/browser_thread.h"
#include "chrome/browser/net/predictor_api.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/pref_names.h"
#include "net/http/http_stream_factory.h"
NetPrefObserver::NetPrefObserver(PrefService* prefs) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
dns_prefetching_enabled_.Init(prefs::kDnsPrefetchingEnabled, prefs, this);
spdy_disabled_.Init(prefs::kDisableSpdy, prefs, this);
ApplySettings();
}
NetPrefObserver::~NetPrefObserver() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
void NetPrefObserver::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
ApplySettings();
}
void NetPrefObserver::ApplySettings() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
chrome_browser_net::EnablePredictor(*dns_prefetching_enabled_);
net::HttpStreamFactory::set_spdy_enabled(!*spdy_disabled_);
}
// static
void NetPrefObserver::RegisterPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kDisableSpdy, false);
}
|