Chromium Code Reviews| Index: webrtc/base/network.cc |
| diff --git a/webrtc/base/network.cc b/webrtc/base/network.cc |
| index 488c475137a2ee8d7ddbea1fa2ace59175cc3f36..9f888cca15f65d8f31e5fa3f264dd6c4418dbbf1 100644 |
| --- a/webrtc/base/network.cc |
| +++ b/webrtc/base/network.cc |
| @@ -371,6 +371,12 @@ BasicNetworkManager::BasicNetworkManager() |
| } |
| BasicNetworkManager::~BasicNetworkManager() { |
| + if (thread_ && network_monitor_ && |
| + thread_->socketserver()->network_binder() == network_monitor_.get()) { |
| + // In case that network binder is still being used by the socket server |
| + // after it is released here. |
| + thread_->socketserver()->set_network_binder(nullptr); |
| + } |
| } |
| void BasicNetworkManager::OnNetworksChanged() { |
| @@ -731,10 +737,13 @@ void BasicNetworkManager::StartNetworkMonitor() { |
| if (factory == nullptr) { |
| return; |
| } |
| - network_monitor_.reset(factory->CreateNetworkMonitor()); |
| if (!network_monitor_) { |
| - return; |
| + network_monitor_.reset(factory->CreateNetworkMonitor()); |
| + ASSERT(network_monitor_); |
| + ASSERT(thread_ && thread_->socketserver()); |
| + thread_->socketserver()->set_network_binder(network_monitor_.get()); |
|
pthatcher1
2016/01/15 19:56:11
While much less complex than before (which is good
|
| } |
| + |
| network_monitor_->SignalNetworksChanged.connect( |
| this, &BasicNetworkManager::OnNetworksChanged); |
| network_monitor_->Start(); |
| @@ -745,7 +754,6 @@ void BasicNetworkManager::StopNetworkMonitor() { |
| return; |
| } |
| network_monitor_->Stop(); |
| - network_monitor_.reset(); |
| } |
| void BasicNetworkManager::OnMessage(Message* msg) { |