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

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

Issue 1981383002: Do not show "Error calling GetScreenBrightnessPercent" in VMTests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 11 matching lines...) Expand all
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/threading/platform_thread.h" 23 #include "base/threading/platform_thread.h"
24 #include "base/timer/timer.h" 24 #include "base/timer/timer.h"
25 #include "chromeos/chromeos_switches.h" 25 #include "chromeos/chromeos_switches.h"
26 #include "chromeos/dbus/fake_power_manager_client.h" 26 #include "chromeos/dbus/fake_power_manager_client.h"
27 #include "chromeos/dbus/power_manager/input_event.pb.h" 27 #include "chromeos/dbus/power_manager/input_event.pb.h"
28 #include "chromeos/dbus/power_manager/peripheral_battery_status.pb.h" 28 #include "chromeos/dbus/power_manager/peripheral_battery_status.pb.h"
29 #include "chromeos/dbus/power_manager/policy.pb.h" 29 #include "chromeos/dbus/power_manager/policy.pb.h"
30 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" 30 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
31 #include "chromeos/dbus/power_manager/suspend.pb.h" 31 #include "chromeos/dbus/power_manager/suspend.pb.h"
32 #include "chromeos/system/statistics_provider.h"
32 #include "components/device_event_log/device_event_log.h" 33 #include "components/device_event_log/device_event_log.h"
33 #include "dbus/bus.h" 34 #include "dbus/bus.h"
34 #include "dbus/message.h" 35 #include "dbus/message.h"
35 #include "dbus/object_path.h" 36 #include "dbus/object_path.h"
36 #include "dbus/object_proxy.h" 37 #include "dbus/object_proxy.h"
37 38
38 namespace chromeos { 39 namespace chromeos {
39 40
41 namespace {
42
40 // Maximum amount of time that the power manager will wait for Chrome to 43 // Maximum amount of time that the power manager will wait for Chrome to
41 // say that it's ready for the system to be suspended, in milliseconds. 44 // say that it's ready for the system to be suspended, in milliseconds.
42 const int kSuspendDelayTimeoutMs = 5000; 45 const int kSuspendDelayTimeoutMs = 5000;
43 46
44 // Human-readable description of Chrome's suspend delay. 47 // Human-readable description of Chrome's suspend delay.
45 const char kSuspendDelayDescription[] = "chrome"; 48 const char kSuspendDelayDescription[] = "chrome";
46 49
50 // The system vendor in a VM.
51 const char kVMSystemVendor[] = "QEMU";
achuithb 2016/05/17 20:18:51 We have this same definition here: https://code.go
52
53 } // namespace
54
47 // The PowerManagerClient implementation used in production. 55 // The PowerManagerClient implementation used in production.
48 class PowerManagerClientImpl : public PowerManagerClient { 56 class PowerManagerClientImpl : public PowerManagerClient {
49 public: 57 public:
50 PowerManagerClientImpl() 58 PowerManagerClientImpl()
51 : origin_thread_id_(base::PlatformThread::CurrentId()), 59 : origin_thread_id_(base::PlatformThread::CurrentId()),
52 power_manager_proxy_(NULL), 60 power_manager_proxy_(NULL),
53 suspend_delay_id_(-1), 61 suspend_delay_id_(-1),
54 has_suspend_delay_id_(false), 62 has_suspend_delay_id_(false),
55 dark_suspend_delay_id_(-1), 63 dark_suspend_delay_id_(-1),
56 has_dark_suspend_delay_id_(false), 64 has_dark_suspend_delay_id_(false),
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 POWER_LOG(ERROR) << "Unable to decode " 459 POWER_LOG(ERROR) << "Unable to decode "
452 << power_manager::kGetPowerSupplyPropertiesMethod 460 << power_manager::kGetPowerSupplyPropertiesMethod
453 << " response"; 461 << " response";
454 } 462 }
455 } 463 }
456 464
457 void OnGetScreenBrightnessPercent( 465 void OnGetScreenBrightnessPercent(
458 const GetScreenBrightnessPercentCallback& callback, 466 const GetScreenBrightnessPercentCallback& callback,
459 dbus::Response* response) { 467 dbus::Response* response) {
460 if (!response) { 468 if (!response) {
461 POWER_LOG(ERROR) << "Error calling " 469 chromeos::system::StatisticsProvider* stats =
462 << power_manager::kGetScreenBrightnessPercentMethod; 470 chromeos::system::StatisticsProvider::GetInstance();
471 std::string system_vendor;
472 // Only log the error when not running in a VM. See crbug.com/585514 and
473 // crbug.com/585504 to see why we should do this.
474 if (stats->GetMachineStatistic(chromeos::system::kSystemVendorKey,
475 &system_vendor) &&
476 system_vendor != kVMSystemVendor) {
achuithb 2016/05/17 20:18:51 Are we confident that this check works in the VM?
xdai1 2016/05/17 20:35:55 I tested this in the VMTest locally and it worked
achuithb 2016/05/17 21:10:47 The previous hwid change (http://crbug.com/585515)
xdai1 2016/05/17 21:35:17 I just checked and unfortunately the HWID error is
477 POWER_LOG(ERROR) << "Error calling "
478 << power_manager::kGetScreenBrightnessPercentMethod;
479 }
463 return; 480 return;
464 } 481 }
465 dbus::MessageReader reader(response); 482 dbus::MessageReader reader(response);
466 double percent = 0.0; 483 double percent = 0.0;
467 if (!reader.PopDouble(&percent)) 484 if (!reader.PopDouble(&percent))
468 POWER_LOG(ERROR) << "Error reading response from powerd: " 485 POWER_LOG(ERROR) << "Error reading response from powerd: "
469 << response->ToString(); 486 << response->ToString();
470 callback.Run(percent); 487 callback.Run(percent);
471 } 488 }
472 489
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 // static 809 // static
793 PowerManagerClient* PowerManagerClient::Create( 810 PowerManagerClient* PowerManagerClient::Create(
794 DBusClientImplementationType type) { 811 DBusClientImplementationType type) {
795 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 812 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
796 return new PowerManagerClientImpl(); 813 return new PowerManagerClientImpl();
797 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 814 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
798 return new FakePowerManagerClient(); 815 return new FakePowerManagerClient();
799 } 816 }
800 817
801 } // namespace chromeos 818 } // 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