Source release 17.1.0
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
// Copyright 2019 Google Inc. All Rights Reserved.
|
||||
// Copyright 2019 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// Clock - A fake clock just for running tests.
|
||||
|
||||
#include "clock.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "clock.h"
|
||||
#include "test_sleep.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace wvutil {
|
||||
|
||||
namespace {
|
||||
// A fake clock that only advances when TestSleep::Sleep is called.
|
||||
class FakeClock : public wvcdm::TestSleep::CallBack {
|
||||
class FakeClock : public TestSleep::CallBack {
|
||||
public:
|
||||
FakeClock() {
|
||||
auto now = std::chrono::steady_clock().now();
|
||||
auto now = std::chrono::system_clock().now();
|
||||
now_ = now.time_since_epoch() / std::chrono::milliseconds(1);
|
||||
TestSleep::set_callback(this);
|
||||
}
|
||||
@@ -33,8 +34,9 @@ FakeClock* g_fake_clock = nullptr;
|
||||
|
||||
// On devices running a fake OEMCrypto, we can use a fake sleep and fake time.
|
||||
int64_t Clock::GetCurrentTime() {
|
||||
TestSleep::SyncFakeClock();
|
||||
if (g_fake_clock == nullptr) g_fake_clock = new FakeClock();
|
||||
return g_fake_clock->now() / 1000;
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
} // namespace wvutil
|
||||
|
||||
Reference in New Issue
Block a user