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

Side by Side Diff: chromeos/dbus/dbus_thread_manager.cc

Issue 14200028: Make CrosSettings and DeviceSettingsService non Lazy instances (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/testing_browser_process.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 7 #include <map>
8 8
9 #include "base/chromeos/chromeos_version.h" 9 #include "base/chromeos/chromeos_version.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // static 514 // static
515 bool DBusThreadManager::IsInitialized() { 515 bool DBusThreadManager::IsInitialized() {
516 return g_dbus_thread_manager != NULL; 516 return g_dbus_thread_manager != NULL;
517 } 517 }
518 518
519 // static 519 // static
520 void DBusThreadManager::Shutdown() { 520 void DBusThreadManager::Shutdown() {
521 // If we called InitializeForTesting, this may get called more than once. 521 // If we called InitializeForTesting, this may get called more than once.
522 // Ensure that we only shutdown DBusThreadManager once. 522 // Ensure that we only shutdown DBusThreadManager once.
523 CHECK(g_dbus_thread_manager || g_dbus_thread_manager_set_for_testing); 523 CHECK(g_dbus_thread_manager || g_dbus_thread_manager_set_for_testing);
524 delete g_dbus_thread_manager; 524 DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager;
525 g_dbus_thread_manager = NULL; 525 g_dbus_thread_manager = NULL;
526 delete dbus_thread_manager;
526 VLOG(1) << "DBusThreadManager Shutdown completed"; 527 VLOG(1) << "DBusThreadManager Shutdown completed";
527 } 528 }
528 529
529 DBusThreadManager::DBusThreadManager() { 530 DBusThreadManager::DBusThreadManager() {
530 dbus::statistics::Initialize(); 531 dbus::statistics::Initialize();
531 } 532 }
532 533
533 DBusThreadManager::~DBusThreadManager() { 534 DBusThreadManager::~DBusThreadManager() {
534 dbus::statistics::Shutdown(); 535 dbus::statistics::Shutdown();
536 if (g_dbus_thread_manager == NULL)
537 return; // Called form Shutdown() or local test instance.
538 // There should never be both a global instance and a local instance.
539 CHECK(this == g_dbus_thread_manager);
540 if (g_dbus_thread_manager_set_for_testing) {
541 g_dbus_thread_manager = NULL;
542 g_dbus_thread_manager_set_for_testing = false;
543 VLOG(1) << "DBusThreadManager destroyed";
544 } else {
545 LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()";
546 }
535 } 547 }
536 548
537 // static 549 // static
538 DBusThreadManager* DBusThreadManager::Get() { 550 DBusThreadManager* DBusThreadManager::Get() {
539 CHECK(g_dbus_thread_manager) 551 CHECK(g_dbus_thread_manager)
540 << "DBusThreadManager::Get() called before Initialize()"; 552 << "DBusThreadManager::Get() called before Initialize()";
541 return g_dbus_thread_manager; 553 return g_dbus_thread_manager;
542 } 554 }
543 555
544 } // namespace chromeos 556 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/test/base/testing_browser_process.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698