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 CHROME_BROWSER_CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 5 #ifndef CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 6 #define CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/ref_counted.h" | 11 #include "chromeos/chromeos_export.h" |
11 | 12 |
12 namespace base { | 13 namespace base { |
13 class Thread; | 14 class Thread; |
14 }; | 15 }; |
15 | 16 |
16 namespace dbus { | 17 namespace dbus { |
17 class Bus; | 18 class Bus; |
18 }; | 19 }; |
19 | 20 |
20 namespace chromeos { | 21 namespace chromeos { |
(...skipping 29 matching lines...) Expand all Loading... |
50 // | 51 // |
51 // D-Bus clients managed by DBusThreadManager are guaranteed to be deleted | 52 // D-Bus clients managed by DBusThreadManager are guaranteed to be deleted |
52 // after the D-Bus thread so the clients don't need to worry if new | 53 // after the D-Bus thread so the clients don't need to worry if new |
53 // incoming messages arrive from the D-Bus thread during shutdown of the | 54 // incoming messages arrive from the D-Bus thread during shutdown of the |
54 // clients. The UI message loop is not running during the shutdown hence | 55 // clients. The UI message loop is not running during the shutdown hence |
55 // the UI message loop won't post tasks to D-BUS clients during the | 56 // the UI message loop won't post tasks to D-BUS clients during the |
56 // shutdown. However, to be extra cautious, clients should use | 57 // shutdown. However, to be extra cautious, clients should use |
57 // WeakPtrFactory when creating callbacks that run on UI thread. See | 58 // WeakPtrFactory when creating callbacks that run on UI thread. See |
58 // session_manager_client.cc for examples. | 59 // session_manager_client.cc for examples. |
59 // | 60 // |
60 class DBusThreadManager { | 61 class CHROMEOS_EXPORT DBusThreadManager { |
61 public: | 62 public: |
62 // Sets the global instance. Must be called before any calls to Get(). | 63 // Sets the global instance. Must be called before any calls to Get(). |
63 // We explicitly initialize and shut down the global object, rather than | 64 // We explicitly initialize and shut down the global object, rather than |
64 // making it a Singleton, to ensure clean startup and shutdown. | 65 // making it a Singleton, to ensure clean startup and shutdown. |
65 static void Initialize(); | 66 static void Initialize(); |
66 | 67 |
67 // Similar to Initialize(), but can inject an alternative | 68 // Similar to Initialize(), but can inject an alternative |
68 // DBusThreadManager such as MockDBusThreadManager for testing. | 69 // DBusThreadManager such as MockDBusThreadManager for testing. |
69 // The injected object will be owned by the internal pointer and deleted | 70 // The injected object will be owned by the internal pointer and deleted |
70 // by Shutdown(). | 71 // by Shutdown(). |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 virtual ~DBusThreadManager(); | 171 virtual ~DBusThreadManager(); |
171 | 172 |
172 protected: | 173 protected: |
173 DBusThreadManager(); | 174 DBusThreadManager(); |
174 | 175 |
175 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); | 176 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); |
176 }; | 177 }; |
177 | 178 |
178 } // namespace chromeos | 179 } // namespace chromeos |
179 | 180 |
180 #endif // CHROME_BROWSER_CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 181 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
OLD | NEW |