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

Side by Side Diff: chromeos/network/network_state_handler.cc

Issue 2883283004: Merged Tether and cellular network types in System Tray. (Closed)
Patch Set: fixed failing TetherServiceTest Created 3 years, 6 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
« no previous file with comments | « chrome/browser/chromeos/tether/tether_service_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chromeos/network/network_state_handler.h" 5 #include "chromeos/network/network_state_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 bool visible_only, 416 bool visible_only,
417 int limit, 417 int limit,
418 NetworkStateList* list) { 418 NetworkStateList* list) {
419 DCHECK(list); 419 DCHECK(list);
420 list->clear(); 420 list->clear();
421 421
422 // Sort the network list if necessary. 422 // Sort the network list if necessary.
423 if (!network_list_sorted_) 423 if (!network_list_sorted_)
424 SortNetworkList(); 424 SortNetworkList();
425 425
426 if (type.MatchesPattern(NetworkTypePattern::Tether())) { 426 if (type.MatchesPattern(NetworkTypePattern::Tether()))
427 GetTetherNetworkList(limit, list); 427 GetTetherNetworkList(limit, list);
428 }
429 428
430 int count = list->size(); 429 int count = list->size();
431 430
432 if (type.Equals(NetworkTypePattern::Tether()) || 431 if (type.Equals(NetworkTypePattern::Tether()) ||
433 (limit != 0 && count >= limit)) { 432 (limit != 0 && count >= limit)) {
434 // If only searching for Tether networks, there is no need to continue 433 // If only searching for Tether networks, there is no need to continue
435 // searching through other network types; likewise, if the limit has already 434 // searching through other network types; likewise, if the limit has already
436 // been reached, there is no need to continue searching. 435 // been reached, there is no need to continue searching.
437 return; 436 return;
438 } 437 }
(...skipping 15 matching lines...) Expand all
454 } 453 }
455 if (limit > 0 && ++count >= limit) 454 if (limit > 0 && ++count >= limit)
456 break; 455 break;
457 } 456 }
458 } 457 }
459 458
460 void NetworkStateHandler::GetTetherNetworkList(int limit, 459 void NetworkStateHandler::GetTetherNetworkList(int limit,
461 NetworkStateList* list) { 460 NetworkStateList* list) {
462 DCHECK(list); 461 DCHECK(list);
463 list->clear(); 462 list->clear();
463
464 if (!IsTechnologyEnabled(NetworkTypePattern::Tether()))
465 return;
466
464 int count = 0; 467 int count = 0;
465
466 for (auto iter = tether_network_list_.begin(); 468 for (auto iter = tether_network_list_.begin();
467 iter != tether_network_list_.end(); ++iter) { 469 iter != tether_network_list_.end(); ++iter) {
468 list->push_back((*iter)->AsNetworkState()); 470 list->push_back((*iter)->AsNetworkState());
469 if (limit > 0 && ++count >= limit) 471 if (limit > 0 && ++count >= limit)
470 return; 472 return;
471 } 473 }
472 } 474 }
473 475
474 const NetworkState* NetworkStateHandler::GetNetworkStateFromServicePath( 476 const NetworkState* NetworkStateHandler::GetNetworkStateFromServicePath(
475 const std::string& service_path, 477 const std::string& service_path,
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 if (type.MatchesType(shill::kTypeVPN)) 1484 if (type.MatchesType(shill::kTypeVPN))
1483 technologies.emplace_back(shill::kTypeVPN); 1485 technologies.emplace_back(shill::kTypeVPN);
1484 if (type.MatchesType(kTypeTether)) 1486 if (type.MatchesType(kTypeTether))
1485 technologies.emplace_back(kTypeTether); 1487 technologies.emplace_back(kTypeTether);
1486 1488
1487 CHECK_GT(technologies.size(), 0ul); 1489 CHECK_GT(technologies.size(), 0ul);
1488 return technologies; 1490 return technologies;
1489 } 1491 }
1490 1492
1491 } // namespace chromeos 1493 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/tether/tether_service_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698