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

Side by Side Diff: chromeos/components/tether/tether_network_disconnection_handler.cc

Issue 2821103003: Remove the configuration of Tether-associated Wi-Fi networks once connectivity is lost. (Closed)
Patch Set: Rebase. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/components/tether/tether_network_disconnection_handler.h" 5 #include "chromeos/components/tether/tether_network_disconnection_handler.h"
6 6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/macros.h"
7 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "chromeos/components/tether/network_configuration_remover.h"
8 #include "chromeos/network/network_handler.h" 12 #include "chromeos/network/network_handler.h"
9 #include "chromeos/network/network_state.h" 13 #include "chromeos/network/network_state.h"
10 #include "chromeos/network/network_state_handler.h" 14 #include "chromeos/network/network_state_handler.h"
11 #include "components/proximity_auth/logging/logging.h" 15 #include "components/proximity_auth/logging/logging.h"
12 16
13 namespace chromeos { 17 namespace chromeos {
14 18
15 namespace tether { 19 namespace tether {
16 20
17 TetherNetworkDisconnectionHandler::TetherNetworkDisconnectionHandler( 21 TetherNetworkDisconnectionHandler::TetherNetworkDisconnectionHandler(
18 ActiveHost* active_host)
19 : TetherNetworkDisconnectionHandler(
20 active_host,
21 NetworkHandler::Get()->network_state_handler()) {}
22
23 TetherNetworkDisconnectionHandler::TetherNetworkDisconnectionHandler(
24 ActiveHost* active_host, 22 ActiveHost* active_host,
25 NetworkStateHandler* network_state_handler) 23 NetworkStateHandler* network_state_handler,
26 : active_host_(active_host), network_state_handler_(network_state_handler) { 24 NetworkConfigurationRemover* network_configuration_remover)
25 : active_host_(active_host),
26 network_state_handler_(network_state_handler),
27 network_configuration_remover_(network_configuration_remover) {
27 network_state_handler_->AddObserver(this, FROM_HERE); 28 network_state_handler_->AddObserver(this, FROM_HERE);
28 } 29 }
29 30
30 TetherNetworkDisconnectionHandler::~TetherNetworkDisconnectionHandler() { 31 TetherNetworkDisconnectionHandler::~TetherNetworkDisconnectionHandler() {
31 network_state_handler_->RemoveObserver(this, FROM_HERE); 32 network_state_handler_->RemoveObserver(this, FROM_HERE);
32 } 33 }
33 34
34 void TetherNetworkDisconnectionHandler::NetworkConnectionStateChanged( 35 void TetherNetworkDisconnectionHandler::NetworkConnectionStateChanged(
35 const NetworkState* network) { 36 const NetworkState* network) {
36 // Note: |active_host_->GetWifiNetworkGuid()| returns "" unless currently 37 // Note: |active_host_->GetWifiNetworkGuid()| returns "" unless currently
37 // connected, so this if() statement is only entered on disconnections. 38 // connected, so this if() statement is only entered on disconnections.
38 if (network->guid() == active_host_->GetWifiNetworkGuid() && 39 if (network->guid() == active_host_->GetWifiNetworkGuid() &&
39 !network->IsConnectedState()) { 40 !network->IsConnectedState()) {
40 PA_LOG(INFO) << "Connection to active host (Wi-Fi network GUID " 41 PA_LOG(INFO) << "Connection to active host (Wi-Fi network GUID "
41 << network->guid() << ") has been lost."; 42 << network->guid() << ") has been lost.";
43
44 network_configuration_remover_->RemoveNetworkConfiguration(
45 active_host_->GetWifiNetworkGuid());
46
42 active_host_->SetActiveHostDisconnected(); 47 active_host_->SetActiveHostDisconnected();
43
44 // TODO(hansberry): Remove Wi-Fi network from "known" networks.
45 } 48 }
46 } 49 }
47 50
48 } // namespace tether 51 } // namespace tether
49 52
50 } // namespace chromeos 53 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698