| 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_aura.h" | |
| 6 | |
| 7 #include "base/trace_event/trace_event.h" | |
| 8 #include "content/public/browser/browser_thread.h" | |
| 9 #include "ui/aura/window_event_dispatcher.h" | |
| 10 #include "ui/aura/window_tree_host.h" | |
| 11 #include "ui/compositor/compositor.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 CompositorResizeLock::CompositorResizeLock( | |
| 16 aura::WindowTreeHost* host, | |
| 17 const gfx::Size new_size, | |
| 18 bool defer_compositor_lock, | |
| 19 const base::TimeDelta& timeout) | |
| 20 : ResizeLock(new_size, defer_compositor_lock), | |
| 21 host_(host), | |
| 22 cancelled_(false), | |
| 23 weak_ptr_factory_(this) { | |
| 24 DCHECK(host_); | |
| 25 | |
| 26 TRACE_EVENT_ASYNC_BEGIN2("ui", "CompositorResizeLock", this, | |
| 27 "width", expected_size().width(), | |
| 28 "height", expected_size().height()); | |
| 29 host_->dispatcher()->HoldPointerMoves(); | |
| 30 | |
| 31 BrowserThread::PostDelayedTask( | |
| 32 BrowserThread::UI, FROM_HERE, | |
| 33 base::Bind(&CompositorResizeLock::CancelLock, | |
| 34 weak_ptr_factory_.GetWeakPtr()), | |
| 35 timeout); | |
| 36 } | |
| 37 | |
| 38 CompositorResizeLock::~CompositorResizeLock() { | |
| 39 CancelLock(); | |
| 40 TRACE_EVENT_ASYNC_END2("ui", "CompositorResizeLock", this, | |
| 41 "width", expected_size().width(), | |
| 42 "height", expected_size().height()); | |
| 43 } | |
| 44 | |
| 45 bool CompositorResizeLock::GrabDeferredLock() { | |
| 46 return ResizeLock::GrabDeferredLock(); | |
| 47 } | |
| 48 | |
| 49 void CompositorResizeLock::UnlockCompositor() { | |
| 50 ResizeLock::UnlockCompositor(); | |
| 51 compositor_lock_ = NULL; | |
| 52 } | |
| 53 | |
| 54 void CompositorResizeLock::LockCompositor() { | |
| 55 ResizeLock::LockCompositor(); | |
| 56 compositor_lock_ = host_->compositor()->GetCompositorLock(); | |
| 57 } | |
| 58 | |
| 59 void CompositorResizeLock::CancelLock() { | |
| 60 if (cancelled_) | |
| 61 return; | |
| 62 cancelled_ = true; | |
| 63 UnlockCompositor(); | |
| 64 host_->dispatcher()->ReleasePointerMoves(); | |
| 65 } | |
| 66 | |
| 67 } // namespace content | |
| OLD | NEW |