Commit 9d9ec179 authored by Miguel Casas-Sanchez's avatar Miguel Casas-Sanchez Committed by Commit Bot

MediaStreamManager: listen to and log OnThermalStateChange

crrev.com/c/2195334 just landed PowerObserver::OnThermalStateChange,
this CL listens to it from MediaStreamManager and logs it in the
WebRTC log.

The utility function PowerMonitorSource::DeviceThermalStateToString
gets #if DCHECK_IS_ON() removed to be used from the new code, which
runs also in non-dcheck_always_on builds.

Bug: 1071431
Change-Id: I5641ae5a96e4ca9504498821ffb3ea91adbec18a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207410Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771045}
parent 3a2804a6
......@@ -85,10 +85,8 @@ void PowerMonitor::NotifyResume() {
void PowerMonitor::NotifyThermalStateChange(
PowerObserver::DeviceThermalState new_state) {
DCHECK(IsInitialized());
#if DCHECK_IS_ON()
DVLOG(1) << "ThermalStateChange: "
<< PowerMonitorSource::DeviceThermalStateToString(new_state);
#endif
GetInstance()->observers_->Notify(
FROM_HERE, &PowerObserver::OnThermalStateChange, new_state);
}
......
......@@ -75,9 +75,8 @@ void PowerMonitorSource::SetInitialOnBatteryPowerState(bool on_battery_power) {
on_battery_power_ = on_battery_power;
}
#if DCHECK_IS_ON()
// static
std::string PowerMonitorSource::DeviceThermalStateToString(
const char* PowerMonitorSource::DeviceThermalStateToString(
PowerObserver::DeviceThermalState state) {
switch (state) {
case PowerObserver::DeviceThermalState::kUnknown:
......@@ -94,6 +93,5 @@ std::string PowerMonitorSource::DeviceThermalStateToString(
NOTREACHED();
return "Unknown";
}
#endif
} // namespace base
......@@ -31,10 +31,8 @@ class BASE_EXPORT PowerMonitorSource {
// Is the computer currently on battery power. Can be called on any thread.
bool IsOnBatteryPower();
#if DCHECK_IS_ON()
static std::string DeviceThermalStateToString(
static const char* DeviceThermalStateToString(
PowerObserver::DeviceThermalState state);
#endif
protected:
friend class PowerMonitorTest;
......
......@@ -43,10 +43,8 @@ ThermalStateObserverMac::ThermalStateObserverMac(
state = NSProcessInfoThermalStateToDeviceThermalState(nsinfo_state);
if (state_for_testing_ != PowerObserver::DeviceThermalState::kUnknown)
state = state_for_testing_;
#if DCHECK_IS_ON()
DVLOG(1) << __func__ << ": "
<< PowerMonitorSource::DeviceThermalStateToString(state);
#endif
state_update_callback.Run(state);
};
......
......@@ -19,6 +19,7 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_source.h"
#include "base/rand_util.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
......@@ -2100,6 +2101,14 @@ void MediaStreamManager::OnResume() {
SendLogMessage(base::StringPrintf("OnResume([this=%p])", this));
}
void MediaStreamManager::OnThermalStateChange(
base::PowerObserver::DeviceThermalState new_state) {
const char* state_name =
base::PowerMonitorSource::DeviceThermalStateToString(new_state);
SendLogMessage(base::StringPrintf(
"OnThermalStateChange({this=%p}, {new_state=%s})", this, state_name));
}
void MediaStreamManager::UseFakeUIFactoryForTests(
base::RepeatingCallback<std::unique_ptr<FakeMediaStreamUIProxy>(void)>
fake_ui_factory) {
......
......@@ -279,6 +279,8 @@ class CONTENT_EXPORT MediaStreamManager
// base::PowerObserver overrides.
void OnSuspend() override;
void OnResume() override;
void OnThermalStateChange(
base::PowerObserver::DeviceThermalState new_state) override;
// Called by the tests to specify a factory for creating
// FakeMediaStreamUIProxys to be used for generated streams.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment