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

Side by Side Diff: chromeos/dbus/power_manager_client.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/power_manager_client.h ('k') | chromeos/dbus/power_policy_controller.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/power_manager_client.h" 5 #include "chromeos/dbus/power_manager_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 14 #include "base/message_loop.h"
14 #include "base/observer_list.h" 15 #include "base/observer_list.h"
15 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
16 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
17 #include "base/time.h" 18 #include "base/time.h"
18 #include "base/timer.h" 19 #include "base/timer.h"
19 #include "chromeos/dbus/power_manager/input_event.pb.h" 20 #include "chromeos/dbus/power_manager/input_event.pb.h"
21 #include "chromeos/dbus/power_manager/policy.pb.h"
20 #include "chromeos/dbus/power_manager/suspend.pb.h" 22 #include "chromeos/dbus/power_manager/suspend.pb.h"
21 #include "chromeos/dbus/power_state_control.pb.h" 23 #include "chromeos/dbus/power_state_control.pb.h"
22 #include "chromeos/dbus/power_supply_properties.pb.h" 24 #include "chromeos/dbus/power_supply_properties.pb.h"
23 #include "chromeos/dbus/video_activity_update.pb.h" 25 #include "chromeos/dbus/video_activity_update.pb.h"
24 #include "dbus/bus.h" 26 #include "dbus/bus.h"
25 #include "dbus/message.h" 27 #include "dbus/message.h"
26 #include "dbus/object_path.h" 28 #include "dbus/object_path.h"
27 #include "dbus/object_proxy.h" 29 #include "dbus/object_proxy.h"
28 #include "third_party/cros_system_api/dbus/service_constants.h" 30 #include "third_party/cros_system_api/dbus/service_constants.h"
29 31
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 LOG(ERROR) << "Error calling " 277 LOG(ERROR) << "Error calling "
276 << power_manager::kHandleVideoActivityMethod; 278 << power_manager::kHandleVideoActivityMethod;
277 return; 279 return;
278 } 280 }
279 power_manager_proxy_->CallMethod( 281 power_manager_proxy_->CallMethod(
280 &method_call, 282 &method_call,
281 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 283 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
282 dbus::ObjectProxy::EmptyResponseCallback()); 284 dbus::ObjectProxy::EmptyResponseCallback());
283 } 285 }
284 286
287 virtual void SetPolicy(
288 const power_manager::PowerManagementPolicy& policy) OVERRIDE {
289 dbus::MethodCall method_call(
290 power_manager::kPowerManagerInterface,
291 power_manager::kSetPolicyMethod);
292 dbus::MessageWriter writer(&method_call);
293 if (!writer.AppendProtoAsArrayOfBytes(policy)) {
294 LOG(ERROR) << "Error calling " << power_manager::kSetPolicyMethod;
295 return;
296 }
297 power_manager_proxy_->CallMethod(
298 &method_call,
299 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
300 dbus::ObjectProxy::EmptyResponseCallback());
301 }
302
285 virtual void RequestPowerStateOverrides( 303 virtual void RequestPowerStateOverrides(
286 uint32 request_id, 304 uint32 request_id,
287 base::TimeDelta duration, 305 base::TimeDelta duration,
288 int overrides, 306 int overrides,
289 const PowerStateRequestIdCallback& callback) OVERRIDE { 307 const PowerStateRequestIdCallback& callback) OVERRIDE {
290 dbus::MethodCall method_call(power_manager::kPowerManagerInterface, 308 dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
291 power_manager::kStateOverrideRequest); 309 power_manager::kStateOverrideRequest);
292 dbus::MessageWriter writer(&method_call); 310 dbus::MessageWriter writer(&method_call);
293 311
294 PowerStateControl protobuf; 312 PowerStateControl protobuf;
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 base::Unretained(this), 855 base::Unretained(this),
838 threshold), 856 threshold),
839 base::TimeDelta::FromMilliseconds(threshold)); 857 base::TimeDelta::FromMilliseconds(threshold));
840 } 858 }
841 859
842 virtual void NotifyUserActivity( 860 virtual void NotifyUserActivity(
843 const base::TimeTicks& last_activity_time) OVERRIDE {} 861 const base::TimeTicks& last_activity_time) OVERRIDE {}
844 virtual void NotifyVideoActivity( 862 virtual void NotifyVideoActivity(
845 const base::TimeTicks& last_activity_time, 863 const base::TimeTicks& last_activity_time,
846 bool is_fullscreen) OVERRIDE {} 864 bool is_fullscreen) OVERRIDE {}
865 virtual void SetPolicy(
866 const power_manager::PowerManagementPolicy& policy) OVERRIDE {}
847 virtual void RequestPowerStateOverrides( 867 virtual void RequestPowerStateOverrides(
848 uint32 request_id, 868 uint32 request_id,
849 base::TimeDelta duration, 869 base::TimeDelta duration,
850 int overrides, 870 int overrides,
851 const PowerStateRequestIdCallback& callback) OVERRIDE { 871 const PowerStateRequestIdCallback& callback) OVERRIDE {
852 // Mimic the behavior of power manager w.r.t. the request_id. 872 // Mimic the behavior of power manager w.r.t. the request_id.
853 if (request_id == 0) { 873 if (request_id == 0) {
854 callback.Run(next_request_id_++); 874 callback.Run(next_request_id_++);
855 } else { 875 } else {
856 callback.Run(request_id); 876 callback.Run(request_id);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 PowerManagerClient* PowerManagerClient::Create( 944 PowerManagerClient* PowerManagerClient::Create(
925 DBusClientImplementationType type, 945 DBusClientImplementationType type,
926 dbus::Bus* bus) { 946 dbus::Bus* bus) {
927 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 947 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
928 return new PowerManagerClientImpl(bus); 948 return new PowerManagerClientImpl(bus);
929 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 949 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
930 return new PowerManagerClientStubImpl(); 950 return new PowerManagerClientStubImpl();
931 } 951 }
932 952
933 } // namespace chromeos 953 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/power_manager_client.h ('k') | chromeos/dbus/power_policy_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698