| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 5 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" | 9 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" |
| 10 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 10 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 11 #include "chrome/browser/chromeos/dbus/sensors_source.h" | 11 #include "chrome/browser/chromeos/dbus/sensors_source.h" |
| 12 #include "chrome/browser/chromeos/dbus/speech_synthesizer_client.h" |
| 12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 13 #include "dbus/bus.h" | 14 #include "dbus/bus.h" |
| 14 | 15 |
| 15 namespace chromeos { | 16 namespace chromeos { |
| 16 | 17 |
| 17 static DBusThreadManager* g_dbus_thread_manager = NULL; | 18 static DBusThreadManager* g_dbus_thread_manager = NULL; |
| 18 | 19 |
| 19 DBusThreadManager::DBusThreadManager() { | 20 DBusThreadManager::DBusThreadManager() { |
| 20 // Create the D-Bus thread. | 21 // Create the D-Bus thread. |
| 21 base::Thread::Options thread_options; | 22 base::Thread::Options thread_options; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 // Start monitoring sensors if needed. | 39 // Start monitoring sensors if needed. |
| 39 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 40 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 40 if (command_line.HasSwitch(switches::kEnableSensors)) { | 41 if (command_line.HasSwitch(switches::kEnableSensors)) { |
| 41 sensors_source_.reset(new SensorsSource); | 42 sensors_source_.reset(new SensorsSource); |
| 42 sensors_source_->Init(system_bus_.get()); | 43 sensors_source_->Init(system_bus_.get()); |
| 43 } | 44 } |
| 44 | 45 |
| 45 // Create the power manager client. | 46 // Create the power manager client. |
| 46 power_manager_client_.reset(PowerManagerClient::Create(system_bus_.get())); | 47 power_manager_client_.reset(PowerManagerClient::Create(system_bus_.get())); |
| 48 |
| 49 // Create the speech synthesizer client. |
| 50 speech_synthesizer_client_.reset( |
| 51 SpeechSynthesizerClient::Create(system_bus_.get())); |
| 47 } | 52 } |
| 48 | 53 |
| 49 DBusThreadManager::~DBusThreadManager() { | 54 DBusThreadManager::~DBusThreadManager() { |
| 50 // Shut down the bus. During the browser shutdown, it's ok to shut down | 55 // Shut down the bus. During the browser shutdown, it's ok to shut down |
| 51 // the bus synchronously. | 56 // the bus synchronously. |
| 52 system_bus_->ShutdownOnDBusThreadAndBlock(); | 57 system_bus_->ShutdownOnDBusThreadAndBlock(); |
| 53 | 58 |
| 54 // Stop the D-Bus thread. | 59 // Stop the D-Bus thread. |
| 55 dbus_thread_->Stop(); | 60 dbus_thread_->Stop(); |
| 56 | 61 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 76 VLOG(1) << "DBusThreadManager Shutdown completed"; | 81 VLOG(1) << "DBusThreadManager Shutdown completed"; |
| 77 } | 82 } |
| 78 | 83 |
| 79 DBusThreadManager* DBusThreadManager::Get() { | 84 DBusThreadManager* DBusThreadManager::Get() { |
| 80 CHECK(g_dbus_thread_manager) | 85 CHECK(g_dbus_thread_manager) |
| 81 << "DBusThreadManager::Get() called before Initialize()"; | 86 << "DBusThreadManager::Get() called before Initialize()"; |
| 82 return g_dbus_thread_manager; | 87 return g_dbus_thread_manager; |
| 83 } | 88 } |
| 84 | 89 |
| 85 } // namespace chromeos | 90 } // namespace chromeos |
| OLD | NEW |