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

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

Issue 2319783002: mash: Allow a subset of D-Bus clients to be created in DBusThreadManager (Closed)
Patch Set: WIP, add DBusThreadManagerAsh and DBusThreadManagerChrome Created 4 years, 3 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
« no previous file with comments | « chromeos/dbus/dbus_client_implementation_type.h ('k') | chromeos/dbus/dbus_thread_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // the UI message loop won't post tasks to D-BUS clients during the 66 // the UI message loop won't post tasks to D-BUS clients during the
67 // shutdown. However, to be extra cautious, clients should use 67 // shutdown. However, to be extra cautious, clients should use
68 // WeakPtrFactory when creating callbacks that run on UI thread. See 68 // WeakPtrFactory when creating callbacks that run on UI thread. See
69 // session_manager_client.cc for examples. 69 // session_manager_client.cc for examples.
70 // 70 //
71 class CHROMEOS_EXPORT DBusThreadManager { 71 class CHROMEOS_EXPORT DBusThreadManager {
72 public: 72 public:
73 // Sets the global instance. Must be called before any calls to Get(). 73 // Sets the global instance. Must be called before any calls to Get().
74 // We explicitly initialize and shut down the global object, rather than 74 // We explicitly initialize and shut down the global object, rather than
75 // making it a Singleton, to ensure clean startup and shutdown. 75 // making it a Singleton, to ensure clean startup and shutdown.
76 // This will initialize real or stub DBusClients depending on command-line 76 // This will initialize real or fake DBusClients depending on command-line
77 // arguments and whether this process runs in a ChromeOS environment. 77 // arguments and whether this process runs in a ChromeOS environment.
78 static void Initialize(); 78 static void Initialize();
79 79
80 // As above, but initializes a subset of the clients.
81 static void Initialize(DBusClientTypeMask clients);
82
80 // Returns a DBusThreadManagerSetter instance that allows tests to 83 // Returns a DBusThreadManagerSetter instance that allows tests to
81 // replace individual D-Bus clients with their own implementations. 84 // replace individual D-Bus clients with their own implementations.
82 // Also initializes the main DBusThreadManager for testing if necessary. 85 // Also initializes the main DBusThreadManager for testing if necessary.
83 static std::unique_ptr<DBusThreadManagerSetter> GetSetterForTesting(); 86 static std::unique_ptr<DBusThreadManagerSetter> GetSetterForTesting();
84 87
85 // Returns true if DBusThreadManager has been initialized. Call this to 88 // Returns true if DBusThreadManager has been initialized. Call this to
86 // avoid initializing + shutting down DBusThreadManager more than once. 89 // avoid initializing + shutting down DBusThreadManager more than once.
87 static bool IsInitialized(); 90 static bool IsInitialized();
88 91
89 // Destroys the global instance. 92 // Destroys the global instance.
90 static void Shutdown(); 93 static void Shutdown();
91 94
92 // Gets the global instance. Initialize() must be called first. 95 // Gets the global instance. Initialize() must be called first.
93 static DBusThreadManager* Get(); 96 static DBusThreadManager* Get();
94 97
95 // Returns true if |client| is stubbed. 98 // Returns true if |client| is faked.
96 bool IsUsingStub(DBusClientBundle::DBusClientType client); 99 bool IsUsingFake(DBusClientBundle::DBusClientType client);
97 100
98 // Returns various D-Bus bus instances, owned by DBusThreadManager. 101 // Returns various D-Bus bus instances, owned by DBusThreadManager.
99 dbus::Bus* GetSystemBus(); 102 dbus::Bus* GetSystemBus();
100 103
101 // All returned objects are owned by DBusThreadManager. Do not use these 104 // All returned objects are owned by DBusThreadManager. Do not use these
102 // pointers after DBusThreadManager has been shut down. 105 // pointers after DBusThreadManager has been shut down.
103 ArcObbMounterClient* GetArcObbMounterClient(); 106 ArcObbMounterClient* GetArcObbMounterClient();
104 CrasAudioClient* GetCrasAudioClient(); 107 CrasAudioClient* GetCrasAudioClient();
105 CrosDisksClient* GetCrosDisksClient(); 108 CrosDisksClient* GetCrosDisksClient();
106 CryptohomeClient* GetCryptohomeClient(); 109 CryptohomeClient* GetCryptohomeClient();
(...skipping 17 matching lines...) Expand all
124 UpdateEngineClient* GetUpdateEngineClient(); 127 UpdateEngineClient* GetUpdateEngineClient();
125 128
126 private: 129 private:
127 friend class DBusThreadManagerSetter; 130 friend class DBusThreadManagerSetter;
128 131
129 // Creates a new DBusThreadManager using the DBusClients set in 132 // Creates a new DBusThreadManager using the DBusClients set in
130 // |client_bundle|. 133 // |client_bundle|.
131 explicit DBusThreadManager(std::unique_ptr<DBusClientBundle> client_bundle); 134 explicit DBusThreadManager(std::unique_ptr<DBusClientBundle> client_bundle);
132 ~DBusThreadManager(); 135 ~DBusThreadManager();
133 136
134 // Creates a global instance of DBusThreadManager with the real 137 // Creates a global instance of DBusThreadManager with real implementations
135 // implementations for all clients that are listed in |unstub_client_mask| and 138 // for all clients in |real_clients| and fake implementations for all clients
136 // stub implementations for all clients that are not included. Cannot be 139 // in |fake_clients|. Cannot be called more than once.
137 // called more than once. 140 static void CreateGlobalInstance(DBusClientTypeMask real_clients,
138 static void CreateGlobalInstance( 141 DBusClientTypeMask fake_clients);
139 DBusClientBundle::DBusClientTypeMask unstub_client_mask);
140 142
141 // Initialize global thread manager instance with all real dbus client 143 // Initializes global thread manager instance with all real dbus clients.
142 // implementations. 144 static void InitializeWithRealClients(DBusClientTypeMask real_clients);
143 static void InitializeWithRealClients();
144 145
145 // Initialize global thread manager instance with stubbed-out dbus clients 146 // Initializes global thread manager instance with all fake dbus clients.
146 // implementation. 147 static void InitializeWithFakeClients(DBusClientTypeMask fake_clients);
147 static void InitializeWithStubs();
148 148
149 // Initialize with stub implementations for only certain clients that are 149 // Initializes the clients in |clients|. Use fake clients except for those in
150 // not included in the comma-separated |unstub_clients| list. 150 // the |force_real_clients_list|, comma-separated like "bluetooth,cras,shill".
151 static void InitializeWithPartialStub(const std::string& unstub_clients); 151 // See dbus_client_bundle.cc for the client names.
152 static void InitializeWithPartialFakes(
153 DBusClientTypeMask clients,
154 const std::string& force_real_clients_list);
152 155
153 // Initializes all currently stored DBusClients with the system bus and 156 // Initializes all currently stored DBusClients with the system bus and
154 // performs additional setup. 157 // performs additional setup.
155 void InitializeClients(); 158 void InitializeClients();
156 159
157 std::unique_ptr<base::Thread> dbus_thread_; 160 std::unique_ptr<base::Thread> dbus_thread_;
158 scoped_refptr<dbus::Bus> system_bus_; 161 scoped_refptr<dbus::Bus> system_bus_;
159 std::unique_ptr<DBusClientBundle> client_bundle_; 162 std::unique_ptr<DBusClientBundle> client_bundle_;
160 163
161 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); 164 DISALLOW_COPY_AND_ASSIGN(DBusThreadManager);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 friend class DBusThreadManager; 197 friend class DBusThreadManager;
195 198
196 DBusThreadManagerSetter(); 199 DBusThreadManagerSetter();
197 200
198 DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerSetter); 201 DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerSetter);
199 }; 202 };
200 203
201 } // namespace chromeos 204 } // namespace chromeos
202 205
203 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ 206 #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/dbus_client_implementation_type.h ('k') | chromeos/dbus/dbus_thread_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698