Chromium Code Reviews| Index: chrome/browser/net/net_pref_observer.h |
| diff --git a/chrome/browser/net/net_pref_observer.h b/chrome/browser/net/net_pref_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..157ce9fee4f754175a7d5c2c34e259d8627ea640 |
| --- /dev/null |
| +++ b/chrome/browser/net/net_pref_observer.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright (c) 2012 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_ |
| + |
| +#include "base/macros.h" |
| +#include "components/prefs/pref_member.h" |
| +#include "net/http/http_network_session.h" |
| + |
| +class PrefService; |
| + |
| +namespace safe_browsing { |
| +class SafeBrowsingService; |
| +} |
| + |
| +namespace user_prefs { |
| +class PrefRegistrySyncable; |
| +} |
| + |
| +class IOThread; |
| + |
| +// Monitors network-related preferences for changes and applies them to |
| +// globally owned HttpNetworkSessions. |
| +// Profile-owned HttpNetworkSessions are taken care of by a |
| +// UpdateNetParamsCallback passed to the constructor. |
| +// The supplied PrefService must outlive this NetPrefObserver. |
| +// Must be used only on the UI thread. |
| +class NetPrefObserver { |
|
mmenke
2017/01/06 16:18:43
NetHttpSessionParamsObserver? There are a number
pmarko
2017/01/08 20:51:48
Done.
|
| + public: |
| + // Type of callback which will be called when enablement of QUIC is changed. |
| + // This callback will be called on the IO thread. |
| + typedef base::Callback<void(net::HttpNetworkSession::ParamsUpdate)> |
| + UpdateNetParamsCallback; |
| + |
| + // |prefs| must be non-NULL and |*prefs| must outlive this. |
| + // |update_net_params_callback| will be invoked on the IO thread when an |
| + // observed network parmeter is changed. |
| + NetPrefObserver(PrefService* prefs, |
| + UpdateNetParamsCallback update_net_params_callback); |
| + ~NetPrefObserver(); |
| + |
| + // Register user preferences which NetPrefObserver uses into |registry|. |
| + static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| + |
| + private: |
| + // Called on UI thread when an observed net pref changes |
| + void ApplySettings(); |
| + |
| + // Called on IO thread from ApplySettings |
| + void ApplySettingsOnIOThread( |
| + IOThread* io_thread, |
| + safe_browsing::SafeBrowsingService* safe_browsing_service, |
| + bool quic_allowed_for_profile); |
| + |
| + BooleanPrefMember quic_allowed_; |
| + UpdateNetParamsCallback update_net_params_callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NetPrefObserver); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ |