blob: 0f2531061645ecf79d96d4209aede1e9e9333952 [file] [log] [blame]
// Copyright 2014 The Chromium OS 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 THERMALD_TEMPERATURE_MONITOR_INTERFACE_H_
#define THERMALD_TEMPERATURE_MONITOR_INTERFACE_H_
#include <memory>
#include <string>
#include "base/callback.h"
#include "base/callback_list.h"
#include "base/macros.h"
namespace thermald {
// Interface for temperature monitors.
//
// A temperature monitor observes a single temperature. Subscribers can
// register with the temperature monitor to be notified upon changes of
// the monitored temperature.
class TemperatureMonitorInterface {
public:
typedef base::Callback<void(int)> TemperatureMonitorCallback;
#if BASE_VER < 860220
typedef base::CallbackList<void(int)>::Subscription Subscription;
#endif
TemperatureMonitorInterface() {}
virtual ~TemperatureMonitorInterface() {}
virtual std::string name() const = 0;
// Subscribe for notifications about temperature changes.
//
// Returns a subscription object. The caller must keep a reference to this
// object for the time the subscription should be active. The subscription
// is canceled when the object is deleted.
#if BASE_VER < 860220
virtual std::unique_ptr<Subscription> Subscribe(
#else
virtual base::CallbackListSubscription Subscribe(
#endif
const TemperatureMonitorCallback &cb) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(TemperatureMonitorInterface);
};
} // namespace thermald
#endif // THERMALD_TEMPERATURE_MONITOR_INTERFACE_H_