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 28 matching lines...) Expand all Loading... |
49 // | 50 // |
50 // D-Bus clients managed by DBusThreadManager are guaranteed to be deleted | 51 // D-Bus clients managed by DBusThreadManager are guaranteed to be deleted |
51 // after the D-Bus thread so the clients don't need to worry if new | 52 // after the D-Bus thread so the clients don't need to worry if new |
52 // incoming messages arrive from the D-Bus thread during shutdown of the | 53 // incoming messages arrive from the D-Bus thread during shutdown of the |
53 // clients. The UI message loop is not running during the shutdown hence | 54 // clients. The UI message loop is not running during the shutdown hence |
54 // the UI message loop won't post tasks to D-BUS clients during the | 55 // the UI message loop won't post tasks to D-BUS clients during the |
55 // shutdown. However, to be extra cautious, clients should use | 56 // shutdown. However, to be extra cautious, clients should use |
56 // WeakPtrFactory when creating callbacks that run on UI thread. See | 57 // WeakPtrFactory when creating callbacks that run on UI thread. See |
57 // session_manager_client.cc for examples. | 58 // session_manager_client.cc for examples. |
58 // | 59 // |
59 class DBusThreadManager { | 60 class CHROMEOS_EXPORT DBusThreadManager { |
60 public: | 61 public: |
61 // Sets the global instance. Must be called before any calls to Get(). | 62 // Sets the global instance. Must be called before any calls to Get(). |
62 // We explicitly initialize and shut down the global object, rather than | 63 // We explicitly initialize and shut down the global object, rather than |
63 // making it a Singleton, to ensure clean startup and shutdown. | 64 // making it a Singleton, to ensure clean startup and shutdown. |
64 static void Initialize(); | 65 static void Initialize(); |
65 | 66 |
66 // Similar to Initialize(), but can inject an alternative | 67 // Similar to Initialize(), but can inject an alternative |
67 // DBusThreadManager such as MockDBusThreadManager for testing. | 68 // DBusThreadManager such as MockDBusThreadManager for testing. |
68 // The injected object will be owned by the internal pointer and deleted | 69 // The injected object will be owned by the internal pointer and deleted |
69 // by Shutdown(). | 70 // by Shutdown(). |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 virtual ~DBusThreadManager(); | 165 virtual ~DBusThreadManager(); |
165 | 166 |
166 protected: | 167 protected: |
167 DBusThreadManager(); | 168 DBusThreadManager(); |
168 | 169 |
169 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); | 170 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); |
170 }; | 171 }; |
171 | 172 |
172 } // namespace chromeos | 173 } // namespace chromeos |
173 | 174 |
174 #endif // CHROME_BROWSER_CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ | 175 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ |
OLD | NEW |