OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
724 sent_first_update_ = false; | 724 sent_first_update_ = false; |
725 StopNetworkMonitor(); | 725 StopNetworkMonitor(); |
726 } | 726 } |
727 } | 727 } |
728 | 728 |
729 void BasicNetworkManager::StartNetworkMonitor() { | 729 void BasicNetworkManager::StartNetworkMonitor() { |
730 NetworkMonitorFactory* factory = NetworkMonitorFactory::GetFactory(); | 730 NetworkMonitorFactory* factory = NetworkMonitorFactory::GetFactory(); |
731 if (factory == nullptr) { | 731 if (factory == nullptr) { |
732 return; | 732 return; |
733 } | 733 } |
734 network_monitor_.reset(factory->CreateNetworkMonitor()); | 734 network_monitor_ = factory->GetOrCreateNetworkMonitor(); |
pthatcher1
2016/01/14 20:07:24
Why is it necessary for the factory to own the net
honghaiz3
2016/01/15 01:00:38
It is a good point. I revised it to own the monito
| |
735 if (!network_monitor_) { | 735 if (!network_monitor_) { |
736 return; | 736 return; |
737 } | 737 } |
738 network_monitor_->SignalNetworksChanged.connect( | 738 network_monitor_->SignalNetworksChanged.connect( |
739 this, &BasicNetworkManager::OnNetworksChanged); | 739 this, &BasicNetworkManager::OnNetworksChanged); |
740 network_monitor_->Start(); | 740 network_monitor_->Start(); |
741 } | 741 } |
742 | 742 |
743 void BasicNetworkManager::StopNetworkMonitor() { | 743 void BasicNetworkManager::StopNetworkMonitor() { |
744 if (!network_monitor_) { | 744 if (!network_monitor_) { |
745 return; | 745 return; |
746 } | 746 } |
747 network_monitor_->Stop(); | 747 network_monitor_->Stop(); |
748 network_monitor_.reset(); | |
749 } | 748 } |
750 | 749 |
751 void BasicNetworkManager::OnMessage(Message* msg) { | 750 void BasicNetworkManager::OnMessage(Message* msg) { |
752 switch (msg->message_id) { | 751 switch (msg->message_id) { |
753 case kUpdateNetworksMessage: { | 752 case kUpdateNetworksMessage: { |
754 UpdateNetworksContinually(); | 753 UpdateNetworksContinually(); |
755 break; | 754 break; |
756 } | 755 } |
757 case kSignalNetworksMessage: { | 756 case kSignalNetworksMessage: { |
758 SignalNetworksChanged(); | 757 SignalNetworksChanged(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 std::stringstream ss; | 911 std::stringstream ss; |
913 // Print out the first space-terminated token of the network desc, plus | 912 // Print out the first space-terminated token of the network desc, plus |
914 // the IP address. | 913 // the IP address. |
915 ss << "Net[" << description_.substr(0, description_.find(' ')) | 914 ss << "Net[" << description_.substr(0, description_.find(' ')) |
916 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ | 915 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ |
917 << ":" << AdapterTypeToString(type_) << "]"; | 916 << ":" << AdapterTypeToString(type_) << "]"; |
918 return ss.str(); | 917 return ss.str(); |
919 } | 918 } |
920 | 919 |
921 } // namespace rtc | 920 } // namespace rtc |
OLD | NEW |