| OLD | NEW |
| 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 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/leak_annotations.h" | 13 #include "base/debug/leak_annotations.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/memory/discardable_memory.h" | 15 #include "base/memory/discardable_memory.h" |
| 16 #include "base/metrics/field_trial.h" |
| 16 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "cc/output/buffer_to_texture_target_map.h" | 22 #include "cc/output/buffer_to_texture_target_map.h" |
| 22 #include "content/app/mojo/mojo_init.h" | 23 #include "content/app/mojo/mojo_init.h" |
| 23 #include "content/common/in_process_child_thread_params.h" | 24 #include "content/common/in_process_child_thread_params.h" |
| 24 #include "content/common/resource_messages.h" | 25 #include "content/common/resource_messages.h" |
| 25 #include "content/common/service_manager/child_connection.h" | 26 #include "content/common/service_manager/child_connection.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 157 } |
| 157 | 158 |
| 158 private: | 159 private: |
| 159 ~QuitOnTestMsgFilter() override {} | 160 ~QuitOnTestMsgFilter() override {} |
| 160 | 161 |
| 161 base::MessageLoop* message_loop_; | 162 base::MessageLoop* message_loop_; |
| 162 }; | 163 }; |
| 163 | 164 |
| 164 class RenderThreadImplBrowserTest : public testing::Test { | 165 class RenderThreadImplBrowserTest : public testing::Test { |
| 165 public: | 166 public: |
| 167 RenderThreadImplBrowserTest() : field_trial_list_(nullptr) {} |
| 168 |
| 166 void SetUp() override { | 169 void SetUp() override { |
| 167 // SequencedWorkerPool is enabled by default in tests. Disable it for this | 170 // SequencedWorkerPool is enabled by default in tests. Disable it for this |
| 168 // test to avoid a DCHECK failure when RenderThreadImpl::Init enables it. | 171 // test to avoid a DCHECK failure when RenderThreadImpl::Init enables it. |
| 169 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler | 172 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler |
| 170 // redirection experiment concludes https://crbug.com/622400. | 173 // redirection experiment concludes https://crbug.com/622400. |
| 171 base::SequencedWorkerPool::DisableForProcessForTesting(); | 174 base::SequencedWorkerPool::DisableForProcessForTesting(); |
| 172 | 175 |
| 173 content_renderer_client_.reset(new ContentRendererClient()); | 176 content_renderer_client_.reset(new ContentRendererClient()); |
| 174 SetRendererClientForTesting(content_renderer_client_.get()); | 177 SetRendererClientForTesting(content_renderer_client_.get()); |
| 175 | 178 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 205 cmd->AppendSwitchASCII(switches::kNumRasterThreads, "1"); | 208 cmd->AppendSwitchASCII(switches::kNumRasterThreads, "1"); |
| 206 cmd->AppendSwitchASCII( | 209 cmd->AppendSwitchASCII( |
| 207 switches::kContentImageTextureTarget, | 210 switches::kContentImageTextureTarget, |
| 208 cc::BufferToTextureTargetMapToString( | 211 cc::BufferToTextureTargetMapToString( |
| 209 cc::DefaultBufferToTextureTargetMapForTesting())); | 212 cc::DefaultBufferToTextureTargetMapForTesting())); |
| 210 | 213 |
| 211 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler = | 214 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler = |
| 212 blink::scheduler::RendererScheduler::Create(); | 215 blink::scheduler::RendererScheduler::Create(); |
| 213 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter( | 216 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter( |
| 214 test_task_counter_.get()); | 217 test_task_counter_.get()); |
| 218 |
| 219 base::FieldTrialList::CreateTrialsFromCommandLine( |
| 220 *cmd, switches::kFieldTrialHandle, -1); |
| 215 thread_ = new RenderThreadImplForTest( | 221 thread_ = new RenderThreadImplForTest( |
| 216 InProcessChildThreadParams(io_task_runner, | 222 InProcessChildThreadParams(io_task_runner, |
| 217 child_connection_->service_token()), | 223 child_connection_->service_token()), |
| 218 std::move(renderer_scheduler), test_task_counter); | 224 std::move(renderer_scheduler), test_task_counter); |
| 219 cmd->InitFromArgv(old_argv); | 225 cmd->InitFromArgv(old_argv); |
| 220 | 226 |
| 221 test_msg_filter_ = make_scoped_refptr( | 227 test_msg_filter_ = make_scoped_refptr( |
| 222 new QuitOnTestMsgFilter(base::MessageLoop::current())); | 228 new QuitOnTestMsgFilter(base::MessageLoop::current())); |
| 223 thread_->AddFilter(test_msg_filter_.get()); | 229 thread_->AddFilter(test_msg_filter_.get()); |
| 224 } | 230 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 241 std::unique_ptr<ContentRendererClient> content_renderer_client_; | 247 std::unique_ptr<ContentRendererClient> content_renderer_client_; |
| 242 | 248 |
| 243 std::unique_ptr<TestBrowserThreadBundle> browser_threads_; | 249 std::unique_ptr<TestBrowserThreadBundle> browser_threads_; |
| 244 std::unique_ptr<TestServiceManagerContext> shell_context_; | 250 std::unique_ptr<TestServiceManagerContext> shell_context_; |
| 245 std::unique_ptr<ChildConnection> child_connection_; | 251 std::unique_ptr<ChildConnection> child_connection_; |
| 246 std::unique_ptr<IPC::ChannelProxy> channel_; | 252 std::unique_ptr<IPC::ChannelProxy> channel_; |
| 247 | 253 |
| 248 std::unique_ptr<MockRenderProcess> mock_process_; | 254 std::unique_ptr<MockRenderProcess> mock_process_; |
| 249 scoped_refptr<QuitOnTestMsgFilter> test_msg_filter_; | 255 scoped_refptr<QuitOnTestMsgFilter> test_msg_filter_; |
| 250 RenderThreadImplForTest* thread_; // Owned by mock_process_. | 256 RenderThreadImplForTest* thread_; // Owned by mock_process_. |
| 257 |
| 258 base::FieldTrialList field_trial_list_; |
| 251 }; | 259 }; |
| 252 | 260 |
| 253 void CheckRenderThreadInputHandlerManager(RenderThreadImpl* thread) { | 261 void CheckRenderThreadInputHandlerManager(RenderThreadImpl* thread) { |
| 254 ASSERT_TRUE(thread->input_handler_manager()); | 262 ASSERT_TRUE(thread->input_handler_manager()); |
| 255 } | 263 } |
| 256 | 264 |
| 257 // Check that InputHandlerManager outlives compositor thread because it uses | 265 // Check that InputHandlerManager outlives compositor thread because it uses |
| 258 // raw pointers to post tasks. | 266 // raw pointers to post tasks. |
| 259 // Disabled under LeakSanitizer due to memory leaks. http://crbug.com/348994 | 267 // Disabled under LeakSanitizer due to memory leaks. http://crbug.com/348994 |
| 260 TEST_F(RenderThreadImplBrowserTest, | 268 TEST_F(RenderThreadImplBrowserTest, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 // These formats are guaranteed to work on all platforms. | 393 // These formats are guaranteed to work on all platforms. |
| 386 ::testing::Values(gfx::BufferFormat::R_8, | 394 ::testing::Values(gfx::BufferFormat::R_8, |
| 387 gfx::BufferFormat::BGR_565, | 395 gfx::BufferFormat::BGR_565, |
| 388 gfx::BufferFormat::RGBA_4444, | 396 gfx::BufferFormat::RGBA_4444, |
| 389 gfx::BufferFormat::RGBA_8888, | 397 gfx::BufferFormat::RGBA_8888, |
| 390 gfx::BufferFormat::BGRA_8888, | 398 gfx::BufferFormat::BGRA_8888, |
| 391 gfx::BufferFormat::YVU_420))); | 399 gfx::BufferFormat::YVU_420))); |
| 392 | 400 |
| 393 } // namespace | 401 } // namespace |
| 394 } // namespace content | 402 } // namespace content |
| OLD | NEW |