OLD | NEW |
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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chromeos/dbus/cryptohome_client.h" | 22 #include "chromeos/dbus/cryptohome_client.h" |
23 #include "chromeos/dbus/dbus_client.h" | 23 #include "chromeos/dbus/dbus_client.h" |
24 #include "chromeos/dbus/dbus_client_bundle.h" | 24 #include "chromeos/dbus/dbus_client_bundle.h" |
25 #include "chromeos/dbus/debug_daemon_client.h" | 25 #include "chromeos/dbus/debug_daemon_client.h" |
26 #include "chromeos/dbus/easy_unlock_client.h" | 26 #include "chromeos/dbus/easy_unlock_client.h" |
27 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 27 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
28 #include "chromeos/dbus/gsm_sms_client.h" | 28 #include "chromeos/dbus/gsm_sms_client.h" |
29 #include "chromeos/dbus/image_burner_client.h" | 29 #include "chromeos/dbus/image_burner_client.h" |
30 #include "chromeos/dbus/introspectable_client.h" | 30 #include "chromeos/dbus/introspectable_client.h" |
31 #include "chromeos/dbus/lorgnette_manager_client.h" | 31 #include "chromeos/dbus/lorgnette_manager_client.h" |
32 #include "chromeos/dbus/mixed_dbus_thread_manager.h" | |
33 #include "chromeos/dbus/modem_messaging_client.h" | 32 #include "chromeos/dbus/modem_messaging_client.h" |
34 #include "chromeos/dbus/nfc_adapter_client.h" | 33 #include "chromeos/dbus/nfc_adapter_client.h" |
35 #include "chromeos/dbus/nfc_device_client.h" | 34 #include "chromeos/dbus/nfc_device_client.h" |
36 #include "chromeos/dbus/nfc_manager_client.h" | 35 #include "chromeos/dbus/nfc_manager_client.h" |
37 #include "chromeos/dbus/nfc_record_client.h" | 36 #include "chromeos/dbus/nfc_record_client.h" |
38 #include "chromeos/dbus/nfc_tag_client.h" | 37 #include "chromeos/dbus/nfc_tag_client.h" |
39 #include "chromeos/dbus/permission_broker_client.h" | 38 #include "chromeos/dbus/permission_broker_client.h" |
40 #include "chromeos/dbus/power_manager_client.h" | 39 #include "chromeos/dbus/power_manager_client.h" |
41 #include "chromeos/dbus/power_policy_controller.h" | 40 #include "chromeos/dbus/power_policy_controller.h" |
42 #include "chromeos/dbus/session_manager_client.h" | 41 #include "chromeos/dbus/session_manager_client.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 client_bundle_.reset(); | 86 client_bundle_.reset(); |
88 | 87 |
89 // Shut down the bus. During the browser shutdown, it's ok to shut down | 88 // Shut down the bus. During the browser shutdown, it's ok to shut down |
90 // the bus synchronously. | 89 // the bus synchronously. |
91 system_bus_->ShutdownOnDBusThreadAndBlock(); | 90 system_bus_->ShutdownOnDBusThreadAndBlock(); |
92 | 91 |
93 // Stop the D-Bus thread. | 92 // Stop the D-Bus thread. |
94 dbus_thread_->Stop(); | 93 dbus_thread_->Stop(); |
95 } | 94 } |
96 | 95 |
| 96 void SetupDefaultEnvironment() { |
| 97 return client_bundle_->SetupDefaultEnvironment(); |
| 98 } |
| 99 |
97 virtual dbus::Bus* GetSystemBus() OVERRIDE { | 100 virtual dbus::Bus* GetSystemBus() OVERRIDE { |
98 return system_bus_.get(); | 101 return system_bus_.get(); |
99 } | 102 } |
100 | 103 |
101 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { | 104 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { |
102 return client_bundle_->bluetooth_adapter_client(); | 105 return client_bundle_->bluetooth_adapter_client(); |
103 } | 106 } |
104 | 107 |
105 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() | 108 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() |
106 OVERRIDE { | 109 OVERRIDE { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return power_policy_controller_.get(); | 248 return power_policy_controller_.get(); |
246 } | 249 } |
247 | 250 |
248 private: | 251 private: |
249 // Constructs all clients and stores them in the respective *_client_ member | 252 // Constructs all clients and stores them in the respective *_client_ member |
250 // variable. | 253 // variable. |
251 void CreateDefaultClients() { | 254 void CreateDefaultClients() { |
252 client_bundle_.reset(new DBusClientBundle()); | 255 client_bundle_.reset(new DBusClientBundle()); |
253 // TODO(crbug.com/345586): Move PowerPolicyController out of | 256 // TODO(crbug.com/345586): Move PowerPolicyController out of |
254 // DBusThreadManagerImpl. | 257 // DBusThreadManagerImpl. |
255 if (!DBusThreadManager::IsUsingStub(DBusClientBundle::POWER_MANAGER)) | 258 power_policy_controller_.reset(new PowerPolicyController); |
256 power_policy_controller_.reset(new PowerPolicyController); | |
257 } | 259 } |
258 | 260 |
259 scoped_ptr<base::Thread> dbus_thread_; | 261 scoped_ptr<base::Thread> dbus_thread_; |
260 scoped_refptr<dbus::Bus> system_bus_; | 262 scoped_refptr<dbus::Bus> system_bus_; |
261 scoped_ptr<DBusClientBundle> client_bundle_; | 263 scoped_ptr<DBusClientBundle> client_bundle_; |
262 scoped_ptr<PowerPolicyController> power_policy_controller_; | 264 scoped_ptr<PowerPolicyController> power_policy_controller_; |
263 | 265 |
264 DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerImpl); | 266 DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerImpl); |
265 }; | 267 }; |
266 | 268 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 CHECK(g_dbus_thread_manager == NULL); | 333 CHECK(g_dbus_thread_manager == NULL); |
332 | 334 |
333 unstub_client_mask_ = DBusClientBundle::ParseUnstubList(unstub_clients); | 335 unstub_client_mask_ = DBusClientBundle::ParseUnstubList(unstub_clients); |
334 // We should have something parsed correctly here. | 336 // We should have something parsed correctly here. |
335 if (unstub_client_mask_ == 0) { | 337 if (unstub_client_mask_ == 0) { |
336 LOG(FATAL) << "Switch values for --" | 338 LOG(FATAL) << "Switch values for --" |
337 << chromeos::switches::kDbusUnstubClients | 339 << chromeos::switches::kDbusUnstubClients |
338 << " cannot be parsed: " | 340 << " cannot be parsed: " |
339 << unstub_clients; | 341 << unstub_clients; |
340 } | 342 } |
341 DBusThreadManager* real_thread_manager = new DBusThreadManagerImpl(); | 343 DBusThreadManagerImpl* dbus_thread_manager = new DBusThreadManagerImpl(); |
342 FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; | |
343 fake_dbus_thread_manager->SetFakeClients(); | |
344 VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; | 344 VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; |
345 g_dbus_thread_manager = new MixedDBusThreadManager(real_thread_manager, | 345 g_dbus_thread_manager = dbus_thread_manager; |
346 fake_dbus_thread_manager); | |
347 InitializeClients(); | 346 InitializeClients(); |
348 fake_dbus_thread_manager->SetupDefaultEnvironment(); | 347 dbus_thread_manager->SetupDefaultEnvironment(); |
349 } | 348 } |
350 | 349 |
351 // static | 350 // static |
352 void DBusThreadManager::InitializeWithStub() { | 351 void DBusThreadManager::InitializeWithStub() { |
353 unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; | 352 unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; |
354 // If we initialize DBusThreadManager twice we may also be shutting it down | 353 // If we initialize DBusThreadManager twice we may also be shutting it down |
355 // early; do not allow that. | 354 // early; do not allow that. |
356 CHECK(g_dbus_thread_manager == NULL); | 355 CHECK(g_dbus_thread_manager == NULL); |
357 FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; | 356 FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; |
358 fake_dbus_thread_manager->SetFakeClients(); | 357 fake_dbus_thread_manager->SetFakeClients(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); | 459 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); |
461 } | 460 } |
462 | 461 |
463 // static | 462 // static |
464 void DBusThreadManager::InitClient(DBusClient* client) { | 463 void DBusThreadManager::InitClient(DBusClient* client) { |
465 if (client) | 464 if (client) |
466 client->Init(g_dbus_thread_manager->GetSystemBus()); | 465 client->Init(g_dbus_thread_manager->GetSystemBus()); |
467 } | 466 } |
468 | 467 |
469 } // namespace chromeos | 468 } // namespace chromeos |
OLD | NEW |