Index: cc/base/swap_promise.h |
diff --git a/cc/base/swap_promise.h b/cc/base/swap_promise.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5b213d2ddb73b78956840c34fa5b904e96b2f283 |
--- /dev/null |
+++ b/cc/base/swap_promise.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CC_BASE_SWAP_PROMISE_H_ |
+#define CC_BASE_SWAP_PROMISE_H_ |
+ |
+#include "base/compiler_specific.h" |
+ |
+namespace cc { |
+ |
+// A SwapPromise can be queued into LTH/LTI to track if an expected swap |
danakj
2013/11/13 23:22:09
spell out LayerTreeHost(Impl) here
Yufeng Shen (Slow to review)
2013/11/14 22:09:55
Done.
|
+// buffer will happen or not. If the swap buffer happens, DidSwap() will |
danakj
2013/11/13 23:22:09
Can you reword this comment to match what I wrote
Yufeng Shen (Slow to review)
2013/11/14 22:09:55
Done.
|
+// be called, and if the swap buffer somehow fails to happen, DidNotSwap() |
+// will be called. |
+// Client wishes to use SwapPromise should have a subclass that defines |
+// the behavior of DidSwap() and DidNotSwap(). Notice that swap buffer can |
+// fail at main/impl thread, so don't assume that DidSwap() and DidNotSwap() |
+// are called at a particular thread. It is better to let the subclass carry |
+// thread-safe member data and operate on that member data in DidSwap() and |
+// DidNotSwap(). |
+class SwapPromise { |
+ public: |
+ enum SwapPromiseType { |
+ SWAP_PROMISE_UNKNOWN, |
+ }; |
+ |
+ explicit SwapPromise(SwapPromiseType type); |
+ virtual ~SwapPromise() {} |
+ |
+ enum DidNotSwapReason { |
+ DID_NOT_SWAP_UNKNOWN, |
+ SWAP_FAILS, |
+ COMMIT_FAILS, |
+ SWAP_PROMISE_LIST_OVERFLOW, |
+ }; |
+ |
+ SwapPromiseType type() { |
danakj
2013/11/13 23:22:09
If there's only one type, what's the point of this
Yufeng Shen (Slow to review)
2013/11/14 22:09:55
It is intended that subclass added in the future w
danakj
2013/11/20 03:00:55
Then I prefer we add it in a later patch that will
Yufeng Shen (Slow to review)
2013/11/20 19:15:41
removed.
|
+ return type_; |
+ } |
+ |
+ virtual void DidSwap() = 0; |
+ virtual void DidNotSwap(DidNotSwapReason reason) = 0; |
+ |
+ protected: |
+ SwapPromiseType type_; |
+}; |
+ |
+} // namespace cc |
+ |
+#endif // CC_BASE_SWAP_PROMISE_H_ |