Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ | 5 #ifndef NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ |
| 6 #define NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ | 6 #define NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ |
| 7 | 7 |
| 8 #include "net/base/network_change_notifier.h" | 8 #include "net/base/network_change_notifier.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 namespace test { | 11 namespace test { |
| 12 | 12 |
| 13 class MockNetworkChangeNotifier : public NetworkChangeNotifier { | 13 class MockNetworkChangeNotifier : public NetworkChangeNotifier { |
| 14 public: | 14 public: |
| 15 MockNetworkChangeNotifier(); | 15 MockNetworkChangeNotifier(); |
| 16 ~MockNetworkChangeNotifier() override; | 16 ~MockNetworkChangeNotifier() override; |
| 17 | 17 |
| 18 ConnectionType GetCurrentConnectionType() const override; | 18 ConnectionType GetCurrentConnectionType() const override; |
| 19 | 19 |
| 20 void ForceNetworkHandlesSupported(); | 20 void ForceNetworkHandlesSupported(); |
| 21 | 21 |
| 22 bool AreNetworkHandlesCurrentlySupported() const override; | 22 bool AreNetworkHandlesCurrentlySupported() const override; |
| 23 | 23 |
| 24 void SetConnectedNetworksList(const NetworkList& network_list); | 24 void SetConnectedNetworksList(const NetworkList& network_list); |
| 25 | 25 |
| 26 void GetCurrentConnectedNetworks(NetworkList* network_list) const override; | 26 void GetCurrentConnectedNetworks(NetworkList* network_list) const override; |
| 27 | 27 |
| 28 void NotifyNetworkMadeDefault(NetworkChangeNotifier::NetworkHandle network); | 28 void NotifyNetworkMadeDefault(NetworkChangeNotifier::NetworkHandle network); |
| 29 | 29 |
| 30 void QueueNetworkMadeDefault(NetworkChangeNotifier::NetworkHandle network); | |
|
Ryan Hamilton
2016/09/10 16:40:34
Can you add some comments. It's not obvious how th
Jana
2016/09/10 23:08:30
Done.
| |
| 31 | |
| 30 void NotifyNetworkDisconnected(NetworkChangeNotifier::NetworkHandle network); | 32 void NotifyNetworkDisconnected(NetworkChangeNotifier::NetworkHandle network); |
| 31 | 33 |
| 34 void QueueNetworkDisconnected(NetworkChangeNotifier::NetworkHandle network); | |
| 35 | |
| 32 private: | 36 private: |
| 33 bool force_network_handles_supported_; | 37 bool force_network_handles_supported_; |
| 34 NetworkChangeNotifier::NetworkList connected_networks_; | 38 NetworkChangeNotifier::NetworkList connected_networks_; |
| 35 }; | 39 }; |
| 36 | 40 |
| 37 // Class to replace existing NetworkChangeNotifier singleton with a | 41 // Class to replace existing NetworkChangeNotifier singleton with a |
| 38 // MockNetworkChangeNotifier for a test. To use, simply create a | 42 // MockNetworkChangeNotifier for a test. To use, simply create a |
| 39 // ScopedMockNetworkChangeNotifier object in the test. | 43 // ScopedMockNetworkChangeNotifier object in the test. |
| 40 class ScopedMockNetworkChangeNotifier { | 44 class ScopedMockNetworkChangeNotifier { |
| 41 public: | 45 public: |
| 42 ScopedMockNetworkChangeNotifier(); | 46 ScopedMockNetworkChangeNotifier(); |
| 43 ~ScopedMockNetworkChangeNotifier(); | 47 ~ScopedMockNetworkChangeNotifier(); |
| 44 | 48 |
| 45 MockNetworkChangeNotifier* mock_network_change_notifier(); | 49 MockNetworkChangeNotifier* mock_network_change_notifier(); |
| 46 | 50 |
| 47 private: | 51 private: |
| 48 std::unique_ptr<NetworkChangeNotifier::DisableForTest> | 52 std::unique_ptr<NetworkChangeNotifier::DisableForTest> |
| 49 disable_network_change_notifier_for_tests_; | 53 disable_network_change_notifier_for_tests_; |
| 50 std::unique_ptr<MockNetworkChangeNotifier> mock_network_change_notifier_; | 54 std::unique_ptr<MockNetworkChangeNotifier> mock_network_change_notifier_; |
| 51 }; | 55 }; |
| 52 | 56 |
| 53 } // namespace test | 57 } // namespace test |
| 54 } // namespace net | 58 } // namespace net |
| 55 | 59 |
| 56 #endif // NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ | 60 #endif // NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ |
| OLD | NEW |