| 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 #include "net/quic/chromium/mock_network_change_notifier.h" | 5 #include "net/quic/chromium/mock_network_change_notifier.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 namespace test { | 10 namespace test { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 void MockNetworkChangeNotifier::GetCurrentConnectedNetworks( | 34 void MockNetworkChangeNotifier::GetCurrentConnectedNetworks( |
| 35 NetworkList* network_list) const { | 35 NetworkList* network_list) const { |
| 36 network_list->clear(); | 36 network_list->clear(); |
| 37 *network_list = connected_networks_; | 37 *network_list = connected_networks_; |
| 38 } | 38 } |
| 39 | 39 |
| 40 void MockNetworkChangeNotifier::NotifyNetworkMadeDefault( | 40 void MockNetworkChangeNotifier::NotifyNetworkMadeDefault( |
| 41 NetworkChangeNotifier::NetworkHandle network) { | 41 NetworkChangeNotifier::NetworkHandle network) { |
| 42 NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange( | 42 QueueNetworkMadeDefault(network); |
| 43 NetworkChangeNotifier::MADE_DEFAULT, network); | |
| 44 // Spin the message loop so the notification is delivered. | 43 // Spin the message loop so the notification is delivered. |
| 45 base::RunLoop().RunUntilIdle(); | 44 base::RunLoop().RunUntilIdle(); |
| 46 } | 45 } |
| 47 | 46 |
| 47 void MockNetworkChangeNotifier::QueueNetworkMadeDefault( |
| 48 NetworkChangeNotifier::NetworkHandle network) { |
| 49 NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange( |
| 50 NetworkChangeNotifier::MADE_DEFAULT, network); |
| 51 } |
| 52 |
| 48 void MockNetworkChangeNotifier::NotifyNetworkDisconnected( | 53 void MockNetworkChangeNotifier::NotifyNetworkDisconnected( |
| 49 NetworkChangeNotifier::NetworkHandle network) { | 54 NetworkChangeNotifier::NetworkHandle network) { |
| 50 NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange( | 55 QueueNetworkDisconnected(network); |
| 51 NetworkChangeNotifier::DISCONNECTED, network); | |
| 52 // Spin the message loop so the notification is delivered. | 56 // Spin the message loop so the notification is delivered. |
| 53 base::RunLoop().RunUntilIdle(); | 57 base::RunLoop().RunUntilIdle(); |
| 54 } | 58 } |
| 55 | 59 |
| 60 void MockNetworkChangeNotifier::QueueNetworkDisconnected( |
| 61 NetworkChangeNotifier::NetworkHandle network) { |
| 62 NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange( |
| 63 NetworkChangeNotifier::DISCONNECTED, network); |
| 64 } |
| 65 |
| 56 ScopedMockNetworkChangeNotifier::ScopedMockNetworkChangeNotifier() | 66 ScopedMockNetworkChangeNotifier::ScopedMockNetworkChangeNotifier() |
| 57 : disable_network_change_notifier_for_tests_( | 67 : disable_network_change_notifier_for_tests_( |
| 58 new NetworkChangeNotifier::DisableForTest()), | 68 new NetworkChangeNotifier::DisableForTest()), |
| 59 mock_network_change_notifier_(new MockNetworkChangeNotifier()) {} | 69 mock_network_change_notifier_(new MockNetworkChangeNotifier()) {} |
| 60 | 70 |
| 61 ScopedMockNetworkChangeNotifier::~ScopedMockNetworkChangeNotifier() {} | 71 ScopedMockNetworkChangeNotifier::~ScopedMockNetworkChangeNotifier() {} |
| 62 | 72 |
| 63 MockNetworkChangeNotifier* | 73 MockNetworkChangeNotifier* |
| 64 ScopedMockNetworkChangeNotifier::mock_network_change_notifier() { | 74 ScopedMockNetworkChangeNotifier::mock_network_change_notifier() { |
| 65 return mock_network_change_notifier_.get(); | 75 return mock_network_change_notifier_.get(); |
| 66 } | 76 } |
| 67 | 77 |
| 68 } // namespace test | 78 } // namespace test |
| 69 } // namespace net | 79 } // namespace net |
| OLD | NEW |