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

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

Issue 1730023004: Revert of Decouple browser-specific GPU IPC messages from GPU service IPCs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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"
12 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
13 11
14 namespace base { 12 namespace base {
15 class TestSimpleTaskRunner; 13 class TestSimpleTaskRunner;
16 } // namespace base 14 } // namespace base
17 15
18 namespace IPC { 16 namespace IPC {
19 class TestSink; 17 class TestSink;
20 } // namespace IPC 18 } // namespace IPC
21 19
22 namespace content { 20 namespace content {
23 21
24 class SyncPointManager; 22 class SyncPointManager;
25 23
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
65 class TestGpuChannelManager : public GpuChannelManager { 24 class TestGpuChannelManager : public GpuChannelManager {
66 public: 25 public:
67 TestGpuChannelManager(GpuChannelManagerDelegate* delegate, 26 TestGpuChannelManager(IPC::TestSink* sink,
68 base::SingleThreadTaskRunner* task_runner, 27 base::SingleThreadTaskRunner* task_runner,
69 base::SingleThreadTaskRunner* io_task_runner, 28 base::SingleThreadTaskRunner* io_task_runner,
70 gpu::SyncPointManager* sync_point_manager, 29 gpu::SyncPointManager* sync_point_manager,
71 GpuMemoryBufferFactory* gpu_memory_buffer_factory); 30 GpuMemoryBufferFactory* gpu_memory_buffer_factory);
72 ~TestGpuChannelManager() override; 31 ~TestGpuChannelManager() override;
73 32
33 // IPC::Sender implementation.
34 bool Send(IPC::Message* msg) override;
35
74 protected: 36 protected:
75 scoped_ptr<GpuChannel> CreateGpuChannel( 37 scoped_ptr<GpuChannel> CreateGpuChannel(
76 int client_id, 38 int client_id,
77 uint64_t client_tracing_id, 39 uint64_t client_tracing_id,
78 bool preempts, 40 bool preempts,
79 bool allow_view_command_buffers, 41 bool allow_view_command_buffers,
80 bool allow_real_time_streams) override; 42 bool allow_real_time_streams) override;
43
44 private:
45 IPC::TestSink* const sink_;
81 }; 46 };
82 47
83 class TestGpuChannel : public GpuChannel { 48 class TestGpuChannel : public GpuChannel {
84 public: 49 public:
85 TestGpuChannel(GpuChannelManager* gpu_channel_manager, 50 TestGpuChannel(IPC::TestSink* sink,
51 GpuChannelManager* gpu_channel_manager,
86 gpu::SyncPointManager* sync_point_manager, 52 gpu::SyncPointManager* sync_point_manager,
87 gfx::GLShareGroup* share_group, 53 gfx::GLShareGroup* share_group,
88 gpu::gles2::MailboxManager* mailbox_manager, 54 gpu::gles2::MailboxManager* mailbox_manager,
89 gpu::PreemptionFlag* preempting_flag, 55 gpu::PreemptionFlag* preempting_flag,
90 gpu::PreemptionFlag* preempted_flag, 56 gpu::PreemptionFlag* preempted_flag,
91 base::SingleThreadTaskRunner* task_runner, 57 base::SingleThreadTaskRunner* task_runner,
92 base::SingleThreadTaskRunner* io_task_runner, 58 base::SingleThreadTaskRunner* io_task_runner,
93 int client_id, 59 int client_id,
94 uint64_t client_tracing_id, 60 uint64_t client_tracing_id,
95 bool allow_view_command_buffers, 61 bool allow_view_command_buffers,
96 bool allow_real_time_streams); 62 bool allow_real_time_streams);
97 ~TestGpuChannel() override; 63 ~TestGpuChannel() override;
98 64
99 IPC::TestSink* sink() { return &sink_; }
100 base::ProcessId GetClientPID() const override; 65 base::ProcessId GetClientPID() const override;
101 66
102 IPC::ChannelHandle Init(base::WaitableEvent* shutdown_event) override; 67 IPC::ChannelHandle Init(base::WaitableEvent* shutdown_event) override;
103 68
104 // IPC::Sender implementation. 69 // IPC::Sender implementation.
105 bool Send(IPC::Message* msg) override; 70 bool Send(IPC::Message* msg) override;
106 71
107 private: 72 private:
108 IPC::TestSink sink_; 73 IPC::TestSink* const sink_;
109 }; 74 };
110 75
111 class GpuChannelTestCommon : public testing::Test { 76 class GpuChannelTestCommon : public testing::Test {
112 public: 77 public:
113 GpuChannelTestCommon(); 78 GpuChannelTestCommon();
114 ~GpuChannelTestCommon() override; 79 ~GpuChannelTestCommon() override;
115 80
116 protected: 81 protected:
82 IPC::TestSink* sink() { return sink_.get(); }
117 GpuChannelManager* channel_manager() { return channel_manager_.get(); } 83 GpuChannelManager* channel_manager() { return channel_manager_.get(); }
118 TestGpuChannelManagerDelegate* channel_manager_delegate() {
119 return channel_manager_delegate_.get();
120 }
121 base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); } 84 base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); }
122 85
123 private: 86 private:
87 scoped_ptr<IPC::TestSink> sink_;
124 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 88 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
125 scoped_refptr<base::TestSimpleTaskRunner> io_task_runner_; 89 scoped_refptr<base::TestSimpleTaskRunner> io_task_runner_;
126 scoped_ptr<gpu::SyncPointManager> sync_point_manager_; 90 scoped_ptr<gpu::SyncPointManager> sync_point_manager_;
127 scoped_ptr<TestGpuChannelManagerDelegate> channel_manager_delegate_;
128 scoped_ptr<GpuChannelManager> channel_manager_; 91 scoped_ptr<GpuChannelManager> channel_manager_;
129 }; 92 };
130 93
131 } // namespace content 94 } // 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