OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 #include "content/common/gpu/gpu_channel_test_common.h" | 5 #include "content/common/gpu/gpu_channel_test_common.h" |
6 | 6 |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "content/common/gpu/gpu_channel_manager_delegate.h" |
9 #include "gpu/command_buffer/service/sync_point_manager.h" | 10 #include "gpu/command_buffer/service/sync_point_manager.h" |
10 #include "ipc/ipc_test_sink.h" | 11 #include "ipc/ipc_test_sink.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
| 15 TestGpuChannelManagerDelegate::TestGpuChannelManagerDelegate() {} |
| 16 |
| 17 TestGpuChannelManagerDelegate::~TestGpuChannelManagerDelegate() {} |
| 18 |
| 19 void TestGpuChannelManagerDelegate::AddSubscription(int32_t client_id, |
| 20 unsigned int target) {} |
| 21 |
| 22 void TestGpuChannelManagerDelegate::ChannelEstablished( |
| 23 const IPC::ChannelHandle& channel_handle) { |
| 24 last_established_channel_handle_ = channel_handle; |
| 25 } |
| 26 |
| 27 void TestGpuChannelManagerDelegate::DidCreateOffscreenContext( |
| 28 const GURL& active_url) {} |
| 29 |
| 30 void TestGpuChannelManagerDelegate::DidDestroyChannel(int client_id) {} |
| 31 |
| 32 void TestGpuChannelManagerDelegate::DidDestroyOffscreenContext( |
| 33 const GURL& active_url) {} |
| 34 |
| 35 void TestGpuChannelManagerDelegate::DidLoseContext( |
| 36 bool offscreen, |
| 37 gpu::error::ContextLostReason reason, |
| 38 const GURL& active_url) {} |
| 39 |
| 40 void TestGpuChannelManagerDelegate::GpuMemoryUmaStats( |
| 41 const GPUMemoryUmaStats& params) {} |
| 42 |
| 43 void TestGpuChannelManagerDelegate::RemoveSubscription(int32_t client_id, |
| 44 unsigned int target) {} |
| 45 |
| 46 void TestGpuChannelManagerDelegate::StoreShaderToDisk( |
| 47 int32_t client_id, |
| 48 const std::string& key, |
| 49 const std::string& shader) {} |
| 50 |
14 TestGpuChannelManager::TestGpuChannelManager( | 51 TestGpuChannelManager::TestGpuChannelManager( |
15 IPC::TestSink* sink, | 52 IPC::TestSink* sink, |
| 53 GpuChannelManagerDelegate* delegate, |
16 base::SingleThreadTaskRunner* task_runner, | 54 base::SingleThreadTaskRunner* task_runner, |
17 base::SingleThreadTaskRunner* io_task_runner, | 55 base::SingleThreadTaskRunner* io_task_runner, |
18 gpu::SyncPointManager* sync_point_manager, | 56 gpu::SyncPointManager* sync_point_manager, |
19 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 57 GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
20 : GpuChannelManager(nullptr, | 58 : GpuChannelManager(delegate, |
| 59 nullptr, |
21 nullptr, | 60 nullptr, |
22 task_runner, | 61 task_runner, |
23 io_task_runner, | 62 io_task_runner, |
24 nullptr, | 63 nullptr, |
25 sync_point_manager, | 64 sync_point_manager, |
26 gpu_memory_buffer_factory), | 65 gpu_memory_buffer_factory), |
27 sink_(sink) {} | 66 sink_(sink) {} |
28 | 67 |
29 TestGpuChannelManager::~TestGpuChannelManager() { | 68 TestGpuChannelManager::~TestGpuChannelManager() { |
30 // Clear gpu channels here so that any IPC messages sent are handled using the | 69 // Clear gpu channels here so that any IPC messages sent are handled using the |
31 // overridden Send method. | 70 // overridden Send method. |
32 gpu_channels_.clear(); | 71 gpu_channels_.clear(); |
33 } | 72 } |
34 | 73 |
35 bool TestGpuChannelManager::Send(IPC::Message* msg) { | |
36 return sink_->Send(msg); | |
37 } | |
38 | |
39 scoped_ptr<GpuChannel> TestGpuChannelManager::CreateGpuChannel( | 74 scoped_ptr<GpuChannel> TestGpuChannelManager::CreateGpuChannel( |
40 int client_id, | 75 int client_id, |
41 uint64_t client_tracing_id, | 76 uint64_t client_tracing_id, |
42 bool preempts, | 77 bool preempts, |
43 bool allow_view_command_buffers, | 78 bool allow_view_command_buffers, |
44 bool allow_real_time_streams) { | 79 bool allow_real_time_streams) { |
45 return make_scoped_ptr(new TestGpuChannel( | 80 return make_scoped_ptr(new TestGpuChannel( |
46 sink_, this, sync_point_manager(), share_group(), mailbox_manager(), | 81 sink_, this, sync_point_manager(), share_group(), mailbox_manager(), |
47 preempts ? preemption_flag() : nullptr, task_runner_.get(), | 82 preempts ? preemption_flag() : nullptr, task_runner_.get(), |
48 io_task_runner_.get(), client_id, client_tracing_id, | 83 io_task_runner_.get(), client_id, client_tracing_id, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 DCHECK(!msg->is_sync()); | 129 DCHECK(!msg->is_sync()); |
95 return sink_->Send(msg); | 130 return sink_->Send(msg); |
96 } | 131 } |
97 | 132 |
98 // TODO(sunnyps): Use a mock memory buffer factory when necessary. | 133 // TODO(sunnyps): Use a mock memory buffer factory when necessary. |
99 GpuChannelTestCommon::GpuChannelTestCommon() | 134 GpuChannelTestCommon::GpuChannelTestCommon() |
100 : sink_(new IPC::TestSink), | 135 : sink_(new IPC::TestSink), |
101 task_runner_(new base::TestSimpleTaskRunner), | 136 task_runner_(new base::TestSimpleTaskRunner), |
102 io_task_runner_(new base::TestSimpleTaskRunner), | 137 io_task_runner_(new base::TestSimpleTaskRunner), |
103 sync_point_manager_(new gpu::SyncPointManager(false)), | 138 sync_point_manager_(new gpu::SyncPointManager(false)), |
104 channel_manager_(new TestGpuChannelManager(sink_.get(), | 139 channel_manager_delegate_(new TestGpuChannelManagerDelegate()), |
105 task_runner_.get(), | 140 channel_manager_( |
106 io_task_runner_.get(), | 141 new TestGpuChannelManager(sink_.get(), |
107 sync_point_manager_.get(), | 142 channel_manager_delegate_.get(), |
108 nullptr)) {} | 143 task_runner_.get(), |
| 144 io_task_runner_.get(), |
| 145 sync_point_manager_.get(), |
| 146 nullptr)) {} |
109 | 147 |
110 GpuChannelTestCommon::~GpuChannelTestCommon() {} | 148 GpuChannelTestCommon::~GpuChannelTestCommon() {} |
111 | 149 |
112 } // namespace content | 150 } // namespace content |
OLD | NEW |