Index: content/common/gpu/gpu_channel.h |
diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h |
index d51a98ba2761383b87df9247cfe2f7ffc2adb608..41a420762393a04efc5d025bd2cbdabeebd90ba8 100644 |
--- a/content/common/gpu/gpu_channel.h |
+++ b/content/common/gpu/gpu_channel.h |
@@ -106,11 +106,6 @@ class CONTENT_EXPORT GpuChannel |
// IPC::Sender implementation: |
bool Send(IPC::Message* msg) override; |
- // Requeue the message that is currently being processed to the beginning of |
- // the queue. Used when the processing of a message gets aborted because of |
- // unscheduling conditions. |
- void RequeueMessage(); |
- |
// SubscriptionRefSet::Observer implementation |
void OnAddSubscription(unsigned int target) override; |
void OnRemoveSubscription(unsigned int target) override; |
@@ -179,10 +174,14 @@ class CONTENT_EXPORT GpuChannel |
// Visible for testing. |
GpuChannelMessageFilter* filter() const { return filter_.get(); } |
- uint32_t GetCurrentOrderNum() const { return current_order_num_; } |
David Yen
2015/09/10 21:23:04
Was this accidentally deleted? I'm using this in m
sunnyps
2015/09/10 23:38:36
Done. Renamed to current_order_num per naming conv
|
- uint32_t GetProcessedOrderNum() const { return processed_order_num_; } |
+ // Returns the global order number for the last processed IPC message. |
+ uint32_t GetProcessedOrderNum() const; |
+ |
+ // Returns the global order number for the last unprocessed IPC message. |
uint32_t GetUnprocessedOrderNum() const; |
+ void HandleMessage(); |
+ |
protected: |
// The message filter on the io thread. |
scoped_refptr<GpuChannelMessageFilter> filter_; |
@@ -210,14 +209,11 @@ class CONTENT_EXPORT GpuChannel |
base::hash_set<int32> routes_; |
}; |
- friend class GpuChannelMessageFilter; |
- friend class GpuChannelMessageQueue; |
- |
void OnDestroy(); |
bool OnControlMessageReceived(const IPC::Message& msg); |
- void HandleMessage(); |
+ void ScheduleHandleMessage(); |
// Message handlers. |
void OnCreateOffscreenCommandBuffer( |
@@ -228,9 +224,6 @@ class CONTENT_EXPORT GpuChannel |
void OnDestroyCommandBuffer(int32 route_id); |
void OnCreateJpegDecoder(int32 route_id, IPC::Message* reply_msg); |
- // Update processed order number and defer preemption. |
- void MessageProcessed(uint32_t order_number); |
- |
// The lifetime of objects of this class is managed by a GpuChannelManager. |
// The GpuChannelManager destroy all the GpuChannels that they own when they |
// are destroyed. So a raw pointer is safe. |
@@ -280,12 +273,6 @@ class CONTENT_EXPORT GpuChannel |
GpuWatchdog* watchdog_; |
bool software_; |
- // Current IPC order number being processed. |
- uint32_t current_order_num_; |
- |
- // Last finished IPC order number. |
- uint32_t processed_order_num_; |
- |
size_t num_stubs_descheduled_; |
// Map of stream id to stream state. |
@@ -397,6 +384,90 @@ class GpuChannelMessageFilter : public IPC::MessageFilter { |
static uint32_t global_order_counter_; |
}; |
+struct GpuChannelMessage { |
+ uint32_t order_number; |
+ base::TimeTicks time_received; |
+ IPC::Message message; |
+ |
+ // TODO(dyen): Temporary sync point data, remove once new sync point lands. |
+ bool retire_sync_point; |
+ uint32 sync_point; |
+ |
+ GpuChannelMessage(uint32_t order_num, const IPC::Message& msg) |
+ : order_number(order_num), |
+ time_received(base::TimeTicks::Now()), |
+ message(msg), |
+ retire_sync_point(false), |
+ sync_point(0) {} |
+}; |
+ |
+class GpuChannelMessageQueue |
+ : public base::RefCountedThreadSafe<GpuChannelMessageQueue> { |
+ public: |
+ static scoped_refptr<GpuChannelMessageQueue> Create( |
+ base::WeakPtr<GpuChannel> gpu_channel, |
dcheng
2015/09/10 21:30:37
const base::WeakPtr<GpuChannel>& here and in the c
sunnyps
2015/09/10 23:38:36
Done. Also removed the unnecessary refcounting her
|
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
+ |
+ // Returns the global order number for the last processed IPC message. |
+ uint32_t GetUnprocessedOrderNum() const; |
+ |
+ // Returns the global order number for the last unprocessed IPC message. |
+ uint32_t GetProccessedOrderNum() const; |
dcheng
2015/09/10 21:30:37
FWIW, simple accessors are usually inline and name
sunnyps
2015/09/10 23:38:36
Done.
|
+ |
+ bool HasQueuedMessages() const; |
+ |
+ base::TimeTicks GetNextMessageTimeTick() const; |
+ |
+ GpuChannelMessage* GetNextMessage() const; |
+ |
+ // Should be called after a message returned by GetNextMessage is processed. |
+ // Returns true if there are more messages on the queue. |
+ bool MessageProcessed(uint32_t order_number); |
+ |
+ void PushBackMessage(uint32_t order_number, const IPC::Message& message); |
+ |
+ bool GenerateSyncPointMessage(gpu::SyncPointManager* sync_point_manager, |
+ uint32_t order_number, |
+ const IPC::Message& message, |
+ bool retire_sync_point, |
+ uint32_t* sync_point_number); |
+ |
+ void DeleteAndDisableMessages(GpuChannelManager* gpu_channel_manager); |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<GpuChannelMessageQueue>; |
+ |
+ GpuChannelMessageQueue( |
+ base::WeakPtr<GpuChannel> gpu_channel, |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
+ ~GpuChannelMessageQueue(); |
+ |
+ void ScheduleHandleMessage(); |
+ |
+ void PushMessageHelper(GpuChannelMessage* msg); |
dcheng
2015/09/10 21:30:37
scoped_ptr<GpuChannelMessage> msg to make the owne
sunnyps
2015/09/10 23:38:36
Done.
|
+ |
+ bool HasQueuedMessagesHelper() const; |
+ |
+ bool enabled_; |
+ |
+ // Highest IPC order number seen, set when queued on the IO thread. |
+ uint32_t unprocessed_order_num_; |
+ std::deque<GpuChannelMessage*> channel_messages_; |
dcheng
2015/09/10 21:30:37
Ownership semantics for these members should be do
sunnyps
2015/09/10 23:38:36
Done.
|
+ std::deque<GpuChannelMessage*> out_of_order_messages_; |
+ |
+ // This lock protects enabled_, unprocessed_order_num_, and both deques. |
+ mutable base::Lock channel_messages_lock_; |
+ |
+ // Last finished IPC order number. Not protected by a lock as it's only |
+ // accessed on the main thread. |
+ uint32_t processed_order_num_; |
+ |
+ base::WeakPtr<GpuChannel> gpu_channel_; |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GpuChannelMessageQueue); |
+}; |
+ |
} // namespace content |
#endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |