| OLD | NEW |
| 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 #ifndef CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 5 #ifndef CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
| 6 #define CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 6 #define CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // WeakPtrFactory when creating callbacks that run on UI thread. See | 76 // WeakPtrFactory when creating callbacks that run on UI thread. See |
| 77 // session_manager_client.cc for examples. | 77 // session_manager_client.cc for examples. |
| 78 // | 78 // |
| 79 class CHROMEOS_EXPORT DBusThreadManager { | 79 class CHROMEOS_EXPORT DBusThreadManager { |
| 80 public: | 80 public: |
| 81 // Sets the global instance. Must be called before any calls to Get(). | 81 // Sets the global instance. Must be called before any calls to Get(). |
| 82 // We explicitly initialize and shut down the global object, rather than | 82 // We explicitly initialize and shut down the global object, rather than |
| 83 // making it a Singleton, to ensure clean startup and shutdown. | 83 // making it a Singleton, to ensure clean startup and shutdown. |
| 84 static void Initialize(); | 84 static void Initialize(); |
| 85 | 85 |
| 86 // Similar to Initialize(), but can inject an alternative | 86 // Sets an alternative DBusThreadManager such as MockDBusThreadManager |
| 87 // DBusThreadManager such as MockDBusThreadManager for testing. | 87 // to be used in |Initialize()| for testing. |
| 88 // The injected object will be owned by the internal pointer and deleted | 88 // The injected object will be owned by the internal pointer and deleted |
| 89 // by Shutdown(). | 89 // by Shutdown(). |
| 90 static void SetInstanceForTesting(DBusThreadManager* dbus_thread_manager); |
| 91 |
| 92 // Similar to Initialize(), but injects an alternative |
| 93 // DBusThreadManager using SetInstanceForTest first. |
| 90 static void InitializeForTesting(DBusThreadManager* dbus_thread_manager); | 94 static void InitializeForTesting(DBusThreadManager* dbus_thread_manager); |
| 91 | 95 |
| 92 // Initialize with stub implementations for tests based on stubs. | 96 // Initialize with stub implementations for tests based on stubs. |
| 93 static void InitializeWithStub(); | 97 static void InitializeWithStub(); |
| 94 | 98 |
| 95 // Returns true if DBusThreadManager has been initialized. Call this to | 99 // Returns true if DBusThreadManager has been initialized. Call this to |
| 96 // avoid initializing + shutting down DBusThreadManager more than once. | 100 // avoid initializing + shutting down DBusThreadManager more than once. |
| 97 static bool IsInitialized(); | 101 static bool IsInitialized(); |
| 98 | 102 |
| 99 // Destroys the global instance. | 103 // Destroys the global instance. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 159 |
| 156 // Initializes |client| with the |system_bus_|. | 160 // Initializes |client| with the |system_bus_|. |
| 157 static void InitClient(DBusClient* client); | 161 static void InitClient(DBusClient* client); |
| 158 | 162 |
| 159 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); | 163 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); |
| 160 }; | 164 }; |
| 161 | 165 |
| 162 } // namespace chromeos | 166 } // namespace chromeos |
| 163 | 167 |
| 164 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 168 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
| OLD | NEW |