| 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 // See network_change_notifier_android.h for design explanations. | 5 // See network_change_notifier_android.h for design explanations. |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 class NetworkChangeNotifierDelegateAndroidObserver | 22 class NetworkChangeNotifierDelegateAndroidObserver |
| 23 : public NetworkChangeNotifierDelegateAndroid::Observer { | 23 : public NetworkChangeNotifierDelegateAndroid::Observer { |
| 24 public: | 24 public: |
| 25 NetworkChangeNotifierDelegateAndroidObserver() | 25 NetworkChangeNotifierDelegateAndroidObserver() |
| 26 : type_notifications_count_(0), max_bandwidth_notifications_count_(0) {} | 26 : type_notifications_count_(0), max_bandwidth_notifications_count_(0) {} |
| 27 | 27 |
| 28 // NetworkChangeNotifierDelegateAndroid::Observer: | 28 // NetworkChangeNotifierDelegateAndroid::Observer: |
| 29 void OnConnectionTypeChanged() override { type_notifications_count_++; } | 29 void OnConnectionTypeChanged() override { type_notifications_count_++; } |
| 30 | 30 |
| 31 void OnMaxBandwidthChanged(double max_bandwidth_mbps) override { | 31 void OnMaxBandwidthChanged(net::NetworkChangeNotifier::ConnectionType type, |
| 32 double max_bandwidth_mbps) override { |
| 32 max_bandwidth_notifications_count_++; | 33 max_bandwidth_notifications_count_++; |
| 33 } | 34 } |
| 34 | 35 |
| 35 int type_notifications_count() const { return type_notifications_count_; } | 36 int type_notifications_count() const { return type_notifications_count_; } |
| 36 int bandwidth_notifications_count() const { | 37 int bandwidth_notifications_count() const { |
| 37 return max_bandwidth_notifications_count_; | 38 return max_bandwidth_notifications_count_; |
| 38 } | 39 } |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 int type_notifications_count_; | 42 int type_notifications_count_; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 TEST_F(NetworkChangeNotifierAndroidTest, InitialSignal) { | 273 TEST_F(NetworkChangeNotifierAndroidTest, InitialSignal) { |
| 273 DNSChangeObserver dns_change_observer; | 274 DNSChangeObserver dns_change_observer; |
| 274 NetworkChangeNotifier::AddDNSObserver(&dns_change_observer); | 275 NetworkChangeNotifier::AddDNSObserver(&dns_change_observer); |
| 275 base::MessageLoop::current()->Run(); | 276 base::MessageLoop::current()->Run(); |
| 276 EXPECT_EQ(1, dns_change_observer.initial_notifications_count()); | 277 EXPECT_EQ(1, dns_change_observer.initial_notifications_count()); |
| 277 EXPECT_EQ(0, dns_change_observer.change_notifications_count()); | 278 EXPECT_EQ(0, dns_change_observer.change_notifications_count()); |
| 278 NetworkChangeNotifier::RemoveDNSObserver(&dns_change_observer); | 279 NetworkChangeNotifier::RemoveDNSObserver(&dns_change_observer); |
| 279 } | 280 } |
| 280 | 281 |
| 281 } // namespace net | 282 } // namespace net |
| OLD | NEW |