Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / content / browser / renderer_host / compositor_resize_lock_aura.cc
blob419b7b326b8a192d41a3479b2db0884f9effe50a
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/debug/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"
13 namespace content {
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 weak_ptr_factory_(this),
23 cancelled_(false) {
24 DCHECK(host_);
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()),
35 timeout);
38 CompositorResizeLock::~CompositorResizeLock() {
39 CancelLock();
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() {
60 if (cancelled_)
61 return;
62 cancelled_ = true;
63 UnlockCompositor();
64 host_->dispatcher()->ReleasePointerMoves();
67 } // namespace content