From 17932a63fd4ef122dfb5146b8527c8479cbe5132 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 19 Dec 2018 12:06:21 -0800 Subject: [PATCH] Change from custom Lock to std::mutex. Rest of merge of http://go/wvgerrit/67884 Some files were deleted on original CL that were not deleted here. Now that we can use C++11, we should use the cross-platform std::mutex type, not the custom pthread version. Bug: 111850982 Test: WV unit/integration tests Change-Id: I48a1e47aa79e5e66b5869c0f766c18d561d26784 --- libwvdrmengine/cdm/util/include/lock.h | 53 -------------------------- libwvdrmengine/cdm/util/src/lock.cpp | 32 ---------------- 2 files changed, 85 deletions(-) delete mode 100644 libwvdrmengine/cdm/util/include/lock.h delete mode 100644 libwvdrmengine/cdm/util/src/lock.cpp diff --git a/libwvdrmengine/cdm/util/include/lock.h b/libwvdrmengine/cdm/util/include/lock.h deleted file mode 100644 index 3eb288f1..00000000 --- a/libwvdrmengine/cdm/util/include/lock.h +++ /dev/null @@ -1,53 +0,0 @@ -// 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. -// -// Lock - Platform independent interface for a Mutex class -// -#ifndef WVCDM_UTIL_LOCK_H_ -#define WVCDM_UTIL_LOCK_H_ - -#include "disallow_copy_and_assign.h" - -namespace wvcdm { - -// Simple lock class. The implementation is platform dependent. -// -// The lock must be unlocked by the thread that locked it. -// The lock is also not recursive (ie. cannot be taken multiple times). -class Lock { - public: - Lock(); - ~Lock(); - - void Acquire(); - void Release(); - - friend class AutoLock; - - private: - class Impl; - Impl* impl_; - - CORE_DISALLOW_COPY_AND_ASSIGN(Lock); -}; - -// Manages the lock automatically. It will be locked when AutoLock -// is constructed and release when AutoLock goes out of scope. -class AutoLock { - public: - explicit AutoLock(Lock& lock) : lock_(&lock) { lock_->Acquire(); } - - explicit AutoLock(Lock* lock) : lock_(lock) { lock_->Acquire(); } - - ~AutoLock() { lock_->Release(); } - - private: - Lock* lock_; - - CORE_DISALLOW_COPY_AND_ASSIGN(AutoLock); -}; - -} // namespace wvcdm - -#endif // WVCDM_UTIL_LOCK_H_ diff --git a/libwvdrmengine/cdm/util/src/lock.cpp b/libwvdrmengine/cdm/util/src/lock.cpp deleted file mode 100644 index c6ceb914..00000000 --- a/libwvdrmengine/cdm/util/src/lock.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// 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. -// -// Lock class - provides a simple android specific mutex implementation - -#include "lock.h" -#include - -namespace wvcdm { - -class Lock::Impl { - public: - android::Mutex lock_; -}; - -Lock::Lock() : impl_(new Lock::Impl()) { -} - -Lock::~Lock() { - delete impl_; -} - -void Lock::Acquire() { - impl_->lock_.lock(); -} - -void Lock::Release() { - impl_->lock_.unlock(); -} - -} // namespace wvcdm