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

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

Issue 1126963006: Move VISUAL_STATE promise to activation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Current state (presubmit warnings, cc_unittests tests failing) Created 5 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
OLDNEW
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 #ifndef CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_ 5 #ifndef CONTENT_RENDERER_GPU_FRAME_UPDATE_MESSAGE_QUEUE_H_
6 #define CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_ 6 #define CONTENT_RENDERER_GPU_FRAME_UPDATE_MESSAGE_QUEUE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "cc/output/activation_promise.h"
16 #include "cc/output/swap_promise.h" 17 #include "cc/output/swap_promise.h"
17 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
18 #include "content/renderer/message_delivery_policy.h" 19 #include "content/renderer/message_delivery_policy.h"
19 20
20 namespace IPC { 21 namespace IPC {
21 class Message; 22 class Message;
22 }; 23 };
23 24
24 namespace content { 25 namespace content {
25 26
26 class FrameSwapMessageSubQueue; 27 class FrameUpdateMessageSubQueue;
27 28
28 // Queue used to keep track of which IPC::Messages should be sent along with a 29 // Queue used to keep track of which IPC::Messages should be sent along with a
29 // particular compositor frame swap. 30 // particular compositor frame swap.
30 class CONTENT_EXPORT FrameSwapMessageQueue 31 class CONTENT_EXPORT FrameUpdateMessageQueue
31 : public base::RefCountedThreadSafe<FrameSwapMessageQueue> { 32 : public base::RefCountedThreadSafe<FrameUpdateMessageQueue> {
32 public: 33 public:
33 class CONTENT_EXPORT SendMessageScope { 34 class CONTENT_EXPORT SendMessageScope {
34 public: 35 public:
35 virtual ~SendMessageScope() {} 36 virtual ~SendMessageScope() {}
36 }; 37 };
37 38
38 FrameSwapMessageQueue(); 39 FrameUpdateMessageQueue();
39 40
40 // Queues message to be returned on a matching DrainMessages call. 41 // Queues message to be returned on a matching DrainMessages call.
41 // 42 //
42 // |policy| determines how messages are matched with DrainMessages calls. 43 // |policy| determines how messages are matched with DrainMessages calls.
43 // |source_frame_number| frame number to queue |msg| for. 44 // |source_frame_number| frame number to queue |msg| for.
44 // |msg| - message to queue. The method takes ownership of |msg|. 45 // |msg| - message to queue. The method takes ownership of |msg|.
45 // |is_first| - output parameter. Set to true if this was the first message 46 // |is_first| - output parameter. Set to true if this was the first message
46 // enqueued for the given source_frame_number. 47 // enqueued for the given source_frame_number.
47 void QueueMessageForFrame(MessageDeliveryPolicy policy, 48 void QueueMessageForFrame(MessageDeliveryPolicy policy,
48 int source_frame_number, 49 int source_frame_number,
49 scoped_ptr<IPC::Message> msg, 50 scoped_ptr<IPC::Message> msg,
50 bool* is_first); 51 bool* is_first);
51 52
52 // Returns true if there are no messages in the queue. 53 // Returns true if there are no messages in the queue.
53 bool Empty() const; 54 bool Empty() const;
54 55
56 // Should be called when a successful activate occurs.
57 //
58 // |source_frame_number| frame number for which the activate occurred.
59 void DidActivate(int source_frame_number,
60 ScopedVector<IPC::Message>* messages);
61
62 void DidNotActivate(int source_frame_number,
63 cc::Promise::DidNotActivate::Reason reason,
64 ScopedVector<IPC::Message>* messages);
65
55 // Should be called when a successful swap occurs. The messages for that swap 66 // Should be called when a successful swap occurs. The messages for that swap
56 // can be obtained by calling DrainMessages. 67 // can be obtained by calling DrainMessages.
57 // 68 //
58 // |source_frame_number| frame number for which the swap occurred. 69 // |source_frame_number| frame number for which the swap occurred.
59 void DidSwap(int source_frame_number); 70 void DidSwap(int source_frame_number);
60 71
61 // Should be called when we know a swap will not occur. This also means we 72 // Should be called when we know a swap will not occur. This also means we
62 // won't be expecting a DrainMessages call. 73 // won't be expecting a DrainMessages call.
63 // 74 //
64 // |source_frame_number| frame number for which the swap will not occur. 75 // |source_frame_number| frame number for which the swap will not occur.
65 // |reason| reason for the which the swap will not occur. 76 // |reason| reason for the which the swap will not occur.
66 // |messages| depending on |reason| it may make sense to deliver certain 77 // |messages| depending on |reason| it may make sense to deliver certain
67 // messages asynchronously. This vector will contain those 78 // messages asynchronously. This vector will contain those
68 // messages. 79 // messages.
69 void DidNotSwap(int source_frame_number, 80 void DidNotSwap(int source_frame_number,
70 cc::SwapPromise::DidNotSwapReason reason, 81 cc::Promise::DidNotSwap::Reason reason,
71 ScopedVector<IPC::Message>* messages); 82 ScopedVector<IPC::Message>* messages);
72 83
73 // A SendMessageScope object must be held by the caller when this method is 84 // A SendMessageScope object must be held by the caller when this method is
74 // called. 85 // called.
75 // 86 //
76 // |messages| vector to store messages, it's not cleared, only appended to. 87 // |messages| vector to store messages, it's not cleared, only appended to.
77 // The method will append messages queued for frame numbers lower 88 // The method will append messages queued for frame numbers lower
78 // or equal to |source_frame_number| 89 // or equal to |source_frame_number|
79 void DrainMessages(ScopedVector<IPC::Message>* messages); 90 void DrainMessagesForSwap(ScopedVector<IPC::Message>* messages);
80 91
81 // SendMessageScope is used to make sure that messages sent from different 92 // SendMessageScope is used to make sure that messages sent from different
82 // threads (impl/main) are scheduled in the right order on the IO threads. 93 // threads (impl/main) are scheduled in the right order on the IO threads.
83 // 94 //
84 // Returns an object that must be kept in scope till an IPC message containing 95 // Returns an object that must be kept in scope till an IPC message containing
85 // |messages| is sent. 96 // |messages| is sent.
86 scoped_ptr<SendMessageScope> AcquireSendMessageScope(); 97 scoped_ptr<SendMessageScope> AcquireSendMessageScope();
87 98
88 static void TransferMessages(ScopedVector<IPC::Message>& source, 99 static void TransferMessages(ScopedVector<IPC::Message>& source,
89 std::vector<IPC::Message>* dest); 100 std::vector<IPC::Message>* dest);
90 101
91 private: 102 private:
92 friend class base::RefCountedThreadSafe<FrameSwapMessageQueue>; 103 friend class base::RefCountedThreadSafe<FrameUpdateMessageQueue>;
93 104
94 FrameSwapMessageSubQueue* GetSubQueue(MessageDeliveryPolicy policy); 105 FrameUpdateMessageSubQueue* GetSubQueue(MessageDeliveryPolicy policy);
95 106
96 ~FrameSwapMessageQueue(); 107 ~FrameUpdateMessageQueue();
97 108
98 mutable base::Lock lock_; 109 mutable base::Lock lock_;
99 scoped_ptr<FrameSwapMessageSubQueue> visual_state_queue_; 110 scoped_ptr<FrameUpdateMessageSubQueue> visual_state_queue_;
100 scoped_ptr<FrameSwapMessageSubQueue> swap_queue_; 111 scoped_ptr<FrameUpdateMessageSubQueue> swap_queue_;
101 ScopedVector<IPC::Message> next_drain_messages_; 112 scoped_ptr<FrameUpdateMessageSubQueue> activation_queue_;
102 113
103 DISALLOW_COPY_AND_ASSIGN(FrameSwapMessageQueue); 114 DISALLOW_COPY_AND_ASSIGN(FrameUpdateMessageQueue);
104 }; 115 };
105 116
106 } // namespace content 117 } // namespace content
107 118
108 #endif // CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_ 119 #endif // CONTENT_RENDERER_GPU_FRAME_UPDATE_MESSAGE_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698