| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 GPU_IPC_SERVICE_GPU_CHANNEL_H_ | 5 #ifndef GPU_IPC_SERVICE_GPU_CHANNEL_H_ |
| 6 #define GPU_IPC_SERVICE_GPU_CHANNEL_H_ | 6 #define GPU_IPC_SERVICE_GPU_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 14 #include "base/containers/scoped_ptr_hash_map.h" | 15 #include "base/containers/scoped_ptr_hash_map.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
| 20 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
| 21 #include "base/trace_event/memory_dump_provider.h" | 21 #include "base/trace_event/memory_dump_provider.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 23 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
| 24 #include "gpu/gpu_export.h" | 24 #include "gpu/gpu_export.h" |
| 25 #include "gpu/ipc/common/gpu_stream_constants.h" | 25 #include "gpu/ipc/common/gpu_stream_constants.h" |
| 26 #include "gpu/ipc/service/gpu_command_buffer_stub.h" | 26 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
| 27 #include "gpu/ipc/service/gpu_memory_manager.h" | 27 #include "gpu/ipc/service/gpu_memory_manager.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 #if defined(OS_ANDROID) | 175 #if defined(OS_ANDROID) |
| 176 const GpuCommandBufferStub* GetOneStub() const; | 176 const GpuCommandBufferStub* GetOneStub() const; |
| 177 #endif | 177 #endif |
| 178 | 178 |
| 179 protected: | 179 protected: |
| 180 // The message filter on the io thread. | 180 // The message filter on the io thread. |
| 181 scoped_refptr<GpuChannelMessageFilter> filter_; | 181 scoped_refptr<GpuChannelMessageFilter> filter_; |
| 182 | 182 |
| 183 // Map of routing id to command buffer stub. | 183 // Map of routing id to command buffer stub. |
| 184 base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuCommandBufferStub>> stubs_; | 184 base::ScopedPtrHashMap<int32_t, std::unique_ptr<GpuCommandBufferStub>> stubs_; |
| 185 | 185 |
| 186 private: | 186 private: |
| 187 bool OnControlMessageReceived(const IPC::Message& msg); | 187 bool OnControlMessageReceived(const IPC::Message& msg); |
| 188 | 188 |
| 189 void HandleMessage(const scoped_refptr<GpuChannelMessageQueue>& queue); | 189 void HandleMessage(const scoped_refptr<GpuChannelMessageQueue>& queue); |
| 190 | 190 |
| 191 // Some messages such as WaitForGetOffsetInRange and WaitForTokenInRange are | 191 // Some messages such as WaitForGetOffsetInRange and WaitForTokenInRange are |
| 192 // processed as soon as possible because the client is blocked until they | 192 // processed as soon as possible because the client is blocked until they |
| 193 // are completed. | 193 // are completed. |
| 194 void HandleOutOfOrderMessage(const IPC::Message& msg); | 194 void HandleOutOfOrderMessage(const IPC::Message& msg); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 219 | 219 |
| 220 // The lifetime of objects of this class is managed by a GpuChannelManager. | 220 // The lifetime of objects of this class is managed by a GpuChannelManager. |
| 221 // The GpuChannelManager destroy all the GpuChannels that they own when they | 221 // The GpuChannelManager destroy all the GpuChannels that they own when they |
| 222 // are destroyed. So a raw pointer is safe. | 222 // are destroyed. So a raw pointer is safe. |
| 223 GpuChannelManager* const gpu_channel_manager_; | 223 GpuChannelManager* const gpu_channel_manager_; |
| 224 | 224 |
| 225 // Sync point manager. Outlives the channel and is guaranteed to outlive the | 225 // Sync point manager. Outlives the channel and is guaranteed to outlive the |
| 226 // message loop. | 226 // message loop. |
| 227 SyncPointManager* const sync_point_manager_; | 227 SyncPointManager* const sync_point_manager_; |
| 228 | 228 |
| 229 scoped_ptr<IPC::SyncChannel> channel_; | 229 std::unique_ptr<IPC::SyncChannel> channel_; |
| 230 | 230 |
| 231 IPC::Listener* unhandled_message_listener_; | 231 IPC::Listener* unhandled_message_listener_; |
| 232 | 232 |
| 233 // Uniquely identifies the channel within this GPU process. | 233 // Uniquely identifies the channel within this GPU process. |
| 234 std::string channel_id_; | 234 std::string channel_id_; |
| 235 | 235 |
| 236 // Used to implement message routing functionality to CommandBuffer objects | 236 // Used to implement message routing functionality to CommandBuffer objects |
| 237 IPC::MessageRouter router_; | 237 IPC::MessageRouter router_; |
| 238 | 238 |
| 239 // Whether the processing of IPCs on this channel is stalled and we should | 239 // Whether the processing of IPCs on this channel is stalled and we should |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 bool ShouldTransitionToIdle() const; | 446 bool ShouldTransitionToIdle() const; |
| 447 | 447 |
| 448 const int32_t stream_id_; | 448 const int32_t stream_id_; |
| 449 const GpuStreamPriority stream_priority_; | 449 const GpuStreamPriority stream_priority_; |
| 450 | 450 |
| 451 // These can be accessed from both IO and main threads and are protected by | 451 // These can be accessed from both IO and main threads and are protected by |
| 452 // |channel_lock_|. | 452 // |channel_lock_|. |
| 453 bool enabled_; | 453 bool enabled_; |
| 454 bool scheduled_; | 454 bool scheduled_; |
| 455 GpuChannel* const channel_; | 455 GpuChannel* const channel_; |
| 456 std::deque<scoped_ptr<GpuChannelMessage>> channel_messages_; | 456 std::deque<std::unique_ptr<GpuChannelMessage>> channel_messages_; |
| 457 mutable base::Lock channel_lock_; | 457 mutable base::Lock channel_lock_; |
| 458 | 458 |
| 459 // The following are accessed on the IO thread only. | 459 // The following are accessed on the IO thread only. |
| 460 // No lock is necessary for preemption state because it's only accessed on the | 460 // No lock is necessary for preemption state because it's only accessed on the |
| 461 // IO thread. | 461 // IO thread. |
| 462 PreemptionState preemption_state_; | 462 PreemptionState preemption_state_; |
| 463 // Maximum amount of time that we can spend in PREEMPTING. | 463 // Maximum amount of time that we can spend in PREEMPTING. |
| 464 // It is reset when we transition to IDLE. | 464 // It is reset when we transition to IDLE. |
| 465 base::TimeDelta max_preemption_time_; | 465 base::TimeDelta max_preemption_time_; |
| 466 // This timer is used and runs tasks on the IO thread. | 466 // This timer is used and runs tasks on the IO thread. |
| 467 scoped_ptr<base::OneShotTimer> timer_; | 467 std::unique_ptr<base::OneShotTimer> timer_; |
| 468 base::ThreadChecker io_thread_checker_; | 468 base::ThreadChecker io_thread_checker_; |
| 469 | 469 |
| 470 // Keeps track of sync point related state such as message order numbers. | 470 // Keeps track of sync point related state such as message order numbers. |
| 471 scoped_refptr<SyncPointOrderData> sync_point_order_data_; | 471 scoped_refptr<SyncPointOrderData> sync_point_order_data_; |
| 472 | 472 |
| 473 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 473 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 474 scoped_refptr<PreemptionFlag> preempting_flag_; | 474 scoped_refptr<PreemptionFlag> preempting_flag_; |
| 475 scoped_refptr<PreemptionFlag> preempted_flag_; | 475 scoped_refptr<PreemptionFlag> preempted_flag_; |
| 476 SyncPointManager* const sync_point_manager_; | 476 SyncPointManager* const sync_point_manager_; |
| 477 | 477 |
| 478 DISALLOW_COPY_AND_ASSIGN(GpuChannelMessageQueue); | 478 DISALLOW_COPY_AND_ASSIGN(GpuChannelMessageQueue); |
| 479 }; | 479 }; |
| 480 | 480 |
| 481 } // namespace gpu | 481 } // namespace gpu |
| 482 | 482 |
| 483 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_H_ | 483 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_H_ |
| OLD | NEW |