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..7dbc95e5e77963901c320ee6075734396683d6f4 |
| --- /dev/null |
| +++ b/chrome/browser/net/net_pref_observer.h |
| @@ -0,0 +1,61 @@ |
| +// 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" |
| + |
| +class PrefService; |
| + |
| +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 { |
| + public: |
| + // Describes what change in terms of net parameters. |
| + struct NetParamsChange { |
| + // New value of QUIC enablement. |
| + bool quic_enabled_new; |
| + }; |
| + |
| + // Type of callback which will be called when enablement of QUIC is changed. |
| + // This callback will be called on the UI thread. |
| + typedef base::Callback<void(NetParamsChange)> 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. |
| + explicit NetPrefObserver(PrefService* prefs, |
|
Bence
2016/12/26 18:47:56
Do not use |explicit|, because constructor takes m
pmarko
2017/01/02 10:33:55
Done.
|
| + 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, |
| + NetParamsChange net_params_change); |
| + |
| + BooleanPrefMember quic_allowed_; |
| + UpdateNetParamsCallback update_net_params_callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NetPrefObserver); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ |