summaryrefslogtreecommitdiffstats
path: root/ash/system/power/power_supply_status.cc
blob: a61b3a5ef416f7891b9a5475d170e3c33171b310 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/system/power/power_supply_status.h"

#include "base/format_macros.h"
#include "base/stringprintf.h"

namespace ash {

#if !defined(OS_CHROMEOS)
PowerSupplyStatus::PowerSupplyStatus()
    : line_power_on(false),
      battery_is_present(false),
      battery_is_full(false),
      battery_seconds_to_empty(0),
      battery_seconds_to_full(0),
      averaged_battery_time_to_empty(0),
      averaged_battery_time_to_full(0),
      battery_percentage(0),
      is_calculating_battery_time(false) {}

std::string PowerSupplyStatus::ToString() const {
  std::string result;
  base::StringAppendF(&result,
                      "line_power_on = %s ",
                      line_power_on ? "true" : "false");
  base::StringAppendF(&result,
                      "battery_is_present = %s ",
                      battery_is_present ? "true" : "false");
  base::StringAppendF(&result,
                      "battery_is_full = %s ",
                      battery_is_full ? "true" : "false");
  base::StringAppendF(&result,
                      "battery_percentage = %f ",
                      battery_percentage);
  base::StringAppendF(&result,
                      "battery_seconds_to_empty = %"PRId64" ",
                      battery_seconds_to_empty);
  base::StringAppendF(&result,
                      "battery_seconds_to_full = %"PRId64" ",
                      battery_seconds_to_full);
  base::StringAppendF(&result,
                      "averaged_battery_time_to_empty = %"PRId64" ",
                      averaged_battery_time_to_empty);
  base::StringAppendF(&result,
                      "averaged_battery_time_to_full = %"PRId64" ",
                      averaged_battery_time_to_full);
  base::StringAppendF(&result,
                      "is_calculating_battery_time = %s ",
                      is_calculating_battery_time ? "true" : "false");
  return result;
}
#endif  // !defined(OS_CHROMEOS)

}  // namespace ash