Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: chromeos/dbus/dbus_thread_manager.cc

Issue 12381002: Improve network stub behavior (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/res/enabled Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/chromeos_switches.cc ('k') | chromeos/dbus/shill_device_client_stub.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/dbus_thread_manager.cc
diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc
index 11ebb6ac94ff7594a4e432aaaf35d0c4b8935845..79de3d08bcae50cf202bf53986ef6827a795cf0e 100644
--- a/chromeos/dbus/dbus_thread_manager.cc
+++ b/chromeos/dbus/dbus_thread_manager.cc
@@ -54,13 +54,15 @@ static bool g_dbus_thread_manager_set_for_testing = false;
// The DBusThreadManager implementation used in production.
class DBusThreadManagerImpl : public DBusThreadManager {
public:
- explicit DBusThreadManagerImpl(DBusClientImplementationType client_type) {
+ explicit DBusThreadManagerImpl(DBusClientImplementationType client_type)
+ : client_type_(client_type),
+ client_type_override_(client_type) {
// If --dbus-stub was requested, pass STUB to specific components;
// Many components like login are not useful with a stub implementation.
- DBusClientImplementationType client_type_maybe_stub = client_type;
if (CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kDbusStub))
- client_type_maybe_stub = STUB_DBUS_CLIENT_IMPLEMENTATION;
+ chromeos::switches::kDbusStub)) {
+ client_type_override_ = STUB_DBUS_CLIENT_IMPLEMENTATION;
+ }
// Create the D-Bus thread.
base::Thread::Options thread_options;
@@ -74,53 +76,60 @@ class DBusThreadManagerImpl : public DBusThreadManager {
system_bus_options.connection_type = dbus::Bus::PRIVATE;
system_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
system_bus_ = new dbus::Bus(system_bus_options);
+ }
+ // InitializeClients gets called after g_dbus_thread_manager is set.
+ // NOTE: Clients that access other clients in their constructor must be
+ // construced in the correct order.
+ void InitializeClients() {
bluetooth_manager_client_.reset(BluetoothManagerClient::Create(
- client_type, system_bus_.get()));
+ client_type_, system_bus_.get()));
bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create(
- client_type, system_bus_.get(), bluetooth_manager_client_.get()));
+ client_type_, system_bus_.get(), bluetooth_manager_client_.get()));
bluetooth_device_client_.reset(BluetoothDeviceClient::Create(
- client_type, system_bus_.get(), bluetooth_adapter_client_.get()));
+ client_type_, system_bus_.get(), bluetooth_adapter_client_.get()));
bluetooth_input_client_.reset(BluetoothInputClient::Create(
- client_type, system_bus_.get(), bluetooth_adapter_client_.get()));
+ client_type_, system_bus_.get(), bluetooth_adapter_client_.get()));
bluetooth_node_client_.reset(BluetoothNodeClient::Create(
- client_type, system_bus_.get(), bluetooth_device_client_.get()));
+ client_type_, system_bus_.get(), bluetooth_device_client_.get()));
bluetooth_out_of_band_client_.reset(BluetoothOutOfBandClient::Create(
- client_type, system_bus_.get()));
+ client_type_, system_bus_.get()));
cros_disks_client_.reset(
- CrosDisksClient::Create(client_type, system_bus_.get()));
+ CrosDisksClient::Create(client_type_, system_bus_.get()));
cryptohome_client_.reset(
- CryptohomeClient::Create(client_type, system_bus_.get()));
+ CryptohomeClient::Create(client_type_, system_bus_.get()));
debug_daemon_client_.reset(
- DebugDaemonClient::Create(client_type, system_bus_.get()));
+ DebugDaemonClient::Create(client_type_, system_bus_.get()));
+
+ shill_manager_client_.reset(
+ ShillManagerClient::Create(client_type_override_, system_bus_.get()));
shill_device_client_.reset(
- ShillDeviceClient::Create(client_type, system_bus_.get()));
+ ShillDeviceClient::Create(client_type_override_, system_bus_.get()));
shill_ipconfig_client_.reset(
- ShillIPConfigClient::Create(client_type, system_bus_.get()));
- shill_manager_client_.reset(
- ShillManagerClient::Create(client_type, system_bus_.get()));
+ ShillIPConfigClient::Create(client_type_override_, system_bus_.get()));
shill_profile_client_.reset(
- ShillProfileClient::Create(client_type, system_bus_.get()));
+ ShillProfileClient::Create(client_type_override_, system_bus_.get()));
shill_service_client_.reset(
- ShillServiceClient::Create(client_type, system_bus_.get()));
+ ShillServiceClient::Create(client_type_override_, system_bus_.get()));
gsm_sms_client_.reset(
- GsmSMSClient::Create(client_type, system_bus_.get()));
- image_burner_client_.reset(ImageBurnerClient::Create(client_type,
+ GsmSMSClient::Create(client_type_override_, system_bus_.get()));
+
+ image_burner_client_.reset(ImageBurnerClient::Create(client_type_,
system_bus_.get()));
introspectable_client_.reset(
- IntrospectableClient::Create(client_type, system_bus_.get()));
+ IntrospectableClient::Create(client_type_, system_bus_.get()));
modem_messaging_client_.reset(
- ModemMessagingClient::Create(client_type, system_bus_.get()));
+ ModemMessagingClient::Create(client_type_, system_bus_.get()));
permission_broker_client_.reset(
- PermissionBrokerClient::Create(client_type, system_bus_.get()));
+ PermissionBrokerClient::Create(client_type_, system_bus_.get()));
power_manager_client_.reset(
- PowerManagerClient::Create(client_type_maybe_stub, system_bus_.get()));
+ PowerManagerClient::Create(client_type_override_, system_bus_.get()));
session_manager_client_.reset(
- SessionManagerClient::Create(client_type, system_bus_.get()));
+ SessionManagerClient::Create(client_type_, system_bus_.get()));
sms_client_.reset(
- SMSClient::Create(client_type, system_bus_.get()));
+ SMSClient::Create(client_type_, system_bus_.get()));
update_engine_client_.reset(
- UpdateEngineClient::Create(client_type, system_bus_.get()));
+ UpdateEngineClient::Create(client_type_, system_bus_.get()));
// PowerPolicyController is dependent on PowerManagerClient, so
// initialize it after the main list of clients.
@@ -346,6 +355,9 @@ class DBusThreadManagerImpl : public DBusThreadManager {
return ibus_panel_service_.get();
}
+ DBusClientImplementationType client_type_;
+ DBusClientImplementationType client_type_override_;
+
// Note: Keep this before other members so they can call AddObserver() in
// their c'tors.
ObserverList<DBusThreadManagerObserver> observers_;
@@ -396,15 +408,18 @@ void DBusThreadManager::Initialize() {
// early; do not allow that.
CHECK(g_dbus_thread_manager == NULL);
// Determine whether we use stub or real client implementations.
+ DBusThreadManagerImpl* dbus_thread_manager_impl;
if (base::chromeos::IsRunningOnChromeOS()) {
- g_dbus_thread_manager =
+ dbus_thread_manager_impl =
new DBusThreadManagerImpl(REAL_DBUS_CLIENT_IMPLEMENTATION);
VLOG(1) << "DBusThreadManager initialized for ChromeOS";
} else {
- g_dbus_thread_manager =
+ dbus_thread_manager_impl =
new DBusThreadManagerImpl(STUB_DBUS_CLIENT_IMPLEMENTATION);
VLOG(1) << "DBusThreadManager initialized with Stub";
}
+ g_dbus_thread_manager = dbus_thread_manager_impl;
+ dbus_thread_manager_impl->InitializeClients();
}
// static
@@ -424,8 +439,10 @@ void DBusThreadManager::InitializeWithStub() {
// If we initialize DBusThreadManager twice we may also be shutting it down
// early; do not allow that.
CHECK(g_dbus_thread_manager == NULL);
- g_dbus_thread_manager =
- new DBusThreadManagerImpl(STUB_DBUS_CLIENT_IMPLEMENTATION);
+ DBusThreadManagerImpl* dbus_thread_manager_impl =
+ new DBusThreadManagerImpl(STUB_DBUS_CLIENT_IMPLEMENTATION);
+ g_dbus_thread_manager = dbus_thread_manager_impl;
+ dbus_thread_manager_impl->InitializeClients();
VLOG(1) << "DBusThreadManager initialized with stub implementation";
}
« no previous file with comments | « chromeos/chromeos_switches.cc ('k') | chromeos/dbus/shill_device_client_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698