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

Unified Diff: components/arc/arc_session_runner.cc

Issue 2720303002: Do nothing on OnSessionStopped if ARC is being restarted. (Closed)
Patch Set: Address comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/arc/arc_session_runner.h ('k') | components/arc/arc_session_runner_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/arc_session_runner.cc
diff --git a/components/arc/arc_session_runner.cc b/components/arc/arc_session_runner.cc
index 571a2c5d2996abb49c69484f41a864092c634131..005539e557b1a6b3038b7ed92c57d2e244ced533 100644
--- a/components/arc/arc_session_runner.cc
+++ b/components/arc/arc_session_runner.cc
@@ -7,7 +7,6 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/task_runner.h"
-#include "components/arc/arc_session.h"
namespace arc {
@@ -29,12 +28,12 @@ ArcSessionRunner::~ArcSessionRunner() {
arc_session_->RemoveObserver(this);
}
-void ArcSessionRunner::AddObserver(ArcSessionObserver* observer) {
+void ArcSessionRunner::AddObserver(Observer* observer) {
DCHECK(thread_checker_.CalledOnValidThread());
observer_list_.AddObserver(observer);
}
-void ArcSessionRunner::RemoveObserver(ArcSessionObserver* observer) {
+void ArcSessionRunner::RemoveObserver(Observer* observer) {
DCHECK(thread_checker_.CalledOnValidThread());
observer_list_.RemoveObserver(observer);
}
@@ -151,12 +150,9 @@ void ArcSessionRunner::OnSessionReady() {
VLOG(0) << "ARC ready";
state_ = State::RUNNING;
-
- for (auto& observer : observer_list_)
- observer.OnSessionReady();
}
-void ArcSessionRunner::OnSessionStopped(StopReason stop_reason) {
+void ArcSessionRunner::OnSessionStopped(ArcStopReason stop_reason) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_NE(state_, State::STOPPED);
DCHECK(arc_session_);
@@ -173,8 +169,9 @@ void ArcSessionRunner::OnSessionStopped(StopReason stop_reason) {
// Otherwise, do nothing.
// If STARTING, ARC instance has not been booted properly, so do not
// restart it automatically.
- if (state_ == State::RUNNING ||
- (state_ == State::STOPPING && run_requested_)) {
+ const bool restarting = (state_ == State::RUNNING ||
+ (state_ == State::STOPPING && run_requested_));
+ if (restarting) {
// This check is for RUNNING case. In RUNNING case |run_requested_| should
// be always true, because if once RequestStop() is called, the state_
// will be set to STOPPING.
@@ -190,11 +187,9 @@ void ArcSessionRunner::OnSessionStopped(StopReason stop_reason) {
weak_ptr_factory_.GetWeakPtr()));
}
- // TODO(hidehiko): Consider to let observers know whether there is scheduled
- // restarting event, or not.
state_ = State::STOPPED;
for (auto& observer : observer_list_)
- observer.OnSessionStopped(stop_reason);
+ observer.OnSessionStopped(stop_reason, restarting);
}
} // namespace arc
« no previous file with comments | « components/arc/arc_session_runner.h ('k') | components/arc/arc_session_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698