| 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/queue_message_swap_promise.h" | 5 #include "content/renderer/gpu/queue_message_swap_promise.h" |
| 6 | 6 |
| 7 #include "content/renderer/gpu/frame_swap_message_queue.h" | 7 #include "content/renderer/gpu/frame_update_message_queue.h" |
| 8 #include "ipc/ipc_message.h" |
| 8 #include "ipc/ipc_sync_message_filter.h" | 9 #include "ipc/ipc_sync_message_filter.h" |
| 9 | 10 |
| 10 namespace content { | 11 namespace content { |
| 11 | 12 |
| 12 QueueMessageSwapPromise::QueueMessageSwapPromise( | 13 QueueMessageSwapPromise::QueueMessageSwapPromise( |
| 13 scoped_refptr<IPC::SyncMessageFilter> message_sender, | 14 scoped_refptr<IPC::SyncMessageFilter> message_sender, |
| 14 scoped_refptr<content::FrameSwapMessageQueue> message_queue, | 15 scoped_refptr<content::FrameUpdateMessageQueue> message_queue, |
| 15 int source_frame_number) | 16 int source_frame_number) |
| 16 : message_sender_(message_sender), | 17 : QueueMessagePromise(message_sender, message_queue, source_frame_number) { |
| 17 message_queue_(message_queue), | |
| 18 source_frame_number_(source_frame_number) | |
| 19 #if DCHECK_IS_ON() | |
| 20 , | |
| 21 completed_(false) | |
| 22 #endif | |
| 23 { | |
| 24 DCHECK(message_sender_.get()); | |
| 25 DCHECK(message_queue_.get()); | |
| 26 } | 18 } |
| 27 | 19 |
| 28 QueueMessageSwapPromise::~QueueMessageSwapPromise() { | 20 QueueMessageSwapPromise::~QueueMessageSwapPromise() { |
| 29 // The promise should have either been kept or broken before it's deleted. | 21 // The promise should have either been kept or broken before it's deleted. |
| 30 #if DCHECK_IS_ON() | 22 #if DCHECK_IS_ON() |
| 31 DCHECK(completed_); | 23 DCHECK(completed_); |
| 32 #endif | 24 #endif |
| 33 } | 25 } |
| 34 | 26 |
| 35 void QueueMessageSwapPromise::DidSwap(cc::CompositorFrameMetadata* metadata) { | 27 void QueueMessageSwapPromise::DidSwap(cc::CompositorFrameMetadata* metadata) { |
| 36 #if DCHECK_IS_ON() | 28 #if DCHECK_IS_ON() |
| 37 DCHECK(!completed_); | 29 DCHECK(!completed_); |
| 38 #endif | 30 #endif |
| 39 message_queue_->DidSwap(source_frame_number_); | 31 message_queue_->DidSwap(source_frame_number_); |
| 40 // The OutputSurface will take care of the Drain+Send. | 32 // The OutputSurface will take care of the Drain+Send. |
| 41 PromiseCompleted(); | 33 PromiseCompleted(); |
| 42 } | 34 } |
| 43 | 35 |
| 44 void QueueMessageSwapPromise::DidNotSwap(DidNotSwapReason reason) { | 36 void QueueMessageSwapPromise::DidNotSwap(DidNotSwap::Reason reason) { |
| 45 #if DCHECK_IS_ON() | 37 #if DCHECK_IS_ON() |
| 46 DCHECK(!completed_); | 38 DCHECK(!completed_); |
| 47 #endif | 39 #endif |
| 48 ScopedVector<IPC::Message> messages; | 40 ScopedVector<IPC::Message> messages; |
| 49 message_queue_->DidNotSwap(source_frame_number_, reason, &messages); | 41 message_queue_->DidNotSwap(source_frame_number_, reason, &messages); |
| 50 for (ScopedVector<IPC::Message>::iterator i = messages.begin(); | 42 DeliverMessages(&messages); |
| 51 i != messages.end(); | |
| 52 ++i) { | |
| 53 message_sender_->Send(*i); | |
| 54 } | |
| 55 messages.weak_clear(); | |
| 56 PromiseCompleted(); | 43 PromiseCompleted(); |
| 57 } | 44 } |
| 58 | 45 |
| 59 void QueueMessageSwapPromise::PromiseCompleted() { | |
| 60 #if DCHECK_IS_ON() | |
| 61 completed_ = true; | |
| 62 #endif | |
| 63 } | |
| 64 | |
| 65 int64 QueueMessageSwapPromise::TraceId() const { | 46 int64 QueueMessageSwapPromise::TraceId() const { |
| 66 return 0; | 47 return 0; |
| 67 } | 48 } |
| 68 | 49 |
| 69 } // namespace content | 50 } // namespace content |
| OLD | NEW |