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 #include "net/base/network_change_notifier_linux.h" | 5 #include "net/base/network_change_notifier_linux.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "net/base/address_tracker_linux.h" | 10 #include "net/base/address_tracker_linux.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); | 75 NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); |
| 76 // When the IP address of a network interface is added/deleted, the | 76 // When the IP address of a network interface is added/deleted, the |
| 77 // connection type may have changed. | 77 // connection type may have changed. |
| 78 OnLinkChanged(); | 78 OnLinkChanged(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void NetworkChangeNotifierLinux::Thread::OnLinkChanged() { | 81 void NetworkChangeNotifierLinux::Thread::OnLinkChanged() { |
| 82 if (last_type_ != GetCurrentConnectionType()) { | 82 if (last_type_ != GetCurrentConnectionType()) { |
| 83 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); | 83 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); |
| 84 last_type_ = GetCurrentConnectionType(); | 84 last_type_ = GetCurrentConnectionType(); |
| 85 double max_bandwidth = | |
| 86 last_type_ == CONNECTION_NONE | |
| 87 ? NetworkChangeNotifier::GetMaxBandwidthForConnectionSubtype( | |
| 88 SUBTYPE_NONE) | |
| 89 : NetworkChangeNotifier::GetMaxBandwidthForConnectionSubtype( | |
| 90 SUBTYPE_UNKNOWN); | |
|
pauljensen
2015/09/15 18:17:40
how about ReallyLongFunctionName(conditon ? SUBTYP
jkarlin
2015/09/16 12:12:22
Good idea. Done.
| |
| 91 NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChange(last_type_, | |
| 92 max_bandwidth); | |
| 85 } | 93 } |
| 86 } | 94 } |
| 87 | 95 |
| 88 NetworkChangeNotifierLinux::NetworkChangeNotifierLinux( | 96 NetworkChangeNotifierLinux::NetworkChangeNotifierLinux( |
| 89 const base::hash_set<std::string>& ignored_interfaces) | 97 const base::hash_set<std::string>& ignored_interfaces) |
| 90 : NetworkChangeNotifier(NetworkChangeCalculatorParamsLinux()), | 98 : NetworkChangeNotifier(NetworkChangeCalculatorParamsLinux()), |
| 91 notifier_thread_(new Thread(ignored_interfaces)) { | 99 notifier_thread_(new Thread(ignored_interfaces)) { |
| 92 // We create this notifier thread because the notification implementation | 100 // We create this notifier thread because the notification implementation |
| 93 // needs a MessageLoopForIO, and there's no guarantee that | 101 // needs a MessageLoopForIO, and there's no guarantee that |
| 94 // MessageLoop::current() meets that criterion. | 102 // MessageLoop::current() meets that criterion. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 120 NetworkChangeNotifierLinux::GetCurrentConnectionType() const { | 128 NetworkChangeNotifierLinux::GetCurrentConnectionType() const { |
| 121 return notifier_thread_->GetCurrentConnectionType(); | 129 return notifier_thread_->GetCurrentConnectionType(); |
| 122 } | 130 } |
| 123 | 131 |
| 124 const internal::AddressTrackerLinux* | 132 const internal::AddressTrackerLinux* |
| 125 NetworkChangeNotifierLinux::GetAddressTrackerInternal() const { | 133 NetworkChangeNotifierLinux::GetAddressTrackerInternal() const { |
| 126 return notifier_thread_->address_tracker(); | 134 return notifier_thread_->address_tracker(); |
| 127 } | 135 } |
| 128 | 136 |
| 129 } // namespace net | 137 } // namespace net |
| OLD | NEW |