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

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

Issue 2720303002: Do nothing on OnSessionStopped if ARC is being restarted. (Closed)
Patch Set: Created 3 years, 9 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // TODO(hidehiko): When the dependency to ArcAuthNotification from this 135 // TODO(hidehiko): When the dependency to ArcAuthNotification from this
136 // class is removed, we should remove this as well. 136 // class is removed, we should remove this as well.
137 ArcAuthNotification::DisableForTesting(); 137 ArcAuthNotification::DisableForTesting();
138 } 138 }
139 139
140 // static 140 // static
141 void ArcSessionManager::EnableCheckAndroidManagementForTesting() { 141 void ArcSessionManager::EnableCheckAndroidManagementForTesting() {
142 g_enable_check_android_management_for_testing = true; 142 g_enable_check_android_management_for_testing = true;
143 } 143 }
144 144
145 void ArcSessionManager::OnSessionReady() { 145 void ArcSessionManager::OnSessionStopped(StopReason reason, bool restarting) {
146 for (auto& observer : arc_session_observer_list_) 146 if (restarting) {
147 observer.OnSessionReady(); 147 // If ARC is being restarted, here do nothing, and just wait for its
148 } 148 // next run.
149 VLOG(1) << "ARC session is stopped, but being restarted: " << reason;
150 return;
151 }
149 152
150 void ArcSessionManager::OnSessionStopped(StopReason reason) {
151 // TODO(crbug.com/625923): Use |reason| to report more detailed errors. 153 // TODO(crbug.com/625923): Use |reason| to report more detailed errors.
152 if (arc_sign_in_timer_.IsRunning()) 154 if (arc_sign_in_timer_.IsRunning())
hidehiko 2017/02/28 16:33:48 Note: this case is the biggest change in this CL.
153 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED); 155 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED);
154 156
155 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) { 157 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) {
hidehiko 2017/02/28 16:33:48 Note: in case of restarting, we do not want to ent
156 // This should be always true, but just in case as this is looked at 158 // This should be always true, but just in case as this is looked at
157 // inside RemoveArcData() at first. 159 // inside RemoveArcData() at first.
158 VLOG(1) << "ARC had previously requested to remove user data."; 160 VLOG(1) << "ARC had previously requested to remove user data.";
159 DCHECK(arc_session_runner_->IsStopped()); 161 DCHECK(arc_session_runner_->IsStopped());
160 RemoveArcData(); 162 RemoveArcData();
161 } else { 163 } else {
162 // To support special "Stop and enable ARC" procedure for enterprise, 164 // To support special "Stop and enable ARC" procedure for enterprise,
163 // here call MaybeReenableArc() asyncronously. 165 // here call MaybeReenableArc() asyncronously.
164 // TODO(hidehiko): Restructure the code. crbug.com/665316 166 // TODO(hidehiko): Restructure the code. crbug.com/665316
165 base::ThreadTaskRunnerHandle::Get()->PostTask( 167 base::ThreadTaskRunnerHandle::Get()->PostTask(
166 FROM_HERE, base::Bind(&ArcSessionManager::MaybeReenableArc, 168 FROM_HERE, base::Bind(&ArcSessionManager::MaybeReenableArc,
167 weak_ptr_factory_.GetWeakPtr())); 169 weak_ptr_factory_.GetWeakPtr()));
168 } 170 }
169 171
170 for (auto& observer : arc_session_observer_list_) 172 for (auto& observer : observer_list_)
171 observer.OnSessionStopped(reason); 173 observer.OnArcSessionStopped(reason);
hidehiko 2017/02/28 16:33:48 Note: The only use case of this is ArcBootNotifica
172 } 174 }
173 175
174 void ArcSessionManager::RemoveArcData() { 176 void ArcSessionManager::RemoveArcData() {
175 // Ignore redundant data removal request. 177 // Ignore redundant data removal request.
176 if (state() == State::REMOVING_DATA_DIR) 178 if (state() == State::REMOVING_DATA_DIR)
177 return; 179 return;
178 180
179 // OnArcDataRemoved resets this flag. 181 // OnArcDataRemoved resets this flag.
180 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, true); 182 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, true);
181 183
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 void ArcSessionManager::AddObserver(Observer* observer) { 572 void ArcSessionManager::AddObserver(Observer* observer) {
571 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 573 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
572 observer_list_.AddObserver(observer); 574 observer_list_.AddObserver(observer);
573 } 575 }
574 576
575 void ArcSessionManager::RemoveObserver(Observer* observer) { 577 void ArcSessionManager::RemoveObserver(Observer* observer) {
576 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 578 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
577 observer_list_.RemoveObserver(observer); 579 observer_list_.RemoveObserver(observer);
578 } 580 }
579 581
580 void ArcSessionManager::AddSessionObserver(ArcSessionObserver* observer) {
581 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
582 arc_session_observer_list_.AddObserver(observer);
583 }
584
585 void ArcSessionManager::RemoveSessionObserver(ArcSessionObserver* observer) {
586 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
587 arc_session_observer_list_.RemoveObserver(observer);
588 }
589
590 bool ArcSessionManager::IsSessionRunning() const { 582 bool ArcSessionManager::IsSessionRunning() const {
591 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 583 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
592 return arc_session_runner_->IsRunning(); 584 return arc_session_runner_->IsRunning();
593 } 585 }
594 586
595 bool ArcSessionManager::IsSessionStopped() const { 587 bool ArcSessionManager::IsSessionStopped() const {
596 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 588 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
597 return arc_session_runner_->IsStopped(); 589 return arc_session_runner_->IsStopped();
598 } 590 }
599 591
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 987
996 #undef MAP_STATE 988 #undef MAP_STATE
997 989
998 // Some compilers report 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
999 // covered exhaustively in a switch statement. 991 // covered exhaustively in a switch statement.
1000 NOTREACHED() << "Invalid value " << static_cast<int>(state); 992 NOTREACHED() << "Invalid value " << static_cast<int>(state);
1001 return os; 993 return os;
1002 } 994 }
1003 995
1004 } // namespace arc 996 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698