Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: webrtc/base/network.cc

Issue 1284113003: Move the concept of multiple route into Network (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return ost.str(); 157 return ost.str();
158 } 158 }
159 159
160 NetworkManager::NetworkManager() { 160 NetworkManager::NetworkManager() {
161 } 161 }
162 162
163 NetworkManager::~NetworkManager() { 163 NetworkManager::~NetworkManager() {
164 } 164 }
165 165
166 NetworkManagerBase::NetworkManagerBase() 166 NetworkManagerBase::NetworkManagerBase()
167 : max_ipv6_networks_(kMaxIPv6Networks), ipv6_enabled_(true) { 167 : network_permission_state_(NetworkManager::STATE_UNKNOWN),
168 max_ipv6_networks_(kMaxIPv6Networks),
169 ipv6_enabled_(true) {
168 } 170 }
169 171
170 NetworkManagerBase::~NetworkManagerBase() { 172 NetworkManagerBase::~NetworkManagerBase() {
171 for (const auto& kv : networks_map_) { 173 for (const auto& kv : networks_map_) {
172 delete kv.second; 174 delete kv.second;
173 } 175 }
174 } 176 }
175 177
178 NetworkManager::NetworkPermissionState
179 NetworkManagerBase::network_permission_state() const {
180 return network_permission_state_;
181 }
182
176 void NetworkManagerBase::GetAnyAddressNetworks(NetworkList* networks) { 183 void NetworkManagerBase::GetAnyAddressNetworks(NetworkList* networks) {
177 if (!ipv4_any_address_network_) { 184 if (!ipv4_any_address_network_) {
178 const rtc::IPAddress ipv4_any_address(INADDR_ANY); 185 const rtc::IPAddress ipv4_any_address(INADDR_ANY);
179 ipv4_any_address_network_.reset( 186 ipv4_any_address_network_.reset(
180 new rtc::Network("any", "any", ipv4_any_address, 0)); 187 new rtc::Network("any", "any", ipv4_any_address, 0));
181 ipv4_any_address_network_->AddIP(ipv4_any_address); 188 ipv4_any_address_network_->AddIP(ipv4_any_address);
182 } 189 }
183 networks->push_back(ipv4_any_address_network_.get()); 190 networks->push_back(ipv4_any_address_network_.get());
184 191
185 if (ipv6_enabled()) { 192 if (ipv6_enabled()) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 for (Network* network : networks_) { 306 for (Network* network : networks_) {
300 network->set_preference(pref); 307 network->set_preference(pref);
301 if (pref > 0) { 308 if (pref > 0) {
302 --pref; 309 --pref;
303 } else { 310 } else {
304 LOG(LS_ERROR) << "Too many network interfaces to handle!"; 311 LOG(LS_ERROR) << "Too many network interfaces to handle!";
305 break; 312 break;
306 } 313 }
307 } 314 }
308 } 315 }
316
317 network_permission_state_ = STATE_ALLOWED;
pthatcher1 2015/08/18 18:34:19 I don't understand. Why is it not allowed until a
juberti1 2015/08/20 06:31:04 I'm not sure we know if it's allowed initially.
pthatcher1 2015/08/20 06:43:36 Outside of Chrome it is. Chrome can change the st
309 } 318 }
310 319
311 BasicNetworkManager::BasicNetworkManager() 320 BasicNetworkManager::BasicNetworkManager()
312 : thread_(NULL), sent_first_update_(false), start_count_(0), 321 : thread_(NULL), sent_first_update_(false), start_count_(0),
313 network_ignore_mask_(kDefaultNetworkIgnoreMask), 322 network_ignore_mask_(kDefaultNetworkIgnoreMask),
314 ignore_non_default_routes_(false) { 323 ignore_non_default_routes_(false) {
315 } 324 }
316 325
317 BasicNetworkManager::~BasicNetworkManager() { 326 BasicNetworkManager::~BasicNetworkManager() {
318 } 327 }
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 666
658 void BasicNetworkManager::StopUpdating() { 667 void BasicNetworkManager::StopUpdating() {
659 ASSERT(Thread::Current() == thread_); 668 ASSERT(Thread::Current() == thread_);
660 if (!start_count_) 669 if (!start_count_)
661 return; 670 return;
662 671
663 --start_count_; 672 --start_count_;
664 if (!start_count_) { 673 if (!start_count_) {
665 thread_->Clear(this); 674 thread_->Clear(this);
666 sent_first_update_ = false; 675 sent_first_update_ = false;
676 set_network_permission_state(NetworkManager::STATE_UNKNOWN);
pthatcher1 2015/08/18 18:34:19 Why does the permission state change when we stop
667 } 677 }
668 } 678 }
669 679
670 void BasicNetworkManager::OnMessage(Message* msg) { 680 void BasicNetworkManager::OnMessage(Message* msg) {
671 switch (msg->message_id) { 681 switch (msg->message_id) {
672 case kUpdateNetworksMessage: { 682 case kUpdateNetworksMessage: {
673 DoUpdateNetworks(); 683 DoUpdateNetworks();
674 break; 684 break;
675 } 685 }
676 case kSignalNetworksMessage: { 686 case kSignalNetworksMessage: {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 std::stringstream ss; 810 std::stringstream ss;
801 // Print out the first space-terminated token of the network desc, plus 811 // Print out the first space-terminated token of the network desc, plus
802 // the IP address. 812 // the IP address.
803 ss << "Net[" << description_.substr(0, description_.find(' ')) 813 ss << "Net[" << description_.substr(0, description_.find(' '))
804 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ 814 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_
805 << ":" << AdapterTypeToString(type_) << "]"; 815 << ":" << AdapterTypeToString(type_) << "]";
806 return ss.str(); 816 return ss.str();
807 } 817 }
808 818
809 } // namespace rtc 819 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698