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 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_RESIZE_LOCK_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_RESIZE_LOCK_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/time/time.h" |
| 12 #include "content/common/content_export.h" |
| 13 #include "ui/compositor/compositor_lock.h" |
| 14 #include "ui/gfx/geometry/size.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class CompositorResizeLockClient { |
| 19 public: |
| 20 virtual ~CompositorResizeLockClient() {} |
| 21 |
| 22 // Creates and returns a CompositorLock for the CompositoResizeLock to |
| 23 // hold. |
| 24 virtual std::unique_ptr<ui::CompositorLock> GetCompositorLock( |
| 25 ui::CompositorLockClient* client) = 0; |
| 26 |
| 27 // Called when the CompositorResizeLock ends. This can happen |
| 28 // before the CompositorResizeLock is destroyed if it times out. |
| 29 virtual void CompositorResizeLockEnded() = 0; |
| 30 }; |
| 31 |
| 32 // Used to prevent further resizes while a resize is pending. |
| 33 class CONTENT_EXPORT CompositorResizeLock |
| 34 : NON_EXPORTED_BASE(public ui::CompositorLockClient) { |
| 35 public: |
| 36 CompositorResizeLock(CompositorResizeLockClient* client, |
| 37 const gfx::Size& new_size); |
| 38 ~CompositorResizeLock() override; |
| 39 |
| 40 // Returns |true| if the call locks the compositor, or false if it was ever |
| 41 // locked/unlocked. |
| 42 bool Lock(); |
| 43 |
| 44 // Releases the lock on the compositor without releasing the whole resize |
| 45 // lock. The client is not told about this. If called before locking, it will |
| 46 // prevent locking from happening. |
| 47 void UnlockCompositor(); |
| 48 |
| 49 const gfx::Size& expected_size() const { return expected_size_; } |
| 50 |
| 51 private: |
| 52 // ui::CompositorLockClient implementation. |
| 53 void CompositorLockTimedOut() override; |
| 54 |
| 55 CompositorResizeLockClient* client_; |
| 56 const gfx::Size expected_size_; |
| 57 std::unique_ptr<ui::CompositorLock> compositor_lock_; |
| 58 bool unlocked_ = false; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(CompositorResizeLock); |
| 61 }; |
| 62 |
| 63 } // namespace content |
| 64 |
| 65 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_RESIZE_LOCK_AURA_H_ |
OLD | NEW |