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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "chromeos/dbus/session_manager_client.h" | 44 #include "chromeos/dbus/session_manager_client.h" |
45 #include "chromeos/dbus/shill_device_client.h" | 45 #include "chromeos/dbus/shill_device_client.h" |
46 #include "chromeos/dbus/shill_ipconfig_client.h" | 46 #include "chromeos/dbus/shill_ipconfig_client.h" |
47 #include "chromeos/dbus/shill_manager_client.h" | 47 #include "chromeos/dbus/shill_manager_client.h" |
48 #include "chromeos/dbus/shill_profile_client.h" | 48 #include "chromeos/dbus/shill_profile_client.h" |
49 #include "chromeos/dbus/shill_service_client.h" | 49 #include "chromeos/dbus/shill_service_client.h" |
50 #include "chromeos/dbus/shill_third_party_vpn_driver_client.h" | 50 #include "chromeos/dbus/shill_third_party_vpn_driver_client.h" |
51 #include "chromeos/dbus/sms_client.h" | 51 #include "chromeos/dbus/sms_client.h" |
52 #include "chromeos/dbus/system_clock_client.h" | 52 #include "chromeos/dbus/system_clock_client.h" |
53 #include "chromeos/dbus/update_engine_client.h" | 53 #include "chromeos/dbus/update_engine_client.h" |
54 #include "chromeos/device_event_log.h" | |
55 #include "dbus/bus.h" | 54 #include "dbus/bus.h" |
56 #include "dbus/dbus_statistics.h" | 55 #include "dbus/dbus_statistics.h" |
57 | 56 |
58 namespace chromeos { | 57 namespace chromeos { |
59 | 58 |
60 static DBusThreadManager* g_dbus_thread_manager = NULL; | 59 static DBusThreadManager* g_dbus_thread_manager = NULL; |
61 static bool g_using_dbus_thread_manager_for_testing = false; | 60 static bool g_using_dbus_thread_manager_for_testing = false; |
62 | 61 |
63 DBusThreadManager::DBusThreadManager(scoped_ptr<DBusClientBundle> client_bundle) | 62 DBusThreadManager::DBusThreadManager(scoped_ptr<DBusClientBundle> client_bundle) |
64 : client_bundle_(client_bundle.Pass()) { | 63 : client_bundle_(client_bundle.Pass()) { |
65 device_event_log::Initialize(0 /* default max entries */); | |
66 dbus::statistics::Initialize(); | 64 dbus::statistics::Initialize(); |
67 | 65 |
68 if (client_bundle_->IsUsingAnyRealClient()) { | 66 if (client_bundle_->IsUsingAnyRealClient()) { |
69 // At least one real DBusClient is used. | 67 // At least one real DBusClient is used. |
70 // Create the D-Bus thread. | 68 // Create the D-Bus thread. |
71 base::Thread::Options thread_options; | 69 base::Thread::Options thread_options; |
72 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 70 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
73 dbus_thread_.reset(new base::Thread("D-Bus thread")); | 71 dbus_thread_.reset(new base::Thread("D-Bus thread")); |
74 dbus_thread_->StartWithOptions(thread_options); | 72 dbus_thread_->StartWithOptions(thread_options); |
75 | 73 |
(...skipping 13 matching lines...) Expand all Loading... |
89 // 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 |
90 // the bus synchronously. | 88 // the bus synchronously. |
91 if (system_bus_.get()) | 89 if (system_bus_.get()) |
92 system_bus_->ShutdownOnDBusThreadAndBlock(); | 90 system_bus_->ShutdownOnDBusThreadAndBlock(); |
93 | 91 |
94 // Stop the D-Bus thread. | 92 // Stop the D-Bus thread. |
95 if (dbus_thread_) | 93 if (dbus_thread_) |
96 dbus_thread_->Stop(); | 94 dbus_thread_->Stop(); |
97 | 95 |
98 dbus::statistics::Shutdown(); | 96 dbus::statistics::Shutdown(); |
99 device_event_log::Shutdown(); | |
100 | 97 |
101 if (!g_dbus_thread_manager) | 98 if (!g_dbus_thread_manager) |
102 return; // Called form Shutdown() or local test instance. | 99 return; // Called form Shutdown() or local test instance. |
103 | 100 |
104 // There should never be both a global instance and a local instance. | 101 // There should never be both a global instance and a local instance. |
105 CHECK(this == g_dbus_thread_manager); | 102 CHECK(this == g_dbus_thread_manager); |
106 if (g_using_dbus_thread_manager_for_testing) { | 103 if (g_using_dbus_thread_manager_for_testing) { |
107 g_dbus_thread_manager = NULL; | 104 g_dbus_thread_manager = NULL; |
108 g_using_dbus_thread_manager_for_testing = false; | 105 g_using_dbus_thread_manager_for_testing = false; |
109 VLOG(1) << "DBusThreadManager destroyed"; | 106 VLOG(1) << "DBusThreadManager destroyed"; |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 client.Pass(); | 671 client.Pass(); |
675 } | 672 } |
676 | 673 |
677 void DBusThreadManagerSetter::SetUpdateEngineClient( | 674 void DBusThreadManagerSetter::SetUpdateEngineClient( |
678 scoped_ptr<UpdateEngineClient> client) { | 675 scoped_ptr<UpdateEngineClient> client) { |
679 DBusThreadManager::Get()->client_bundle_->update_engine_client_ = | 676 DBusThreadManager::Get()->client_bundle_->update_engine_client_ = |
680 client.Pass(); | 677 client.Pass(); |
681 } | 678 } |
682 | 679 |
683 } // namespace chromeos | 680 } // namespace chromeos |
OLD | NEW |