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

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

Issue 12186010: chromeos: Add power management policy prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix observer registration and bool prefs Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.h ('k') | chromeos/dbus/mock_dbus_thread_manager.h » ('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 #include "chromeos/dbus/dbus_thread_manager.h" 5 #include "chromeos/dbus/dbus_thread_manager.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/chromeos/chromeos_version.h" 9 #include "base/chromeos/chromeos_version.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 21 matching lines...) Expand all
32 #include "chromeos/dbus/ibus/ibus_config_client.h" 32 #include "chromeos/dbus/ibus/ibus_config_client.h"
33 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h" 33 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h"
34 #include "chromeos/dbus/ibus/ibus_engine_service.h" 34 #include "chromeos/dbus/ibus/ibus_engine_service.h"
35 #include "chromeos/dbus/ibus/ibus_input_context_client.h" 35 #include "chromeos/dbus/ibus/ibus_input_context_client.h"
36 #include "chromeos/dbus/ibus/ibus_panel_service.h" 36 #include "chromeos/dbus/ibus/ibus_panel_service.h"
37 #include "chromeos/dbus/image_burner_client.h" 37 #include "chromeos/dbus/image_burner_client.h"
38 #include "chromeos/dbus/introspectable_client.h" 38 #include "chromeos/dbus/introspectable_client.h"
39 #include "chromeos/dbus/modem_messaging_client.h" 39 #include "chromeos/dbus/modem_messaging_client.h"
40 #include "chromeos/dbus/permission_broker_client.h" 40 #include "chromeos/dbus/permission_broker_client.h"
41 #include "chromeos/dbus/power_manager_client.h" 41 #include "chromeos/dbus/power_manager_client.h"
42 #include "chromeos/dbus/power_policy_controller.h"
42 #include "chromeos/dbus/session_manager_client.h" 43 #include "chromeos/dbus/session_manager_client.h"
43 #include "chromeos/dbus/sms_client.h" 44 #include "chromeos/dbus/sms_client.h"
44 #include "chromeos/dbus/speech_synthesizer_client.h" 45 #include "chromeos/dbus/speech_synthesizer_client.h"
45 #include "chromeos/dbus/update_engine_client.h" 46 #include "chromeos/dbus/update_engine_client.h"
46 #include "dbus/bus.h" 47 #include "dbus/bus.h"
47 #include "dbus/dbus_statistics.h" 48 #include "dbus/dbus_statistics.h"
48 49
49 namespace chromeos { 50 namespace chromeos {
50 51
51 static DBusThreadManager* g_dbus_thread_manager = NULL; 52 static DBusThreadManager* g_dbus_thread_manager = NULL;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 power_manager_client_.reset( 118 power_manager_client_.reset(
118 PowerManagerClient::Create(client_type_maybe_stub, system_bus_.get())); 119 PowerManagerClient::Create(client_type_maybe_stub, system_bus_.get()));
119 session_manager_client_.reset( 120 session_manager_client_.reset(
120 SessionManagerClient::Create(client_type, system_bus_.get())); 121 SessionManagerClient::Create(client_type, system_bus_.get()));
121 sms_client_.reset( 122 sms_client_.reset(
122 SMSClient::Create(client_type, system_bus_.get())); 123 SMSClient::Create(client_type, system_bus_.get()));
123 speech_synthesizer_client_.reset( 124 speech_synthesizer_client_.reset(
124 SpeechSynthesizerClient::Create(client_type, system_bus_.get())); 125 SpeechSynthesizerClient::Create(client_type, system_bus_.get()));
125 update_engine_client_.reset( 126 update_engine_client_.reset(
126 UpdateEngineClient::Create(client_type, system_bus_.get())); 127 UpdateEngineClient::Create(client_type, system_bus_.get()));
128
129 // PowerPolicyController is dependent on PowerManagerClient, so
130 // initialize it after the main list of clients.
131 power_policy_controller_.reset(
132 new PowerPolicyController(this, power_manager_client_.get()));
127 } 133 }
128 134
129 virtual ~DBusThreadManagerImpl() { 135 virtual ~DBusThreadManagerImpl() {
130 FOR_EACH_OBSERVER(DBusThreadManagerObserver, observers_, 136 FOR_EACH_OBSERVER(DBusThreadManagerObserver, observers_,
131 OnDBusThreadManagerDestroying(this)); 137 OnDBusThreadManagerDestroying(this));
132 138
133 // Shut down the bus. During the browser shutdown, it's ok to shut down 139 // Shut down the bus. During the browser shutdown, it's ok to shut down
134 // the bus synchronously. 140 // the bus synchronously.
135 system_bus_->ShutdownOnDBusThreadAndBlock(); 141 system_bus_->ShutdownOnDBusThreadAndBlock();
136 if (ibus_bus_.get()) 142 if (ibus_bus_.get())
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 280 }
275 281
276 virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE { 282 virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE {
277 return permission_broker_client_.get(); 283 return permission_broker_client_.get();
278 } 284 }
279 285
280 virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE { 286 virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE {
281 return power_manager_client_.get(); 287 return power_manager_client_.get();
282 } 288 }
283 289
290 virtual PowerPolicyController* GetPowerPolicyController() OVERRIDE {
291 return power_policy_controller_.get();
292 }
293
284 virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE { 294 virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE {
285 return session_manager_client_.get(); 295 return session_manager_client_.get();
286 } 296 }
287 297
288 virtual SMSClient* GetSMSClient() OVERRIDE { 298 virtual SMSClient* GetSMSClient() OVERRIDE {
289 return sms_client_.get(); 299 return sms_client_.get();
290 } 300 }
291 301
292 virtual SpeechSynthesizerClient* GetSpeechSynthesizerClient() OVERRIDE { 302 virtual SpeechSynthesizerClient* GetSpeechSynthesizerClient() OVERRIDE {
293 return speech_synthesizer_client_.get(); 303 return speech_synthesizer_client_.get();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 return; 345 return;
336 } 346 }
337 delete ibus_engine_services_[object_path]; 347 delete ibus_engine_services_[object_path];
338 ibus_engine_services_.erase(object_path); 348 ibus_engine_services_.erase(object_path);
339 } 349 }
340 350
341 virtual IBusPanelService* GetIBusPanelService() OVERRIDE { 351 virtual IBusPanelService* GetIBusPanelService() OVERRIDE {
342 return ibus_panel_service_.get(); 352 return ibus_panel_service_.get();
343 } 353 }
344 354
355 // Note: Keep this before other members so they can call AddObserver() in
356 // their c'tors.
357 ObserverList<DBusThreadManagerObserver> observers_;
358
345 scoped_ptr<base::Thread> dbus_thread_; 359 scoped_ptr<base::Thread> dbus_thread_;
346 scoped_refptr<dbus::Bus> system_bus_; 360 scoped_refptr<dbus::Bus> system_bus_;
347 scoped_refptr<dbus::Bus> ibus_bus_; 361 scoped_refptr<dbus::Bus> ibus_bus_;
348 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; 362 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_;
349 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; 363 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_;
350 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; 364 scoped_ptr<BluetoothInputClient> bluetooth_input_client_;
351 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; 365 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_;
352 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_; 366 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_;
353 scoped_ptr<BluetoothOutOfBandClient> bluetooth_out_of_band_client_; 367 scoped_ptr<BluetoothOutOfBandClient> bluetooth_out_of_band_client_;
354 scoped_ptr<CrosDisksClient> cros_disks_client_; 368 scoped_ptr<CrosDisksClient> cros_disks_client_;
(...skipping 13 matching lines...) Expand all
368 scoped_ptr<SessionManagerClient> session_manager_client_; 382 scoped_ptr<SessionManagerClient> session_manager_client_;
369 scoped_ptr<SMSClient> sms_client_; 383 scoped_ptr<SMSClient> sms_client_;
370 scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_; 384 scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_;
371 scoped_ptr<UpdateEngineClient> update_engine_client_; 385 scoped_ptr<UpdateEngineClient> update_engine_client_;
372 scoped_ptr<IBusClient> ibus_client_; 386 scoped_ptr<IBusClient> ibus_client_;
373 scoped_ptr<IBusConfigClient> ibus_config_client_; 387 scoped_ptr<IBusConfigClient> ibus_config_client_;
374 scoped_ptr<IBusInputContextClient> ibus_input_context_client_; 388 scoped_ptr<IBusInputContextClient> ibus_input_context_client_;
375 scoped_ptr<IBusEngineFactoryService> ibus_engine_factory_service_; 389 scoped_ptr<IBusEngineFactoryService> ibus_engine_factory_service_;
376 std::map<dbus::ObjectPath, IBusEngineService*> ibus_engine_services_; 390 std::map<dbus::ObjectPath, IBusEngineService*> ibus_engine_services_;
377 scoped_ptr<IBusPanelService> ibus_panel_service_; 391 scoped_ptr<IBusPanelService> ibus_panel_service_;
392 scoped_ptr<PowerPolicyController> power_policy_controller_;
378 393
379 std::string ibus_address_; 394 std::string ibus_address_;
380
381 ObserverList<DBusThreadManagerObserver> observers_;
382 }; 395 };
383 396
384 // static 397 // static
385 void DBusThreadManager::Initialize() { 398 void DBusThreadManager::Initialize() {
386 // Ignore Initialize() if we set a test DBusThreadManager. 399 // Ignore Initialize() if we set a test DBusThreadManager.
387 if (g_dbus_thread_manager_set_for_testing) 400 if (g_dbus_thread_manager_set_for_testing)
388 return; 401 return;
389 // If we initialize DBusThreadManager twice we may also be shutting it down 402 // If we initialize DBusThreadManager twice we may also be shutting it down
390 // early; do not allow that. 403 // early; do not allow that.
391 CHECK(g_dbus_thread_manager == NULL); 404 CHECK(g_dbus_thread_manager == NULL);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } 460 }
448 461
449 // static 462 // static
450 DBusThreadManager* DBusThreadManager::Get() { 463 DBusThreadManager* DBusThreadManager::Get() {
451 CHECK(g_dbus_thread_manager) 464 CHECK(g_dbus_thread_manager)
452 << "DBusThreadManager::Get() called before Initialize()"; 465 << "DBusThreadManager::Get() called before Initialize()";
453 return g_dbus_thread_manager; 466 return g_dbus_thread_manager;
454 } 467 }
455 468
456 } // namespace chromeos 469 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.h ('k') | chromeos/dbus/mock_dbus_thread_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698