Commit 3e60c042 authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Commit Bot

bluetooth: Rename DBusThreadManagerLinux to BluezDBusThreadManager

DBusThreadManagerLinux will be used on Chrome OS to create an
alternate set of DBus clients. Renames the file in preparation of this.

TBR=avi@chromium.org, michaelpg@chromium.org

Bug: 882771
Change-Id: I953fb4bfcc0b3faf0b68fba5f0c18b248f6072f6
Reviewed-on: https://chromium-review.googlesource.com/1238097
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarSonny Sasaka <sonnysasaka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593762}
parent 93cf6f91
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "components/metrics/metrics_service.h" #include "components/metrics/metrics_service.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h" #include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
#include "media/audio/audio_manager.h" #include "media/audio/audio_manager.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -98,7 +98,7 @@ void ChromeBrowserMainPartsLinux::PostProfileInit() { ...@@ -98,7 +98,7 @@ void ChromeBrowserMainPartsLinux::PostProfileInit() {
void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() { void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() {
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
bluez::DBusThreadManagerLinux::Initialize(); bluez::BluezDBusThreadManager::Initialize();
bluez::BluezDBusManager::Initialize(); bluez::BluezDBusManager::Initialize();
#endif #endif
...@@ -108,7 +108,7 @@ void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() { ...@@ -108,7 +108,7 @@ void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() {
void ChromeBrowserMainPartsLinux::PostDestroyThreads() { void ChromeBrowserMainPartsLinux::PostDestroyThreads() {
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
bluez::BluezDBusManager::Shutdown(); bluez::BluezDBusManager::Shutdown();
bluez::DBusThreadManagerLinux::Shutdown(); bluez::BluezDBusThreadManager::Shutdown();
#endif #endif
ChromeBrowserMainPartsPosix::PostDestroyThreads(); ChromeBrowserMainPartsPosix::PostDestroyThreads();
......
...@@ -415,10 +415,10 @@ component("bluetooth") { ...@@ -415,10 +415,10 @@ component("bluetooth") {
] ]
if (is_linux) { if (is_linux) {
sources += [ sources += [
"dbus/bluez_dbus_thread_manager.cc",
"dbus/bluez_dbus_thread_manager.h",
"dbus/dbus_bluez_manager_wrapper_linux.cc", "dbus/dbus_bluez_manager_wrapper_linux.cc",
"dbus/dbus_bluez_manager_wrapper_linux.h", "dbus/dbus_bluez_manager_wrapper_linux.h",
"dbus/dbus_thread_manager_linux.cc",
"dbus/dbus_thread_manager_linux.h",
] ]
} }
if (is_chromeos) { if (is_chromeos) {
......
...@@ -31,12 +31,11 @@ ...@@ -31,12 +31,11 @@
#include "device/bluetooth/dbus/bluetooth_media_client.h" #include "device/bluetooth/dbus/bluetooth_media_client.h"
#include "device/bluetooth/dbus/bluetooth_media_transport_client.h" #include "device/bluetooth/dbus/bluetooth_media_transport_client.h"
#include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h"
#include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
#include "third_party/cros_system_api/dbus/service_constants.h" #include "third_party/cros_system_api/dbus/service_constants.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#elif defined(OS_LINUX)
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h"
#endif #endif
namespace bluez { namespace bluez {
...@@ -242,7 +241,7 @@ void BluezDBusManager::Initialize() { ...@@ -242,7 +241,7 @@ void BluezDBusManager::Initialize() {
CreateGlobalInstance(chromeos::DBusThreadManager::Get()->GetSystemBus(), CreateGlobalInstance(chromeos::DBusThreadManager::Get()->GetSystemBus(),
chromeos::DBusThreadManager::Get()->IsUsingFakes()); chromeos::DBusThreadManager::Get()->IsUsingFakes());
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
CreateGlobalInstance(bluez::DBusThreadManagerLinux::Get()->GetSystemBus(), CreateGlobalInstance(BluezDBusThreadManager::Get()->GetSystemBus(),
false /* use_dbus_stubs */); false /* use_dbus_stubs */);
#endif #endif
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h" #include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
namespace bluez { namespace bluez {
static DBusThreadManagerLinux* g_linux_dbus_manager = NULL; static BluezDBusThreadManager* g_bluez_dbus_thread_manager = NULL;
DBusThreadManagerLinux::DBusThreadManagerLinux() { BluezDBusThreadManager::BluezDBusThreadManager() {
base::Thread::Options thread_options; base::Thread::Options thread_options;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO; thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
dbus_thread_.reset(new base::Thread("D-Bus thread")); dbus_thread_.reset(new base::Thread("Bluez D-Bus thread"));
dbus_thread_->StartWithOptions(thread_options); dbus_thread_->StartWithOptions(thread_options);
// Create the connection to the system bus. // Create the connection to the system bus.
...@@ -26,7 +26,7 @@ DBusThreadManagerLinux::DBusThreadManagerLinux() { ...@@ -26,7 +26,7 @@ DBusThreadManagerLinux::DBusThreadManagerLinux() {
system_bus_ = new dbus::Bus(system_bus_options); system_bus_ = new dbus::Bus(system_bus_options);
} }
DBusThreadManagerLinux::~DBusThreadManagerLinux() { BluezDBusThreadManager::~BluezDBusThreadManager() {
// Shut down the bus. During the browser shutdown, it's ok to shut down // Shut down the bus. During the browser shutdown, it's ok to shut down
// the bus synchronously. // the bus synchronously.
if (system_bus_.get()) if (system_bus_.get())
...@@ -36,38 +36,38 @@ DBusThreadManagerLinux::~DBusThreadManagerLinux() { ...@@ -36,38 +36,38 @@ DBusThreadManagerLinux::~DBusThreadManagerLinux() {
if (dbus_thread_) if (dbus_thread_)
dbus_thread_->Stop(); dbus_thread_->Stop();
if (!g_linux_dbus_manager) if (!g_bluez_dbus_thread_manager)
return; // Called form Shutdown() or local test instance. return; // Called form Shutdown() or local test instance.
// There should never be both a global instance and a local instance. // There should never be both a global instance and a local instance.
CHECK(this == g_linux_dbus_manager); CHECK(this == g_bluez_dbus_thread_manager);
} }
dbus::Bus* DBusThreadManagerLinux::GetSystemBus() { dbus::Bus* BluezDBusThreadManager::GetSystemBus() {
return system_bus_.get(); return system_bus_.get();
} }
// static // static
void DBusThreadManagerLinux::Initialize() { void BluezDBusThreadManager::Initialize() {
CHECK(!g_linux_dbus_manager); CHECK(!g_bluez_dbus_thread_manager);
g_linux_dbus_manager = new DBusThreadManagerLinux(); g_bluez_dbus_thread_manager = new BluezDBusThreadManager();
} }
// static // static
void DBusThreadManagerLinux::Shutdown() { void BluezDBusThreadManager::Shutdown() {
// Ensure that we only shutdown LinuxDBusManager once. // Ensure that we only shutdown BluezDBusThreadManager once.
CHECK(g_linux_dbus_manager); CHECK(g_bluez_dbus_thread_manager);
DBusThreadManagerLinux* dbus_thread_manager = g_linux_dbus_manager; BluezDBusThreadManager* dbus_thread_manager = g_bluez_dbus_thread_manager;
g_linux_dbus_manager = NULL; g_bluez_dbus_thread_manager = NULL;
delete dbus_thread_manager; delete dbus_thread_manager;
VLOG(1) << "LinuxDBusManager Shutdown completed"; VLOG(1) << "BluezDBusThreadManager Shutdown completed";
} }
// static // static
DBusThreadManagerLinux* DBusThreadManagerLinux::Get() { BluezDBusThreadManager* BluezDBusThreadManager::Get() {
CHECK(g_linux_dbus_manager) CHECK(g_bluez_dbus_thread_manager)
<< "LinuxDBusManager::Get() called before Initialize()"; << "BluezDBusThreadManager::Get() called before Initialize()";
return g_linux_dbus_manager; return g_bluez_dbus_thread_manager;
} }
} // namespace bluez } // namespace bluez
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef DEVICE_BLUETOOTH_DBUS_DBUS_THREAD_MANAGER_LINUX_H_ #ifndef DEVICE_BLUETOOTH_DBUS_BLUEZ_DBUS_THREAD_MANAGER_H_
#define DEVICE_BLUETOOTH_DBUS_DBUS_THREAD_MANAGER_LINUX_H_ #define DEVICE_BLUETOOTH_DBUS_BLUEZ_DBUS_THREAD_MANAGER_H_
#include <memory> #include <memory>
...@@ -22,9 +22,9 @@ class Bus; ...@@ -22,9 +22,9 @@ class Bus;
namespace bluez { namespace bluez {
// LinuxDBusManager manages the D-Bus thread, the thread dedicated to // BluezDBusThreadManager manages the D-Bus thread, the thread dedicated to
// handling asynchronous D-Bus operations. // handling asynchronous D-Bus operations.
class DEVICE_BLUETOOTH_EXPORT DBusThreadManagerLinux { class DEVICE_BLUETOOTH_EXPORT BluezDBusThreadManager {
public: public:
// Sets the global instance. Must be called before any calls to Get(). // Sets the global instance. Must be called before any calls to Get().
// We explicitly initialize and shut down the global object, rather than // We explicitly initialize and shut down the global object, rather than
...@@ -35,25 +35,19 @@ class DEVICE_BLUETOOTH_EXPORT DBusThreadManagerLinux { ...@@ -35,25 +35,19 @@ class DEVICE_BLUETOOTH_EXPORT DBusThreadManagerLinux {
static void Shutdown(); static void Shutdown();
// Gets the global instance. Initialize() must be called first. // Gets the global instance. Initialize() must be called first.
static DBusThreadManagerLinux* Get(); static BluezDBusThreadManager* Get();
// Returns various D-Bus bus instances, owned by LinuxDBusManager. // Returns various D-Bus bus instances, owned by BluezDBusThreadManager.
dbus::Bus* GetSystemBus(); dbus::Bus* GetSystemBus();
private: private:
explicit DBusThreadManagerLinux(); explicit BluezDBusThreadManager();
~DBusThreadManagerLinux(); ~BluezDBusThreadManager();
// Creates a global instance of LinuxDBusManager with the real
// implementations for all clients that are listed in |unstub_client_mask| and
// stub implementations for all clients that are not included. Cannot be
// called more than once.
static void CreateGlobalInstance();
std::unique_ptr<base::Thread> dbus_thread_; std::unique_ptr<base::Thread> dbus_thread_;
scoped_refptr<dbus::Bus> system_bus_; scoped_refptr<dbus::Bus> system_bus_;
DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerLinux); DISALLOW_COPY_AND_ASSIGN(BluezDBusThreadManager);
}; };
} // namespace bluez } // namespace bluez
......
...@@ -5,20 +5,20 @@ ...@@ -5,20 +5,20 @@
#include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.h" #include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h" #include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
namespace bluez { namespace bluez {
// static // static
void DBusBluezManagerWrapperLinux::Initialize() { void DBusBluezManagerWrapperLinux::Initialize() {
DBusThreadManagerLinux::Initialize(); BluezDBusThreadManager::Initialize();
BluezDBusManager::Initialize(); BluezDBusManager::Initialize();
} }
// static // static
void DBusBluezManagerWrapperLinux::Shutdown() { void DBusBluezManagerWrapperLinux::Shutdown() {
bluez::BluezDBusManager::Shutdown(); bluez::BluezDBusManager::Shutdown();
bluez::DBusThreadManagerLinux::Shutdown(); bluez::BluezDBusThreadManager::Shutdown();
} }
} // namespace bluez } // namespace bluez
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
namespace bluez { namespace bluez {
// This class abstracts the initialization of DBusThreadManagerLinux and // This class abstracts the initialization of BluezDBusThreadManager and
// BluezDBusManager. Targets that don't use DBus can provide stub // BluezDBusManager. Targets that don't use DBus can provide stub
// implementations. // implementations.
class DEVICE_BLUETOOTH_EXPORT DBusBluezManagerWrapperLinux { class DEVICE_BLUETOOTH_EXPORT DBusBluezManagerWrapperLinux {
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h" #include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
#endif #endif
#if BUILDFLAG(ENABLE_NACL) #if BUILDFLAG(ENABLE_NACL)
...@@ -141,7 +141,7 @@ void ShellBrowserMainParts::PostMainMessageLoopStart() { ...@@ -141,7 +141,7 @@ void ShellBrowserMainParts::PostMainMessageLoopStart() {
// TODO(michaelpg): Verify this works for target environments. // TODO(michaelpg): Verify this works for target environments.
ui::InitializeInputMethodForTesting(); ui::InitializeInputMethodForTesting();
bluez::DBusThreadManagerLinux::Initialize(); bluez::BluezDBusThreadManager::Initialize();
bluez::BluezDBusManager::Initialize(); bluez::BluezDBusManager::Initialize();
#else #else
ui::InitializeInputMethodForTesting(); ui::InitializeInputMethodForTesting();
...@@ -311,7 +311,7 @@ void ShellBrowserMainParts::PostDestroyThreads() { ...@@ -311,7 +311,7 @@ void ShellBrowserMainParts::PostDestroyThreads() {
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
device::BluetoothAdapterFactory::Shutdown(); device::BluetoothAdapterFactory::Shutdown();
bluez::BluezDBusManager::Shutdown(); bluez::BluezDBusManager::Shutdown();
bluez::DBusThreadManagerLinux::Shutdown(); bluez::BluezDBusThreadManager::Shutdown();
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment