* Reject session clobbering. [ Merge of http://go/wvgerrit/14634 ] This fixes a bug in I17de92b3e682c9c731f755e69466bdae7f560393 in which sessions can be clobbered by a forced session ID. This bug manifested in subtle test failures which involved repeatedly creating sessions. This was traced to OEMCrypto not being terminated, then upward to a leaked CryptoSession and CdmSession, and then finally to clobbered session IDs. To avoid the bug in future, first, reject duplicate session IDs. Second, change the OpenSession API to make forced IDs explicit. * Fix unit test namespaces. [ Merge of http://go/wvgerrit/14622 ] This fixes some odd errors that occur when linking multiple test suites into one executable. When two object files both contain a definition of wvcdm::MockCryptoSession, for example, one will win silently and cause the other's tests to misbehave and/or crash. The solution is to put all mocks into an anonymous namespace, since each wvcdm::(anonymous)::MockCryptoSession is separate. In order to avoid lots of repetitions of wvcdm:: in the anonymous namespaces, all anonymous namespaces in unit tests now live inside or the wvcdm namespace. This has been done even for tests which are not currently using mocks. * Move timer and timer_unittest to Android. [ Merge of http://go/wvgerrit/14619 ] These are not used anywhere else. Change-Id: I234f31e9b5c79061205728783596ebaff65e0aff
52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
//
|
|
// Timer - Platform independent interface for a Timer class
|
|
//
|
|
#ifndef CDM_BASE_CORE_TIMER_H_
|
|
#define CDM_BASE_CORE_TIMER_H_
|
|
|
|
#include "wv_cdm_types.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);
|
|
void Stop();
|
|
bool IsRunning();
|
|
|
|
private:
|
|
Impl *impl_;
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(Timer);
|
|
};
|
|
|
|
} // namespace wvcdm
|
|
|
|
#endif // CDM_BASE_CORE_TIMER_H_
|