OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "base/synchronization/waitable_event.h" | 6 #include "base/synchronization/waitable_event.h" |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.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_messages.h" | 10 #include "content/common/gpu/gpu_messages.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 void Release() { } | 37 void Release() { } |
38 bool Send(Message* msg) override { return channel_->Send(msg); } | 38 bool Send(Message* msg) override { return channel_->Send(msg); } |
39 | 39 |
40 virtual void Start() { | 40 virtual void Start() { |
41 StartThread(&ipc_thread_, base::MessageLoop::TYPE_IO); | 41 StartThread(&ipc_thread_, base::MessageLoop::TYPE_IO); |
42 channel_.reset(CreateChannel()); | 42 channel_.reset(CreateChannel()); |
43 } | 43 } |
44 | 44 |
45 virtual void Shutdown() { | 45 virtual void Shutdown() { |
46 WaitableEvent ipc_done(false, false); | 46 WaitableEvent ipc_done(false, false); |
47 ipc_thread_.message_loop()->PostTask( | 47 ipc_thread_.task_runner()->PostTask( |
48 FROM_HERE, base::Bind(&SimpleWorker::OnShutdown, this, &ipc_done)); | 48 FROM_HERE, base::Bind(&SimpleWorker::OnShutdown, this, &ipc_done)); |
49 | 49 |
50 channel_.reset(); | 50 channel_.reset(); |
51 | 51 |
52 ipc_done.Wait(); | 52 ipc_done.Wait(); |
53 ipc_thread_.Stop(); | 53 ipc_thread_.Stop(); |
54 } | 54 } |
55 | 55 |
56 protected: | 56 protected: |
57 SyncChannel* CreateChannel() { | 57 SyncChannel* CreateChannel() { |
58 scoped_ptr<SyncChannel> channel = SyncChannel::Create( | 58 scoped_ptr<SyncChannel> channel = SyncChannel::Create( |
59 channel_name_, mode_, this, ipc_thread_.message_loop_proxy().get(), | 59 channel_name_, mode_, this, ipc_thread_.task_runner().get(), true, |
60 true, &shutdown_event_); | 60 &shutdown_event_); |
61 return channel.release(); | 61 return channel.release(); |
62 } | 62 } |
63 | 63 |
64 void OnShutdown(WaitableEvent* ipc_event) { | 64 void OnShutdown(WaitableEvent* ipc_event) { |
65 base::RunLoop().RunUntilIdle(); | 65 base::RunLoop().RunUntilIdle(); |
66 ipc_event->Signal(); | 66 ipc_event->Signal(); |
67 } | 67 } |
68 | 68 |
69 const base::Thread& ipc_thread() const { return ipc_thread_; } | 69 const base::Thread& ipc_thread() const { return ipc_thread_; } |
70 | 70 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 class SimpleGpuClient : public IPC::SimpleWorker { | 104 class SimpleGpuClient : public IPC::SimpleWorker { |
105 public: | 105 public: |
106 SimpleGpuClient() | 106 SimpleGpuClient() |
107 : IPC::SimpleWorker(IPC::Channel::MODE_CLIENT, "simple_client"), | 107 : IPC::SimpleWorker(IPC::Channel::MODE_CLIENT, "simple_client"), |
108 router_(this) { | 108 router_(this) { |
109 } | 109 } |
110 | 110 |
111 void Start() override { | 111 void Start() override { |
112 IPC::SimpleWorker::Start(); | 112 IPC::SimpleWorker::Start(); |
113 gpu_channel_manager_.reset( | 113 gpu_channel_manager_.reset( |
114 new GpuChannelManager(&router_, | 114 new GpuChannelManager(&router_, NULL, ipc_thread().task_runner().get(), |
115 NULL, | 115 shutdown_event(), channel())); |
116 ipc_thread().message_loop_proxy().get(), | |
117 shutdown_event(), | |
118 channel())); | |
119 } | 116 } |
120 | 117 |
121 void Shutdown() override { | 118 void Shutdown() override { |
122 gpu_channel_manager_.reset(); | 119 gpu_channel_manager_.reset(); |
123 IPC::SimpleWorker::Shutdown(); | 120 IPC::SimpleWorker::Shutdown(); |
124 } | 121 } |
125 | 122 |
126 GpuChannelManager* gpu_channel_manager() { | 123 GpuChannelManager* gpu_channel_manager() { |
127 return gpu_channel_manager_.get(); | 124 return gpu_channel_manager_.get(); |
128 } | 125 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 const ValueState* state2 = | 214 const ValueState* state2 = |
218 pending_value_buffer_state2->GetState(GL_MOUSE_POSITION_CHROMIUM); | 215 pending_value_buffer_state2->GetState(GL_MOUSE_POSITION_CHROMIUM); |
219 ASSERT_NE(state1, state2); | 216 ASSERT_NE(state1, state2); |
220 | 217 |
221 ASSERT_EQ(state1->int_value[0], value_state1.int_value[0]); | 218 ASSERT_EQ(state1->int_value[0], value_state1.int_value[0]); |
222 ASSERT_EQ(state2->int_value[0], value_state2.int_value[0]); | 219 ASSERT_EQ(state2->int_value[0], value_state2.int_value[0]); |
223 ASSERT_NE(state1->int_value[0], state2->int_value[0]); | 220 ASSERT_NE(state1->int_value[0], state2->int_value[0]); |
224 } | 221 } |
225 | 222 |
226 } // namespace content | 223 } // namespace content |
OLD | NEW |