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

Side by Side Diff: chrome/browser/chromeos/dbus/dbus_thread_manager.h

Issue 9838085: Move files inside chrome/browser/chromeos/dbus to chromeos/dbus (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: _ Created 8 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_
7 #pragma once
8
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/ref_counted.h"
11
12 namespace base {
13 class Thread;
14 };
15
16 namespace dbus {
17 class Bus;
18 };
19
20 namespace chromeos {
21
22 // Style Note: Clients are sorted by names.
23 class BluetoothAdapterClient;
24 class BluetoothDeviceClient;
25 class BluetoothInputClient;
26 class BluetoothManagerClient;
27 class BluetoothNodeClient;
28 class CashewClient;
29 class CrosDisksClient;
30 class CryptohomeClient;
31 class ImageBurnerClient;
32 class IntrospectableClient;
33 class PowerManagerClient;
34 class SessionManagerClient;
35 class SpeechSynthesizerClient;
36 class UpdateEngineClient;
37
38 // DBusThreadManager manages the D-Bus thread, the thread dedicated to
39 // handling asynchronous D-Bus operations.
40 //
41 // This class also manages D-Bus connections and D-Bus clients, which
42 // depend on the D-Bus thread to ensure the right order of shutdowns for
43 // the D-Bus thread, the D-Bus connections, and the D-Bus clients.
44 //
45 // CALLBACKS IN D-BUS CLIENTS:
46 //
47 // D-Bus clients managed by DBusThreadManager are guaranteed to be deleted
48 // after the D-Bus thread so the clients don't need to worry if new
49 // incoming messages arrive from the D-Bus thread during shutdown of the
50 // clients. The UI message loop is not running during the shutdown hence
51 // the UI message loop won't post tasks to D-BUS clients during the
52 // shutdown. However, to be extra cautious, clients should use
53 // WeakPtrFactory when creating callbacks that run on UI thread. See
54 // session_manager_client.cc for examples.
55 //
56 class DBusThreadManager {
57 public:
58 // Sets the global instance. Must be called before any calls to Get().
59 // We explicitly initialize and shut down the global object, rather than
60 // making it a Singleton, to ensure clean startup and shutdown.
61 static void Initialize();
62
63 // Similar to Initialize(), but can inject an alternative
64 // DBusThreadManager such as MockDBusThreadManager for testing.
65 // The injected object will be owned by the internal pointer and deleted
66 // by Shutdown().
67 static void InitializeForTesting(DBusThreadManager* dbus_thread_manager);
68
69 // Destroys the global instance.
70 static void Shutdown();
71
72 // Gets the global instance. Initialize() must be called first.
73 static DBusThreadManager* Get();
74
75 // Returns the D-Bus system bus instance, owned by DBusThreadManager.
76 virtual dbus::Bus* GetSystemBus() = 0;
77
78 // Returns the bluetooth adapter client, owned by DBusThreadManager.
79 // Do not cache this pointer and use it after DBusThreadManager is shut
80 // down.
81 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() = 0;
82
83 // Returns the bluetooth device client, owned by DBusThreadManager.
84 // Do not cache this pointer and use it after DBusThreadManager is shut
85 // down.
86 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() = 0;
87
88 // Returns the bluetooth input client, owned by DBusThreadManager.
89 // Do not cache this pointer and use it after DBusThreadManager is shut
90 // down.
91 virtual BluetoothInputClient* GetBluetoothInputClient() = 0;
92
93 // Returns the bluetooth manager client, owned by DBusThreadManager.
94 // Do not cache this pointer and use it after DBusThreadManager is shut
95 // down.
96 virtual BluetoothManagerClient* GetBluetoothManagerClient() = 0;
97
98 // Returns the bluetooth node client, owned by DBusThreadManager.
99 // Do not cache this pointer and use it after DBusThreadManager is shut
100 // down.
101 virtual BluetoothNodeClient* GetBluetoothNodeClient() = 0;
102
103 // Returns the Cashew client, owned by DBusThreadManager.
104 // Do not cache this pointer and use it after DBusThreadManager is shut
105 // down.
106 virtual CashewClient* GetCashewClient() = 0;
107
108 // Returns the cros-disks client, owned by DBusThreadManager.
109 // Do not cache this pointer and use it after DBusThreadManager is shut
110 // down.
111 virtual CrosDisksClient* GetCrosDisksClient() = 0;
112
113 // Returns the Cryptohome client, owned by DBusThreadManager.
114 // Do not cache this pointer and use it after DBusThreadManager is shut
115 // down.
116 virtual CryptohomeClient* GetCryptohomeClient() = 0;
117
118 // Returns the image burner client, owned by DBusThreadManager.
119 // Do not cache this pointer and use it after DBusThreadManger is shut
120 // down.
121 virtual ImageBurnerClient* GetImageBurnerClient() = 0;
122
123 // Returns the introspectable object client, owned by DBusThreadManager.
124 // Do not cache this pointer and use it after DBusThreadManger is shut
125 // down.
126 virtual IntrospectableClient* GetIntrospectableClient() = 0;
127
128 // Returns the power manager client, owned by DBusThreadManager.
129 // See also comments at session_manager_client().
130 virtual PowerManagerClient* GetPowerManagerClient() = 0;
131
132 // Returns the session manager client, owned by DBusThreadManager.
133 // Do not cache this pointer and use it after DBusThreadManager is shut
134 // down.
135 virtual SessionManagerClient* GetSessionManagerClient() = 0;
136
137 // Returns the speech synthesizer client, owned by DBusThreadManager.
138 // Do not cache this pointer and use it after DBusThreadManager is shut
139 // down.
140 virtual SpeechSynthesizerClient* GetSpeechSynthesizerClient() = 0;
141
142 // Returns the update engine client, owned by DBusThreadManager. Do not
143 // cache this pointer and use it after DBusThreadManager is shut down.
144 virtual UpdateEngineClient* GetUpdateEngineClient() = 0;
145
146 virtual ~DBusThreadManager();
147
148 protected:
149 DBusThreadManager();
150
151 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager);
152 };
153
154 } // namespace chromeos
155
156 #endif // CHROME_BROWSER_CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698