Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/gpu/frame_swap_message_queue.h" | 5 #include "content/renderer/gpu/frame_swap_message_queue.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 } | 139 } |
| 140 | 140 |
| 141 void FrameSwapMessageQueue::QueueMessageForFrame(MessageDeliveryPolicy policy, | 141 void FrameSwapMessageQueue::QueueMessageForFrame(MessageDeliveryPolicy policy, |
| 142 int source_frame_number, | 142 int source_frame_number, |
| 143 scoped_ptr<IPC::Message> msg, | 143 scoped_ptr<IPC::Message> msg, |
| 144 bool* is_first) { | 144 bool* is_first) { |
| 145 base::AutoLock lock(lock_); | 145 base::AutoLock lock(lock_); |
| 146 GetSubQueue(policy)->QueueMessage(source_frame_number, msg.Pass(), is_first); | 146 GetSubQueue(policy)->QueueMessage(source_frame_number, msg.Pass(), is_first); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void FrameSwapMessageQueue::DidActivate(int source_frame_number) { | |
| 150 base::AutoLock lock(lock_); | |
| 151 visual_state_queue_->DrainMessages(source_frame_number, | |
| 152 &next_drain_messages_); | |
| 153 } | |
| 154 | |
| 149 void FrameSwapMessageQueue::DidSwap(int source_frame_number) { | 155 void FrameSwapMessageQueue::DidSwap(int source_frame_number) { |
| 150 base::AutoLock lock(lock_); | 156 base::AutoLock lock(lock_); |
| 151 | 157 swap_queue_->DrainMessages(0, &next_drain_messages_); |
| 152 visual_state_queue_->DrainMessages(source_frame_number, | |
| 153 &next_drain_messages_); | |
| 154 } | 158 } |
| 155 | 159 |
| 156 void FrameSwapMessageQueue::DidNotSwap(int source_frame_number, | 160 void FrameSwapMessageQueue::DidNotSwap(int source_frame_number, |
| 157 cc::SwapPromise::DidNotSwapReason reason, | 161 cc::SwapPromise::DidNotSwapReason reason, |
| 158 ScopedVector<IPC::Message>* messages) { | 162 ScopedVector<IPC::Message>* messages) { |
| 159 base::AutoLock lock(lock_); | 163 base::AutoLock lock(lock_); |
| 160 switch (reason) { | 164 switch (reason) { |
| 161 case cc::SwapPromise::SWAP_FAILS: | 165 case cc::SwapPromise::SWAP_FAILS: |
| 162 case cc::SwapPromise::COMMIT_NO_UPDATE: | 166 case cc::SwapPromise::COMMIT_NO_UPDATE: |
| 163 swap_queue_->DrainMessages(source_frame_number, messages); | 167 swap_queue_->DrainMessages(source_frame_number, messages); |
| 164 visual_state_queue_->DrainMessages(source_frame_number, messages); | 168 visual_state_queue_->DrainMessages(source_frame_number, messages); |
| 165 break; | 169 break; |
| 166 case cc::SwapPromise::COMMIT_FAILS: | 170 case cc::SwapPromise::COMMIT_FAILS: |
| 171 case cc::SwapPromise::ACTIVATION_FAILS: | |
| 167 // Do not queue any responses here. | 172 // Do not queue any responses here. |
| 168 // If COMMIT_FAILS the renderer is shutting down, which will | 173 // If COMMIT_FAILS the renderer is shutting down, which will |
|
piman
2015/05/13 22:47:15
Is the comment still true for ACTIVATION_FAILS?
If
| |
| 169 // result in the RenderFrameHostImpl destructor firing the | 174 // result in the RenderFrameHostImpl destructor firing the |
| 170 // remaining response callbacks itself. | 175 // remaining response callbacks itself. |
| 171 break; | 176 break; |
| 172 default: | |
| 173 NOTREACHED(); | |
| 174 } | 177 } |
| 175 } | 178 } |
| 176 | 179 |
| 177 void FrameSwapMessageQueue::DrainMessages( | 180 void FrameSwapMessageQueue::DrainMessages( |
| 178 ScopedVector<IPC::Message>* messages) { | 181 ScopedVector<IPC::Message>* messages) { |
| 179 lock_.AssertAcquired(); | 182 lock_.AssertAcquired(); |
| 180 | |
| 181 swap_queue_->DrainMessages(0, messages); | |
| 182 messages->insert(messages->end(), | 183 messages->insert(messages->end(), |
| 183 next_drain_messages_.begin(), | 184 next_drain_messages_.begin(), |
| 184 next_drain_messages_.end()); | 185 next_drain_messages_.end()); |
| 185 next_drain_messages_.weak_clear(); | 186 next_drain_messages_.weak_clear(); |
| 186 } | 187 } |
| 187 | 188 |
| 188 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> | 189 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> |
| 189 FrameSwapMessageQueue::AcquireSendMessageScope() { | 190 FrameSwapMessageQueue::AcquireSendMessageScope() { |
| 190 return make_scoped_ptr(new SendMessageScopeImpl(&lock_)); | 191 return make_scoped_ptr(new SendMessageScopeImpl(&lock_)); |
| 191 } | 192 } |
| 192 | 193 |
| 193 // static | 194 // static |
| 194 void FrameSwapMessageQueue::TransferMessages(ScopedVector<IPC::Message>& source, | 195 void FrameSwapMessageQueue::TransferMessages(ScopedVector<IPC::Message>& source, |
| 195 vector<IPC::Message>* dest) { | 196 vector<IPC::Message>* dest) { |
| 196 for (vector<IPC::Message*>::iterator i = source.begin(); i != source.end(); | 197 for (vector<IPC::Message*>::iterator i = source.begin(); i != source.end(); |
| 197 ++i) { | 198 ++i) { |
| 198 IPC::Message* m(*i); | 199 IPC::Message* m(*i); |
| 199 dest->push_back(*m); | 200 dest->push_back(*m); |
| 200 delete m; | 201 delete m; |
| 201 } | 202 } |
| 202 source.weak_clear(); | 203 source.weak_clear(); |
| 203 } | 204 } |
| 204 | 205 |
| 205 } // namespace content | 206 } // namespace content |
| OLD | NEW |