Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(985)

Side by Side Diff: ui/compositor/compositor_lock.h

Issue 2773433003: Fix CompositorResizeLock to do something. (Closed)
Patch Set: resizelock: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 #ifndef UI_COMPOSITOR_COMPOSITOR_LOCK_H_
6 #define UI_COMPOSITOR_COMPOSITOR_LOCK_H_
7
8 #include "base/macros.h"
9 #include "ui/compositor/compositor_export.h"
10
11 namespace ui {
12
13 class Compositor;
14 class CompositorLock;
15
16 class CompositorLockClient {
17 public:
18 virtual ~CompositorLockClient() {}
19
20 // Called if the CompositorLock ends before being destroyed due to timeout.
21 virtual void CompositorLockTimedOut() = 0;
22 };
23
24 class CompositorLockDelegate {
25 public:
26 virtual ~CompositorLockDelegate() {}
27
28 // Called to perform the unlock operation.
29 virtual void RemoveCompositorLock(CompositorLock*) = 0;
30 };
31
32 // This class represents a lock on the compositor, that can be used to prevent
33 // commits to the compositor tree while we're waiting for an asynchronous
34 // event. The typical use case is when waiting for a renderer to produce a frame
35 // at the right size. The caller keeps a reference on this object, and drops the
36 // reference once it desires to release the lock.
37 // By default, the lock will be cancelled after a short timeout to ensure
38 // responsiveness of the UI, so the compositor tree should be kept in a
39 // "reasonable" state while the lock is held. The timeout length, or no timeout,
40 // can be requested at the time the lock is created.
41 // Don't instantiate this class directly, use Compositor::GetCompositorLock.
42 class COMPOSITOR_EXPORT CompositorLock {
43 public:
44 // The |client| is informed about events from the CompositorLock. The
45 // |delegate| is used to perform actual unlocking. If |timeout| is zero then
46 // no timeout is scheduled, else a timeout is scheduled on the |task_runner|.
47 explicit CompositorLock(CompositorLockClient* client,
48 CompositorLockDelegate* delegate);
49 ~CompositorLock();
50
51 private:
52 friend class Compositor;
53 friend class FakeCompositorLock;
54
55 // Causes the CompositorLock to end due to a timeout.
56 void TimeoutLock();
57
58 CompositorLockClient* const client_;
59 CompositorLockDelegate* delegate_;
60
61 DISALLOW_COPY_AND_ASSIGN(CompositorLock);
62 };
63
64 } // namespace ui
65
66 #endif // UI_COMPOSITOR_COMPOSITOR_LOCK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698