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

Side by Side Diff: chromeos/dbus/dbus_thread_manager.cc

Issue 282873005: chromeos: Use FakeDBusThreadManager for --dbus-stub. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/ChromeOS/Chrome OS/ Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/dbus/dbus_thread_manager.h" 5 #include "chromeos/dbus/dbus_thread_manager.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 static DBusThreadManager* g_dbus_thread_manager = NULL; 57 static DBusThreadManager* g_dbus_thread_manager = NULL;
58 static DBusThreadManager* g_dbus_thread_manager_for_testing = NULL; 58 static DBusThreadManager* g_dbus_thread_manager_for_testing = NULL;
59 59
60 // The bundle of all D-Bus clients used in DBusThreadManagerImpl. The bundle 60 // The bundle of all D-Bus clients used in DBusThreadManagerImpl. The bundle
61 // is used to delete them at once in the right order before shutting down the 61 // is used to delete them at once in the right order before shutting down the
62 // system bus. See also the comment in the destructor of DBusThreadManagerImpl. 62 // system bus. See also the comment in the destructor of DBusThreadManagerImpl.
63 class DBusClientBundle { 63 class DBusClientBundle {
64 public: 64 public:
65 DBusClientBundle() { 65 DBusClientBundle() {
66 DBusClientImplementationType client_type = REAL_DBUS_CLIENT_IMPLEMENTATION; 66 const DBusClientImplementationType type = REAL_DBUS_CLIENT_IMPLEMENTATION;
67 DBusClientImplementationType client_type_override = client_type;
68 // If --dbus-stub was requested, pass STUB to specific components;
69 // Many components like login are not useful with a stub implementation.
70 if (CommandLine::ForCurrentProcess()->HasSwitch(
71 chromeos::switches::kDbusStub)) {
72 client_type_override = STUB_DBUS_CLIENT_IMPLEMENTATION;
73 }
74 67
75 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create()); 68 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create());
76 bluetooth_agent_manager_client_.reset( 69 bluetooth_agent_manager_client_.reset(
77 BluetoothAgentManagerClient::Create()); 70 BluetoothAgentManagerClient::Create());
78 bluetooth_device_client_.reset(BluetoothDeviceClient::Create()); 71 bluetooth_device_client_.reset(BluetoothDeviceClient::Create());
79 bluetooth_gatt_characteristic_client_.reset( 72 bluetooth_gatt_characteristic_client_.reset(
80 BluetoothGattCharacteristicClient::Create()); 73 BluetoothGattCharacteristicClient::Create());
81 bluetooth_gatt_descriptor_client_.reset( 74 bluetooth_gatt_descriptor_client_.reset(
82 BluetoothGattDescriptorClient::Create()); 75 BluetoothGattDescriptorClient::Create());
83 bluetooth_gatt_manager_client_.reset(BluetoothGattManagerClient::Create()); 76 bluetooth_gatt_manager_client_.reset(BluetoothGattManagerClient::Create());
84 bluetooth_gatt_service_client_.reset(BluetoothGattServiceClient::Create()); 77 bluetooth_gatt_service_client_.reset(BluetoothGattServiceClient::Create());
85 bluetooth_input_client_.reset(BluetoothInputClient::Create()); 78 bluetooth_input_client_.reset(BluetoothInputClient::Create());
86 bluetooth_profile_manager_client_.reset( 79 bluetooth_profile_manager_client_.reset(
87 BluetoothProfileManagerClient::Create()); 80 BluetoothProfileManagerClient::Create());
88 cras_audio_client_.reset(CrasAudioClient::Create()); 81 cras_audio_client_.reset(CrasAudioClient::Create());
89 cros_disks_client_.reset(CrosDisksClient::Create(client_type)); 82 cros_disks_client_.reset(CrosDisksClient::Create(type));
90 cryptohome_client_.reset(CryptohomeClient::Create()); 83 cryptohome_client_.reset(CryptohomeClient::Create());
91 debug_daemon_client_.reset(DebugDaemonClient::Create()); 84 debug_daemon_client_.reset(DebugDaemonClient::Create());
92 lorgnette_manager_client_.reset(LorgnetteManagerClient::Create()); 85 lorgnette_manager_client_.reset(LorgnetteManagerClient::Create());
93 shill_manager_client_.reset(ShillManagerClient::Create()); 86 shill_manager_client_.reset(ShillManagerClient::Create());
94 shill_device_client_.reset(ShillDeviceClient::Create()); 87 shill_device_client_.reset(ShillDeviceClient::Create());
95 shill_ipconfig_client_.reset(ShillIPConfigClient::Create()); 88 shill_ipconfig_client_.reset(ShillIPConfigClient::Create());
96 shill_service_client_.reset(ShillServiceClient::Create()); 89 shill_service_client_.reset(ShillServiceClient::Create());
97 shill_profile_client_.reset(ShillProfileClient::Create()); 90 shill_profile_client_.reset(ShillProfileClient::Create());
98 gsm_sms_client_.reset(GsmSMSClient::Create()); 91 gsm_sms_client_.reset(GsmSMSClient::Create());
99 image_burner_client_.reset(ImageBurnerClient::Create()); 92 image_burner_client_.reset(ImageBurnerClient::Create());
100 introspectable_client_.reset(IntrospectableClient::Create()); 93 introspectable_client_.reset(IntrospectableClient::Create());
101 modem_messaging_client_.reset(ModemMessagingClient::Create()); 94 modem_messaging_client_.reset(ModemMessagingClient::Create());
102 // Create the NFC clients in the correct order based on their dependencies. 95 // Create the NFC clients in the correct order based on their dependencies.
103 nfc_manager_client_.reset(NfcManagerClient::Create()); 96 nfc_manager_client_.reset(NfcManagerClient::Create());
104 nfc_adapter_client_.reset( 97 nfc_adapter_client_.reset(
105 NfcAdapterClient::Create(nfc_manager_client_.get())); 98 NfcAdapterClient::Create(nfc_manager_client_.get()));
106 nfc_device_client_.reset( 99 nfc_device_client_.reset(
107 NfcDeviceClient::Create(nfc_adapter_client_.get())); 100 NfcDeviceClient::Create(nfc_adapter_client_.get()));
108 nfc_tag_client_.reset(NfcTagClient::Create(nfc_adapter_client_.get())); 101 nfc_tag_client_.reset(NfcTagClient::Create(nfc_adapter_client_.get()));
109 nfc_record_client_.reset(NfcRecordClient::Create(nfc_device_client_.get(), 102 nfc_record_client_.reset(NfcRecordClient::Create(nfc_device_client_.get(),
110 nfc_tag_client_.get())); 103 nfc_tag_client_.get()));
111 permission_broker_client_.reset(PermissionBrokerClient::Create()); 104 permission_broker_client_.reset(PermissionBrokerClient::Create());
112 power_manager_client_.reset( 105 power_manager_client_.reset(PowerManagerClient::Create(type));
113 PowerManagerClient::Create(client_type_override)); 106 session_manager_client_.reset(SessionManagerClient::Create(type));
114 session_manager_client_.reset(SessionManagerClient::Create(client_type));
115 sms_client_.reset(SMSClient::Create()); 107 sms_client_.reset(SMSClient::Create());
116 system_clock_client_.reset(SystemClockClient::Create()); 108 system_clock_client_.reset(SystemClockClient::Create());
117 update_engine_client_.reset(UpdateEngineClient::Create(client_type)); 109 update_engine_client_.reset(UpdateEngineClient::Create(type));
118 } 110 }
119 111
120 BluetoothAdapterClient* bluetooth_adapter_client() { 112 BluetoothAdapterClient* bluetooth_adapter_client() {
121 return bluetooth_adapter_client_.get(); 113 return bluetooth_adapter_client_.get();
122 } 114 }
123 BluetoothAgentManagerClient* bluetooth_agent_manager_client() { 115 BluetoothAgentManagerClient* bluetooth_agent_manager_client() {
124 return bluetooth_agent_manager_client_.get(); 116 return bluetooth_agent_manager_client_.get();
125 } 117 }
126 BluetoothDeviceClient* bluetooth_device_client() { 118 BluetoothDeviceClient* bluetooth_device_client() {
127 return bluetooth_device_client_.get(); 119 return bluetooth_device_client_.get();
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // If we initialize DBusThreadManager twice we may also be shutting it down 474 // If we initialize DBusThreadManager twice we may also be shutting it down
483 // early; do not allow that. 475 // early; do not allow that.
484 CHECK(g_dbus_thread_manager == NULL); 476 CHECK(g_dbus_thread_manager == NULL);
485 477
486 if (g_dbus_thread_manager_for_testing) { 478 if (g_dbus_thread_manager_for_testing) {
487 g_dbus_thread_manager = g_dbus_thread_manager_for_testing; 479 g_dbus_thread_manager = g_dbus_thread_manager_for_testing;
488 InitializeClients(); 480 InitializeClients();
489 VLOG(1) << "DBusThreadManager initialized with test implementation"; 481 VLOG(1) << "DBusThreadManager initialized with test implementation";
490 return; 482 return;
491 } 483 }
484
492 // Determine whether we use stub or real client implementations. 485 // Determine whether we use stub or real client implementations.
493 if (base::SysInfo::IsRunningOnChromeOS()) { 486 if (!base::SysInfo::IsRunningOnChromeOS() ||
487 CommandLine::ForCurrentProcess()->HasSwitch(
488 chromeos::switches::kDbusStub)) {
489 InitializeWithStub();
490 } else {
494 g_dbus_thread_manager = new DBusThreadManagerImpl; 491 g_dbus_thread_manager = new DBusThreadManagerImpl;
495 InitializeClients(); 492 InitializeClients();
496 VLOG(1) << "DBusThreadManager initialized for ChromeOS"; 493 VLOG(1) << "DBusThreadManager initialized for Chrome OS";
497 } else {
498 InitializeWithStub();
499 } 494 }
500 } 495 }
501 496
502 // static 497 // static
503 void DBusThreadManager::SetInstanceForTesting( 498 void DBusThreadManager::SetInstanceForTesting(
504 DBusThreadManager* dbus_thread_manager) { 499 DBusThreadManager* dbus_thread_manager) {
505 CHECK(!g_dbus_thread_manager); 500 CHECK(!g_dbus_thread_manager);
506 CHECK(!g_dbus_thread_manager_for_testing); 501 CHECK(!g_dbus_thread_manager_for_testing);
507 g_dbus_thread_manager_for_testing = dbus_thread_manager; 502 g_dbus_thread_manager_for_testing = dbus_thread_manager;
508 } 503 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); 619 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects();
625 } 620 }
626 621
627 // static 622 // static
628 void DBusThreadManager::InitClient(DBusClient* client) { 623 void DBusThreadManager::InitClient(DBusClient* client) {
629 if (client) 624 if (client)
630 client->Init(g_dbus_thread_manager->GetSystemBus()); 625 client->Init(g_dbus_thread_manager->GetSystemBus());
631 } 626 }
632 627
633 } // namespace chromeos 628 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698