| 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 "gpu/command_buffer/service/sync_point_manager.h" | 9 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 10 #include "ipc/ipc_test_sink.h" | 10 #include "ipc/ipc_test_sink.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 TestGpuChannelManager::TestGpuChannelManager( | 14 TestGpuChannelManager::TestGpuChannelManager( |
| 15 IPC::TestSink* sink, | 15 IPC::TestSink* sink, |
| 16 base::SingleThreadTaskRunner* task_runner, | 16 base::SingleThreadTaskRunner* task_runner, |
| 17 base::SingleThreadTaskRunner* io_task_runner, | 17 base::SingleThreadTaskRunner* io_task_runner, |
| 18 gpu::SyncPointManager* sync_point_manager, | 18 gpu::SyncPointManager* sync_point_manager, |
| 19 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 19 GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
| 20 : GpuChannelManager(nullptr, | 20 : GpuChannelManager(nullptr, |
| 21 nullptr, | 21 nullptr, |
| 22 task_runner, | 22 task_runner, |
| 23 io_task_runner, | 23 io_task_runner, |
| 24 nullptr, | 24 nullptr, |
| 25 nullptr, | |
| 26 sync_point_manager, | 25 sync_point_manager, |
| 27 gpu_memory_buffer_factory), | 26 gpu_memory_buffer_factory), |
| 28 sink_(sink) {} | 27 sink_(sink) {} |
| 29 | 28 |
| 30 TestGpuChannelManager::~TestGpuChannelManager() { | 29 TestGpuChannelManager::~TestGpuChannelManager() { |
| 31 // Clear gpu channels here so that any IPC messages sent are handled using the | 30 // Clear gpu channels here so that any IPC messages sent are handled using the |
| 32 // overridden Send method. | 31 // overridden Send method. |
| 33 gpu_channels_.clear(); | 32 gpu_channels_.clear(); |
| 34 } | 33 } |
| 35 | 34 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 TestGpuChannel::~TestGpuChannel() { | 75 TestGpuChannel::~TestGpuChannel() { |
| 77 // Call stubs here so that any IPC messages sent are handled using the | 76 // Call stubs here so that any IPC messages sent are handled using the |
| 78 // overridden Send method. | 77 // overridden Send method. |
| 79 stubs_.clear(); | 78 stubs_.clear(); |
| 80 } | 79 } |
| 81 | 80 |
| 82 base::ProcessId TestGpuChannel::GetClientPID() const { | 81 base::ProcessId TestGpuChannel::GetClientPID() const { |
| 83 return base::kNullProcessId; | 82 return base::kNullProcessId; |
| 84 } | 83 } |
| 85 | 84 |
| 86 IPC::ChannelHandle TestGpuChannel::Init( | 85 IPC::ChannelHandle TestGpuChannel::Init(base::WaitableEvent* shutdown_event) { |
| 87 base::WaitableEvent* shutdown_event, | |
| 88 IPC::AttachmentBroker* attachment_broker) { | |
| 89 filter_->OnFilterAdded(sink_); | 86 filter_->OnFilterAdded(sink_); |
| 90 return IPC::ChannelHandle(channel_id()); | 87 return IPC::ChannelHandle(channel_id()); |
| 91 } | 88 } |
| 92 | 89 |
| 93 bool TestGpuChannel::Send(IPC::Message* msg) { | 90 bool TestGpuChannel::Send(IPC::Message* msg) { |
| 94 DCHECK(!msg->is_sync()); | 91 DCHECK(!msg->is_sync()); |
| 95 return sink_->Send(msg); | 92 return sink_->Send(msg); |
| 96 } | 93 } |
| 97 | 94 |
| 98 // TODO(sunnyps): Use a mock memory buffer factory when necessary. | 95 // TODO(sunnyps): Use a mock memory buffer factory when necessary. |
| 99 GpuChannelTestCommon::GpuChannelTestCommon() | 96 GpuChannelTestCommon::GpuChannelTestCommon() |
| 100 : sink_(new IPC::TestSink), | 97 : sink_(new IPC::TestSink), |
| 101 task_runner_(new base::TestSimpleTaskRunner), | 98 task_runner_(new base::TestSimpleTaskRunner), |
| 102 io_task_runner_(new base::TestSimpleTaskRunner), | 99 io_task_runner_(new base::TestSimpleTaskRunner), |
| 103 sync_point_manager_(new gpu::SyncPointManager(false)), | 100 sync_point_manager_(new gpu::SyncPointManager(false)), |
| 104 channel_manager_(new TestGpuChannelManager(sink_.get(), | 101 channel_manager_(new TestGpuChannelManager(sink_.get(), |
| 105 task_runner_.get(), | 102 task_runner_.get(), |
| 106 io_task_runner_.get(), | 103 io_task_runner_.get(), |
| 107 sync_point_manager_.get(), | 104 sync_point_manager_.get(), |
| 108 nullptr)) {} | 105 nullptr)) {} |
| 109 | 106 |
| 110 GpuChannelTestCommon::~GpuChannelTestCommon() {} | 107 GpuChannelTestCommon::~GpuChannelTestCommon() {} |
| 111 | 108 |
| 112 } // namespace content | 109 } // namespace content |
| OLD | NEW |