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

Side by Side Diff: chrome/browser/chromeos/arc/arc_session_manager.cc

Issue 2678273005: arc: Logging ARC data removal reasons (Closed)
Patch Set: Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/arc/arc_session_manager.h" 5 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/shelf/shelf_delegate.h" 9 #include "ash/common/shelf/shelf_delegate.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 void ArcSessionManager::OnSessionStopped(StopReason reason) { 162 void ArcSessionManager::OnSessionStopped(StopReason reason) {
163 // TODO(crbug.com/625923): Use |reason| to report more detailed errors. 163 // TODO(crbug.com/625923): Use |reason| to report more detailed errors.
164 if (arc_sign_in_timer_.IsRunning()) 164 if (arc_sign_in_timer_.IsRunning())
165 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED); 165 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED);
166 166
167 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) { 167 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) {
168 // This should be always true, but just in case as this is looked at 168 // This should be always true, but just in case as this is looked at
169 // inside RemoveArcData() at first. 169 // inside RemoveArcData() at first.
170 VLOG(1) << "ARC had previously requested to remove user data.";
170 DCHECK(arc_session_runner_->IsStopped()); 171 DCHECK(arc_session_runner_->IsStopped());
171 RemoveArcData(); 172 RemoveArcData();
172 } else { 173 } else {
173 // To support special "Stop and enable ARC" procedure for enterprise, 174 // To support special "Stop and enable ARC" procedure for enterprise,
174 // here call MaybeReenableArc() asyncronously. 175 // here call MaybeReenableArc() asyncronously.
175 // TODO(hidehiko): Restructure the code. crbug.com/665316 176 // TODO(hidehiko): Restructure the code. crbug.com/665316
176 base::ThreadTaskRunnerHandle::Get()->PostTask( 177 base::ThreadTaskRunnerHandle::Get()->PostTask(
177 FROM_HERE, base::Bind(&ArcSessionManager::MaybeReenableArc, 178 FROM_HERE, base::Bind(&ArcSessionManager::MaybeReenableArc,
178 weak_ptr_factory_.GetWeakPtr())); 179 weak_ptr_factory_.GetWeakPtr()));
179 } 180 }
180 181
181 for (auto& observer : arc_session_observer_list_) 182 for (auto& observer : arc_session_observer_list_)
182 observer.OnSessionStopped(reason); 183 observer.OnSessionStopped(reason);
183 } 184 }
184 185
185 void ArcSessionManager::RemoveArcData() { 186 void ArcSessionManager::RemoveArcData() {
186 // Ignore redundant data removal request. 187 // Ignore redundant data removal request.
187 if (state() == State::REMOVING_DATA_DIR) 188 if (state() == State::REMOVING_DATA_DIR)
188 return; 189 return;
189 190
190 // OnArcDataRemoved resets this flag. 191 // OnArcDataRemoved resets this flag.
191 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, true); 192 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, true);
192 193
193 if (!arc_session_runner_->IsStopped()) { 194 if (!arc_session_runner_->IsStopped()) {
194 // Just set a flag. On session stopped, this will be re-called, 195 // Just set a flag. On session stopped, this will be re-called,
195 // then session manager should remove the data. 196 // then session manager should remove the data.
196 return; 197 return;
197 } 198 }
198 199
200 VLOG(1) << "Starting ARC data removal";
199 SetState(State::REMOVING_DATA_DIR); 201 SetState(State::REMOVING_DATA_DIR);
200 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveArcData( 202 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveArcData(
201 cryptohome::Identification( 203 cryptohome::Identification(
202 multi_user_util::GetAccountIdFromProfile(profile_)), 204 multi_user_util::GetAccountIdFromProfile(profile_)),
203 base::Bind(&ArcSessionManager::OnArcDataRemoved, 205 base::Bind(&ArcSessionManager::OnArcDataRemoved,
204 weak_ptr_factory_.GetWeakPtr())); 206 weak_ptr_factory_.GetWeakPtr()));
205 } 207 }
206 208
207 void ArcSessionManager::OnArcDataRemoved(bool success) { 209 void ArcSessionManager::OnArcDataRemoved(bool success) {
208 LOG_IF(ERROR, !success) << "Required ARC user data wipe failed."; 210 if (success)
211 VLOG(1) << "ARC data removal successful";
212 else
213 LOG(ERROR) << "Request for ARC user data removal failed.";
209 214
210 // TODO(khmel): Browser tests may shutdown profile by itself. Update browser 215 // TODO(khmel): Browser tests may shutdown profile by itself. Update browser
211 // tests and remove this check. 216 // tests and remove this check.
212 if (state() == State::NOT_INITIALIZED) 217 if (state() == State::NOT_INITIALIZED)
213 return; 218 return;
214 219
215 for (auto& observer : observer_list_) 220 for (auto& observer : observer_list_)
216 observer.OnArcDataRemoved(); 221 observer.OnArcDataRemoved();
217 222
218 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, false); 223 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, false);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } 360 }
356 361
357 if (result == ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED || 362 if (result == ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED ||
358 result == ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT || 363 result == ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT ||
359 result == ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR || 364 result == ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR ||
360 // OVERALL_SIGN_IN_TIMEOUT might be an indication that ARC believes it is 365 // OVERALL_SIGN_IN_TIMEOUT might be an indication that ARC believes it is
361 // fully setup, but Chrome does not. 366 // fully setup, but Chrome does not.
362 result == ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT || 367 result == ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT ||
363 // Just to be safe, remove data if we don't know the cause. 368 // Just to be safe, remove data if we don't know the cause.
364 result == ProvisioningResult::UNKNOWN_ERROR) { 369 result == ProvisioningResult::UNKNOWN_ERROR) {
370 VLOG(1) << "ARC provisioning failed: " << result << ". Removing user data";
hidehiko 2017/02/08 04:19:33 How about logging in L320 or so? After the line, w
Luis Héctor Chávez 2017/02/08 18:11:16 I want to comply with the comment I'm adding to Re
365 RemoveArcData(); 371 RemoveArcData();
366 } 372 }
367 373
368 // We'll delay shutting down the ARC instance in this case to allow people 374 // We'll delay shutting down the ARC instance in this case to allow people
369 // to send feedback. 375 // to send feedback.
370 if (support_host_) 376 if (support_host_)
371 support_host_->ShowError(error, true /* = show send feedback button */); 377 support_host_->ShowError(error, true /* = show send feedback button */);
372 } 378 }
373 379
374 void ArcSessionManager::SetState(State state) { 380 void ArcSessionManager::SetState(State state) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 pref_change_registrar_.Init(profile_->GetPrefs()); 435 pref_change_registrar_.Init(profile_->GetPrefs());
430 pref_change_registrar_.Add( 436 pref_change_registrar_.Add(
431 prefs::kArcEnabled, 437 prefs::kArcEnabled,
432 base::Bind(&ArcSessionManager::OnOptInPreferenceChanged, 438 base::Bind(&ArcSessionManager::OnOptInPreferenceChanged,
433 weak_ptr_factory_.GetWeakPtr())); 439 weak_ptr_factory_.GetWeakPtr()));
434 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) { 440 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) {
435 // Don't start ARC if there is a pending request to remove the data. Restart 441 // Don't start ARC if there is a pending request to remove the data. Restart
436 // ARC once data removal finishes. 442 // ARC once data removal finishes.
437 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) { 443 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) {
438 reenable_arc_ = true; 444 reenable_arc_ = true;
445 VLOG(1) << "ARC previously requested to remove data.";
439 RemoveArcData(); 446 RemoveArcData();
440 } else { 447 } else {
441 OnOptInPreferenceChanged(); 448 OnOptInPreferenceChanged();
442 } 449 }
443 } else { 450 } else {
451 VLOG(1) << "ARC disabled on profile. Removing data.";
444 RemoveArcData(); 452 RemoveArcData();
445 PrefServiceSyncableFromProfile(profile_)->AddObserver(this); 453 PrefServiceSyncableFromProfile(profile_)->AddObserver(this);
446 OnIsSyncingChanged(); 454 OnIsSyncingChanged();
447 } 455 }
448 } 456 }
449 457
450 void ArcSessionManager::OnIsSyncingChanged() { 458 void ArcSessionManager::OnIsSyncingChanged() {
451 sync_preferences::PrefServiceSyncable* const pref_service_syncable = 459 sync_preferences::PrefServiceSyncable* const pref_service_syncable =
452 PrefServiceSyncableFromProfile(profile_); 460 PrefServiceSyncableFromProfile(profile_);
453 if (!pref_service_syncable->IsSyncing()) 461 if (!pref_service_syncable->IsSyncing())
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 observer.OnArcOptInChanged(arc_enabled); 538 observer.OnArcOptInChanged(arc_enabled);
531 539
532 // Hide auth notification if it was opened before and arc.enabled pref was 540 // Hide auth notification if it was opened before and arc.enabled pref was
533 // explicitly set to true or false. 541 // explicitly set to true or false.
534 if (!g_disable_ui_for_testing && 542 if (!g_disable_ui_for_testing &&
535 profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) { 543 profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) {
536 ArcAuthNotification::Hide(); 544 ArcAuthNotification::Hide();
537 } 545 }
538 546
539 if (!arc_enabled) { 547 if (!arc_enabled) {
540 // Reset any pending request to re-enable Arc. 548 // Reset any pending request to re-enable ARC.
549 VLOG(1) << "ARC opt-out. Removing user data.";
541 reenable_arc_ = false; 550 reenable_arc_ = false;
542 StopArc(); 551 StopArc();
543 RemoveArcData(); 552 RemoveArcData();
544 return; 553 return;
545 } 554 }
546 555
547 if (state_ == State::ACTIVE) 556 if (state_ == State::ACTIVE)
548 return; 557 return;
549 558
550 if (state_ == State::REMOVING_DATA_DIR) { 559 if (state_ == State::REMOVING_DATA_DIR) {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 966
958 void ArcSessionManager::SetAttemptUserExitCallbackForTesting( 967 void ArcSessionManager::SetAttemptUserExitCallbackForTesting(
959 const base::Closure& callback) { 968 const base::Closure& callback) {
960 DCHECK(!callback.is_null()); 969 DCHECK(!callback.is_null());
961 attempt_user_exit_callback_ = callback; 970 attempt_user_exit_callback_ = callback;
962 } 971 }
963 972
964 std::ostream& operator<<(std::ostream& os, 973 std::ostream& operator<<(std::ostream& os,
965 const ArcSessionManager::State& state) { 974 const ArcSessionManager::State& state) {
966 switch (state) { 975 switch (state) {
967 case ArcSessionManager::State::NOT_INITIALIZED: 976 case ArcSessionManager::State::NOT_INITIALIZED:
Yusuke Sato 2017/02/08 07:48:55 same
Luis Héctor Chávez 2017/02/08 18:11:16 Done.
968 return os << "NOT_INITIALIZED"; 977 return os << "NOT_INITIALIZED";
969 case ArcSessionManager::State::STOPPED: 978 case ArcSessionManager::State::STOPPED:
970 return os << "STOPPED"; 979 return os << "STOPPED";
971 case ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE: 980 case ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE:
972 return os << "SHOWING_TERMS_OF_SERVICE"; 981 return os << "SHOWING_TERMS_OF_SERVICE";
973 case ArcSessionManager::State::CHECKING_ANDROID_MANAGEMENT: 982 case ArcSessionManager::State::CHECKING_ANDROID_MANAGEMENT:
974 return os << "CHECKING_ANDROID_MANAGEMENT"; 983 return os << "CHECKING_ANDROID_MANAGEMENT";
975 case ArcSessionManager::State::REMOVING_DATA_DIR: 984 case ArcSessionManager::State::REMOVING_DATA_DIR:
976 return os << "REMOVING_DATA_DIR"; 985 return os << "REMOVING_DATA_DIR";
977 case ArcSessionManager::State::ACTIVE: 986 case ArcSessionManager::State::ACTIVE:
978 return os << "ACTIVE"; 987 return os << "ACTIVE";
979 } 988 }
980 989
981 // Some compiler reports an error even if all values of an enum-class are 990 // Some compilers report an error even if all values of an enum-class are
982 // covered indivisually in a switch statement. 991 // covered exhaustively in a switch statement.
983 NOTREACHED(); 992 NOTREACHED();
984 return os; 993 return os;
Yusuke Sato 2017/02/08 07:48:55 same
Luis Héctor Chávez 2017/02/08 18:11:16 Done.
985 } 994 }
986 995
987 } // namespace arc 996 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698