Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: content/renderer/gpu/frame_swap_message_queue.h

Issue 240163005: Deliver IPC messages together with SwapCompositorFrame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing doc Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/memory/scoped_ptr.h"
13 #include "base/synchronization/lock.h"
14 #include "content/common/content_export.h"
15
16 namespace IPC {
17 class Message;
18 };
19
20 namespace content {
21
22 // Queue used to keep track of which IPC::Messages should be sent along with a
23 // particular compositor frame swap.
24 class CONTENT_EXPORT FrameSwapMessageQueue :
25 public base::RefCountedThreadSafe<FrameSwapMessageQueue> {
26 public:
27 typedef scoped_ptr<base::AutoLock> SendMessageScope;
28 FrameSwapMessageQueue();
29
30 // Queues message to be sent on next drain.
31 //
32 // |msg| - message to queue. The method takes ownership of |msg|.
33 void QueueMessage(IPC::Message* msg);
34
35 // Queues message to take place on next drain coresponding to the given
36 // source_frame_number. Takes ownership of |msg|.
37 //
38 // |source_frame_number| frame number to queue |msg| for.
39 // |msg| - message to queue. The method takes ownership of |msg|.
40 // Returns false if the given source frame number had already been drained at
41 // least once.
42 bool TryQueueMessage(int source_frame_number, IPC::Message* msg);
43
44 // SendMessageScope must exist till after the messages are sent. The
45 // SendMessageScope is used to make sure that messages sent directly from the
46 // main thread can't overtake the message containing |messages|.
47 //
48 // |source_frame_number| frame number to get messages for
49 // |messages| vector to store messages. it's not cleared, only appended to.
50 // The method will append messages queued for frame numbers lower
51 // or equal to |source_frame_number|
52 // Returns an object that must be kept in scope till an IPC message containing
53 // |messages| is sent.
54 SendMessageScope DrainMessages(int source_frame_number,
55 std::vector<IPC::Message>* messages);
56
57 private:
58 friend class base::RefCountedThreadSafe<FrameSwapMessageQueue>;
59 typedef std::map<int, std::vector<IPC::Message*> > FrameQueueMap;
60
61 static void TransferMessages(std::vector<IPC::Message*>& source,
62 std::vector<IPC::Message>* dest);
63
64 ~FrameSwapMessageQueue();
65
66 base::Lock lock_;
67 int highest_swapped_source_frame_number_;
68 FrameQueueMap queued_messages_;
69
70 DISALLOW_COPY_AND_ASSIGN(FrameSwapMessageQueue);
71 };
72
73 } // namespace content
74
75 #endif // CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698