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

Unified Diff: cc/trees/swap_promise_manager.cc

Issue 2323423002: cc: Add SwapPromiseManager and SurfaceSequenceGenerator. (Closed)
Patch Set: rebase Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/swap_promise_manager.cc
diff --git a/cc/trees/swap_promise_manager.cc b/cc/trees/swap_promise_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d0e1bf15ba58a59b2291698e2ea1fa5376b6239a
--- /dev/null
+++ b/cc/trees/swap_promise_manager.cc
@@ -0,0 +1,58 @@
+// Copyright 2016 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.
+
+#include "cc/trees/swap_promise_manager.h"
+
+#include "cc/output/swap_promise.h"
+#include "cc/trees/swap_promise_monitor.h"
+
+namespace cc {
+
+SwapPromiseManager::SwapPromiseManager() {}
+
+SwapPromiseManager::~SwapPromiseManager() {
+ DCHECK(swap_promise_monitor_.empty());
+ BreakSwapPromises(SwapPromise::COMMIT_FAILS);
+}
+
+void SwapPromiseManager::QueueSwapPromise(
+ std::unique_ptr<SwapPromise> swap_promise) {
+ DCHECK(swap_promise);
+ swap_promise_list_.push_back(std::move(swap_promise));
+}
+
+void SwapPromiseManager::InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) {
+ swap_promise_monitor_.insert(monitor);
+}
+
+void SwapPromiseManager::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) {
+ swap_promise_monitor_.erase(monitor);
+}
+
+void SwapPromiseManager::NotifySwapPromiseMonitorsOfSetNeedsCommit() {
+ std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
+ for (; it != swap_promise_monitor_.end(); it++)
vmpstr 2016/09/12 20:44:31 for (auto* swap_promise_monitor : swap_promise_mon
Khushal 2016/09/12 22:53:03 Done.
+ (*it)->OnSetNeedsCommitOnMain();
+}
+
+void SwapPromiseManager::WillCommit() {
+ for (const auto& swap_promise : swap_promise_list_)
+ swap_promise->OnCommit();
+}
+
+std::vector<std::unique_ptr<SwapPromise>>
+SwapPromiseManager::TakeSwapPromises() {
+ std::vector<std::unique_ptr<SwapPromise>> result;
+ result.swap(swap_promise_list_);
+ return result;
+}
+
+void SwapPromiseManager::BreakSwapPromises(
+ SwapPromise::DidNotSwapReason reason) {
+ for (const auto& swap_promise : swap_promise_list_)
+ swap_promise->DidNotSwap(reason);
+ swap_promise_list_.clear();
+}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698