| OLD | NEW |
| 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 "chrome/browser/chromeos/tether/tether_service.h" | 5 #include "chrome/browser/chromeos/tether/tether_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 void TetherService::StopTether() { | 128 void TetherService::StopTether() { |
| 129 initializer_delegate_->ShutdownTether(); | 129 initializer_delegate_->ShutdownTether(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void TetherService::Shutdown() { | 132 void TetherService::Shutdown() { |
| 133 if (shut_down_) | 133 if (shut_down_) |
| 134 return; | 134 return; |
| 135 | 135 |
| 136 shut_down_ = true; | 136 shut_down_ = true; |
| 137 | 137 |
| 138 // Remove all observers. This ensures that once Shutdown() is called, no more |
| 139 // calls to UpdateTetherTechnologyState() will be triggered. |
| 138 power_manager_client_->RemoveObserver(this); | 140 power_manager_client_->RemoveObserver(this); |
| 139 session_manager_client_->RemoveObserver(this); | 141 session_manager_client_->RemoveObserver(this); |
| 140 cryptauth_service_->GetCryptAuthDeviceManager()->RemoveObserver(this); | 142 cryptauth_service_->GetCryptAuthDeviceManager()->RemoveObserver(this); |
| 141 network_state_handler_->RemoveObserver(this, FROM_HERE); | 143 network_state_handler_->RemoveObserver(this, FROM_HERE); |
| 142 if (adapter_) | 144 if (adapter_) |
| 143 adapter_->RemoveObserver(this); | 145 adapter_->RemoveObserver(this); |
| 144 registrar_.RemoveAll(); | 146 registrar_.RemoveAll(); |
| 145 | 147 |
| 146 UpdateTetherTechnologyState(); | 148 // Shut down the feature. Note that this does not change Tether's technology |
| 149 // state in NetworkStateHandler because doing so could cause visual jank just |
| 150 // as the user logs out. |
| 151 StopTether(); |
| 147 } | 152 } |
| 148 | 153 |
| 149 void TetherService::SuspendImminent() { | 154 void TetherService::SuspendImminent() { |
| 150 suspended_ = true; | 155 suspended_ = true; |
| 151 UpdateTetherTechnologyState(); | 156 UpdateTetherTechnologyState(); |
| 152 } | 157 } |
| 153 | 158 |
| 154 void TetherService::SuspendDone(const base::TimeDelta& sleep_duration) { | 159 void TetherService::SuspendDone(const base::TimeDelta& sleep_duration) { |
| 155 suspended_ = false; | 160 suspended_ = false; |
| 156 UpdateTetherTechnologyState(); | 161 UpdateTetherTechnologyState(); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 290 } |
| 286 | 291 |
| 287 bool TetherService::IsEnabledbyPreference() const { | 292 bool TetherService::IsEnabledbyPreference() const { |
| 288 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringEnabled); | 293 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringEnabled); |
| 289 } | 294 } |
| 290 | 295 |
| 291 void TetherService::SetInitializerDelegateForTest( | 296 void TetherService::SetInitializerDelegateForTest( |
| 292 std::unique_ptr<InitializerDelegate> initializer_delegate) { | 297 std::unique_ptr<InitializerDelegate> initializer_delegate) { |
| 293 initializer_delegate_ = std::move(initializer_delegate); | 298 initializer_delegate_ = std::move(initializer_delegate); |
| 294 } | 299 } |
| OLD | NEW |