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

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

Issue 12082103: chromeos: Pass suspend-delay description to powerd. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « no previous file | no next file » | 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"
(...skipping 10 matching lines...) Expand all
21 #include "chromeos/dbus/power_supply_properties.pb.h" 21 #include "chromeos/dbus/power_supply_properties.pb.h"
22 #include "chromeos/dbus/video_activity_update.pb.h" 22 #include "chromeos/dbus/video_activity_update.pb.h"
23 #include "dbus/bus.h" 23 #include "dbus/bus.h"
24 #include "dbus/message.h" 24 #include "dbus/message.h"
25 #include "dbus/object_path.h" 25 #include "dbus/object_path.h"
26 #include "dbus/object_proxy.h" 26 #include "dbus/object_proxy.h"
27 #include "third_party/cros_system_api/dbus/service_constants.h" 27 #include "third_party/cros_system_api/dbus/service_constants.h"
28 28
29 namespace chromeos { 29 namespace chromeos {
30 30
31 // Maximum amount of time that the power manager will wait for Chrome to
32 // say that it's ready for the system to be suspended, in milliseconds.
31 const int kSuspendDelayTimeoutMs = 5000; 33 const int kSuspendDelayTimeoutMs = 5000;
32 34
35 // Human-readable description of Chrome's suspend delay.
36 const char kSuspendDelayDescription[] = "chrome";
37
33 // The PowerManagerClient implementation used in production. 38 // The PowerManagerClient implementation used in production.
34 class PowerManagerClientImpl : public PowerManagerClient { 39 class PowerManagerClientImpl : public PowerManagerClient {
35 public: 40 public:
36 explicit PowerManagerClientImpl(dbus::Bus* bus) 41 explicit PowerManagerClientImpl(dbus::Bus* bus)
37 : origin_thread_id_(base::PlatformThread::CurrentId()), 42 : origin_thread_id_(base::PlatformThread::CurrentId()),
38 power_manager_proxy_(NULL), 43 power_manager_proxy_(NULL),
39 suspend_delay_id_(-1), 44 suspend_delay_id_(-1),
40 has_suspend_delay_id_(false), 45 has_suspend_delay_id_(false),
41 pending_suspend_id_(-1), 46 pending_suspend_id_(-1),
42 suspend_is_pending_(false), 47 suspend_is_pending_(false),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Register to powerd for suspend notifications. 123 // Register to powerd for suspend notifications.
119 dbus::MethodCall method_call( 124 dbus::MethodCall method_call(
120 power_manager::kPowerManagerInterface, 125 power_manager::kPowerManagerInterface,
121 power_manager::kRegisterSuspendDelayMethod); 126 power_manager::kRegisterSuspendDelayMethod);
122 dbus::MessageWriter writer(&method_call); 127 dbus::MessageWriter writer(&method_call);
123 128
124 power_manager::RegisterSuspendDelayRequest protobuf_request; 129 power_manager::RegisterSuspendDelayRequest protobuf_request;
125 base::TimeDelta timeout = 130 base::TimeDelta timeout =
126 base::TimeDelta::FromMilliseconds(kSuspendDelayTimeoutMs); 131 base::TimeDelta::FromMilliseconds(kSuspendDelayTimeoutMs);
127 protobuf_request.set_timeout(timeout.ToInternalValue()); 132 protobuf_request.set_timeout(timeout.ToInternalValue());
133 protobuf_request.set_description(kSuspendDelayDescription);
128 134
129 if (!writer.AppendProtoAsArrayOfBytes(protobuf_request)) { 135 if (!writer.AppendProtoAsArrayOfBytes(protobuf_request)) {
130 LOG(ERROR) << "Error constructing message for " 136 LOG(ERROR) << "Error constructing message for "
131 << power_manager::kRegisterSuspendDelayMethod; 137 << power_manager::kRegisterSuspendDelayMethod;
132 return; 138 return;
133 } 139 }
134 power_manager_proxy_->CallMethod( 140 power_manager_proxy_->CallMethod(
135 &method_call, 141 &method_call,
136 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 142 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
137 base::Bind( 143 base::Bind(
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 PowerManagerClient* PowerManagerClient::Create( 888 PowerManagerClient* PowerManagerClient::Create(
883 DBusClientImplementationType type, 889 DBusClientImplementationType type,
884 dbus::Bus* bus) { 890 dbus::Bus* bus) {
885 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 891 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
886 return new PowerManagerClientImpl(bus); 892 return new PowerManagerClientImpl(bus);
887 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 893 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
888 return new PowerManagerClientStubImpl(); 894 return new PowerManagerClientStubImpl();
889 } 895 }
890 896
891 } // namespace chromeos 897 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698