ImportanceAssertion.h [plain text]
#ifndef ImportanceAssertion_h
#define ImportanceAssertion_h
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
#if __has_include(<libproc_internal.h>)
#include <libproc_internal.h>
#endif
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
extern "C" int proc_denap_assertion_begin_with_msg(mach_msg_header_t*, uint64_t *);
extern "C" int proc_denap_assertion_complete(uint64_t);
#else
extern "C" int proc_importance_assertion_begin_with_msg(mach_msg_header_t*, mach_msg_trailer_t*, uint64_t*);
extern "C" int proc_importance_assertion_complete(uint64_t assertion_handle);
#endif
namespace IPC {
class ImportanceAssertion {
WTF_MAKE_NONCOPYABLE(ImportanceAssertion);
public:
explicit ImportanceAssertion(mach_msg_header_t* header)
: m_assertion(0)
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
proc_denap_assertion_begin_with_msg(header, &m_assertion);
#else
proc_importance_assertion_begin_with_msg(header, 0, &m_assertion);
#endif
}
~ImportanceAssertion()
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
proc_denap_assertion_complete(m_assertion);
#else
proc_importance_assertion_complete(m_assertion);
#endif
}
private:
uint64_t m_assertion;
};
}
#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
#endif // ImportanceAssertion_h