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

Side by Side Diff: content/common/gpu/gpu_channel_test_common.h

Issue 1711533002: Decouple browser-specific GPU IPC messages from GPU service IPCs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restored if guards on GpuChannelManager 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 unified diff | Download patch
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/common/gpu/gpu_channel.h" 8 #include "content/common/gpu/gpu_channel.h"
9 #include "content/common/gpu/gpu_channel_manager.h" 9 #include "content/common/gpu/gpu_channel_manager.h"
10 #include "content/common/gpu/gpu_channel_manager_delegate.h"
11 #include "ipc/ipc_test_sink.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 13
12 namespace base { 14 namespace base {
13 class TestSimpleTaskRunner; 15 class TestSimpleTaskRunner;
14 } // namespace base 16 } // namespace base
15 17
16 namespace IPC { 18 namespace IPC {
17 class TestSink; 19 class TestSink;
18 } // namespace IPC 20 } // namespace IPC
19 21
20 namespace content { 22 namespace content {
21 23
22 class SyncPointManager; 24 class SyncPointManager;
23 25
26 class TestGpuChannelManagerDelegate : public GpuChannelManagerDelegate {
27 public:
28 TestGpuChannelManagerDelegate();
29 ~TestGpuChannelManagerDelegate() override;
30
31 const IPC::ChannelHandle& last_established_channel_handle() const {
32 return last_established_channel_handle_;
33 }
34
35 private:
36 // GpuChannelManagerDelegate implementation:
37 void AddSubscription(int32_t client_id, unsigned int target) override;
38 void ChannelEstablished(const IPC::ChannelHandle& channel_handle) override;
39 void DidCreateOffscreenContext(const GURL& active_url) override;
40 void DidDestroyChannel(int client_id) override;
41 void DidDestroyOffscreenContext(const GURL& active_url) override;
42 void DidLoseContext(bool offscreen,
43 gpu::error::ContextLostReason reason,
44 const GURL& active_url) override;
45 void GpuMemoryUmaStats(const GPUMemoryUmaStats& params) override;
46 void RemoveSubscription(int32_t client_id, unsigned int target) override;
47 void StoreShaderToDisk(int32_t client_id,
48 const std::string& key,
49 const std::string& shader) override;
50 #if defined(OS_MACOSX)
51 void SendAcceleratedSurfaceBuffersSwapped(
52 const AcceleratedSurfaceBuffersSwappedParams& params) override;
53 #endif
54 #if defined(OS_WIN)
55 void SendAcceleratedSurfaceCreatedChildWindow(
56 const gfx::PluginWindowHandle& parent_window,
57 const gfx::PluginWindowHandle& child_window) override;
58 #endif
59
60 IPC::ChannelHandle last_established_channel_handle_;
61
62 DISALLOW_COPY_AND_ASSIGN(TestGpuChannelManagerDelegate);
63 };
64
24 class TestGpuChannelManager : public GpuChannelManager { 65 class TestGpuChannelManager : public GpuChannelManager {
25 public: 66 public:
26 TestGpuChannelManager(IPC::TestSink* sink, 67 TestGpuChannelManager(GpuChannelManagerDelegate* delegate,
27 base::SingleThreadTaskRunner* task_runner, 68 base::SingleThreadTaskRunner* task_runner,
28 base::SingleThreadTaskRunner* io_task_runner, 69 base::SingleThreadTaskRunner* io_task_runner,
29 gpu::SyncPointManager* sync_point_manager, 70 gpu::SyncPointManager* sync_point_manager,
30 GpuMemoryBufferFactory* gpu_memory_buffer_factory); 71 GpuMemoryBufferFactory* gpu_memory_buffer_factory);
31 ~TestGpuChannelManager() override; 72 ~TestGpuChannelManager() override;
32 73
33 // IPC::Sender implementation.
34 bool Send(IPC::Message* msg) override;
35
36 protected: 74 protected:
37 scoped_ptr<GpuChannel> CreateGpuChannel( 75 scoped_ptr<GpuChannel> CreateGpuChannel(
38 int client_id, 76 int client_id,
39 uint64_t client_tracing_id, 77 uint64_t client_tracing_id,
40 bool preempts, 78 bool preempts,
41 bool allow_view_command_buffers, 79 bool allow_view_command_buffers,
42 bool allow_real_time_streams) override; 80 bool allow_real_time_streams) override;
43
44 private:
45 IPC::TestSink* const sink_;
46 }; 81 };
47 82
48 class TestGpuChannel : public GpuChannel { 83 class TestGpuChannel : public GpuChannel {
49 public: 84 public:
50 TestGpuChannel(IPC::TestSink* sink, 85 TestGpuChannel(GpuChannelManager* gpu_channel_manager,
51 GpuChannelManager* gpu_channel_manager,
52 gpu::SyncPointManager* sync_point_manager, 86 gpu::SyncPointManager* sync_point_manager,
53 gfx::GLShareGroup* share_group, 87 gfx::GLShareGroup* share_group,
54 gpu::gles2::MailboxManager* mailbox_manager, 88 gpu::gles2::MailboxManager* mailbox_manager,
55 gpu::PreemptionFlag* preempting_flag, 89 gpu::PreemptionFlag* preempting_flag,
56 gpu::PreemptionFlag* preempted_flag, 90 gpu::PreemptionFlag* preempted_flag,
57 base::SingleThreadTaskRunner* task_runner, 91 base::SingleThreadTaskRunner* task_runner,
58 base::SingleThreadTaskRunner* io_task_runner, 92 base::SingleThreadTaskRunner* io_task_runner,
59 int client_id, 93 int client_id,
60 uint64_t client_tracing_id, 94 uint64_t client_tracing_id,
61 bool allow_view_command_buffers, 95 bool allow_view_command_buffers,
62 bool allow_real_time_streams); 96 bool allow_real_time_streams);
63 ~TestGpuChannel() override; 97 ~TestGpuChannel() override;
64 98
99 IPC::TestSink* sink() { return &sink_; }
65 base::ProcessId GetClientPID() const override; 100 base::ProcessId GetClientPID() const override;
66 101
67 IPC::ChannelHandle Init(base::WaitableEvent* shutdown_event) override; 102 IPC::ChannelHandle Init(base::WaitableEvent* shutdown_event) override;
68 103
69 // IPC::Sender implementation. 104 // IPC::Sender implementation.
70 bool Send(IPC::Message* msg) override; 105 bool Send(IPC::Message* msg) override;
71 106
72 private: 107 private:
73 IPC::TestSink* const sink_; 108 IPC::TestSink sink_;
74 }; 109 };
75 110
76 class GpuChannelTestCommon : public testing::Test { 111 class GpuChannelTestCommon : public testing::Test {
77 public: 112 public:
78 GpuChannelTestCommon(); 113 GpuChannelTestCommon();
79 ~GpuChannelTestCommon() override; 114 ~GpuChannelTestCommon() override;
80 115
81 protected: 116 protected:
82 IPC::TestSink* sink() { return sink_.get(); }
83 GpuChannelManager* channel_manager() { return channel_manager_.get(); } 117 GpuChannelManager* channel_manager() { return channel_manager_.get(); }
118 TestGpuChannelManagerDelegate* channel_manager_delegate() {
119 return channel_manager_delegate_.get();
120 }
84 base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); } 121 base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); }
85 122
86 private: 123 private:
87 scoped_ptr<IPC::TestSink> sink_;
88 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 124 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
89 scoped_refptr<base::TestSimpleTaskRunner> io_task_runner_; 125 scoped_refptr<base::TestSimpleTaskRunner> io_task_runner_;
90 scoped_ptr<gpu::SyncPointManager> sync_point_manager_; 126 scoped_ptr<gpu::SyncPointManager> sync_point_manager_;
127 scoped_ptr<TestGpuChannelManagerDelegate> channel_manager_delegate_;
91 scoped_ptr<GpuChannelManager> channel_manager_; 128 scoped_ptr<GpuChannelManager> channel_manager_;
92 }; 129 };
93 130
94 } // namespace content 131 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager_unittest.cc ('k') | content/common/gpu/gpu_channel_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698