Commit 70c310e1 authored by Kazuhiro Inaba's avatar Kazuhiro Inaba Committed by Commit Bot

arc: Copy the upgrade params to reuse for the container restart.

RestartArcSession() can reuse the upgrade_params_ data that was
previousely set. Moving the content is not appropriate.

BUG=b:143439620
BUG=b:142144019
BUG=b:143092860
TEST=ArcSessionRunnerTest.Restart
TEST=`adb reboot` successfully restarts the ARC container.

Change-Id: Ie7a9254e03de29efde94a4a8918e80a1b871471c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1883427Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Kazuhiro Inaba <kinaba@chromium.org>
Auto-Submit: Kazuhiro Inaba <kinaba@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709869}
parent ddcff1e4
...@@ -251,7 +251,9 @@ void ArcSessionRunner::StartArcSession() { ...@@ -251,7 +251,9 @@ void ArcSessionRunner::StartArcSession() {
RecordInstanceCrashUma(ArcContainerLifetimeEvent::CONTAINER_STARTING); RecordInstanceCrashUma(ArcContainerLifetimeEvent::CONTAINER_STARTING);
} }
if (target_mode_ == ArcInstanceMode::FULL_INSTANCE) { if (target_mode_ == ArcInstanceMode::FULL_INSTANCE) {
arc_session_->RequestUpgrade(std::move(upgrade_params_)); // Do not std::move the params intentionally. RestartArcSession() can
// reuse the params without preceded by resetting them.
arc_session_->RequestUpgrade(upgrade_params_);
} }
} }
......
...@@ -33,10 +33,11 @@ constexpr int kContainerCrashedEarly = ...@@ -33,10 +33,11 @@ constexpr int kContainerCrashedEarly =
static_cast<int>(ArcContainerLifetimeEvent::CONTAINER_CRASHED_EARLY); static_cast<int>(ArcContainerLifetimeEvent::CONTAINER_CRASHED_EARLY);
constexpr int kContainerCrashed = constexpr int kContainerCrashed =
static_cast<int>(ArcContainerLifetimeEvent::CONTAINER_CRASHED); static_cast<int>(ArcContainerLifetimeEvent::CONTAINER_CRASHED);
constexpr char kDefaultLocale[] = "en-US";
UpgradeParams DefaultUpgradeParams() { UpgradeParams DefaultUpgradeParams() {
UpgradeParams params; UpgradeParams params;
params.locale = "en-US"; params.locale = kDefaultLocale;
return params; return params;
} }
...@@ -294,6 +295,9 @@ TEST_F(ArcSessionRunnerTest, Restart) { ...@@ -294,6 +295,9 @@ TEST_F(ArcSessionRunnerTest, Restart) {
EXPECT_TRUE(restarting_called()); EXPECT_TRUE(restarting_called());
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_TRUE(arc_session()->is_running()); EXPECT_TRUE(arc_session()->is_running());
// Checks if the restart retains the original parameter.
EXPECT_EQ(std::string(kDefaultLocale),
arc_session()->upgrade_locale_param());
arc_session_runner()->RequestStop(); arc_session_runner()->RequestStop();
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
......
...@@ -37,6 +37,7 @@ UpgradeParams::UpgradeParams() ...@@ -37,6 +37,7 @@ UpgradeParams::UpgradeParams()
skip_gms_core_cache(base::CommandLine::ForCurrentProcess()->HasSwitch( skip_gms_core_cache(base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kArcDisableGmsCoreCache)) {} chromeos::switches::kArcDisableGmsCoreCache)) {}
UpgradeParams::UpgradeParams(const UpgradeParams& other) = default;
UpgradeParams::UpgradeParams(UpgradeParams&& other) = default; UpgradeParams::UpgradeParams(UpgradeParams&& other) = default;
UpgradeParams& UpgradeParams::operator=(UpgradeParams&& other) = default; UpgradeParams& UpgradeParams::operator=(UpgradeParams&& other) = default;
UpgradeParams::~UpgradeParams() = default; UpgradeParams::~UpgradeParams() = default;
......
...@@ -37,6 +37,8 @@ struct UpgradeParams { ...@@ -37,6 +37,8 @@ struct UpgradeParams {
// https://cs.chromium.org/chromium/src/tools/clang/plugins/FindBadConstructsConsumer.cpp // https://cs.chromium.org/chromium/src/tools/clang/plugins/FindBadConstructsConsumer.cpp
UpgradeParams(); UpgradeParams();
~UpgradeParams(); ~UpgradeParams();
// Intentionally allows copying. The parameter is for container restart.
UpgradeParams(const UpgradeParams& other);
UpgradeParams(UpgradeParams&& other); UpgradeParams(UpgradeParams&& other);
UpgradeParams& operator=(UpgradeParams&& other); UpgradeParams& operator=(UpgradeParams&& other);
...@@ -75,9 +77,6 @@ struct UpgradeParams { ...@@ -75,9 +77,6 @@ struct UpgradeParams {
// pre-installed. // pre-installed.
// Should be empty if |is_demo_session| is not set. // Should be empty if |is_demo_session| is not set.
base::FilePath demo_session_apps_path; base::FilePath demo_session_apps_path;
private:
DISALLOW_COPY_AND_ASSIGN(UpgradeParams);
}; };
} // namespace arc } // namespace arc
......
...@@ -18,6 +18,7 @@ void FakeArcSession::StartMiniInstance() {} ...@@ -18,6 +18,7 @@ void FakeArcSession::StartMiniInstance() {}
void FakeArcSession::RequestUpgrade(UpgradeParams params) { void FakeArcSession::RequestUpgrade(UpgradeParams params) {
upgrade_requested_ = true; upgrade_requested_ = true;
upgrade_locale_param_ = params.locale;
if (boot_failure_emulation_enabled_) { if (boot_failure_emulation_enabled_) {
for (auto& observer : observer_list_) for (auto& observer : observer_list_)
observer.OnSessionStopped(boot_failure_reason_, false, true); observer.OnSessionStopped(boot_failure_reason_, false, true);
......
...@@ -47,6 +47,9 @@ class FakeArcSession : public ArcSession { ...@@ -47,6 +47,9 @@ class FakeArcSession : public ArcSession {
// Returns true if the session is considered as running. // Returns true if the session is considered as running.
bool is_running() const { return running_; } bool is_running() const { return running_; }
// Returns an upgrade parameter passed to the session.
std::string upgrade_locale_param() const { return upgrade_locale_param_; }
// Returns FakeArcSession instance. This can be used for a factory // Returns FakeArcSession instance. This can be used for a factory
// in ArcBridgeServiceImpl. // in ArcBridgeServiceImpl.
static std::unique_ptr<ArcSession> Create(); static std::unique_ptr<ArcSession> Create();
...@@ -59,6 +62,7 @@ class FakeArcSession : public ArcSession { ...@@ -59,6 +62,7 @@ class FakeArcSession : public ArcSession {
bool upgrade_requested_ = false; bool upgrade_requested_ = false;
bool running_ = false; bool running_ = false;
bool stop_requested_ = false; bool stop_requested_ = false;
std::string upgrade_locale_param_;
DISALLOW_COPY_AND_ASSIGN(FakeArcSession); DISALLOW_COPY_AND_ASSIGN(FakeArcSession);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment