#include "chrome/browser/web_applications/locks/partitioned_lock_manager.h"
#include <memory>
#include <utility>
#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/scoped_refptr.h"
#include "base/not_fatal_until.h"
#include "base/task/sequenced_task_runner.h"
#include "base/values.h"
#include "chrome/browser/web_applications/locks/partitioned_lock.h"
#include "chrome/browser/web_applications/locks/partitioned_lock_id.h"
namespace web_app {
PartitionedLockHolder::PartitionedLockHolder() = default;
PartitionedLockHolder::~PartitionedLockHolder() = default;
PartitionedLockManager::PartitionedLockRequest::PartitionedLockRequest(
PartitionedLockId lock_id,
LockType type)
: … { … }
PartitionedLockManager::AcquireOptions::AcquireOptions() = default;
PartitionedLockManager::LockRequest::LockRequest() = default;
PartitionedLockManager::LockRequest::LockRequest(
LockType type,
base::WeakPtr<PartitionedLockHolder> locks_holder,
base::OnceClosure acquired_callback,
const base::Location& location)
: … { … }
PartitionedLockManager::LockRequest::LockRequest(LockRequest&&) noexcept =
default;
PartitionedLockManager::LockRequest::~LockRequest() = default;
PartitionedLockManager::Lock::Lock() = default;
PartitionedLockManager::Lock::Lock(Lock&&) noexcept = default;
PartitionedLockManager::Lock::~Lock() = default;
PartitionedLockManager::Lock& PartitionedLockManager::Lock::operator=(
PartitionedLockManager::Lock&&) noexcept = default;
PartitionedLockManager::PartitionedLockManager()
: … { … }
PartitionedLockManager::~PartitionedLockManager() = default;
int64_t PartitionedLockManager::LocksHeldForTesting() const { … }
int64_t PartitionedLockManager::RequestsWaitingForTesting() const { … }
void PartitionedLockManager::AcquireLocks(
base::flat_set<PartitionedLockRequest> lock_requests,
base::WeakPtr<PartitionedLockHolder> locks_holder,
LocksAcquiredCallback callback,
AcquireOptions acquire_options,
const base::Location& location) { … }
PartitionedLockManager::TestLockResult PartitionedLockManager::TestLock(
PartitionedLockRequest request) { … }
std::vector<base::Location>
PartitionedLockManager::GetHeldAndQueuedLockLocations(
const base::flat_set<PartitionedLockRequest>& requests) const { … }
std::vector<PartitionedLockId> PartitionedLockManager::GetUnacquirableLocks(
std::vector<PartitionedLockRequest>& lock_requests) { … }
void PartitionedLockManager::RemoveLockId(const PartitionedLockId& lock_id) { … }
base::Value PartitionedLockManager::ToDebugValue(
TransformLockIdToStringFn transform) const { … }
void PartitionedLockManager::AcquireLock(
PartitionedLockRequest request,
base::WeakPtr<PartitionedLockHolder> locks_holder,
base::OnceClosure acquired_callback,
const base::Location& location) { … }
void PartitionedLockManager::LockReleased(base::Location request_location,
PartitionedLockId lock_id) { … }
std::set<PartitionedLockHolder*> PartitionedLockManager::GetQueuedRequests(
const PartitionedLockId& lock_id) const { … }
bool operator<(const PartitionedLockManager::PartitionedLockRequest& x,
const PartitionedLockManager::PartitionedLockRequest& y) { … }
bool operator==(const PartitionedLockManager::PartitionedLockRequest& x,
const PartitionedLockManager::PartitionedLockRequest& y) { … }
bool operator!=(const PartitionedLockManager::PartitionedLockRequest& x,
const PartitionedLockManager::PartitionedLockRequest& y) { … }
}