| Index: components/arc/arc_session.cc
|
| diff --git a/components/arc/arc_session.cc b/components/arc/arc_session.cc
|
| index 2de8f50f28c683ddb949e76b93aba72a009b17dc..c3dc19525e4e6baa690c5022a26dcb8650f05c89 100644
|
| --- a/components/arc/arc_session.cc
|
| +++ b/components/arc/arc_session.cc
|
| @@ -27,6 +27,7 @@
|
| #include "chromeos/dbus/session_manager_client.h"
|
| #include "components/arc/arc_bridge_host_impl.h"
|
| #include "components/arc/arc_features.h"
|
| +#include "components/arc/arc_session_observer.h"
|
| #include "components/user_manager/user_manager.h"
|
| #include "mojo/edk/embedder/embedder.h"
|
| #include "mojo/edk/embedder/named_platform_handle.h"
|
| @@ -124,7 +125,7 @@ class ArcSessionImpl : public ArcSession,
|
| //
|
| // At any state, Stop() can be called. It does not immediately stop the
|
| // instance, but will eventually stop it.
|
| - // The actual stop will be notified via Observer::OnStopped().
|
| + // The actual stop will be notified via ArcSessionObserver::OnStopped().
|
| //
|
| // When Stop() is called, it makes various behavior based on the current
|
| // phase.
|
| @@ -232,7 +233,7 @@ class ArcSessionImpl : public ArcSession,
|
| void ArcInstanceStopped(bool clean) override;
|
|
|
| // Completes the termination procedure.
|
| - void OnStopped(ArcBridgeService::StopReason reason);
|
| + void OnStopped(ArcSessionObserver::StopReason reason);
|
|
|
| // Checks whether a function runs on the thread where the instance is
|
| // created.
|
| @@ -343,13 +344,13 @@ void ArcSessionImpl::OnSocketCreated(
|
|
|
| if (stop_requested_) {
|
| VLOG(1) << "Stop() called while connecting";
|
| - OnStopped(ArcBridgeService::StopReason::SHUTDOWN);
|
| + OnStopped(ArcSessionObserver::StopReason::SHUTDOWN);
|
| return;
|
| }
|
|
|
| if (!socket_fd.is_valid()) {
|
| LOG(ERROR) << "ARC: Error creating socket";
|
| - OnStopped(ArcBridgeService::StopReason::GENERIC_BOOT_FAILURE);
|
| + OnStopped(ArcSessionObserver::StopReason::GENERIC_BOOT_FAILURE);
|
| return;
|
| }
|
|
|
| @@ -390,15 +391,15 @@ void ArcSessionImpl::OnInstanceStarted(
|
| StopArcInstance();
|
| return;
|
| }
|
| - OnStopped(ArcBridgeService::StopReason::SHUTDOWN);
|
| + OnStopped(ArcSessionObserver::StopReason::SHUTDOWN);
|
| return;
|
| }
|
|
|
| if (result != StartArcInstanceResult::SUCCESS) {
|
| LOG(ERROR) << "Failed to start ARC instance";
|
| OnStopped(result == StartArcInstanceResult::LOW_FREE_DISK_SPACE
|
| - ? ArcBridgeService::StopReason::LOW_DISK_SPACE
|
| - : ArcBridgeService::StopReason::GENERIC_BOOT_FAILURE);
|
| + ? ArcSessionObserver::StopReason::LOW_DISK_SPACE
|
| + : ArcSessionObserver::StopReason::GENERIC_BOOT_FAILURE);
|
| return;
|
| }
|
|
|
| @@ -409,7 +410,7 @@ void ArcSessionImpl::OnInstanceStarted(
|
| // Stop().
|
| base::ScopedFD cancel_fd;
|
| if (!CreatePipe(&cancel_fd, &accept_cancel_pipe_)) {
|
| - OnStopped(ArcBridgeService::StopReason::GENERIC_BOOT_FAILURE);
|
| + OnStopped(ArcSessionObserver::StopReason::GENERIC_BOOT_FAILURE);
|
| return;
|
| }
|
|
|
| @@ -499,7 +500,7 @@ void ArcSessionImpl::OnMojoConnected(mojo::edk::ScopedPlatformHandle fd) {
|
| VLOG(2) << "Mojo is connected. ARC is running.";
|
| state_ = State::RUNNING;
|
| for (auto& observer : observer_list_)
|
| - observer.OnReady();
|
| + observer.OnSessionReady();
|
| }
|
|
|
| void ArcSessionImpl::Stop() {
|
| @@ -515,7 +516,7 @@ void ArcSessionImpl::Stop() {
|
| arc_bridge_host_.reset();
|
| switch (state_) {
|
| case State::NOT_STARTED:
|
| - OnStopped(ArcBridgeService::StopReason::SHUTDOWN);
|
| + OnStopped(ArcSessionObserver::StopReason::SHUTDOWN);
|
| return;
|
|
|
| case State::CREATING_SOCKET:
|
| @@ -572,24 +573,24 @@ void ArcSessionImpl::ArcInstanceStopped(bool clean) {
|
| // unlock the BlockingPool thread.
|
| accept_cancel_pipe_.reset();
|
|
|
| - ArcBridgeService::StopReason reason;
|
| + ArcSessionObserver::StopReason reason;
|
| if (stop_requested_) {
|
| // If the ARC instance is stopped after its explicit request,
|
| // return SHUTDOWN.
|
| - reason = ArcBridgeService::StopReason::SHUTDOWN;
|
| + reason = ArcSessionObserver::StopReason::SHUTDOWN;
|
| } else if (clean) {
|
| // If the ARC instance is stopped, but it is not explicitly requested,
|
| // then this is triggered by some failure during the starting procedure.
|
| // Return GENERIC_BOOT_FAILURE for the case.
|
| - reason = ArcBridgeService::StopReason::GENERIC_BOOT_FAILURE;
|
| + reason = ArcSessionObserver::StopReason::GENERIC_BOOT_FAILURE;
|
| } else {
|
| // Otherwise, this is caused by CRASH occured inside of the ARC instance.
|
| - reason = ArcBridgeService::StopReason::CRASH;
|
| + reason = ArcSessionObserver::StopReason::CRASH;
|
| }
|
| OnStopped(reason);
|
| }
|
|
|
| -void ArcSessionImpl::OnStopped(ArcBridgeService::StopReason reason) {
|
| +void ArcSessionImpl::OnStopped(ArcSessionObserver::StopReason reason) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| // OnStopped() should be called once per instance.
|
| DCHECK_NE(state_, State::STOPPED);
|
| @@ -597,7 +598,7 @@ void ArcSessionImpl::OnStopped(ArcBridgeService::StopReason reason) {
|
| arc_bridge_host_.reset();
|
| state_ = State::STOPPED;
|
| for (auto& observer : observer_list_)
|
| - observer.OnStopped(reason);
|
| + observer.OnSessionStopped(reason);
|
| }
|
|
|
| void ArcSessionImpl::OnShutdown() {
|
| @@ -622,7 +623,7 @@ void ArcSessionImpl::OnShutdown() {
|
| // Directly set to the STOPPED stateby OnStopped(). Note that calling
|
| // StopArcInstance() may not work well. At least, because the UI thread is
|
| // already stopped here, ArcInstanceStopped() callback cannot be invoked.
|
| - OnStopped(ArcBridgeService::StopReason::SHUTDOWN);
|
| + OnStopped(ArcSessionObserver::StopReason::SHUTDOWN);
|
| }
|
|
|
| } // namespace
|
| @@ -630,11 +631,11 @@ void ArcSessionImpl::OnShutdown() {
|
| ArcSession::ArcSession() = default;
|
| ArcSession::~ArcSession() = default;
|
|
|
| -void ArcSession::AddObserver(Observer* observer) {
|
| +void ArcSession::AddObserver(ArcSessionObserver* observer) {
|
| observer_list_.AddObserver(observer);
|
| }
|
|
|
| -void ArcSession::RemoveObserver(Observer* observer) {
|
| +void ArcSession::RemoveObserver(ArcSessionObserver* observer) {
|
| observer_list_.RemoveObserver(observer);
|
| }
|
|
|
|
|