Index: chromeos/network/network_state_handler.cc |
diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc |
index eaed6e9ce3c70e4908cc14f6f4b8b1ca8aae67cc..2c23bd3285d3a1f79b76a13ef67dcb5c3d997805 100644 |
--- a/chromeos/network/network_state_handler.cc |
+++ b/chromeos/network/network_state_handler.cc |
@@ -7,6 +7,7 @@ |
#include <stddef.h> |
#include "base/bind.h" |
+#include "base/command_line.h" |
#include "base/format_macros.h" |
#include "base/guid.h" |
#include "base/json/json_string_value_serializer.h" |
@@ -19,6 +20,7 @@ |
#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
#include "base/values.h" |
+#include "chromeos/chromeos_switches.h" |
#include "chromeos/network/device_state.h" |
#include "chromeos/network/network_event_log.h" |
#include "chromeos/network/network_state.h" |
@@ -133,7 +135,13 @@ NetworkStateHandler::TechnologyState NetworkStateHandler::GetTechnologyState( |
state = TECHNOLOGY_UNINITIALIZED; |
else if (shill_property_handler_->IsTechnologyAvailable(technology)) |
state = TECHNOLOGY_AVAILABLE; |
- else |
+ else if (technology == kTypeTether && |
+ base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ chromeos::switches::kEnableTether)) { |
+ // TODO (hansberry): Provide Tether a way to enable and disable the |
+ // technology. |
+ state = TECHNOLOGY_ENABLED; |
stevenjb
2017/02/21 22:43:56
If we but {} around one if clause, we should put i
Ryan Hansberry
2017/02/21 23:26:37
Done. Decided to not add a VLOG.
|
+ } else |
state = TECHNOLOGY_UNAVAILABLE; |
VLOG(2) << "GetTechnologyState: " << type.ToDebugString() << " = " << state; |
return state; |
@@ -307,6 +315,20 @@ void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type, |
} |
} |
+void NetworkStateHandler::GetTetherNetworkList(int limit, |
+ NetworkStateList* list) { |
+ DCHECK(list); |
+ list->clear(); |
+ int count = 0; |
+ |
+ for (auto iter = tether_network_list_.begin(); |
+ iter != tether_network_list_.end(); ++iter) { |
+ list->push_back((*iter)->AsNetworkState()); |
+ if (limit > 0 && ++count >= limit) |
+ return; |
+ } |
+} |
+ |
const NetworkState* NetworkStateHandler::GetNetworkStateFromServicePath( |
const std::string& service_path, |
bool configured_only) const { |
@@ -343,9 +365,19 @@ const NetworkState* NetworkStateHandler::GetNetworkStateFromGuid( |
return nullptr; |
} |
-const std::string NetworkStateHandler::CreateTetherNetworkState( |
- const std::string& name) { |
- const std::string& guid = base::GenerateGUID(); |
+void NetworkStateHandler::AddTetherNetworkState(const std::string& guid, |
+ const std::string& name) { |
+#if DCHECK_IS_ON() |
stevenjb
2017/02/21 22:43:56
This #if is only needed if there is logic other th
Ryan Hansberry
2017/02/21 23:26:37
Done.
|
+ DCHECK(!guid.empty()); |
+#endif |
+ |
+ // If the network already exists, do nothing. |
+ for (auto iter = tether_network_list_.begin(); |
+ iter != tether_network_list_.end(); ++iter) { |
+ if (iter->get()->AsNetworkState()->guid() == guid) { |
stevenjb
2017/02/21 22:43:56
I would add:
NET_LOG(ERROR) << "Add tether network
Ryan Hansberry
2017/02/21 23:26:37
Done.
|
+ return; |
+ } |
+ } |
std::unique_ptr<NetworkState> tether_managed_state = |
base::MakeUnique<NetworkState>(base::GenerateGUID()); |
@@ -357,8 +389,6 @@ const std::string NetworkStateHandler::CreateTetherNetworkState( |
tether_network_list_.push_back(std::move(tether_managed_state)); |
NotifyNetworkListChanged(); |
- |
- return guid; |
} |
void NetworkStateHandler::RemoveTetherNetworkState(const std::string& guid) { |
@@ -1028,6 +1058,9 @@ std::string NetworkStateHandler::GetTechnologyForType( |
if (type.MatchesType(shill::kTypeCellular)) |
return shill::kTypeCellular; |
+ if (type.MatchesType(kTypeTether)) |
+ return kTypeTether; |
+ |
NOTREACHED(); |
return std::string(); |
} |