summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/chromeos.gyp23
-rw-r--r--chromeos/chromeos_export.h26
-rw-r--r--chromeos/dbus/power_supply_status.cc44
-rw-r--r--chromeos/dbus/power_supply_status.h33
4 files changed, 126 insertions, 0 deletions
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp
new file mode 100644
index 0000000..bf6bd00
--- /dev/null
+++ b/chromeos/chromeos.gyp
@@ -0,0 +1,23 @@
+# 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.
+
+{
+ 'variables': {
+ 'chromium_code': 1,
+ },
+ 'targets': [
+ {
+ 'target_name': 'chromeos',
+ 'type': '<(component)',
+ 'dependencies': [
+ '../base/base.gyp:base',
+ ],
+ 'sources': [
+ 'chromeos_export.h',
+ 'dbus/power_supply_status.cc',
+ 'dbus/power_supply_status.h',
+ ],
+ },
+ ]
+}
diff --git a/chromeos/chromeos_export.h b/chromeos/chromeos_export.h
new file mode 100644
index 0000000..7be813f
--- /dev/null
+++ b/chromeos/chromeos_export.h
@@ -0,0 +1,26 @@
+// 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.
+
+#ifndef CHROMEOS_CHROMEOS_EXPORT_H_
+#define CHROMEOS_CHROMEOS_EXPORT_H_
+#pragma once
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(CHROMEOS_IMPLEMENTATION)
+#define CHROMEOS_EXPORT __declspec(dllexport)
+#else
+#define CHROMEOS_EXPORT __declspec(dllimport)
+#endif // defined(CHROMEOS_IMPLEMENTATION)
+
+#else // defined(WIN32)
+#define CHROMEOS_EXPORT __attribute__((visibility("default")))
+#endif
+
+#else // defined(COMPONENT_BUILD)
+#define CHROMEOS_EXPORT
+#endif
+
+#endif // CHROMEOS_CHROMEOS_EXPORT_H_
diff --git a/chromeos/dbus/power_supply_status.cc b/chromeos/dbus/power_supply_status.cc
new file mode 100644
index 0000000..cc0d9f2
--- /dev/null
+++ b/chromeos/dbus/power_supply_status.cc
@@ -0,0 +1,44 @@
+// 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 "chromeos/dbus/power_supply_status.h"
+
+#include "base/format_macros.h"
+#include "base/stringprintf.h"
+
+namespace 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),
+ battery_percentage(0) {
+}
+
+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);
+ return result;
+}
+
+} // namespace chromeos
diff --git a/chromeos/dbus/power_supply_status.h b/chromeos/dbus/power_supply_status.h
new file mode 100644
index 0000000..8e435d7
--- /dev/null
+++ b/chromeos/dbus/power_supply_status.h
@@ -0,0 +1,33 @@
+// 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.
+
+#ifndef CHROMEOS_DBUS_POWER_SUPPLY_STATUS_H_
+#define CHROMEOS_DBUS_POWER_SUPPLY_STATUS_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "chromeos/chromeos_export.h"
+
+namespace chromeos {
+
+struct CHROMEOS_EXPORT PowerSupplyStatus {
+ bool line_power_on;
+
+ bool battery_is_present;
+ bool battery_is_full;
+
+ // Time in seconds until the battery is empty or full, 0 for unknown.
+ int64 battery_seconds_to_empty;
+ int64 battery_seconds_to_full;
+
+ double battery_percentage;
+
+ PowerSupplyStatus();
+ std::string ToString() const;
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_DBUS_POWER_SUPPLY_STATUS_H_