[ Merge of http://go/wvgerrit/89848 ] Apps query a number of properties at initialization. The mediaDrm API getProperty allows the query of a single property at a time. This causes a series of requests. If no crypto sessions are concurrently open, a series of expensive OEMCrypto Initialization and Termination calls will occur. In this change OEMCrypto termination is delayed. If an OEMCrypto Terminate is followed in close succession by an Initialize, neither will occur avoiding the overhead. A timer enables a countdown process. If no session activity occurs, the timer will eventually terminate OEMCrypto and exit. Bug: 136282358 Test: Android unit/integration tests Change-Id: I442b7919b4e7835c52583516c8bc64d0c150241d
61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine Master
|
|
// License Agreement.
|
|
//
|
|
// Timer - Platform independent interface for a Timer class
|
|
//
|
|
#ifndef CDM_BASE_TIMER_H_
|
|
#define CDM_BASE_TIMER_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "utils/StrongPointer.h"
|
|
|
|
#include "disallow_copy_and_assign.h"
|
|
|
|
namespace wvcdm {
|
|
|
|
// Timer Handler class.
|
|
//
|
|
// Derive from this class if you wish to receive events when the timer
|
|
// expires. Provide the handler when setting up a new Timer.
|
|
|
|
class TimerHandler {
|
|
public:
|
|
TimerHandler() {}
|
|
virtual ~TimerHandler() {}
|
|
|
|
virtual void OnTimerEvent() = 0;
|
|
};
|
|
|
|
// Timer class. The implementation is platform dependent.
|
|
//
|
|
// This class provides a simple recurring timer API. The class receiving
|
|
// timer expiry events should derive from TimerHandler.
|
|
// Specify the receiver class and the periodicty of timer events when
|
|
// the timer is initiated by calling Start.
|
|
|
|
class Timer {
|
|
public:
|
|
class Impl;
|
|
|
|
Timer();
|
|
~Timer();
|
|
|
|
bool Start(TimerHandler* handler, uint32_t time_in_secs);
|
|
// Enable |wait_for_exit| only if the method is being invoked from a thread
|
|
// other than the timer thread. Deadlock might occur if enabled and called
|
|
// from the timer thread.
|
|
void Stop(bool wait_for_exit);
|
|
bool IsRunning();
|
|
|
|
private:
|
|
android::sp<Impl> impl_;
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(Timer);
|
|
};
|
|
|
|
} // namespace wvcdm
|
|
|
|
#endif // CDM_BASE_TIMER_H_
|