Chromium Code Reviews| 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_monitor_.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_monitor_.insert(monitor); | |
| 27 } | |
| 28 | |
| 29 void SwapPromiseManager::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) { | |
| 30 swap_promise_monitor_.erase(monitor); | |
| 31 } | |
| 32 | |
| 33 void SwapPromiseManager::NotifySwapPromiseMonitorsOfSetNeedsCommit() { | |
| 34 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | |
| 35 for (; it != swap_promise_monitor_.end(); it++) | |
| 36 (*it)->OnSetNeedsCommitOnMain(); | |
| 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 return std::move(swap_promise_list_); | |
|
vmpstr
2016/09/09 20:45:45
This leaves swap_promise_list_ in an unspecified s
Khushal
2016/09/09 21:09:34
Thanks for pointing this out. It was quite subtle,
| |
| 47 } | |
| 48 | |
| 49 void SwapPromiseManager::BreakSwapPromises( | |
| 50 SwapPromise::DidNotSwapReason reason) { | |
| 51 for (const auto& swap_promise : swap_promise_list_) | |
| 52 swap_promise->DidNotSwap(reason); | |
| 53 swap_promise_list_.clear(); | |
| 54 } | |
| 55 | |
| 56 } // namespace cc | |
| OLD | NEW |