| Index: ui/compositor/compositor_lock.cc
|
| diff --git a/ui/compositor/compositor_lock.cc b/ui/compositor/compositor_lock.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..542afbc1862b011dec52a6abbc2dc305285ea63f
|
| --- /dev/null
|
| +++ b/ui/compositor/compositor_lock.cc
|
| @@ -0,0 +1,39 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/compositor/compositor_lock.h"
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/sequenced_task_runner.h"
|
| +#include "base/task_runner.h"
|
| +#include "ui/compositor/compositor.h"
|
| +
|
| +namespace ui {
|
| +
|
| +CompositorLock::CompositorLock(CompositorLockClient* client,
|
| + CompositorLockDelegate* delegate,
|
| + base::SequencedTaskRunner* task_runner,
|
| + base::TimeDelta timeout)
|
| + : client_(client), delegate_(std::move(delegate)), weak_ptr_factory_(this) {
|
| + if (!timeout.is_zero()) {
|
| + task_runner->PostDelayedTask(FROM_HERE,
|
| + base::Bind(&CompositorLock::TimeoutLock,
|
| + weak_ptr_factory_.GetWeakPtr()),
|
| + timeout);
|
| + }
|
| +}
|
| +
|
| +CompositorLock::~CompositorLock() {
|
| + if (delegate_)
|
| + delegate_->DoUnlockCompositor();
|
| +}
|
| +
|
| +void CompositorLock::TimeoutLock() {
|
| + delegate_->DoUnlockCompositor();
|
| + delegate_ = nullptr;
|
| + if (client_)
|
| + client_->CompositorLockTimedOut();
|
| +}
|
| +
|
| +} // namespace ui
|
|
|