| Index: content/browser/renderer_host/compositor_resize_lock.cc
|
| diff --git a/content/browser/renderer_host/compositor_resize_lock.cc b/content/browser/renderer_host/compositor_resize_lock.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a6dfd2b5d9a0fb8a707298404b6382cb70e135b2
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/compositor_resize_lock.cc
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2014 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 "content/browser/renderer_host/compositor_resize_lock.h"
|
| +
|
| +#include "base/trace_event/trace_event.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +#include "ui/compositor/compositor.h"
|
| +
|
| +namespace content {
|
| +
|
| +CompositorResizeLock::CompositorResizeLock(CompositorResizeLockClient* client,
|
| + const gfx::Size& new_size)
|
| + : client_(client), expected_size_(new_size) {
|
| + TRACE_EVENT_ASYNC_BEGIN2("ui", "CompositorResizeLock", this, "width",
|
| + expected_size().width(), "height",
|
| + expected_size().height());
|
| +}
|
| +
|
| +CompositorResizeLock::~CompositorResizeLock() {
|
| + compositor_lock_ = nullptr;
|
| + if (client_)
|
| + client_->CompositorResizeLockEnded();
|
| +
|
| + TRACE_EVENT_ASYNC_END2("ui", "CompositorResizeLock", this, "width",
|
| + expected_size().width(), "height",
|
| + expected_size().height());
|
| +}
|
| +
|
| +bool CompositorResizeLock::Lock() {
|
| + if (unlocked_ || compositor_lock_)
|
| + return false;
|
| + compositor_lock_ = client_->GetCompositorLock(this);
|
| + return true;
|
| +}
|
| +
|
| +void CompositorResizeLock::UnlockCompositor() {
|
| + unlocked_ = true;
|
| + compositor_lock_ = nullptr;
|
| +}
|
| +
|
| +void CompositorResizeLock::CompositorLockTimedOut() {
|
| + UnlockCompositor();
|
| + if (client_) {
|
| + client_->CompositorResizeLockEnded();
|
| + client_ = nullptr;
|
| + }
|
| +}
|
| +
|
| +} // namespace content
|
|
|