Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: chromeos/dbus/dbus_thread_manager.cc

Issue 2472203003: Prevent double DBusThreadManager initialization. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/dbus_thread_manager.cc
diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc
index 1a9e7c642b6bfc59637b1de4c3bb0d1900e72579..5b78eef4d98f2f4356f0cf145b878cfc2f121ef1 100644
--- a/chromeos/dbus/dbus_thread_manager.cc
+++ b/chromeos/dbus/dbus_thread_manager.cc
@@ -41,7 +41,7 @@
namespace chromeos {
-static DBusThreadManager* g_dbus_thread_manager = NULL;
+static DBusThreadManager* g_dbus_thread_manager = nullptr;
static bool g_using_dbus_thread_manager_for_testing = false;
DBusThreadManager::DBusThreadManager(ProcessMask process_mask,
@@ -90,9 +90,9 @@ DBusThreadManager::~DBusThreadManager() {
return; // Called form Shutdown() or local test instance.
// There should never be both a global instance and a local instance.
- CHECK(this == g_dbus_thread_manager);
+ CHECK_EQ(this, g_dbus_thread_manager);
if (g_using_dbus_thread_manager_for_testing) {
- g_dbus_thread_manager = NULL;
+ g_dbus_thread_manager = nullptr;
g_using_dbus_thread_manager_for_testing = false;
VLOG(1) << "DBusThreadManager destroyed";
} else {
@@ -242,6 +242,7 @@ std::unique_ptr<DBusThreadManagerSetter>
DBusThreadManager::GetSetterForTesting() {
if (!g_using_dbus_thread_manager_for_testing) {
g_using_dbus_thread_manager_for_testing = true;
+ CHECK(!g_dbus_thread_manager);
// TODO(jamescook): Don't initialize clients as a side-effect of using a
// test API. For now, assume the caller wants all clients.
g_dbus_thread_manager =
@@ -254,7 +255,7 @@ DBusThreadManager::GetSetterForTesting() {
// static
bool DBusThreadManager::IsInitialized() {
- return g_dbus_thread_manager != NULL;
+ return !!g_dbus_thread_manager;
}
// static
@@ -262,7 +263,7 @@ void DBusThreadManager::Shutdown() {
// Ensure that we only shutdown DBusThreadManager once.
CHECK(g_dbus_thread_manager);
DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager;
- g_dbus_thread_manager = NULL;
+ g_dbus_thread_manager = nullptr;
g_using_dbus_thread_manager_for_testing = false;
delete dbus_thread_manager;
VLOG(1) << "DBusThreadManager Shutdown completed";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698