0

Migrate chromeos::DBusThreadManager to namespace ash

This CL is part of the Chrome OS source code directory migration:
https://docs.google.com/document/d/1g-98HpzA8XcoGBWUv1gQNr4rbnD5yfvbtYZyPDDbkaE.

Bug: 1164001
Change-Id: Ie61000b26076f921187bc8dcb99397f9899d903d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3836621
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Yeunjoo Choi <ychoi@igalia.com>
Owners-Override: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1037539}
This commit is contained in:
Yeunjoo Choi
2022-08-22 02:34:33 +00:00
committed by Chromium LUCI CQ
parent 40706d35cb
commit d1331bf08f
17 changed files with 32 additions and 40 deletions

@ -36,7 +36,7 @@ class AnsibleManagementTestHelper {
Profile* profile_; Profile* profile_;
base::test::ScopedFeatureList scoped_feature_list_; base::test::ScopedFeatureList scoped_feature_list_;
// Owned by chromeos::DBusThreadManager // Owned by ash::DBusThreadManager
ash::FakeCiceroneClient* fake_cicerone_client_; ash::FakeCiceroneClient* fake_cicerone_client_;
}; };

@ -125,10 +125,10 @@ void InitializeDBus() {
chromeos::SystemSaltGetter::Initialize(); chromeos::SystemSaltGetter::Initialize();
// Initialize DBusThreadManager for the browser. // Initialize DBusThreadManager for the browser.
chromeos::DBusThreadManager::Initialize(); DBusThreadManager::Initialize();
// Initialize Chrome dbus clients. // Initialize Chrome dbus clients.
dbus::Bus* bus = chromeos::DBusThreadManager::Get()->GetSystemBus(); dbus::Bus* bus = DBusThreadManager::Get()->GetSystemBus();
shill_clients::Initialize(bus); shill_clients::Initialize(bus);
@ -212,7 +212,7 @@ void InitializeDBus() {
void InitializeFeatureListDependentDBus() { void InitializeFeatureListDependentDBus() {
using chromeos::InitializeDBusClient; using chromeos::InitializeDBusClient;
dbus::Bus* bus = chromeos::DBusThreadManager::Get()->GetSystemBus(); dbus::Bus* bus = DBusThreadManager::Get()->GetSystemBus();
if (floss::features::IsFlossEnabled()) { if (floss::features::IsFlossEnabled()) {
InitializeDBusClient<floss::FlossDBusManager>(bus); InitializeDBusClient<floss::FlossDBusManager>(bus);
} else { } else {
@ -329,7 +329,7 @@ void ShutdownDBus() {
AnomalyDetectorClient::Shutdown(); AnomalyDetectorClient::Shutdown();
shill_clients::Shutdown(); shill_clients::Shutdown();
chromeos::DBusThreadManager::Shutdown(); DBusThreadManager::Shutdown();
chromeos::SystemSaltGetter::Shutdown(); chromeos::SystemSaltGetter::Shutdown();
} }

@ -278,7 +278,7 @@ class PluginVmInstallerTestBase : public testing::Test {
// A pointer to a singleton object which is valid until // A pointer to a singleton object which is valid until
// ConciergeClient::Shutdown() is called. // ConciergeClient::Shutdown() is called.
ash::FakeConciergeClient* fake_concierge_client_; ash::FakeConciergeClient* fake_concierge_client_;
// Owned by chromeos::DBusThreadManager // Owned by ash::DBusThreadManager
chromeos::FakeDlcserviceClient* fake_dlcservice_client_; chromeos::FakeDlcserviceClient* fake_dlcservice_client_;
private: private:

@ -137,7 +137,7 @@ BrowserPolicyConnectorAsh::BrowserPolicyConnectorAsh()
// DBusThreadManager or DeviceSettingsService may be // DBusThreadManager or DeviceSettingsService may be
// uninitialized on unit tests. // uninitialized on unit tests.
if (chromeos::DBusThreadManager::IsInitialized() && if (ash::DBusThreadManager::IsInitialized() &&
ash::DeviceSettingsService::IsInitialized()) { ash::DeviceSettingsService::IsInitialized()) {
std::unique_ptr<DeviceCloudPolicyStoreAsh> device_cloud_policy_store = std::unique_ptr<DeviceCloudPolicyStoreAsh> device_cloud_policy_store =
std::make_unique<DeviceCloudPolicyStoreAsh>( std::make_unique<DeviceCloudPolicyStoreAsh>(

@ -133,7 +133,7 @@ void ChromeFeatureListCreator::CreatePrefService() {
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
// DBus must be initialized before constructing the policy connector. // DBus must be initialized before constructing the policy connector.
CHECK(chromeos::DBusThreadManager::IsInitialized()); CHECK(ash::DBusThreadManager::IsInitialized());
browser_policy_connector_ = browser_policy_connector_ =
std::make_unique<policy::BrowserPolicyConnectorAsh>(); std::make_unique<policy::BrowserPolicyConnectorAsh>();
#else #else

@ -140,7 +140,7 @@ class ProfileProviderRealCollectionTest : public testing::Test {
const ProfileProviderRealCollectionTest&) = delete; const ProfileProviderRealCollectionTest&) = delete;
void SetUp() override { void SetUp() override {
chromeos::DBusThreadManager::Initialize(); ash::DBusThreadManager::Initialize();
// ProfileProvider requires chromeos::LoginState and // ProfileProvider requires chromeos::LoginState and
// chromeos::PowerManagerClient to be initialized. // chromeos::PowerManagerClient to be initialized.
chromeos::PowerManagerClient::InitializeFake(); chromeos::PowerManagerClient::InitializeFake();
@ -186,7 +186,7 @@ class ProfileProviderRealCollectionTest : public testing::Test {
TestingBrowserProcess::DeleteInstance(); TestingBrowserProcess::DeleteInstance();
chromeos::LoginState::Shutdown(); chromeos::LoginState::Shutdown();
chromeos::PowerManagerClient::Shutdown(); chromeos::PowerManagerClient::Shutdown();
chromeos::DBusThreadManager::Shutdown(); ash::DBusThreadManager::Shutdown();
variations::testing::ClearAllVariationParams(); variations::testing::ClearAllVariationParams();
} }

@ -26,8 +26,7 @@ void CreateShell() {
shell_init_params.local_state = g_browser_process->local_state(); shell_init_params.local_state = g_browser_process->local_state();
shell_init_params.keyboard_ui_factory = shell_init_params.keyboard_ui_factory =
std::make_unique<ChromeKeyboardUIFactory>(); std::make_unique<ChromeKeyboardUIFactory>();
shell_init_params.dbus_bus = shell_init_params.dbus_bus = ash::DBusThreadManager::Get()->GetSystemBus();
chromeos::DBusThreadManager::Get()->GetSystemBus();
ash::Shell::CreateInstance(std::move(shell_init_params)); ash::Shell::CreateInstance(std::move(shell_init_params));
} }

@ -9,7 +9,7 @@
#include "base/logging.h" #include "base/logging.h"
namespace chromeos { namespace ash {
static DBusThreadManager* g_dbus_thread_manager = nullptr; static DBusThreadManager* g_dbus_thread_manager = nullptr;
@ -23,9 +23,9 @@ void DBusThreadManager::Initialize() {
g_dbus_thread_manager = new DBusThreadManager(); g_dbus_thread_manager = new DBusThreadManager();
if (!g_dbus_thread_manager->IsUsingFakes()) if (!g_dbus_thread_manager->IsUsingFakes())
VLOG(1) << "DBusThreadManager initialized for ChromeOS"; VLOG(1) << "ash::DBusThreadManager initialized for ChromeOS";
else else
VLOG(1) << "DBusThreadManager created for testing"; VLOG(1) << "ash::DBusThreadManager created for testing";
} }
// static // static
@ -52,4 +52,4 @@ DBusThreadManager* DBusThreadManager::Get() {
return g_dbus_thread_manager; return g_dbus_thread_manager;
} }
} // namespace chromeos } // namespace ash

@ -8,11 +8,11 @@
#include "base/component_export.h" #include "base/component_export.h"
#include "chromeos/dbus/init/dbus_thread_manager_base.h" #include "chromeos/dbus/init/dbus_thread_manager_base.h"
namespace chromeos { namespace ash {
// Ash implementation of DBusThreadManagerBase. // Ash implementation of DBusThreadManagerBase.
class COMPONENT_EXPORT(ASH_DBUS) DBusThreadManager class COMPONENT_EXPORT(ASH_DBUS) DBusThreadManager
: public DBusThreadManagerBase { : public chromeos::DBusThreadManagerBase {
public: public:
// Sets the global instance. Must be called before any calls to Get(). // Sets the global instance. Must be called before any calls to Get().
// We explicitly initialize and shut down the global object, rather than // We explicitly initialize and shut down the global object, rather than
@ -36,11 +36,6 @@ class COMPONENT_EXPORT(ASH_DBUS) DBusThreadManager
~DBusThreadManager() override; ~DBusThreadManager() override;
}; };
} // namespace chromeos } // namespace ash
// TODO(https://crbug.com/1164001): remove after moved to ash.
namespace ash {
using ::chromeos::DBusThreadManager;
}
#endif // CHROMEOS_ASH_COMPONENTS_DBUS_DBUS_THREAD_MANAGER_H_ #endif // CHROMEOS_ASH_COMPONENTS_DBUS_DBUS_THREAD_MANAGER_H_

@ -6,7 +6,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace chromeos { namespace ash {
TEST(DBusThreadManagerTest, Initialize) { TEST(DBusThreadManagerTest, Initialize) {
DBusThreadManager::Initialize(); DBusThreadManager::Initialize();
@ -22,4 +22,4 @@ TEST(DBusThreadManagerTest, Initialize) {
EXPECT_FALSE(DBusThreadManager::IsInitialized()); EXPECT_FALSE(DBusThreadManager::IsInitialized());
} }
} // namespace chromeos } // namespace ash

@ -38,7 +38,7 @@ class CrOSSystemTracingSession {
// |true| if tracing was started and |false| otherwise. // |true| if tracing was started and |false| otherwise.
void StartTracing(const std::string& config, SuccessCallback callback) { void StartTracing(const std::string& config, SuccessCallback callback) {
DCHECK(!is_tracing_); DCHECK(!is_tracing_);
if (!chromeos::DBusThreadManager::IsInitialized()) { if (!ash::DBusThreadManager::IsInitialized()) {
if (callback) if (callback)
std::move(callback).Run(/*success=*/false); std::move(callback).Run(/*success=*/false);
return; return;

@ -116,7 +116,7 @@ ShellBrowserMainParts::~ShellBrowserMainParts() = default;
void ShellBrowserMainParts::PostCreateMainMessageLoop() { void ShellBrowserMainParts::PostCreateMainMessageLoop() {
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
chromeos::DBusThreadManager::Initialize(); ash::DBusThreadManager::Initialize();
#elif BUILDFLAG(IS_CHROMEOS_LACROS) #elif BUILDFLAG(IS_CHROMEOS_LACROS)
chromeos::LacrosDBusThreadManager::Initialize(); chromeos::LacrosDBusThreadManager::Initialize();
#endif #endif
@ -212,7 +212,7 @@ void ShellBrowserMainParts::PostDestroyThreads() {
#endif #endif
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
chromeos::DBusThreadManager::Shutdown(); ash::DBusThreadManager::Shutdown();
#elif BUILDFLAG(IS_CHROMEOS_LACROS) #elif BUILDFLAG(IS_CHROMEOS_LACROS)
chromeos::LacrosDBusThreadManager::Shutdown(); chromeos::LacrosDBusThreadManager::Shutdown();
#endif #endif

@ -108,8 +108,8 @@ void ShellBrowserMainParts::PostCreateMainMessageLoop() {
// Perform initialization of D-Bus objects here rather than in the below // Perform initialization of D-Bus objects here rather than in the below
// helper classes so those classes' tests can initialize stub versions of the // helper classes so those classes' tests can initialize stub versions of the
// D-Bus objects. // D-Bus objects.
chromeos::DBusThreadManager::Initialize(); ash::DBusThreadManager::Initialize();
dbus::Bus* bus = chromeos::DBusThreadManager::Get()->GetSystemBus(); dbus::Bus* bus = ash::DBusThreadManager::Get()->GetSystemBus();
#elif BUILDFLAG(IS_CHROMEOS_LACROS) #elif BUILDFLAG(IS_CHROMEOS_LACROS)
chromeos::LacrosDBusThreadManager::Initialize(); chromeos::LacrosDBusThreadManager::Initialize();
dbus::Bus* bus = chromeos::LacrosDBusThreadManager::Get()->GetSystemBus(); dbus::Bus* bus = chromeos::LacrosDBusThreadManager::Get()->GetSystemBus();
@ -315,7 +315,7 @@ void ShellBrowserMainParts::PostDestroyThreads() {
#endif #endif
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
chromeos::DBusThreadManager::Shutdown(); ash::DBusThreadManager::Shutdown();
#elif BUILDFLAG(IS_CHROMEOS_LACROS) #elif BUILDFLAG(IS_CHROMEOS_LACROS)
chromeos::LacrosDBusThreadManager::Shutdown(); chromeos::LacrosDBusThreadManager::Shutdown();
#endif #endif

@ -18,7 +18,7 @@ namespace extensions {
// Handles network-related tasks for app_shell on Chrome OS. // Handles network-related tasks for app_shell on Chrome OS.
class ShellNetworkController : public ash::NetworkStateHandlerObserver { class ShellNetworkController : public ash::NetworkStateHandlerObserver {
public: public:
// This class must be instantiated after chromeos::DBusThreadManager and // This class must be instantiated after ash::DBusThreadManager and
// destroyed before it. // destroyed before it.
explicit ShellNetworkController(const std::string& preferred_network_name); explicit ShellNetworkController(const std::string& preferred_network_name);

@ -126,10 +126,8 @@ void OnSetRlzPingSent(int retry_count, bool success);
void SetRlzPingSent(int retry_count) { void SetRlzPingSent(int retry_count) {
// GetSystemBus() could return null in tests. // GetSystemBus() could return null in tests.
base::SequencedTaskRunner* const origin_task_runner = base::SequencedTaskRunner* const origin_task_runner =
chromeos::DBusThreadManager::Get()->GetSystemBus() ash::DBusThreadManager::Get()->GetSystemBus()
? chromeos::DBusThreadManager::Get() ? ash::DBusThreadManager::Get()->GetSystemBus()->GetOriginTaskRunner()
->GetSystemBus()
->GetOriginTaskRunner()
: nullptr; : nullptr;
if (origin_task_runner && !origin_task_runner->RunsTasksInCurrentSequence()) { if (origin_task_runner && !origin_task_runner->RunsTasksInCurrentSequence()) {
origin_task_runner->PostTask(FROM_HERE, origin_task_runner->PostTask(FROM_HERE,

@ -1112,7 +1112,7 @@ class ScopedTestDebugDaemonClient : public ash::FakeDebugDaemonClient {
}; };
TEST_F(RlzLibTest, SetRlzPingSent) { TEST_F(RlzLibTest, SetRlzPingSent) {
chromeos::DBusThreadManager::Initialize(); ash::DBusThreadManager::Initialize();
auto debug_daemon_client = std::make_unique<ScopedTestDebugDaemonClient>(); auto debug_daemon_client = std::make_unique<ScopedTestDebugDaemonClient>();
const char* kPingResponse = const char* kPingResponse =
"stateful-events: CAF\r\n" "stateful-events: CAF\r\n"
@ -1133,7 +1133,7 @@ TEST_F(RlzLibTest, SetRlzPingSent) {
EXPECT_EQ(debug_daemon_client->num_set_rlz_ping_sent(), EXPECT_EQ(debug_daemon_client->num_set_rlz_ping_sent(),
1 + rlz_lib::RlzValueStoreChromeOS::kMaxRetryCount); 1 + rlz_lib::RlzValueStoreChromeOS::kMaxRetryCount);
debug_daemon_client.reset(); debug_daemon_client.reset();
chromeos::DBusThreadManager::Shutdown(); ash::DBusThreadManager::Shutdown();
} }
TEST_F(RlzLibTest, NoRecordCAFEvent) { TEST_F(RlzLibTest, NoRecordCAFEvent) {

@ -22,7 +22,7 @@ MtpDeviceManager* g_mtp_device_manager = nullptr;
} // namespace } // namespace
MtpDeviceManager::MtpDeviceManager() MtpDeviceManager::MtpDeviceManager()
: bus_(chromeos::DBusThreadManager::Get()->GetSystemBus()) { : bus_(ash::DBusThreadManager::Get()->GetSystemBus()) {
// Listen for future mtpd service owner changes, in case it is not // Listen for future mtpd service owner changes, in case it is not
// available right now. There is no guarantee that mtpd is running already. // available right now. There is no guarantee that mtpd is running already.
dbus::Bus::ServiceOwnerChangeCallback mtpd_owner_changed_callback = dbus::Bus::ServiceOwnerChangeCallback mtpd_owner_changed_callback =