OLD | NEW |
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/threading/thread_task_runner_handle.h" | 7 #include "base/threading/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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 void DispatchToGpuPlatformSupportTaskOnIO(IPC::Message* msg) { | 28 void DispatchToGpuPlatformSupportTaskOnIO(IPC::Message* msg) { |
29 IPC::MessageFilter* filter = | 29 IPC::MessageFilter* filter = |
30 ui::OzonePlatform::GetInstance()->GetGpuMessageFilter(); | 30 ui::OzonePlatform::GetInstance()->GetGpuMessageFilter(); |
31 if (filter) | 31 if (filter) |
32 filter->OnMessageReceived(*msg); | 32 filter->OnMessageReceived(*msg); |
33 delete msg; | 33 delete msg; |
34 } | 34 } |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 class FakeGpuProcess : public IPC::Sender { | 38 class FakeGpuProcess : public IPC::Channel { |
39 public: | 39 public: |
40 FakeGpuProcess( | 40 FakeGpuProcess( |
41 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) | 41 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) |
42 : ui_task_runner_(ui_task_runner) {} | 42 : ui_task_runner_(ui_task_runner) {} |
43 ~FakeGpuProcess() override {} | 43 ~FakeGpuProcess() override {} |
44 | 44 |
45 void Init() { | |
46 } | |
47 | |
48 void InitOnIO() { | 45 void InitOnIO() { |
49 IPC::MessageFilter* filter = | 46 IPC::MessageFilter* filter = |
50 ui::OzonePlatform::GetInstance()->GetGpuMessageFilter(); | 47 ui::OzonePlatform::GetInstance()->GetGpuMessageFilter(); |
51 | 48 |
52 if (filter) | 49 if (filter) |
53 filter->OnFilterAdded(this); | 50 filter->OnFilterAdded(this); |
54 } | 51 } |
55 | 52 |
| 53 // IPC::Channel implementation: |
56 bool Send(IPC::Message* msg) override { | 54 bool Send(IPC::Message* msg) override { |
57 ui_task_runner_->PostTask( | 55 ui_task_runner_->PostTask( |
58 FROM_HERE, base::Bind(&DispatchToGpuPlatformSupportHostTask, msg)); | 56 FROM_HERE, base::Bind(&DispatchToGpuPlatformSupportHostTask, msg)); |
59 return true; | 57 return true; |
60 } | 58 } |
61 | 59 |
| 60 bool Connect() override { |
| 61 NOTREACHED(); |
| 62 return false; |
| 63 } |
| 64 |
| 65 void Close() override { NOTREACHED(); } |
| 66 |
| 67 base::ProcessId GetPeerPID() const override { |
| 68 NOTREACHED(); |
| 69 return base::kNullProcessId; |
| 70 } |
| 71 |
| 72 base::ProcessId GetSelfPID() const override { |
| 73 NOTREACHED(); |
| 74 return base::kNullProcessId; |
| 75 } |
| 76 |
| 77 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) |
| 78 int GetClientFileDescriptor() const override { |
| 79 NOTREACHED(); |
| 80 return 0; |
| 81 } |
| 82 |
| 83 base::ScopedFD TakeClientFileDescriptor() override { |
| 84 NOTREACHED(); |
| 85 return base::ScopedFD(); |
| 86 } |
| 87 #endif |
| 88 |
62 private: | 89 private: |
63 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 90 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
64 }; | 91 }; |
65 | 92 |
66 class FakeGpuProcessHost { | 93 class FakeGpuProcessHost { |
67 public: | 94 public: |
68 FakeGpuProcessHost( | 95 FakeGpuProcessHost( |
69 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner, | 96 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner, |
70 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_io_task_runner) | 97 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_io_task_runner) |
71 : gpu_task_runner_(gpu_task_runner), | 98 : gpu_task_runner_(gpu_task_runner), |
(...skipping 25 matching lines...) Expand all Loading... |
97 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) { | 124 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) { |
98 io_helper_thread_.reset(new base::Thread("IOHelperThread")); | 125 io_helper_thread_.reset(new base::Thread("IOHelperThread")); |
99 if (!io_helper_thread_->StartWithOptions( | 126 if (!io_helper_thread_->StartWithOptions( |
100 base::Thread::Options(base::MessageLoop::TYPE_IO, 0))) | 127 base::Thread::Options(base::MessageLoop::TYPE_IO, 0))) |
101 return false; | 128 return false; |
102 | 129 |
103 fake_gpu_process_.reset(new FakeGpuProcess(ui_task_runner)); | 130 fake_gpu_process_.reset(new FakeGpuProcess(ui_task_runner)); |
104 io_helper_thread_->task_runner()->PostTask( | 131 io_helper_thread_->task_runner()->PostTask( |
105 FROM_HERE, base::Bind(&FakeGpuProcess::InitOnIO, | 132 FROM_HERE, base::Bind(&FakeGpuProcess::InitOnIO, |
106 base::Unretained(fake_gpu_process_.get()))); | 133 base::Unretained(fake_gpu_process_.get()))); |
107 fake_gpu_process_->Init(); | |
108 | 134 |
109 fake_gpu_process_host_.reset(new FakeGpuProcessHost( | 135 fake_gpu_process_host_.reset(new FakeGpuProcessHost( |
110 gpu_task_runner, io_helper_thread_->task_runner())); | 136 gpu_task_runner, io_helper_thread_->task_runner())); |
111 fake_gpu_process_host_->Init(); | 137 fake_gpu_process_host_->Init(); |
112 | 138 |
113 return true; | 139 return true; |
114 } | 140 } |
115 | 141 |
116 } // namespace ui | 142 } // namespace ui |
OLD | NEW |