OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/compositor/compositor_lock.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/sequenced_task_runner.h" |
| 9 #include "base/task_runner.h" |
| 10 #include "ui/compositor/compositor.h" |
| 11 |
| 12 namespace ui { |
| 13 |
| 14 CompositorLock::CompositorLock(CompositorLockClient* client, |
| 15 CompositorLockDelegate* delegate, |
| 16 base::SequencedTaskRunner* task_runner, |
| 17 base::TimeDelta timeout) |
| 18 : client_(client), delegate_(std::move(delegate)), weak_ptr_factory_(this) { |
| 19 if (!timeout.is_zero()) { |
| 20 task_runner->PostDelayedTask(FROM_HERE, |
| 21 base::Bind(&CompositorLock::TimeoutLock, |
| 22 weak_ptr_factory_.GetWeakPtr()), |
| 23 timeout); |
| 24 } |
| 25 } |
| 26 |
| 27 CompositorLock::~CompositorLock() { |
| 28 if (delegate_) |
| 29 delegate_->DoUnlockCompositor(); |
| 30 } |
| 31 |
| 32 void CompositorLock::TimeoutLock() { |
| 33 delegate_->DoUnlockCompositor(); |
| 34 delegate_ = nullptr; |
| 35 if (client_) |
| 36 client_->CompositorLockTimedOut(); |
| 37 } |
| 38 |
| 39 } // namespace ui |
OLD | NEW |