| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "chromeos/dbus/session_manager_client.h" | 42 #include "chromeos/dbus/session_manager_client.h" |
| 43 #include "chromeos/dbus/shill_device_client.h" | 43 #include "chromeos/dbus/shill_device_client.h" |
| 44 #include "chromeos/dbus/shill_ipconfig_client.h" | 44 #include "chromeos/dbus/shill_ipconfig_client.h" |
| 45 #include "chromeos/dbus/shill_manager_client.h" | 45 #include "chromeos/dbus/shill_manager_client.h" |
| 46 #include "chromeos/dbus/shill_profile_client.h" | 46 #include "chromeos/dbus/shill_profile_client.h" |
| 47 #include "chromeos/dbus/shill_service_client.h" | 47 #include "chromeos/dbus/shill_service_client.h" |
| 48 #include "chromeos/dbus/shill_third_party_vpn_driver_client.h" | 48 #include "chromeos/dbus/shill_third_party_vpn_driver_client.h" |
| 49 #include "chromeos/dbus/sms_client.h" | 49 #include "chromeos/dbus/sms_client.h" |
| 50 #include "chromeos/dbus/system_clock_client.h" | 50 #include "chromeos/dbus/system_clock_client.h" |
| 51 #include "chromeos/dbus/update_engine_client.h" | 51 #include "chromeos/dbus/update_engine_client.h" |
| 52 #include "chromeos/device_event_log.h" |
| 52 #include "dbus/bus.h" | 53 #include "dbus/bus.h" |
| 53 #include "dbus/dbus_statistics.h" | 54 #include "dbus/dbus_statistics.h" |
| 54 | 55 |
| 55 namespace chromeos { | 56 namespace chromeos { |
| 56 | 57 |
| 57 static DBusThreadManager* g_dbus_thread_manager = NULL; | 58 static DBusThreadManager* g_dbus_thread_manager = NULL; |
| 58 static bool g_using_dbus_thread_manager_for_testing = false; | 59 static bool g_using_dbus_thread_manager_for_testing = false; |
| 59 | 60 |
| 60 DBusThreadManager::DBusThreadManager(scoped_ptr<DBusClientBundle> client_bundle) | 61 DBusThreadManager::DBusThreadManager(scoped_ptr<DBusClientBundle> client_bundle) |
| 61 : client_bundle_(client_bundle.Pass()) { | 62 : client_bundle_(client_bundle.Pass()) { |
| 63 device_event_log::Initialize(0 /* default max entries */); |
| 62 dbus::statistics::Initialize(); | 64 dbus::statistics::Initialize(); |
| 63 | 65 |
| 64 if (client_bundle_->IsUsingAnyRealClient()) { | 66 if (client_bundle_->IsUsingAnyRealClient()) { |
| 65 // At least one real DBusClient is used. | 67 // At least one real DBusClient is used. |
| 66 // Create the D-Bus thread. | 68 // Create the D-Bus thread. |
| 67 base::Thread::Options thread_options; | 69 base::Thread::Options thread_options; |
| 68 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 70 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 69 dbus_thread_.reset(new base::Thread("D-Bus thread")); | 71 dbus_thread_.reset(new base::Thread("D-Bus thread")); |
| 70 dbus_thread_->StartWithOptions(thread_options); | 72 dbus_thread_->StartWithOptions(thread_options); |
| 71 | 73 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 85 // Shut down the bus. During the browser shutdown, it's ok to shut down | 87 // Shut down the bus. During the browser shutdown, it's ok to shut down |
| 86 // the bus synchronously. | 88 // the bus synchronously. |
| 87 if (system_bus_.get()) | 89 if (system_bus_.get()) |
| 88 system_bus_->ShutdownOnDBusThreadAndBlock(); | 90 system_bus_->ShutdownOnDBusThreadAndBlock(); |
| 89 | 91 |
| 90 // Stop the D-Bus thread. | 92 // Stop the D-Bus thread. |
| 91 if (dbus_thread_) | 93 if (dbus_thread_) |
| 92 dbus_thread_->Stop(); | 94 dbus_thread_->Stop(); |
| 93 | 95 |
| 94 dbus::statistics::Shutdown(); | 96 dbus::statistics::Shutdown(); |
| 97 device_event_log::Shutdown(); |
| 95 | 98 |
| 96 if (!g_dbus_thread_manager) | 99 if (!g_dbus_thread_manager) |
| 97 return; // Called form Shutdown() or local test instance. | 100 return; // Called form Shutdown() or local test instance. |
| 98 | 101 |
| 99 // There should never be both a global instance and a local instance. | 102 // There should never be both a global instance and a local instance. |
| 100 CHECK(this == g_dbus_thread_manager); | 103 CHECK(this == g_dbus_thread_manager); |
| 101 if (g_using_dbus_thread_manager_for_testing) { | 104 if (g_using_dbus_thread_manager_for_testing) { |
| 102 g_dbus_thread_manager = NULL; | 105 g_dbus_thread_manager = NULL; |
| 103 g_using_dbus_thread_manager_for_testing = false; | 106 g_using_dbus_thread_manager_for_testing = false; |
| 104 VLOG(1) << "DBusThreadManager destroyed"; | 107 VLOG(1) << "DBusThreadManager destroyed"; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 client.Pass(); | 648 client.Pass(); |
| 646 } | 649 } |
| 647 | 650 |
| 648 void DBusThreadManagerSetter::SetUpdateEngineClient( | 651 void DBusThreadManagerSetter::SetUpdateEngineClient( |
| 649 scoped_ptr<UpdateEngineClient> client) { | 652 scoped_ptr<UpdateEngineClient> client) { |
| 650 DBusThreadManager::Get()->client_bundle_->update_engine_client_ = | 653 DBusThreadManager::Get()->client_bundle_->update_engine_client_ = |
| 651 client.Pass(); | 654 client.Pass(); |
| 652 } | 655 } |
| 653 | 656 |
| 654 } // namespace chromeos | 657 } // namespace chromeos |
| OLD | NEW |