Commit af8e8219 authored by khmel@google.com's avatar khmel@google.com Committed by Commit Bot

arc: Pass locale and preferred languages as a ARC boot parameter.

      for Activity manager and Play Store is not closed after initial
      start.

Test: Locally, confirmed that configuration changed is called only once
Bug: b/67734479
Bug: b/76398711
Change-Id: I121243c03704587454516393467df08f9981f0c9
Reviewed-on: https://chromium-review.googlesource.com/1079457
Commit-Queue: Yury Khmel <khmel@chromium.org>
Reviewed-by: default avatarStefan Kuhne <skuhne@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565054}
parent 991984ee
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/string_split.h"
#include "base/task_scheduler/post_task.h" #include "base/task_scheduler/post_task.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
...@@ -790,7 +791,7 @@ void ArcSessionManager::MaybeStartTermsOfServiceNegotiation() { ...@@ -790,7 +791,7 @@ void ArcSessionManager::MaybeStartTermsOfServiceNegotiation() {
// Start the mini-container here to save time starting the container if the // Start the mini-container here to save time starting the container if the
// user decides to opt-in. // user decides to opt-in.
arc_session_runner_->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner_->RequestStartMiniInstance();
terms_of_service_negotiator_->StartNegotiation( terms_of_service_negotiator_->StartNegotiation(
base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated, base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated,
...@@ -935,7 +936,14 @@ void ArcSessionManager::StartArc() { ...@@ -935,7 +936,14 @@ void ArcSessionManager::StartArc() {
arc_start_time_ = base::Time::Now(); arc_start_time_ = base::Time::Now();
provisioning_reported_ = false; provisioning_reported_ = false;
arc_session_runner_->RequestStart(ArcInstanceMode::FULL_INSTANCE);
std::string locale;
std::string preferred_lanaguages;
GetLocaleAndPreferredLanguages(profile_, &locale, &preferred_lanaguages);
// Empty |preferred_lanaguages| is converted to empty array.
arc_session_runner_->RequestUpgrade(
locale, base::SplitString(preferred_lanaguages, ",",
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL));
} }
void ArcSessionManager::StopArc() { void ArcSessionManager::StopArc() {
...@@ -1078,7 +1086,7 @@ void ArcSessionManager::EmitLoginPromptVisibleCalled() { ...@@ -1078,7 +1086,7 @@ void ArcSessionManager::EmitLoginPromptVisibleCalled() {
if (!IsArcAvailable()) if (!IsArcAvailable())
return; return;
arc_session_runner_->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner_->RequestStartMiniInstance();
} }
std::ostream& operator<<(std::ostream& os, std::ostream& operator<<(std::ostream& os,
......
...@@ -146,7 +146,6 @@ class ArcSettingsServiceImpl ...@@ -146,7 +146,6 @@ class ArcSettingsServiceImpl
void SyncBootTimeSettings() const; void SyncBootTimeSettings() const;
// Retrieves Chrome's state for the settings that need to be synced on each // Retrieves Chrome's state for the settings that need to be synced on each
// Android boot after AppInstance is ready and send it to Android. // Android boot after AppInstance is ready and send it to Android.
// TODO(crbug.com/762553): Sync settings at proper time.
void SyncAppTimeSettings(); void SyncAppTimeSettings();
// Send particular settings to Android. // Send particular settings to Android.
// Keep these lines ordered lexicographically. // Keep these lines ordered lexicographically.
...@@ -369,13 +368,19 @@ void ArcSettingsServiceImpl::SyncBootTimeSettings() const { ...@@ -369,13 +368,19 @@ void ArcSettingsServiceImpl::SyncBootTimeSettings() const {
} }
void ArcSettingsServiceImpl::SyncAppTimeSettings() { void ArcSettingsServiceImpl::SyncAppTimeSettings() {
SyncLocale();
// Applying system locales change on ARC will cause restarting other services // Applying system locales change on ARC will cause restarting other services
// and applications on ARC and doing such change in early phase may lead to // and applications on ARC and doing such change in early phase may lead to
// ARC OptIn failure. So that observing preferred languages change should be // ARC OptIn failure b/65385376. So that observing preferred languages change
// deferred at least until |mojom::AppInstance| is ready. But it's not ideal // should be deferred at least until |mojom::AppInstance| is ready.
// (b/6773449, b/65385376). // Note that locale and preferred languages are passed to Android container on
// boot time and current sync is redundant in most cases. However there is
// race when preferred languages may be changed during the ARC booting.
// Tracking and applying this information is complex task thar requires
// syncronization ARC session start, ArcSettingsService and
// ArcSettingsServiceImpl creation/destroying. Android framework has ability
// to supress reduntant calls so having this little overhead simplifies common
// implementation.
SyncLocale();
AddPrefToObserve(::prefs::kApplicationLocale); AddPrefToObserve(::prefs::kApplicationLocale);
AddPrefToObserve(::prefs::kLanguagePreferredLanguages); AddPrefToObserve(::prefs::kLanguagePreferredLanguages);
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/app_install_event_log_manager_wrapper.h" #include "chrome/browser/chromeos/policy/app_install_event_log_manager_wrapper.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/tether/tether_service.h" #include "chrome/browser/chromeos/tether/tether_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
...@@ -113,6 +114,9 @@ void StartUserSession(Profile* user_profile, const std::string& login_user_id) { ...@@ -113,6 +114,9 @@ void StartUserSession(Profile* user_profile, const std::string& login_user_id) {
user_session_mgr->InitializeCerts(user_profile); user_session_mgr->InitializeCerts(user_profile);
user_session_mgr->InitializeCRLSetFetcher(user); user_session_mgr->InitializeCRLSetFetcher(user);
user_session_mgr->InitializeCertificateTransparencyComponents(user); user_session_mgr->InitializeCertificateTransparencyComponents(user);
ProfileHelper::Get()->ProfileStartup(user_profile);
if (lock_screen_apps::StateController::IsEnabled()) if (lock_screen_apps::StateController::IsEnabled())
lock_screen_apps::StateController::Get()->SetPrimaryProfile(user_profile); lock_screen_apps::StateController::Get()->SetPrimaryProfile(user_profile);
......
...@@ -1503,6 +1503,8 @@ bool UserSessionManager::InitializeUserSession(Profile* profile) { ...@@ -1503,6 +1503,8 @@ bool UserSessionManager::InitializeUserSession(Profile* profile) {
return false; return false;
} }
ProfileHelper::Get()->ProfileStartup(profile);
if (start_session_type_ == PRIMARY_USER_SESSION) { if (start_session_type_ == PRIMARY_USER_SESSION) {
UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow();
WizardController* oobe_controller = WizardController::default_controller(); WizardController* oobe_controller = WizardController::default_controller();
......
...@@ -112,7 +112,7 @@ void SupervisedUserCreationFlow::LaunchExtraSteps(Profile* profile) { ...@@ -112,7 +112,7 @@ void SupervisedUserCreationFlow::LaunchExtraSteps(Profile* profile) {
LOG(ERROR) << "LaunchExtraSteps for " << this << " host is " << host(); LOG(ERROR) << "LaunchExtraSteps for " << this << " host is " << host();
logged_in_ = true; logged_in_ = true;
manager_profile_ = profile; manager_profile_ = profile;
ProfileHelper::Get()->ProfileStartup(profile, true); ProfileHelper::Get()->ProfileStartup(profile);
if (token_validated_ && logged_in_) { if (token_validated_ && logged_in_) {
if (!session_started_) if (!session_started_)
......
...@@ -241,7 +241,7 @@ bool ProfileHelper::IsEphemeralUserProfile(const Profile* profile) { ...@@ -241,7 +241,7 @@ bool ProfileHelper::IsEphemeralUserProfile(const Profile* profile) {
return ChromeUserManager::Get()->AreEphemeralUsersEnabled(); return ChromeUserManager::Get()->AreEphemeralUsersEnabled();
} }
void ProfileHelper::ProfileStartup(Profile* profile, bool process_startup) { void ProfileHelper::ProfileStartup(Profile* profile) {
// Initialize Chrome OS preferences like touch pad sensitivity. For the // Initialize Chrome OS preferences like touch pad sensitivity. For the
// preferences to work in the guest mode, the initialization has to be // preferences to work in the guest mode, the initialization has to be
// done after |profile| is switched to the incognito profile (which // done after |profile| is switched to the incognito profile (which
......
...@@ -136,7 +136,7 @@ class ProfileHelper ...@@ -136,7 +136,7 @@ class ProfileHelper
// Initialize a bunch of services that are tied to a browser profile. // Initialize a bunch of services that are tied to a browser profile.
// TODO(dzhioev): Investigate whether or not this method is needed. // TODO(dzhioev): Investigate whether or not this method is needed.
void ProfileStartup(Profile* profile, bool process_startup); void ProfileStartup(Profile* profile);
// Returns active user profile dir in a format [u-$hash]. // Returns active user profile dir in a format [u-$hash].
base::FilePath GetActiveUserProfileDir(); base::FilePath GetActiveUserProfileDir();
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_migration_guide_notification.h" #include "chrome/browser/chromeos/arc/arc_migration_guide_notification.h"
#include "chrome/browser/chromeos/arc/arc_session_manager.h" #include "chrome/browser/chromeos/arc/arc_session_manager.h"
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
...@@ -24,11 +25,13 @@ ...@@ -24,11 +25,13 @@
#include "chrome/browser/ui/ash/launcher/arc_shelf_spinner_item_controller.h" #include "chrome/browser/ui/ash/launcher/arc_shelf_spinner_item_controller.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/shelf_spinner_controller.h" #include "chrome/browser/ui/ash/launcher/shelf_spinner_controller.h"
#include "chrome/common/pref_names.h"
#include "components/arc/arc_bridge_service.h" #include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_service_manager.h" #include "components/arc/arc_service_manager.h"
#include "components/arc/arc_util.h" #include "components/arc/arc_util.h"
#include "components/arc/common/intent_helper.mojom.h" #include "components/arc/common/intent_helper.mojom.h"
#include "components/arc/intent_helper/arc_intent_helper_bridge.h" #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
#include "components/prefs/pref_service.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
...@@ -527,6 +530,26 @@ bool ParseIntent(const std::string& intent_as_string, Intent* intent) { ...@@ -527,6 +530,26 @@ bool ParseIntent(const std::string& intent_as_string, Intent* intent) {
return true; return true;
} }
void GetLocaleAndPreferredLanguages(const Profile* profile,
std::string* out_locale,
std::string* out_preferred_languages) {
const PrefService::Preference* locale_pref =
profile->GetPrefs()->FindPreference(::prefs::kApplicationLocale);
DCHECK(locale_pref);
const bool value_exists = locale_pref->GetValue()->GetAsString(out_locale);
DCHECK(value_exists);
if (out_locale->empty())
*out_locale = g_browser_process->GetApplicationLocale();
// |preferredLanguages| consists of comma separated locale strings. It may be
// empty or contain empty items, but those are ignored on ARC. If an item
// has no country code, it is derived in ARC. In such a case, it may
// conflict with another item in the list, then these will be dedupped (the
// first one is taken) in ARC.
*out_preferred_languages =
profile->GetPrefs()->GetString(::prefs::kLanguagePreferredLanguages);
}
Intent::Intent() = default; Intent::Intent() = default;
Intent::~Intent() = default; Intent::~Intent() = default;
......
...@@ -157,6 +157,12 @@ std::string GetLaunchIntent(const std::string& package_name, ...@@ -157,6 +157,12 @@ std::string GetLaunchIntent(const std::string& package_name,
// cannot be parsed. // cannot be parsed.
bool ParseIntent(const std::string& intent_as_string, Intent* intent); bool ParseIntent(const std::string& intent_as_string, Intent* intent);
// Returns current active locale and list of preferred languages for the given
// |profile|.
void GetLocaleAndPreferredLanguages(const Profile* profle,
std::string* out_locale,
std::string* out_preferred_languages);
} // namespace arc } // namespace arc
#endif // CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_UTILS_H_ #endif // CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_UTILS_H_
...@@ -72,7 +72,6 @@ ...@@ -72,7 +72,6 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/app_mode/app_launch_utils.h" #include "chrome/browser/chromeos/app_mode/app_launch_utils.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
#include "chromeos/cryptohome/cryptohome_parameters.h" #include "chromeos/cryptohome/cryptohome_parameters.h"
...@@ -362,9 +361,6 @@ bool StartupBrowserCreator::LaunchBrowser( ...@@ -362,9 +361,6 @@ bool StartupBrowserCreator::LaunchBrowser(
profile_launch_observer.Get().AddLaunched(profile); profile_launch_observer.Get().AddLaunched(profile);
#if defined(OS_CHROMEOS)
chromeos::ProfileHelper::Get()->ProfileStartup(profile, process_startup);
#endif
return true; return true;
} }
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#define COMPONENTS_ARC_ARC_SESSION_H_ #define COMPONENTS_ARC_ARC_SESSION_H_
#include <memory> #include <memory>
#include <string>
#include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
...@@ -48,8 +50,12 @@ class ArcSession { ...@@ -48,8 +50,12 @@ class ArcSession {
// Sends a D-Bus message to upgrade to a full instance if // Sends a D-Bus message to upgrade to a full instance if
// possible. This might be done asynchronously; the message might only be sent // possible. This might be done asynchronously; the message might only be sent
// after other operations have completed. // after other operations have completed. |locale| and |preferred_languages|
virtual void RequestUpgrade() = 0; // define language configuration set during Android container boot.
// |preferred_languages| may be empty.
virtual void RequestUpgrade(
const std::string& locale,
const std::vector<std::string>& preferred_languages) = 0;
// Requests to stop the currently-running instance regardless of its mode. // Requests to stop the currently-running instance regardless of its mode.
// The completion is notified via OnSessionStopped() of the Observer. // The completion is notified via OnSessionStopped() of the Observer.
......
...@@ -269,10 +269,15 @@ void ArcSessionImpl::StartMiniInstance() { ...@@ -269,10 +269,15 @@ void ArcSessionImpl::StartMiniInstance() {
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void ArcSessionImpl::RequestUpgrade() { void ArcSessionImpl::RequestUpgrade(
const std::string& locale,
const std::vector<std::string>& preferred_languages) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!locale.empty());
upgrade_requested_ = true; upgrade_requested_ = true;
locale_ = locale;
preferred_languages_ = preferred_languages;
switch (state_) { switch (state_) {
case State::NOT_STARTED: case State::NOT_STARTED:
...@@ -362,6 +367,10 @@ void ArcSessionImpl::DoUpgrade() { ...@@ -362,6 +367,10 @@ void ArcSessionImpl::DoUpgrade() {
<< packages_cache_mode_string << "."; << packages_cache_mode_string << ".";
} }
request.set_locale(locale_);
for (const std::string& language : preferred_languages_)
request.add_preferred_languages(language);
chromeos::SessionManagerClient* client = GetSessionManagerClient(); chromeos::SessionManagerClient* client = GetSessionManagerClient();
client->UpgradeArcContainer( client->UpgradeArcContainer(
request, request,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include <ostream> #include <ostream>
#include <string> #include <string>
#include <vector>
#include "base/callback.h" #include "base/callback.h"
#include "base/files/scoped_file.h" #include "base/files/scoped_file.h"
...@@ -140,7 +141,9 @@ class ArcSessionImpl : public ArcSession, ...@@ -140,7 +141,9 @@ class ArcSessionImpl : public ArcSession,
// ArcSession overrides: // ArcSession overrides:
void StartMiniInstance() override; void StartMiniInstance() override;
void RequestUpgrade() override; void RequestUpgrade(
const std::string& locale,
const std::vector<std::string>& preferred_languages) override;
void Stop() override; void Stop() override;
bool IsStopRequested() override; bool IsStopRequested() override;
void OnShutdown() override; void OnShutdown() override;
...@@ -200,6 +203,10 @@ class ArcSessionImpl : public ArcSession, ...@@ -200,6 +203,10 @@ class ArcSessionImpl : public ArcSession,
// to notify cancelling of the procedure. // to notify cancelling of the procedure.
base::ScopedFD accept_cancel_pipe_; base::ScopedFD accept_cancel_pipe_;
// Locale and preferred languages to set in Android container during the boot.
std::string locale_;
std::vector<std::string> preferred_languages_;
// Mojo endpoint. // Mojo endpoint.
std::unique_ptr<mojom::ArcBridgeHost> arc_bridge_host_; std::unique_ptr<mojom::ArcBridgeHost> arc_bridge_host_;
......
...@@ -30,6 +30,7 @@ namespace { ...@@ -30,6 +30,7 @@ namespace {
constexpr char kFakeGmail[] = "user@gmail.com"; constexpr char kFakeGmail[] = "user@gmail.com";
constexpr char kFakeGmailGaiaId[] = "1234567890"; constexpr char kFakeGmailGaiaId[] = "1234567890";
constexpr char kDefaultLocale[] = "en-US";
class FakeDelegate : public ArcSessionImpl::Delegate { class FakeDelegate : public ArcSessionImpl::Delegate {
public: public:
...@@ -236,7 +237,7 @@ TEST_F(ArcSessionImplTest, Upgrade_LowDisk) { ...@@ -236,7 +237,7 @@ TEST_F(ArcSessionImplTest, Upgrade_LowDisk) {
TestArcSessionObserver observer(arc_session.get(), &run_loop); TestArcSessionObserver observer(arc_session.get(), &run_loop);
ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer)); ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer));
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
run_loop.Run(); run_loop.Run();
EXPECT_EQ(ArcSessionImpl::State::STOPPED, arc_session->GetStateForTesting()); EXPECT_EQ(ArcSessionImpl::State::STOPPED, arc_session->GetStateForTesting());
...@@ -255,7 +256,7 @@ TEST_F(ArcSessionImplTest, Upgrade_Success) { ...@@ -255,7 +256,7 @@ TEST_F(ArcSessionImplTest, Upgrade_Success) {
ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer)); ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer));
// Then, upgrade to a full instance. // Then, upgrade to a full instance.
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(ArcSessionImpl::State::RUNNING_FULL_INSTANCE, EXPECT_EQ(ArcSessionImpl::State::RUNNING_FULL_INSTANCE,
...@@ -275,7 +276,7 @@ TEST_F(ArcSessionImplTest, Upgrade_DBusFail) { ...@@ -275,7 +276,7 @@ TEST_F(ArcSessionImplTest, Upgrade_DBusFail) {
EmulateDBusFailure(); EmulateDBusFailure();
// Then upgrade, which should fail. // Then upgrade, which should fail.
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(ArcSessionImpl::State::STOPPED, arc_session->GetStateForTesting()); EXPECT_EQ(ArcSessionImpl::State::STOPPED, arc_session->GetStateForTesting());
...@@ -300,7 +301,7 @@ TEST_F(ArcSessionImplTest, Upgrade_MojoConnectionFail) { ...@@ -300,7 +301,7 @@ TEST_F(ArcSessionImplTest, Upgrade_MojoConnectionFail) {
ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer)); ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer));
// Upgrade should fail, due to Mojo connection fail set above. // Upgrade should fail, due to Mojo connection fail set above.
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(ArcSessionImpl::State::STOPPED, arc_session->GetStateForTesting()); EXPECT_EQ(ArcSessionImpl::State::STOPPED, arc_session->GetStateForTesting());
...@@ -321,7 +322,7 @@ TEST_F(ArcSessionImplTest, Upgrade_StartingMiniInstance) { ...@@ -321,7 +322,7 @@ TEST_F(ArcSessionImplTest, Upgrade_StartingMiniInstance) {
arc_session->GetStateForTesting()); arc_session->GetStateForTesting());
// Before moving forward to RUNNING_MINI_INSTANCE, start upgrading it. // Before moving forward to RUNNING_MINI_INSTANCE, start upgrading it.
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
// The state should not immediately switch to STARTING_FULL_INSTANCE, yet. // The state should not immediately switch to STARTING_FULL_INSTANCE, yet.
EXPECT_EQ(ArcSessionImpl::State::STARTING_MINI_INSTANCE, EXPECT_EQ(ArcSessionImpl::State::STARTING_MINI_INSTANCE,
...@@ -382,7 +383,7 @@ TEST_F(ArcSessionImplTest, Stop_StartingFullInstanceForUpgrade) { ...@@ -382,7 +383,7 @@ TEST_F(ArcSessionImplTest, Stop_StartingFullInstanceForUpgrade) {
ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer)); ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer));
// Then upgrade. // Then upgrade.
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
ASSERT_EQ(ArcSessionImpl::State::STARTING_FULL_INSTANCE, ASSERT_EQ(ArcSessionImpl::State::STARTING_FULL_INSTANCE,
arc_session->GetStateForTesting()); arc_session->GetStateForTesting());
...@@ -410,7 +411,7 @@ TEST_F(ArcSessionImplTest, Stop_ConnectingMojoForUpgrade) { ...@@ -410,7 +411,7 @@ TEST_F(ArcSessionImplTest, Stop_ConnectingMojoForUpgrade) {
ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer)); ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer));
// Then upgrade. This should suspend at Mojo connection. // Then upgrade. This should suspend at Mojo connection.
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
ASSERT_EQ(ArcSessionImpl::State::CONNECTING_MOJO, ASSERT_EQ(ArcSessionImpl::State::CONNECTING_MOJO,
arc_session->GetStateForTesting()); arc_session->GetStateForTesting());
...@@ -436,7 +437,7 @@ TEST_F(ArcSessionImplTest, Stop_RunningFullInstanceForUpgrade) { ...@@ -436,7 +437,7 @@ TEST_F(ArcSessionImplTest, Stop_RunningFullInstanceForUpgrade) {
ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer)); ASSERT_NO_FATAL_FAILURE(SetupMiniContainer(arc_session.get(), &observer));
// And upgrade successfully. // And upgrade successfully.
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
ASSERT_EQ(ArcSessionImpl::State::RUNNING_FULL_INSTANCE, ASSERT_EQ(ArcSessionImpl::State::RUNNING_FULL_INSTANCE,
arc_session->GetStateForTesting()); arc_session->GetStateForTesting());
...@@ -463,7 +464,7 @@ TEST_F(ArcSessionImplTest, ...@@ -463,7 +464,7 @@ TEST_F(ArcSessionImplTest,
arc_session->GetStateForTesting()); arc_session->GetStateForTesting());
// Request to upgrade during starting mini container. // Request to upgrade during starting mini container.
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
// Then, the state should stay at STARTING_MINI_INSTANCE. // Then, the state should stay at STARTING_MINI_INSTANCE.
ASSERT_EQ(ArcSessionImpl::State::STARTING_MINI_INSTANCE, ASSERT_EQ(ArcSessionImpl::State::STARTING_MINI_INSTANCE,
arc_session->GetStateForTesting()); arc_session->GetStateForTesting());
...@@ -512,7 +513,7 @@ TEST_F(ArcSessionImplTest, ArcStopInstance) { ...@@ -512,7 +513,7 @@ TEST_F(ArcSessionImplTest, ArcStopInstance) {
auto arc_session = CreateArcSession(); auto arc_session = CreateArcSession();
TestArcSessionObserver observer(arc_session.get()); TestArcSessionObserver observer(arc_session.get());
arc_session->StartMiniInstance(); arc_session->StartMiniInstance();
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
ASSERT_EQ(ArcSessionImpl::State::RUNNING_FULL_INSTANCE, ASSERT_EQ(ArcSessionImpl::State::RUNNING_FULL_INSTANCE,
arc_session->GetStateForTesting()); arc_session->GetStateForTesting());
...@@ -536,7 +537,7 @@ TEST_F(ArcSessionImplTest, ArcStopInstance) { ...@@ -536,7 +537,7 @@ TEST_F(ArcSessionImplTest, ArcStopInstance) {
TEST_F(ArcSessionImplTest, ArcStopInstance_WrongContainerInstanceId) { TEST_F(ArcSessionImplTest, ArcStopInstance_WrongContainerInstanceId) {
auto arc_session = CreateArcSession(); auto arc_session = CreateArcSession();
arc_session->StartMiniInstance(); arc_session->StartMiniInstance();
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
ASSERT_EQ(ArcSessionImpl::State::RUNNING_FULL_INSTANCE, ASSERT_EQ(ArcSessionImpl::State::RUNNING_FULL_INSTANCE,
arc_session->GetStateForTesting()); arc_session->GetStateForTesting());
...@@ -592,7 +593,7 @@ TEST_P(ArcSessionImplPackagesCacheModeTest, PackagesCacheModes) { ...@@ -592,7 +593,7 @@ TEST_P(ArcSessionImplPackagesCacheModeTest, PackagesCacheModes) {
arc_session->StartMiniInstance(); arc_session->StartMiniInstance();
if (state.full_container) if (state.full_container)
arc_session->RequestUpgrade(); arc_session->RequestUpgrade(kDefaultLocale, {} /* preferred_languages */);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(state.expected_packages_cache_mode, GetSessionManagerClient() EXPECT_EQ(state.expected_packages_cache_mode, GetSessionManagerClient()
->last_upgrade_arc_request() ->last_upgrade_arc_request()
......
...@@ -137,6 +137,19 @@ void ArcSessionRunner::RemoveObserver(Observer* observer) { ...@@ -137,6 +137,19 @@ void ArcSessionRunner::RemoveObserver(Observer* observer) {
observer_list_.RemoveObserver(observer); observer_list_.RemoveObserver(observer);
} }
void ArcSessionRunner::RequestStartMiniInstance() {
RequestStart(ArcInstanceMode::MINI_INSTANCE);
}
void ArcSessionRunner::RequestUpgrade(
const std::string& locale,
const std::vector<std::string>& preferred_languages) {
locale_ = locale;
preferred_languages_ = preferred_languages;
RequestStart(ArcInstanceMode::FULL_INSTANCE);
}
void ArcSessionRunner::RequestStart(ArcInstanceMode request_mode) { void ArcSessionRunner::RequestStart(ArcInstanceMode request_mode) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
...@@ -233,7 +246,7 @@ void ArcSessionRunner::StartArcSession() { ...@@ -233,7 +246,7 @@ 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(); arc_session_->RequestUpgrade(locale_, preferred_languages_);
} }
void ArcSessionRunner::RestartArcSession() { void ArcSessionRunner::RestartArcSession() {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define COMPONENTS_ARC_ARC_SESSION_RUNNER_H_ #define COMPONENTS_ARC_ARC_SESSION_RUNNER_H_
#include <memory> #include <memory>
#include <vector>
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -74,9 +75,13 @@ class ArcSessionRunner : public ArcSession::Observer { ...@@ -74,9 +75,13 @@ class ArcSessionRunner : public ArcSession::Observer {
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer); void RemoveObserver(Observer* observer);
// Starts the ARC service, then it will connect the Mojo channel. When the // Starts the mini ARC instance.
// bridge becomes ready, registered Observer's OnSessionReady() is called. void RequestStartMiniInstance();
void RequestStart(ArcInstanceMode request_mode);
// Starts the full ARC instance, then it will connect the Mojo channel. When
// the bridge becomes ready, registered Observer's OnSessionReady() is called.
void RequestUpgrade(const std::string& locale,
const std::vector<std::string>& preferred_languages);
// Stops the ARC service. // Stops the ARC service.
void RequestStop(); void RequestStop();
...@@ -101,6 +106,9 @@ class ArcSessionRunner : public ArcSession::Observer { ...@@ -101,6 +106,9 @@ class ArcSessionRunner : public ArcSession::Observer {
// Restarts an ARC instance. // Restarts an ARC instance.
void RestartArcSession(); void RestartArcSession();
// Starts an ARC instance in |request_mode|.
void RequestStart(ArcInstanceMode request_mode);
// ArcSession::Observer: // ArcSession::Observer:
void OnSessionStopped(ArcStopReason reason, void OnSessionStopped(ArcStopReason reason,
bool was_running, bool was_running,
...@@ -128,6 +136,10 @@ class ArcSessionRunner : public ArcSession::Observer { ...@@ -128,6 +136,10 @@ class ArcSessionRunner : public ArcSession::Observer {
// nullptr if the state is STOPPED, otherwise non-nullptr. // nullptr if the state is STOPPED, otherwise non-nullptr.
std::unique_ptr<ArcSession> arc_session_; std::unique_ptr<ArcSession> arc_session_;
// Locale and preferred languages to set in Android container during the boot.
std::string locale_;
std::vector<std::string> preferred_languages_;
// WeakPtrFactory to use callbacks. // WeakPtrFactory to use callbacks.
base::WeakPtrFactory<ArcSessionRunner> weak_ptr_factory_; base::WeakPtrFactory<ArcSessionRunner> weak_ptr_factory_;
......
...@@ -170,7 +170,8 @@ TEST_F(ArcSessionRunnerTest, Basic) { ...@@ -170,7 +170,8 @@ TEST_F(ArcSessionRunnerTest, Basic) {
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_TRUE(arc_session()->is_running()); EXPECT_TRUE(arc_session()->is_running());
...@@ -186,7 +187,8 @@ TEST_F(ArcSessionRunnerTest, StopMidStartup) { ...@@ -186,7 +187,8 @@ TEST_F(ArcSessionRunnerTest, StopMidStartup) {
base::Bind(&ArcSessionRunnerTest::CreateSuspendedArcSession)); base::Bind(&ArcSessionRunnerTest::CreateSuspendedArcSession));
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_FALSE(arc_session()->is_running()); EXPECT_FALSE(arc_session()->is_running());
...@@ -201,7 +203,7 @@ TEST_F(ArcSessionRunnerTest, StopMidStartup_MiniInstance) { ...@@ -201,7 +203,7 @@ TEST_F(ArcSessionRunnerTest, StopMidStartup_MiniInstance) {
base::Bind(&ArcSessionRunnerTest::CreateSuspendedArcSession)); base::Bind(&ArcSessionRunnerTest::CreateSuspendedArcSession));
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
arc_session_runner()->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner()->RequestStartMiniInstance();
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_FALSE(arc_session()->is_running()); EXPECT_FALSE(arc_session()->is_running());
...@@ -217,7 +219,8 @@ TEST_F(ArcSessionRunnerTest, BootFailure) { ...@@ -217,7 +219,8 @@ TEST_F(ArcSessionRunnerTest, BootFailure) {
ArcStopReason::GENERIC_BOOT_FAILURE)); ArcStopReason::GENERIC_BOOT_FAILURE));
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
EXPECT_EQ(ArcStopReason::GENERIC_BOOT_FAILURE, stop_reason()); EXPECT_EQ(ArcStopReason::GENERIC_BOOT_FAILURE, stop_reason());
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
EXPECT_FALSE(restarting()); EXPECT_FALSE(restarting());
...@@ -232,7 +235,7 @@ TEST_F(ArcSessionRunnerTest, BootFailure_MiniInstance) { ...@@ -232,7 +235,7 @@ TEST_F(ArcSessionRunnerTest, BootFailure_MiniInstance) {
// If starting the mini instance fails, arc_session_runner()'s state goes back // If starting the mini instance fails, arc_session_runner()'s state goes back
// to STOPPED, but its observers won't be notified. // to STOPPED, but its observers won't be notified.
arc_session_runner()->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner()->RequestStartMiniInstance();
arc_session()->EmulateMiniContainerStart(); arc_session()->EmulateMiniContainerStart();
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
EXPECT_FALSE(stopped_called()); EXPECT_FALSE(stopped_called());
...@@ -240,7 +243,8 @@ TEST_F(ArcSessionRunnerTest, BootFailure_MiniInstance) { ...@@ -240,7 +243,8 @@ TEST_F(ArcSessionRunnerTest, BootFailure_MiniInstance) {
// Also make sure that RequestStart() works just fine after the boot // Also make sure that RequestStart() works just fine after the boot
// failure. // failure.
ResetArcSessionFactory(base::Bind(FakeArcSession::Create)); ResetArcSessionFactory(base::Bind(FakeArcSession::Create));
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_TRUE(arc_session()->is_running()); EXPECT_TRUE(arc_session()->is_running());
} }
...@@ -255,7 +259,7 @@ TEST_F(ArcSessionRunnerTest, Crash_MiniInstance) { ...@@ -255,7 +259,7 @@ TEST_F(ArcSessionRunnerTest, Crash_MiniInstance) {
// If starting the mini instance fails, arc_session_runner()'s state goes back // If starting the mini instance fails, arc_session_runner()'s state goes back
// to STOPPED, but its observers won't be notified. // to STOPPED, but its observers won't be notified.
arc_session_runner()->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner()->RequestStartMiniInstance();
arc_session()->EmulateMiniContainerStart(); arc_session()->EmulateMiniContainerStart();
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
EXPECT_FALSE(stopped_called()); EXPECT_FALSE(stopped_called());
...@@ -266,11 +270,12 @@ TEST_F(ArcSessionRunnerTest, Crash_MiniInstance) { ...@@ -266,11 +270,12 @@ TEST_F(ArcSessionRunnerTest, Crash_MiniInstance) {
TEST_F(ArcSessionRunnerTest, Upgrade) { TEST_F(ArcSessionRunnerTest, Upgrade) {
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
arc_session_runner()->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner()->RequestStartMiniInstance();
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_FALSE(arc_session()->is_running()); EXPECT_FALSE(arc_session()->is_running());
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_TRUE(arc_session()->is_running()); EXPECT_TRUE(arc_session()->is_running());
} }
...@@ -280,7 +285,8 @@ TEST_F(ArcSessionRunnerTest, Restart) { ...@@ -280,7 +285,8 @@ TEST_F(ArcSessionRunnerTest, Restart) {
arc_session_runner()->SetRestartDelayForTesting(base::TimeDelta()); arc_session_runner()->SetRestartDelayForTesting(base::TimeDelta());
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_TRUE(arc_session()->is_running()); EXPECT_TRUE(arc_session()->is_running());
...@@ -302,7 +308,8 @@ TEST_F(ArcSessionRunnerTest, GracefulStop) { ...@@ -302,7 +308,8 @@ TEST_F(ArcSessionRunnerTest, GracefulStop) {
arc_session_runner()->SetRestartDelayForTesting(base::TimeDelta()); arc_session_runner()->SetRestartDelayForTesting(base::TimeDelta());
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_TRUE(arc_session()->is_running()); EXPECT_TRUE(arc_session()->is_running());
...@@ -318,7 +325,8 @@ TEST_F(ArcSessionRunnerTest, Shutdown) { ...@@ -318,7 +325,8 @@ TEST_F(ArcSessionRunnerTest, Shutdown) {
arc_session_runner()->SetRestartDelayForTesting(base::TimeDelta()); arc_session_runner()->SetRestartDelayForTesting(base::TimeDelta());
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
ASSERT_TRUE(arc_session()); ASSERT_TRUE(arc_session());
EXPECT_TRUE(arc_session()->is_running()); EXPECT_TRUE(arc_session()->is_running());
...@@ -351,12 +359,13 @@ TEST_F(ArcSessionRunnerTest, RemoveUnknownObserver) { ...@@ -351,12 +359,13 @@ TEST_F(ArcSessionRunnerTest, RemoveUnknownObserver) {
TEST_F(ArcSessionRunnerTest, UmaRecording_StartUpgradeShutdown) { TEST_F(ArcSessionRunnerTest, UmaRecording_StartUpgradeShutdown) {
base::HistogramTester tester; base::HistogramTester tester;
arc_session_runner()->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner()->RequestStartMiniInstance();
tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting, tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting,
1 /* count of the sample */); 1 /* count of the sample */);
// Boot continue should not increase the count. // Boot continue should not increase the count.
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting, tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting,
1); 1);
...@@ -370,7 +379,8 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_StartUpgradeShutdown) { ...@@ -370,7 +379,8 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_StartUpgradeShutdown) {
TEST_F(ArcSessionRunnerTest, UmaRecording_StartShutdown) { TEST_F(ArcSessionRunnerTest, UmaRecording_StartShutdown) {
base::HistogramTester tester; base::HistogramTester tester;
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting, tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting,
1); 1);
// "0" should be recorded as a restart count on shutdown. // "0" should be recorded as a restart count on shutdown.
...@@ -386,10 +396,11 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_CrashTwice) { ...@@ -386,10 +396,11 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_CrashTwice) {
arc_session_runner()->SetRestartDelayForTesting(base::TimeDelta()); arc_session_runner()->SetRestartDelayForTesting(base::TimeDelta());
EXPECT_FALSE(arc_session()); EXPECT_FALSE(arc_session());
arc_session_runner()->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner()->RequestStartMiniInstance();
tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting, tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting,
1); 1);
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
// Stop the instance with CRASH. // Stop the instance with CRASH.
arc_session()->StopWithReason(ArcStopReason::CRASH); arc_session()->StopWithReason(ArcStopReason::CRASH);
...@@ -413,7 +424,7 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_CrashTwice) { ...@@ -413,7 +424,7 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_CrashTwice) {
TEST_F(ArcSessionRunnerTest, UmaRecording_CrashMini) { TEST_F(ArcSessionRunnerTest, UmaRecording_CrashMini) {
base::HistogramTester tester; base::HistogramTester tester;
arc_session_runner()->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner()->RequestStartMiniInstance();
tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting, tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting,
1); 1);
...@@ -432,7 +443,7 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_CrashMini) { ...@@ -432,7 +443,7 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_CrashMini) {
TEST_F(ArcSessionRunnerTest, UmaRecording_BootFail) { TEST_F(ArcSessionRunnerTest, UmaRecording_BootFail) {
base::HistogramTester tester; base::HistogramTester tester;
arc_session_runner()->RequestStart(ArcInstanceMode::MINI_INSTANCE); arc_session_runner()->RequestStartMiniInstance();
tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting, tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting,
1); 1);
...@@ -450,7 +461,8 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_BootFail) { ...@@ -450,7 +461,8 @@ TEST_F(ArcSessionRunnerTest, UmaRecording_BootFail) {
TEST_F(ArcSessionRunnerTest, UmaRecording_LowDisk) { TEST_F(ArcSessionRunnerTest, UmaRecording_LowDisk) {
base::HistogramTester tester; base::HistogramTester tester;
arc_session_runner()->RequestStart(ArcInstanceMode::FULL_INSTANCE); arc_session_runner()->RequestUpgrade(std::string() /* locale */,
{} /* preferred_languages */);
tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting, tester.ExpectUniqueSample("Arc.ContainerLifetimeEvent", kContainerStarting,
1); 1);
......
...@@ -16,7 +16,9 @@ FakeArcSession::~FakeArcSession() = default; ...@@ -16,7 +16,9 @@ FakeArcSession::~FakeArcSession() = default;
void FakeArcSession::StartMiniInstance() {} void FakeArcSession::StartMiniInstance() {}
void FakeArcSession::RequestUpgrade() { void FakeArcSession::RequestUpgrade(
const std::string& locale,
const std::vector<std::string>& preferred_languages) {
upgrade_requested_ = true; upgrade_requested_ = true;
if (boot_failure_emulation_enabled_) { if (boot_failure_emulation_enabled_) {
for (auto& observer : observer_list_) for (auto& observer : observer_list_)
......
...@@ -21,7 +21,9 @@ class FakeArcSession : public ArcSession { ...@@ -21,7 +21,9 @@ class FakeArcSession : public ArcSession {
// ArcSession overrides: // ArcSession overrides:
void StartMiniInstance() override; void StartMiniInstance() override;
void RequestUpgrade() override; void RequestUpgrade(
const std::string& locale,
const std::vector<std::string>& preferred_languages) override;
void Stop() override; void Stop() override;
bool IsStopRequested() override; bool IsStopRequested() override;
void OnShutdown() override; void OnShutdown() override;
......
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