OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #include "cc/trees/swap_promise_manager.h" |
| 6 |
| 7 #include "cc/output/swap_promise.h" |
| 8 #include "cc/trees/swap_promise_monitor.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 SwapPromiseManager::SwapPromiseManager() {} |
| 13 |
| 14 SwapPromiseManager::~SwapPromiseManager() { |
| 15 DCHECK(swap_promise_monitors_.empty()); |
| 16 BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
| 17 } |
| 18 |
| 19 void SwapPromiseManager::QueueSwapPromise( |
| 20 std::unique_ptr<SwapPromise> swap_promise) { |
| 21 DCHECK(swap_promise); |
| 22 swap_promise_list_.push_back(std::move(swap_promise)); |
| 23 } |
| 24 |
| 25 void SwapPromiseManager::InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) { |
| 26 swap_promise_monitors_.insert(monitor); |
| 27 } |
| 28 |
| 29 void SwapPromiseManager::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) { |
| 30 swap_promise_monitors_.erase(monitor); |
| 31 } |
| 32 |
| 33 void SwapPromiseManager::NotifySwapPromiseMonitorsOfSetNeedsCommit() { |
| 34 for (auto* swap_promise_monitor : swap_promise_monitors_) { |
| 35 swap_promise_monitor->OnSetNeedsCommitOnMain(); |
| 36 } |
| 37 } |
| 38 |
| 39 void SwapPromiseManager::WillCommit() { |
| 40 for (const auto& swap_promise : swap_promise_list_) |
| 41 swap_promise->OnCommit(); |
| 42 } |
| 43 |
| 44 std::vector<std::unique_ptr<SwapPromise>> |
| 45 SwapPromiseManager::TakeSwapPromises() { |
| 46 std::vector<std::unique_ptr<SwapPromise>> result; |
| 47 result.swap(swap_promise_list_); |
| 48 return result; |
| 49 } |
| 50 |
| 51 void SwapPromiseManager::BreakSwapPromises( |
| 52 SwapPromise::DidNotSwapReason reason) { |
| 53 for (const auto& swap_promise : swap_promise_list_) |
| 54 swap_promise->DidNotSwap(reason); |
| 55 swap_promise_list_.clear(); |
| 56 } |
| 57 |
| 58 } // namespace cc |
OLD | NEW |