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

Side by Side Diff: content/renderer/render_thread_impl_browsertest.cc

Issue 2568543002: Fix data race in RenderThreadImplBrowserTest (Closed)
Patch Set: . Created 4 years 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 | « content/renderer/render_thread_impl.cc ('k') | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 public: 120 public:
121 RenderThreadImplForTest( 121 RenderThreadImplForTest(
122 const InProcessChildThreadParams& params, 122 const InProcessChildThreadParams& params,
123 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, 123 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler,
124 scoped_refptr<base::SingleThreadTaskRunner>& test_task_counter) 124 scoped_refptr<base::SingleThreadTaskRunner>& test_task_counter)
125 : RenderThreadImpl(params, std::move(scheduler), test_task_counter) {} 125 : RenderThreadImpl(params, std::move(scheduler), test_task_counter) {}
126 126
127 ~RenderThreadImplForTest() override {} 127 ~RenderThreadImplForTest() override {}
128 }; 128 };
129 129
130 class DummyListener : public IPC::Listener {
131 public:
132 ~DummyListener() override {}
133
134 bool OnMessageReceived(const IPC::Message& message) override { return true; }
135 };
136
137 #if defined(COMPILER_MSVC) 130 #if defined(COMPILER_MSVC)
138 #pragma warning(pop) 131 #pragma warning(pop)
139 #endif 132 #endif
140 133
141 void QuitTask(base::MessageLoop* message_loop) { 134 void QuitTask(base::MessageLoop* message_loop) {
142 message_loop->QuitWhenIdle(); 135 message_loop->QuitWhenIdle();
143 } 136 }
144 137
145 class QuitOnTestMsgFilter : public IPC::MessageFilter { 138 class QuitOnTestMsgFilter : public IPC::MessageFilter {
146 public: 139 public:
(...skipping 27 matching lines...) Expand all
174 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler 167 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler
175 // redirection experiment concludes https://crbug.com/622400. 168 // redirection experiment concludes https://crbug.com/622400.
176 base::SequencedWorkerPool::DisableForProcessForTesting(); 169 base::SequencedWorkerPool::DisableForProcessForTesting();
177 170
178 content_renderer_client_.reset(new ContentRendererClient()); 171 content_renderer_client_.reset(new ContentRendererClient());
179 SetRendererClientForTesting(content_renderer_client_.get()); 172 SetRendererClientForTesting(content_renderer_client_.get());
180 173
181 browser_threads_.reset( 174 browser_threads_.reset(
182 new TestBrowserThreadBundle(TestBrowserThreadBundle::IO_MAINLOOP)); 175 new TestBrowserThreadBundle(TestBrowserThreadBundle::IO_MAINLOOP));
183 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = 176 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
184 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); 177 base::ThreadTaskRunnerHandle::Get();
185 178
186 InitializeMojo(); 179 InitializeMojo();
187 ipc_support_.reset(new mojo::edk::test::ScopedIPCSupport(io_task_runner)); 180 ipc_support_.reset(new mojo::edk::test::ScopedIPCSupport(io_task_runner));
188 shell_context_.reset(new TestServiceManagerContext); 181 shell_context_.reset(new TestServiceManagerContext);
189 child_connection_.reset(new ChildConnection( 182 child_connection_.reset(new ChildConnection(
190 mojom::kRendererServiceName, "test", mojo::edk::GenerateRandomToken(), 183 mojom::kRendererServiceName, "test", mojo::edk::GenerateRandomToken(),
191 ServiceManagerConnection::GetForProcess()->GetConnector(), 184 ServiceManagerConnection::GetForProcess()->GetConnector(),
192 io_task_runner)); 185 io_task_runner));
193 186
194 mojo::MessagePipe pipe; 187 mojo::MessagePipe pipe;
195 IPC::mojom::ChannelBootstrapPtr channel_bootstrap; 188 IPC::mojom::ChannelBootstrapPtr channel_bootstrap;
196 child_connection_->GetRemoteInterfaces()->GetInterface(&channel_bootstrap); 189 child_connection_->GetRemoteInterfaces()->GetInterface(&channel_bootstrap);
197 190
198 dummy_listener_.reset(new DummyListener);
199 channel_ = IPC::ChannelProxy::Create( 191 channel_ = IPC::ChannelProxy::Create(
200 IPC::ChannelMojo::CreateServerFactory( 192 IPC::ChannelMojo::CreateServerFactory(
201 channel_bootstrap.PassInterface().PassHandle(), io_task_runner), 193 channel_bootstrap.PassInterface().PassHandle(), io_task_runner),
202 dummy_listener_.get(), io_task_runner); 194 nullptr, io_task_runner);
203 195
204 mock_process_.reset(new MockRenderProcess); 196 mock_process_.reset(new MockRenderProcess);
205 test_task_counter_ = make_scoped_refptr(new TestTaskCounter()); 197 test_task_counter_ = make_scoped_refptr(new TestTaskCounter());
206 198
207 // RenderThreadImpl expects the browser to pass these flags. 199 // RenderThreadImpl expects the browser to pass these flags.
208 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 200 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
209 base::CommandLine::StringVector old_argv = cmd->argv(); 201 base::CommandLine::StringVector old_argv = cmd->argv();
210 202
211 cmd->AppendSwitchASCII(switches::kNumRasterThreads, "1"); 203 cmd->AppendSwitchASCII(switches::kNumRasterThreads, "1");
212 cmd->AppendSwitchASCII( 204 cmd->AppendSwitchASCII(
(...skipping 19 matching lines...) Expand all
232 IPC::Sender* sender() { return channel_.get(); } 224 IPC::Sender* sender() { return channel_.get(); }
233 225
234 scoped_refptr<TestTaskCounter> test_task_counter_; 226 scoped_refptr<TestTaskCounter> test_task_counter_;
235 TestContentClientInitializer content_client_initializer_; 227 TestContentClientInitializer content_client_initializer_;
236 std::unique_ptr<ContentRendererClient> content_renderer_client_; 228 std::unique_ptr<ContentRendererClient> content_renderer_client_;
237 229
238 std::unique_ptr<TestBrowserThreadBundle> browser_threads_; 230 std::unique_ptr<TestBrowserThreadBundle> browser_threads_;
239 std::unique_ptr<mojo::edk::test::ScopedIPCSupport> ipc_support_; 231 std::unique_ptr<mojo::edk::test::ScopedIPCSupport> ipc_support_;
240 std::unique_ptr<TestServiceManagerContext> shell_context_; 232 std::unique_ptr<TestServiceManagerContext> shell_context_;
241 std::unique_ptr<ChildConnection> child_connection_; 233 std::unique_ptr<ChildConnection> child_connection_;
242 std::unique_ptr<DummyListener> dummy_listener_;
243 std::unique_ptr<IPC::ChannelProxy> channel_; 234 std::unique_ptr<IPC::ChannelProxy> channel_;
244 235
245 std::unique_ptr<MockRenderProcess> mock_process_; 236 std::unique_ptr<MockRenderProcess> mock_process_;
246 scoped_refptr<QuitOnTestMsgFilter> test_msg_filter_; 237 scoped_refptr<QuitOnTestMsgFilter> test_msg_filter_;
247 RenderThreadImplForTest* thread_; // Owned by mock_process_. 238 RenderThreadImplForTest* thread_; // Owned by mock_process_.
248 }; 239 };
249 240
250 void CheckRenderThreadInputHandlerManager(RenderThreadImpl* thread) { 241 void CheckRenderThreadInputHandlerManager(RenderThreadImpl* thread) {
251 ASSERT_TRUE(thread->input_handler_manager()); 242 ASSERT_TRUE(thread->input_handler_manager());
252 } 243 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // These formats are guaranteed to work on all platforms. 373 // These formats are guaranteed to work on all platforms.
383 ::testing::Values(gfx::BufferFormat::R_8, 374 ::testing::Values(gfx::BufferFormat::R_8,
384 gfx::BufferFormat::BGR_565, 375 gfx::BufferFormat::BGR_565,
385 gfx::BufferFormat::RGBA_4444, 376 gfx::BufferFormat::RGBA_4444,
386 gfx::BufferFormat::RGBA_8888, 377 gfx::BufferFormat::RGBA_8888,
387 gfx::BufferFormat::BGRA_8888, 378 gfx::BufferFormat::BGRA_8888,
388 gfx::BufferFormat::YVU_420))); 379 gfx::BufferFormat::YVU_420)));
389 380
390 } // namespace 381 } // namespace
391 } // namespace content 382 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698