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

Unified Diff: third_party/WebKit/Source/platform/battery/battery_status.h

Issue 1740843002: Revert of Migrates battery_status from content/renderer/ to WebKit/platform/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/battery/battery_status.h
diff --git a/third_party/WebKit/Source/platform/battery/battery_status.h b/third_party/WebKit/Source/platform/battery/battery_status.h
deleted file mode 100644
index 5ae6ed95909939636eaeda0f6624cc48aea4aa8f..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/platform/battery/battery_status.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2014 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 BLINK_PLATFORM_BATTERY_BATTERY_STATUS_H_
-#define BLINK_PLATFORM_BATTERY_BATTERY_STATUS_H_
-
-#include "platform/PlatformExport.h"
-#include "wtf/Assertions.h"
-
-#include <cmath>
-#include <limits>
-
-namespace blink {
-
-// Simple struct to hold the battery status. This class is copyable.
-class PLATFORM_EXPORT BatteryStatus final {
- public:
- BatteryStatus()
- : charging_(true),
- charging_time_(0),
- discharging_time_(std::numeric_limits<double>::infinity()),
- level_(1) {}
- BatteryStatus(bool charging,
- double charging_time,
- double discharging_time,
- double level)
- : charging_(charging),
- charging_time_(charging_time),
- discharging_time_(discharging_time),
- level_(EnsureTwoSignificantDigits(level)) {}
- BatteryStatus(const BatteryStatus&) = default;
- BatteryStatus& operator=(const BatteryStatus&) = default;
-
- bool charging() const { return charging_; }
- double charging_time() const { return charging_time_; }
- double discharging_time() const { return discharging_time_; }
- double level() const { return level_; }
-
- private:
- double EnsureTwoSignificantDigits(double level) {
- // Convert battery level value which should be in [0, 1] to a value in
- // [0, 1] with 2 digits of precision. This is to provide a consistent
- // experience across platforms (e.g. on Mac and Android the battery changes
- // are generally reported with 1% granularity). It also serves the purpose
- // of reducing the possibility of fingerprinting and triggers less level
- // change events on platforms where the granularity is high.
- ASSERT(level >= 0 && level <= 1);
- return std::round(level * 100) / 100.f;
- }
-
- bool charging_;
- double charging_time_;
- double discharging_time_;
- double level_;
-};
-
-} // namespace blink
-
-#endif // BLINK_PLATFORM_BATTERY_BATTERY_STATUS_H_

Powered by Google App Engine
This is Rietveld 408576698