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

Unified Diff: components/arc/arc_session.cc

Issue 2887363003: Read container_instance_id. (Closed)
Patch Set: Address comments. Created 3 years, 7 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
Index: components/arc/arc_session.cc
diff --git a/components/arc/arc_session.cc b/components/arc/arc_session.cc
index b27415a94eff714db4957317936aaccfb74d8ba1..0357c21983db2e0175dae96e6bb9ad38a3032354 100644
--- a/components/arc/arc_session.cc
+++ b/components/arc/arc_session.cc
@@ -219,7 +219,8 @@ class ArcSessionImpl : public ArcSession,
// DBus callback for StartArcInstance().
void OnInstanceStarted(mojo::edk::ScopedPlatformHandle socket_fd,
- StartArcInstanceResult result);
+ StartArcInstanceResult result,
+ const std::string& container_instance_id);
// Synchronously accepts a connection on |socket_fd| and then processes the
// connected socket's file descriptor.
@@ -232,7 +233,8 @@ class ArcSessionImpl : public ArcSession,
void StopArcInstance();
// chromeos::SessionManagerClient::Observer:
- void ArcInstanceStopped(bool clean) override;
+ void ArcInstanceStopped(bool clean,
+ const std::string& container_instance_id) override;
// Completes the termination procedure.
void OnStopped(ArcStopReason reason);
@@ -253,6 +255,10 @@ class ArcSessionImpl : public ArcSession,
// When Stop() is called, this flag is set.
bool stop_requested_ = false;
+ // Container instance id passed from session_manager.
+ // Should be available only after OnInstanceStarted.
Luis Héctor Chávez 2017/05/19 15:23:03 nit: OnInstanceStarted()
hidehiko 2017/05/22 08:38:06 Done.
+ std::string container_instance_id_;
+
// In CONNECTING_MOJO state, this is set to the write side of the pipe
// to notify cancelling of the procedure.
base::ScopedFD accept_cancel_pipe_;
@@ -381,16 +387,11 @@ void ArcSessionImpl::OnSocketCreated(
void ArcSessionImpl::OnInstanceStarted(
mojo::edk::ScopedPlatformHandle socket_fd,
- StartArcInstanceResult result) {
+ StartArcInstanceResult result,
+ const std::string& container_instance_id) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (state_ == State::STOPPED) {
- // This is the case that error is notified via DBus before the
- // OnInstanceStarted() callback is invoked. The stopping procedure has
- // been run, so do nothing.
- return;
- }
-
DCHECK_EQ(state_, State::STARTING_INSTANCE);
+ container_instance_id_ = container_instance_id;
if (stop_requested_) {
if (result == StartArcInstanceResult::SUCCESS) {
@@ -481,14 +482,6 @@ mojo::ScopedMessagePipeHandle ArcSessionImpl::ConnectMojo(
void ArcSessionImpl::OnMojoConnected(
mojo::ScopedMessagePipeHandle server_pipe) {
DCHECK(thread_checker_.CalledOnValidThread());
-
- if (state_ == State::STOPPED) {
- // This is the case that error is notified via DBus before the
- // OnMojoConnected() callback is invoked. The stopping procedure has
- // been run, so do nothing.
- return;
- }
-
DCHECK_EQ(state_, State::CONNECTING_MOJO);
accept_cancel_pipe_.reset();
@@ -576,11 +569,19 @@ void ArcSessionImpl::StopArcInstance() {
base::Bind(&DoNothingInstanceStopped));
}
-void ArcSessionImpl::ArcInstanceStopped(bool clean) {
+void ArcSessionImpl::ArcInstanceStopped(
+ bool clean,
+ const std::string& container_instance_id) {
DCHECK(thread_checker_.CalledOnValidThread());
VLOG(1) << "Notified that ARC instance is stopped "
<< (clean ? "cleanly" : "uncleanly");
+ if (container_instance_id != container_instance_id_) {
+ VLOG(1) << "Container instance id mismatch. Do nothing."
+ << container_instance_id << " vs " << container_instance_id_;
+ return;
+ }
Luis Héctor Chávez 2017/05/19 15:23:03 nit: do you want to reset the container id here? J
hidehiko 2017/05/22 08:38:06 Done.
+
// In case that crash happens during before the Mojo channel is connected,
// unlock the BlockingPool thread.
accept_cancel_pipe_.reset();
« chromeos/dbus/session_manager_client.h ('K') | « chromeos/dbus/session_manager_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698