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. Tests that call |
88 // The injected object will be owned by the internal pointer and deleted | 88 // DBusThreadManager::Initialize() (such as browser_tests and |
89 // by Shutdown(). | 89 // interactive_ui_tests) should use this instead of calling |
| 90 // |InitiailzeForTesting|. The injected object will be owned by the |
| 91 // internal pointer and deleted by Shutdown(). |
| 92 static void SetInstanceForTesting(DBusThreadManager* dbus_thread_manager); |
| 93 |
| 94 // Similar to Initialize(), but injects an alternative |
| 95 // DBusThreadManager using SetInstanceForTest first. The injected |
| 96 // object will be owned by the internal pointer and deleted by |
| 97 // Shutdown(). |
90 static void InitializeForTesting(DBusThreadManager* dbus_thread_manager); | 98 static void InitializeForTesting(DBusThreadManager* dbus_thread_manager); |
91 | 99 |
92 // Initialize with stub implementations for tests based on stubs. | 100 // Initialize with stub implementations for tests based on stubs. |
93 static void InitializeWithStub(); | 101 static void InitializeWithStub(); |
94 | 102 |
95 // Returns true if DBusThreadManager has been initialized. Call this to | 103 // Returns true if DBusThreadManager has been initialized. Call this to |
96 // avoid initializing + shutting down DBusThreadManager more than once. | 104 // avoid initializing + shutting down DBusThreadManager more than once. |
97 static bool IsInitialized(); | 105 static bool IsInitialized(); |
98 | 106 |
99 // Destroys the global instance. | 107 // Destroys the global instance. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 163 |
156 // Initializes |client| with the |system_bus_|. | 164 // Initializes |client| with the |system_bus_|. |
157 static void InitClient(DBusClient* client); | 165 static void InitClient(DBusClient* client); |
158 | 166 |
159 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); | 167 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); |
160 }; | 168 }; |
161 | 169 |
162 } // namespace chromeos | 170 } // namespace chromeos |
163 | 171 |
164 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 172 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
OLD | NEW |