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

Unified Diff: chromeos/network/network_state_handler.cc

Issue 2818593003: [CrOS Tether] Add tether network properties (battery percentage, carrier, and signal strength) to t… (Closed)
Patch Set: Tether networks connectable by default, and generated Closure compiler externs. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/network/network_state_handler.cc
diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
index aeba782ca751cfe87730c31e6c33375bf4defc5b..77916705facd5287fe1cc36e8910fc094c239ed4 100644
--- a/chromeos/network/network_state_handler.cc
+++ b/chromeos/network/network_state_handler.cc
@@ -13,7 +13,6 @@
#include "base/json/json_string_value_serializer.h"
#include "base/json/json_writer.h"
#include "base/location.h"
-#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
@@ -25,6 +24,7 @@
#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler_observer.h"
+#include "chromeos/network/tether_constants.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos {
@@ -297,7 +297,21 @@ void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type,
NetworkStateList* list) {
DCHECK(list);
list->clear();
- int count = 0;
+
+ if (type.MatchesPattern(NetworkTypePattern::Tether())) {
+ GetTetherNetworkList(limit, list);
+ }
+
+ int count = list->size();
+
+ if (type.Equals(NetworkTypePattern::Tether()) ||
+ (limit != 0 && count >= limit)) {
+ // If only searching for tether networks, there is no need to continue
+ // searching through other network types; likewise, if the limit has already
+ // been reached, there is no need to continue searching.
+ return;
+ }
+
// Sort the network list if necessary.
if (!network_list_sorted_)
SortNetworkList();
@@ -366,6 +380,8 @@ void NetworkStateHandler::AddTetherNetworkState(const std::string& guid,
std::unique_ptr<NetworkState> tether_network_state =
base::MakeUnique<NetworkState>(guid);
+ // Tether networks are always connectable
+ tether_network_state->connectable_ = true;
tether_network_state->set_name(name);
tether_network_state->set_type(kTypeTether);
tether_network_state->SetGuid(guid);
@@ -574,7 +590,7 @@ void NetworkStateHandler::SetLastErrorForTest(const std::string& service_path,
const std::string& error) {
NetworkState* network_state = GetModifiableNetworkState(service_path);
if (!network_state) {
- LOG(ERROR) << "No matching NetworkState for: " << service_path;
+ NET_LOG(ERROR) << "No matching NetworkState for: " << service_path;
return;
}
network_state->last_error_ = error;

Powered by Google App Engine
This is Rietveld 408576698