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 @@
#include "components/metrics/metrics_service.h"
#include "content/public/browser/browser_task_traits.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 "ui/base/l10n/l10n_util.h"
......@@ -98,7 +98,7 @@ void ChromeBrowserMainPartsLinux::PostProfileInit() {
void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() {
#if !defined(OS_CHROMEOS)
bluez::DBusThreadManagerLinux::Initialize();
bluez::BluezDBusThreadManager::Initialize();
bluez::BluezDBusManager::Initialize();
#endif
......@@ -108,7 +108,7 @@ void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() {
void ChromeBrowserMainPartsLinux::PostDestroyThreads() {
#if !defined(OS_CHROMEOS)
bluez::BluezDBusManager::Shutdown();
bluez::DBusThreadManagerLinux::Shutdown();
bluez::BluezDBusThreadManager::Shutdown();
#endif
ChromeBrowserMainPartsPosix::PostDestroyThreads();
......
......@@ -415,10 +415,10 @@ component("bluetooth") {
]
if (is_linux) {
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.h",
"dbus/dbus_thread_manager_linux.cc",
"dbus/dbus_thread_manager_linux.h",
]
}
if (is_chromeos) {
......
......@@ -31,12 +31,11 @@
#include "device/bluetooth/dbus/bluetooth_media_client.h"
#include "device/bluetooth/dbus/bluetooth_media_transport_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"
#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
#elif defined(OS_LINUX)
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h"
#endif
namespace bluez {
......@@ -242,7 +241,7 @@ void BluezDBusManager::Initialize() {
CreateGlobalInstance(chromeos::DBusThreadManager::Get()->GetSystemBus(),
chromeos::DBusThreadManager::Get()->IsUsingFakes());
#elif defined(OS_LINUX)
CreateGlobalInstance(bluez::DBusThreadManagerLinux::Get()->GetSystemBus(),
CreateGlobalInstance(BluezDBusThreadManager::Get()->GetSystemBus(),
false /* use_dbus_stubs */);
#endif
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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/threading/thread.h"
......@@ -10,12 +10,12 @@
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;
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);
// Create the connection to the system bus.
......@@ -26,7 +26,7 @@ DBusThreadManagerLinux::DBusThreadManagerLinux() {
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
// the bus synchronously.
if (system_bus_.get())
......@@ -36,38 +36,38 @@ DBusThreadManagerLinux::~DBusThreadManagerLinux() {
if (dbus_thread_)
dbus_thread_->Stop();
if (!g_linux_dbus_manager)
if (!g_bluez_dbus_thread_manager)
return; // Called form Shutdown() or local test 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();
}
// static
void DBusThreadManagerLinux::Initialize() {
CHECK(!g_linux_dbus_manager);
g_linux_dbus_manager = new DBusThreadManagerLinux();
void BluezDBusThreadManager::Initialize() {
CHECK(!g_bluez_dbus_thread_manager);
g_bluez_dbus_thread_manager = new BluezDBusThreadManager();
}
// static
void DBusThreadManagerLinux::Shutdown() {
// Ensure that we only shutdown LinuxDBusManager once.
CHECK(g_linux_dbus_manager);
DBusThreadManagerLinux* dbus_thread_manager = g_linux_dbus_manager;
g_linux_dbus_manager = NULL;
void BluezDBusThreadManager::Shutdown() {
// Ensure that we only shutdown BluezDBusThreadManager once.
CHECK(g_bluez_dbus_thread_manager);
BluezDBusThreadManager* dbus_thread_manager = g_bluez_dbus_thread_manager;
g_bluez_dbus_thread_manager = NULL;
delete dbus_thread_manager;
VLOG(1) << "LinuxDBusManager Shutdown completed";
VLOG(1) << "BluezDBusThreadManager Shutdown completed";
}
// static
DBusThreadManagerLinux* DBusThreadManagerLinux::Get() {
CHECK(g_linux_dbus_manager)
<< "LinuxDBusManager::Get() called before Initialize()";
return g_linux_dbus_manager;
BluezDBusThreadManager* BluezDBusThreadManager::Get() {
CHECK(g_bluez_dbus_thread_manager)
<< "BluezDBusThreadManager::Get() called before Initialize()";
return g_bluez_dbus_thread_manager;
}
} // namespace bluez
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_BLUETOOTH_DBUS_DBUS_THREAD_MANAGER_LINUX_H_
#define DEVICE_BLUETOOTH_DBUS_DBUS_THREAD_MANAGER_LINUX_H_
#ifndef DEVICE_BLUETOOTH_DBUS_BLUEZ_DBUS_THREAD_MANAGER_H_
#define DEVICE_BLUETOOTH_DBUS_BLUEZ_DBUS_THREAD_MANAGER_H_
#include <memory>
......@@ -22,9 +22,9 @@ class Bus;
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.
class DEVICE_BLUETOOTH_EXPORT DBusThreadManagerLinux {
class DEVICE_BLUETOOTH_EXPORT BluezDBusThreadManager {
public:
// Sets the global instance. Must be called before any calls to Get().
// We explicitly initialize and shut down the global object, rather than
......@@ -35,25 +35,19 @@ class DEVICE_BLUETOOTH_EXPORT DBusThreadManagerLinux {
static void Shutdown();
// 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();
private:
explicit DBusThreadManagerLinux();
~DBusThreadManagerLinux();
// 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();
explicit BluezDBusThreadManager();
~BluezDBusThreadManager();
std::unique_ptr<base::Thread> dbus_thread_;
scoped_refptr<dbus::Bus> system_bus_;
DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerLinux);
DISALLOW_COPY_AND_ASSIGN(BluezDBusThreadManager);
};
} // namespace bluez
......
......@@ -5,20 +5,20 @@
#include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.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 {
// static
void DBusBluezManagerWrapperLinux::Initialize() {
DBusThreadManagerLinux::Initialize();
BluezDBusThreadManager::Initialize();
BluezDBusManager::Initialize();
}
// static
void DBusBluezManagerWrapperLinux::Shutdown() {
bluez::BluezDBusManager::Shutdown();
bluez::DBusThreadManagerLinux::Shutdown();
bluez::BluezDBusThreadManager::Shutdown();
}
} // namespace bluez
......@@ -10,7 +10,7 @@
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
// implementations.
class DEVICE_BLUETOOTH_EXPORT DBusBluezManagerWrapperLinux {
......
......@@ -65,7 +65,7 @@
#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
#elif defined(OS_LINUX)
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h"
#include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
#endif
#if BUILDFLAG(ENABLE_NACL)
......@@ -141,7 +141,7 @@ void ShellBrowserMainParts::PostMainMessageLoopStart() {
// TODO(michaelpg): Verify this works for target environments.
ui::InitializeInputMethodForTesting();
bluez::DBusThreadManagerLinux::Initialize();
bluez::BluezDBusThreadManager::Initialize();
bluez::BluezDBusManager::Initialize();
#else
ui::InitializeInputMethodForTesting();
......@@ -311,7 +311,7 @@ void ShellBrowserMainParts::PostDestroyThreads() {
#elif defined(OS_LINUX)
device::BluetoothAdapterFactory::Shutdown();
bluez::BluezDBusManager::Shutdown();
bluez::DBusThreadManagerLinux::Shutdown();
bluez::BluezDBusThreadManager::Shutdown();
#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