OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 "content/browser/renderer_host/compositor_resize_lock.h" |
| 6 |
| 7 #include "base/trace_event/trace_event.h" |
| 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "ui/compositor/compositor.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 CompositorResizeLock::CompositorResizeLock(CompositorResizeLockClient* client, |
| 14 const gfx::Size& new_size) |
| 15 : client_(client), expected_size_(new_size) { |
| 16 TRACE_EVENT_ASYNC_BEGIN2("ui", "CompositorResizeLock", this, "width", |
| 17 expected_size().width(), "height", |
| 18 expected_size().height()); |
| 19 } |
| 20 |
| 21 CompositorResizeLock::~CompositorResizeLock() { |
| 22 compositor_lock_ = nullptr; |
| 23 if (client_) |
| 24 client_->CompositorResizeLockEnded(); |
| 25 |
| 26 TRACE_EVENT_ASYNC_END2("ui", "CompositorResizeLock", this, "width", |
| 27 expected_size().width(), "height", |
| 28 expected_size().height()); |
| 29 } |
| 30 |
| 31 bool CompositorResizeLock::Lock() { |
| 32 if (unlocked_ || compositor_lock_) |
| 33 return false; |
| 34 compositor_lock_ = client_->GetCompositorLock(this); |
| 35 return true; |
| 36 } |
| 37 |
| 38 void CompositorResizeLock::UnlockCompositor() { |
| 39 unlocked_ = true; |
| 40 compositor_lock_ = nullptr; |
| 41 } |
| 42 |
| 43 void CompositorResizeLock::CompositorLockTimedOut() { |
| 44 UnlockCompositor(); |
| 45 if (client_) { |
| 46 client_->CompositorResizeLockEnded(); |
| 47 client_ = nullptr; |
| 48 } |
| 49 } |
| 50 |
| 51 } // namespace content |
OLD | NEW |