OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_ |
| 6 #define CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/synchronization/lock.h" |
| 13 |
| 14 namespace IPC { |
| 15 class Message; |
| 16 }; |
| 17 |
| 18 namespace content { |
| 19 |
| 20 class FrameSwapMessageQueue : |
| 21 public base::RefCountedThreadSafe<FrameSwapMessageQueue> { |
| 22 public: |
| 23 FrameSwapMessageQueue(); |
| 24 |
| 25 // takes ownership of |msg| |
| 26 void QueueMessage(IPC::Message* msg); |
| 27 // takes ownership of |msg| |
| 28 // returns false if the given frame number had already been drained. |
| 29 bool TryQueueMessage(int source_frame_number, IPC::Message* msg); |
| 30 void DrainMessages(int source_frame_number, |
| 31 std::vector<IPC::Message>* messages); |
| 32 |
| 33 private: |
| 34 friend class base::RefCountedThreadSafe<FrameSwapMessageQueue>; |
| 35 ~FrameSwapMessageQueue(); |
| 36 typedef std::map<int, std::vector<IPC::Message*> > FrameQueueMap; |
| 37 |
| 38 base::Lock lock_; |
| 39 int highest_swapped_source_frame_number_; |
| 40 FrameQueueMap queued_messages_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(FrameSwapMessageQueue); |
| 43 }; |
| 44 |
| 45 } // namespace content |
| 46 |
| 47 #endif // CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_ |
OLD | NEW |