Chromium Code Reviews| Index: webrtc/base/network.h |
| diff --git a/webrtc/base/network.h b/webrtc/base/network.h |
| index a41da4a69a0f01f41fd7344ce89d99b6f0e593d2..2bd280976386bb743d5c16ebdc76fde234c944a6 100644 |
| --- a/webrtc/base/network.h |
| +++ b/webrtc/base/network.h |
| @@ -37,6 +37,8 @@ class Network; |
| class NetworkMonitorInterface; |
| class Thread; |
| +static const uint16_t kMaxNetworkCost = 999; |
| +static const uint16_t kNetworkCostForUnknownType = 10; |
|
pthatcher1
2016/05/17 21:23:11
See my comments about these names in another CL (I
honghaiz3
2016/05/18 07:41:46
Done. I once worried that one client may set its c
|
| // By default, ignore loopback interfaces on the host. |
| const int kDefaultNetworkIgnoreMask = ADAPTER_TYPE_LOOPBACK; |
| @@ -249,6 +251,8 @@ class BasicNetworkManager : public NetworkManagerBase, |
| // Only updates the networks; does not reschedule the next update. |
| void UpdateNetworksOnce(); |
| + AdapterType GetAdapterTypeFromName(const char* network_name) const; |
| + |
| Thread* thread_; |
| bool sent_first_update_; |
| int start_count_; |
| @@ -273,6 +277,7 @@ class Network { |
| ~Network(); |
| sigslot::signal1<const Network*> SignalInactive; |
| + sigslot::signal1<const Network*> SignalNetworkTypeChanged; |
|
pthatcher1
2016/05/17 21:23:11
SignalTypeChanged would be enough, since this is a
honghaiz3
2016/05/18 07:41:46
Done.
|
| const DefaultLocalAddressProvider* default_local_address_provider() { |
| return default_local_address_provider_; |
| @@ -344,7 +349,23 @@ class Network { |
| void set_ignored(bool ignored) { ignored_ = ignored; } |
| AdapterType type() const { return type_; } |
| - void set_type(AdapterType type) { type_ = type; } |
| + void set_type(AdapterType type) { |
| + if (type_ != type) { |
|
pthatcher1
2016/05/17 21:23:11
I'd slightly prefer this with an early return:
if
honghaiz3
2016/05/18 07:41:46
Done.
|
| + type_ = type; |
| + SignalNetworkTypeChanged(this); |
| + } |
| + } |
| + |
| + uint16_t GetCost() const { |
| + switch (type_) { |
| + case rtc::ADAPTER_TYPE_UNKNOWN: |
| + return kNetworkCostForUnknownType; |
| + case rtc::ADAPTER_TYPE_CELLULAR: |
| + return kMaxNetworkCost; |
| + default: |
|
pthatcher1
2016/05/17 21:23:11
Again, see my comments in the other CL where I thi
honghaiz3
2016/05/18 07:41:46
Done.
|
| + return 0; |
| + } |
| + } |
| // A unique id assigned by the network manager, which may be signaled |
| // to the remote side in the candidate. |