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

Unified Diff: tools/ThermalManager.h

Issue 1671573002: Create a thermal manager class and wire it in to nanobench behind a flag (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks 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: tools/ThermalManager.h
diff --git a/tools/ThermalManager.h b/tools/ThermalManager.h
new file mode 100644
index 0000000000000000000000000000000000000000..a67f3d0e9acc55e1825ff95c8f3ceadcc5cd1d52
--- /dev/null
+++ b/tools/ThermalManager.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef ThermalManager_DEFINED
+#define ThermalManager_DEFINED
+
+#include "SkString.h"
+#include "SkTArray.h"
+
+#define USE_THERMAL_MANAGER defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
djsollen 2016/02/05 04:54:15 It would be more clear to me if you wrote it somet
joshualitt 2016/02/05 13:50:20 Acknowledged.
joshualitt 2016/02/05 13:50:20 Acknowledged.
mtklein 2016/02/05 13:54:21 More than that, Derek's version is legal preproces
+
+#if USE_THERMAL_MANAGER
+
+/*
+ * This simple class monitors the thermal part of sysfs to ensure we don't trigger thermal events
+ */
+
+class ThermalManager {
+public:
+ ThermalManager(int32_t threshold = 1);
+
+ bool coolOffIfNecessary(uint32_t sleepInterval = 10, uint32_t maxSleeps = 1000);
djsollen 2016/02/05 04:54:15 can you document that the sleep interval is in sec
joshualitt 2016/02/05 13:50:20 Acknowledged.
+
+private:
+ static int32_t OpenFileAndReadInt32(const char* path);
+
+ static int32_t GetTemp(SkString thermalZonePath) {
+ SkString temperatureFilePath(thermalZonePath);
+ temperatureFilePath.appendf("/temp");
+ return OpenFileAndReadInt32(temperatureFilePath.c_str());
+ }
+
+ struct TripPoint {
+ TripPoint(SkString thermalZoneRoot, SkString pointName, int32_t threshold);
+
+ bool willTrip();
+
+ SkString fThermalZoneRoot;
+ SkString fPointName;
+ int32_t fBase;
+ int32_t fPoint;
+ int32_t fThreshold;
+ bool fDisabled;
+ };
+
+ SkTArray<TripPoint> fTripPoints;
+};
+#endif
+#endif
« no previous file with comments | « gyp/tools.gyp ('k') | tools/ThermalManager.cpp » ('j') | tools/ThermalManager.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698