Commit f758e80d authored by Yue Li's avatar Yue Li Committed by Commit Bot

Update lifecyle of Assitant client

- Assistant need to be destructed before voice interaction controller
  client in order to correctly remove the observer.

Bug: b/112273549
Test: Manual Test
Change-Id: I6360dcdca38dd8d50ac6bbf768841f34d375b31b
Reviewed-on: https://chromium-review.googlesource.com/1164411
Commit-Queue: Yue Li <updowndota@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581281}
parent 70de218a
......@@ -186,6 +186,10 @@
#include "components/rlz/rlz_tracker.h"
#endif
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
#include "chrome/browser/ui/ash/assistant/assistant_client.h"
#endif
namespace chromeos {
namespace {
......@@ -686,6 +690,12 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
arc_voice_interaction_controller_client_ =
std::make_unique<arc::VoiceInteractionControllerClient>();
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
// Assistant has to be initialized before session_controller_client to avoid
// race of SessionChanged event and assistant_client initialization.
assistant_client_ = std::make_unique<AssistantClient>();
#endif
chromeos::ResourceReporter::GetInstance()->StartMonitoring(
task_manager::TaskManagerInterface::GetTaskManager());
......@@ -1061,6 +1071,12 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
arc_service_launcher_->Shutdown();
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
// Assistant has to shut down before voice interaction controller client to
// correctly remove the observer.
assistant_client_.reset();
#endif
arc_voice_interaction_controller_client_.reset();
// Unregister CrosSettings observers before CrosSettings is destroyed.
......
......@@ -12,6 +12,7 @@
#include "chrome/browser/chrome_browser_main_linux.h"
#include "chrome/browser/chromeos/external_metrics.h"
#include "chrome/browser/memory/memory_kills_monitor.h"
#include "chromeos/assistant/buildflags.h"
class SpokenFeedbackEventRewriterDelegate;
......@@ -24,6 +25,10 @@ class ArcServiceLauncher;
class VoiceInteractionControllerClient;
}
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
class AssistantClient;
#endif
namespace chromeos {
class ArcKioskAppManager;
......@@ -111,6 +116,10 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
std::unique_ptr<arc::VoiceInteractionControllerClient>
arc_voice_interaction_controller_client_;
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
std::unique_ptr<AssistantClient> assistant_client_;
#endif
std::unique_ptr<LowDiskNotification> low_disk_notification_;
std::unique_ptr<ArcKioskAppManager> arc_kiosk_app_manager_;
......
......@@ -70,10 +70,6 @@
#include "chrome/browser/exo_parts.h"
#endif
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
#include "chrome/browser/ui/ash/assistant/assistant_client.h"
#endif
namespace {
void PushProcessCreationTimeToAsh() {
......@@ -198,12 +194,6 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
chromeos::input_method::InputMethodManager::Get());
ime_controller_client_->Init();
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
// Assistant has to be initialized before session_controller_client to avoid
// race of SessionChanged event and assistant_client initialization.
assistant_client_ = std::make_unique<AssistantClient>();
#endif
session_controller_client_ = std::make_unique<SessionControllerClient>();
session_controller_client_->Init();
......@@ -288,9 +278,6 @@ void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
system_tray_client_.reset();
shell_state_client_.reset();
session_controller_client_.reset();
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
assistant_client_.reset();
#endif
chrome_new_window_client_.reset();
network_portal_notification_controller_.reset();
media_client_.reset();
......
......@@ -10,7 +10,6 @@
#include "base/macros.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/common/buildflags.h"
#include "chromeos/assistant/buildflags.h"
namespace aura {
class UserActivityForwarder;
......@@ -49,10 +48,6 @@ class WallpaperControllerClient;
class ExoParts;
#endif
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
class AssistantClient;
#endif
namespace internal {
class ChromeLauncherControllerInitializer;
}
......@@ -114,10 +109,6 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts {
std::unique_ptr<ExoParts> exo_parts_;
#endif
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
std::unique_ptr<AssistantClient> assistant_client_;
#endif
// Initialized in PostProfileInit in all configs:
std::unique_ptr<CastConfigClientMediaRouter> cast_config_client_media_router_;
std::unique_ptr<LoginScreenClient> login_screen_client_;
......
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