Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: content/common/gpu/gpu_channel_test_common.cc

Issue 1846253003: Revert of Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/gpu_channel_test_common.h ('k') | content/common/gpu/gpu_channel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/gpu_channel_test_common.cc
diff --git a/content/common/gpu/gpu_channel_test_common.cc b/content/common/gpu/gpu_channel_test_common.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fe6f700014dca4e232da161ef52cd0e9b759b2bf
--- /dev/null
+++ b/content/common/gpu/gpu_channel_test_common.cc
@@ -0,0 +1,169 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/gpu/gpu_channel_test_common.h"
+
+#include "base/test/test_simple_task_runner.h"
+#include "base/thread_task_runner_handle.h"
+#include "content/common/gpu/gpu_channel_manager_delegate.h"
+#include "gpu/command_buffer/service/sync_point_manager.h"
+#include "ipc/ipc_test_sink.h"
+#include "url/gurl.h"
+
+namespace content {
+
+TestGpuChannelManagerDelegate::TestGpuChannelManagerDelegate() {}
+
+TestGpuChannelManagerDelegate::~TestGpuChannelManagerDelegate() {}
+
+void TestGpuChannelManagerDelegate::SetActiveURL(const GURL& url) {}
+
+void TestGpuChannelManagerDelegate::AddSubscription(int32_t client_id,
+ unsigned int target) {}
+
+void TestGpuChannelManagerDelegate::DidCreateOffscreenContext(
+ const GURL& active_url) {}
+
+void TestGpuChannelManagerDelegate::DidDestroyChannel(int client_id) {}
+
+void TestGpuChannelManagerDelegate::DidDestroyOffscreenContext(
+ const GURL& active_url) {}
+
+void TestGpuChannelManagerDelegate::DidLoseContext(
+ bool offscreen,
+ gpu::error::ContextLostReason reason,
+ const GURL& active_url) {}
+
+void TestGpuChannelManagerDelegate::GpuMemoryUmaStats(
+ const gpu::GPUMemoryUmaStats& params) {}
+
+void TestGpuChannelManagerDelegate::RemoveSubscription(int32_t client_id,
+ unsigned int target) {}
+
+void TestGpuChannelManagerDelegate::StoreShaderToDisk(
+ int32_t client_id,
+ const std::string& key,
+ const std::string& shader) {}
+
+#if defined(OS_MACOSX)
+void TestGpuChannelManagerDelegate::SendAcceleratedSurfaceBuffersSwapped(
+ int32_t surface_id,
+ CAContextID ca_context_id,
+ const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface,
+ const gfx::Size& size,
+ float scale_factor,
+ std::vector<ui::LatencyInfo> latency_info) {}
+#endif
+
+#if defined(OS_WIN)
+void TestGpuChannelManagerDelegate::SendAcceleratedSurfaceCreatedChildWindow(
+ gpu::SurfaceHandle parent_window,
+ gpu::SurfaceHandle child_window) {}
+#endif
+
+TestGpuChannelManager::TestGpuChannelManager(
+ const gpu::GpuPreferences& gpu_preferences,
+ GpuChannelManagerDelegate* delegate,
+ base::SingleThreadTaskRunner* task_runner,
+ base::SingleThreadTaskRunner* io_task_runner,
+ gpu::SyncPointManager* sync_point_manager,
+ GpuMemoryBufferFactory* gpu_memory_buffer_factory)
+ : GpuChannelManager(gpu_preferences,
+ delegate,
+ nullptr,
+ task_runner,
+ io_task_runner,
+ nullptr,
+ sync_point_manager,
+ gpu_memory_buffer_factory) {}
+
+TestGpuChannelManager::~TestGpuChannelManager() {
+ // Clear gpu channels here so that any IPC messages sent are handled using the
+ // overridden Send method.
+ gpu_channels_.clear();
+}
+
+scoped_ptr<GpuChannel> TestGpuChannelManager::CreateGpuChannel(
+ int client_id,
+ uint64_t client_tracing_id,
+ bool preempts,
+ bool allow_view_command_buffers,
+ bool allow_real_time_streams) {
+ return make_scoped_ptr(new TestGpuChannel(
+ this, sync_point_manager(), share_group(), mailbox_manager(),
+ preempts ? preemption_flag() : nullptr,
+ preempts ? nullptr : preemption_flag(), task_runner_.get(),
+ io_task_runner_.get(), client_id, client_tracing_id,
+ allow_view_command_buffers, allow_real_time_streams));
+}
+
+TestGpuChannel::TestGpuChannel(GpuChannelManager* gpu_channel_manager,
+ gpu::SyncPointManager* sync_point_manager,
+ gfx::GLShareGroup* share_group,
+ gpu::gles2::MailboxManager* mailbox_manager,
+ gpu::PreemptionFlag* preempting_flag,
+ gpu::PreemptionFlag* preempted_flag,
+ base::SingleThreadTaskRunner* task_runner,
+ base::SingleThreadTaskRunner* io_task_runner,
+ int client_id,
+ uint64_t client_tracing_id,
+ bool allow_view_command_buffers,
+ bool allow_real_time_streams)
+ : GpuChannel(gpu_channel_manager,
+ sync_point_manager,
+ nullptr,
+ share_group,
+ mailbox_manager,
+ preempting_flag,
+ preempted_flag,
+ task_runner,
+ io_task_runner,
+ client_id,
+ client_tracing_id,
+ allow_view_command_buffers,
+ allow_real_time_streams) {}
+
+TestGpuChannel::~TestGpuChannel() {
+ // Call stubs here so that any IPC messages sent are handled using the
+ // overridden Send method.
+ stubs_.clear();
+}
+
+base::ProcessId TestGpuChannel::GetClientPID() const {
+ return base::kNullProcessId;
+}
+
+IPC::ChannelHandle TestGpuChannel::Init(base::WaitableEvent* shutdown_event) {
+ filter_->OnFilterAdded(&sink_);
+ return IPC::ChannelHandle(channel_id());
+}
+
+bool TestGpuChannel::Send(IPC::Message* msg) {
+ DCHECK(!msg->is_sync());
+ return sink_.Send(msg);
+}
+
+// TODO(sunnyps): Use a mock memory buffer factory when necessary.
+GpuChannelTestCommon::GpuChannelTestCommon()
+ : task_runner_(new base::TestSimpleTaskRunner),
+ io_task_runner_(new base::TestSimpleTaskRunner),
+ sync_point_manager_(new gpu::SyncPointManager(false)),
+ channel_manager_delegate_(new TestGpuChannelManagerDelegate()),
+ channel_manager_(
+ new TestGpuChannelManager(gpu_preferences_,
+ channel_manager_delegate_.get(),
+ task_runner_.get(),
+ io_task_runner_.get(),
+ sync_point_manager_.get(),
+ nullptr)) {}
+
+GpuChannelTestCommon::~GpuChannelTestCommon() {
+ // Destroying channels causes tasks to run on the IO task runner.
+ channel_manager_ = nullptr;
+ // Clear pending tasks to avoid refptr cycles that get flagged by ASAN.
+ task_runner_->ClearPendingTasks();
+ io_task_runner_->ClearPendingTasks();
+}
+
+} // namespace content
« no previous file with comments | « content/common/gpu/gpu_channel_test_common.h ('k') | content/common/gpu/gpu_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698