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

Side by Side Diff: ui/ozone/public/ozone_gpu_test_helper.cc

Issue 1308993007: [Ozone] Update GPUTestHelper to properly use the message filter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/ozone/public/ozone_gpu_test_helper.h" 5 #include "ui/ozone/public/ozone_gpu_test_helper.h"
6 6
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "ipc/ipc_listener.h" 8 #include "ipc/ipc_listener.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "ipc/ipc_sender.h" 10 #include "ipc/ipc_sender.h"
11 #include "ipc/message_filter.h" 11 #include "ipc/message_filter.h"
12 #include "ui/ozone/public/gpu_platform_support.h" 12 #include "ui/ozone/public/gpu_platform_support.h"
13 #include "ui/ozone/public/gpu_platform_support_host.h" 13 #include "ui/ozone/public/gpu_platform_support_host.h"
14 #include "ui/ozone/public/ozone_platform.h" 14 #include "ui/ozone/public/ozone_platform.h"
15 15
16 namespace ui { 16 namespace ui {
17 17
18 namespace { 18 namespace {
19 19
20 const int kGpuProcessHostId = 1; 20 const int kGpuProcessHostId = 1;
21 21
22 } // namespace 22 void DispatchToGpuPlatformSupportHostTask(IPC::Message* msg) {
23
24 static void DispatchToGpuPlatformSupportHostTask(IPC::Message* msg) {
25 ui::OzonePlatform::GetInstance() 23 ui::OzonePlatform::GetInstance()
26 ->GetGpuPlatformSupportHost() 24 ->GetGpuPlatformSupportHost()
27 ->OnMessageReceived(*msg); 25 ->OnMessageReceived(*msg);
28 delete msg; 26 delete msg;
29 } 27 }
30 28
29 void DispatchToGpuPlatformSupportTask(IPC::Message* msg) {
30 ui::OzonePlatform::GetInstance()->GetGpuPlatformSupport()->OnMessageReceived(
31 *msg);
32 delete msg;
33 }
34
35 void DispatchToGpuPlatformSupportTaskOnIO(
36 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner,
37 IPC::Message* msg) {
38 IPC::MessageFilter* filter = ui::OzonePlatform::GetInstance()
39 ->GetGpuPlatformSupport()
40 ->GetMessageFilter();
41 if (filter && filter->OnMessageReceived(*msg)) {
42 delete msg;
43 return;
44 }
45
46 gpu_task_runner->PostTask(FROM_HERE,
47 base::Bind(DispatchToGpuPlatformSupportTask, msg));
48 }
49
50 } // namespace
51
31 class FakeGpuProcess : public IPC::Sender { 52 class FakeGpuProcess : public IPC::Sender {
32 public: 53 public:
33 FakeGpuProcess( 54 FakeGpuProcess(
34 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) 55 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner)
35 : ui_task_runner_(ui_task_runner) {} 56 : ui_task_runner_(ui_task_runner) {}
36 ~FakeGpuProcess() override {} 57 ~FakeGpuProcess() override {}
37 58
38 void Init() { 59 void Init() {
39 ui::OzonePlatform::GetInstance() 60 ui::OzonePlatform::GetInstance()
40 ->GetGpuPlatformSupport() 61 ->GetGpuPlatformSupport()
(...skipping 12 matching lines...) Expand all
53 bool Send(IPC::Message* msg) override { 74 bool Send(IPC::Message* msg) override {
54 ui_task_runner_->PostTask( 75 ui_task_runner_->PostTask(
55 FROM_HERE, base::Bind(&DispatchToGpuPlatformSupportHostTask, msg)); 76 FROM_HERE, base::Bind(&DispatchToGpuPlatformSupportHostTask, msg));
56 return true; 77 return true;
57 } 78 }
58 79
59 private: 80 private:
60 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 81 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
61 }; 82 };
62 83
63 static void DispatchToGpuPlatformSupportTask(IPC::Message* msg) {
64 ui::OzonePlatform::GetInstance()->GetGpuPlatformSupport()->OnMessageReceived(
65 *msg);
66 delete msg;
67 }
68
69 class FakeGpuProcessHost { 84 class FakeGpuProcessHost {
70 public: 85 public:
71 FakeGpuProcessHost( 86 FakeGpuProcessHost(
72 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) 87 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner,
73 : gpu_task_runner_(gpu_task_runner) {} 88 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_io_task_runner)
89 : gpu_task_runner_(gpu_task_runner),
90 gpu_io_task_runner_(gpu_io_task_runner) {}
74 ~FakeGpuProcessHost() {} 91 ~FakeGpuProcessHost() {}
75 92
76 void Init() { 93 void Init() {
77 base::Callback<void(IPC::Message*)> sender = 94 base::Callback<void(IPC::Message*)> sender =
78 base::Bind(&DispatchToGpuPlatformSupportTask); 95 base::Bind(&DispatchToGpuPlatformSupportTaskOnIO, gpu_task_runner_);
79 96
80 ui::OzonePlatform::GetInstance() 97 ui::OzonePlatform::GetInstance()
81 ->GetGpuPlatformSupportHost() 98 ->GetGpuPlatformSupportHost()
82 ->OnChannelEstablished(kGpuProcessHostId, gpu_task_runner_, sender); 99 ->OnChannelEstablished(kGpuProcessHostId, gpu_io_task_runner_, sender);
83 } 100 }
84 101
85 private: 102 private:
86 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; 103 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_;
104 scoped_refptr<base::SingleThreadTaskRunner> gpu_io_task_runner_;
87 }; 105 };
88 106
89 OzoneGpuTestHelper::OzoneGpuTestHelper() { 107 OzoneGpuTestHelper::OzoneGpuTestHelper() {
90 } 108 }
91 109
92 OzoneGpuTestHelper::~OzoneGpuTestHelper() { 110 OzoneGpuTestHelper::~OzoneGpuTestHelper() {
93 } 111 }
94 112
95 bool OzoneGpuTestHelper::Initialize( 113 bool OzoneGpuTestHelper::Initialize(
96 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, 114 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
97 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) { 115 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) {
98 io_helper_thread_.reset(new base::Thread("IOHelperThread")); 116 io_helper_thread_.reset(new base::Thread("IOHelperThread"));
99 if (!io_helper_thread_->StartWithOptions( 117 if (!io_helper_thread_->StartWithOptions(
100 base::Thread::Options(base::MessageLoop::TYPE_IO, 0))) 118 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)))
101 return false; 119 return false;
102 120
103 fake_gpu_process_.reset(new FakeGpuProcess(ui_task_runner)); 121 fake_gpu_process_.reset(new FakeGpuProcess(ui_task_runner));
104 io_helper_thread_->task_runner()->PostTask( 122 io_helper_thread_->task_runner()->PostTask(
105 FROM_HERE, base::Bind(&FakeGpuProcess::InitOnIO, 123 FROM_HERE, base::Bind(&FakeGpuProcess::InitOnIO,
106 base::Unretained(fake_gpu_process_.get()))); 124 base::Unretained(fake_gpu_process_.get())));
107 fake_gpu_process_->Init(); 125 fake_gpu_process_->Init();
108 126
109 fake_gpu_process_host_.reset(new FakeGpuProcessHost(gpu_task_runner)); 127 fake_gpu_process_host_.reset(new FakeGpuProcessHost(
128 gpu_task_runner, io_helper_thread_->task_runner()));
110 fake_gpu_process_host_->Init(); 129 fake_gpu_process_host_->Init();
111 130
112 return true; 131 return true;
113 } 132 }
114 133
115 } // namespace ui 134 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698