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.
5 #include "content/browser/renderer_host/compositor_resize_lock_aura.h"
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"
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
),
23 weak_ptr_factory_(this) {
26 TRACE_EVENT_ASYNC_BEGIN2("ui", "CompositorResizeLock", this,
27 "width", expected_size().width(),
28 "height", expected_size().height());
29 host_
->dispatcher()->HoldPointerMoves();
31 BrowserThread::PostDelayedTask(
32 BrowserThread::UI
, FROM_HERE
,
33 base::Bind(&CompositorResizeLock::CancelLock
,
34 weak_ptr_factory_
.GetWeakPtr()),
38 CompositorResizeLock::~CompositorResizeLock() {
40 TRACE_EVENT_ASYNC_END2("ui", "CompositorResizeLock", this,
41 "width", expected_size().width(),
42 "height", expected_size().height());
45 bool CompositorResizeLock::GrabDeferredLock() {
46 return ResizeLock::GrabDeferredLock();
49 void CompositorResizeLock::UnlockCompositor() {
50 ResizeLock::UnlockCompositor();
51 compositor_lock_
= NULL
;
54 void CompositorResizeLock::LockCompositor() {
55 ResizeLock::LockCompositor();
56 compositor_lock_
= host_
->compositor()->GetCompositorLock();
59 void CompositorResizeLock::CancelLock() {
64 host_
->dispatcher()->ReleasePointerMoves();
67 } // namespace content