Chromium Code Reviews| 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..683d7a2e4b67ca92f7138ee99c2bef820070bdba 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_; } |
| - 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. |
| @@ -315,11 +302,10 @@ class CONTENT_EXPORT GpuChannel |
| // - it generates mailbox names for clients of the GPU process on the IO thread. |
| class GpuChannelMessageFilter : public IPC::MessageFilter { |
| public: |
| - GpuChannelMessageFilter( |
| - scoped_refptr<GpuChannelMessageQueue> message_queue, |
| - gpu::SyncPointManager* sync_point_manager, |
| - scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| - bool future_sync_points); |
| + GpuChannelMessageFilter(GpuChannelMessageQueue* message_queue, |
| + gpu::SyncPointManager* sync_point_manager, |
| + base::SingleThreadTaskRunner* task_runner, |
| + bool future_sync_points); |
| // IPC::MessageFilter implementation. |
| void OnFilterAdded(IPC::Sender* sender) override; |
| @@ -397,6 +383,97 @@ 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( |
| + const base::WeakPtr<GpuChannel>& gpu_channel, |
| + 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 processed_order_num() const { return processed_order_num_; } |
| + |
| + // Returns the global order number for the next IPC message to be processed. |
| + uint32_t current_order_num() const { return current_order_num_; } |
| + |
| + 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(const base::WeakPtr<GpuChannel>& gpu_channel, |
| + base::SingleThreadTaskRunner* task_runner); |
| + ~GpuChannelMessageQueue(); |
| + |
| + void ScheduleHandleMessage(); |
| + |
| + void PushMessageHelper(scoped_ptr<GpuChannelMessage> msg); |
| + |
| + bool HasQueuedMessagesHelper() const; |
| + |
| + bool enabled_; |
| + |
| + // Highest IPC order number seen, set when queued on the IO thread. |
| + uint32_t unprocessed_order_num_; |
| + // Both deques own the messages. |
| + std::deque<GpuChannelMessage*> channel_messages_; |
| + 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_; |
| + |
| + // Next unprocessed IPC message order number. Not protected by a lock as it's |
| + // only accessed on the main thread. |
| + uint32_t current_order_num_; |
|
piman
2015/09/11 00:38:33
This is not referenced anywhere anymore. Remove/re
sunnyps
2015/09/11 01:53:22
Done.
|
| + |
| + 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_ |