| 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 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 #if defined(COMPILER_MSVC) | 96 #if defined(COMPILER_MSVC) |
| 97 // See explanation for other RenderViewHostImpl which is the same issue. | 97 // See explanation for other RenderViewHostImpl which is the same issue. |
| 98 #pragma warning(push) | 98 #pragma warning(push) |
| 99 #pragma warning(disable: 4250) | 99 #pragma warning(disable: 4250) |
| 100 #endif | 100 #endif |
| 101 | 101 |
| 102 class RenderThreadImplForTest : public RenderThreadImpl { | 102 class RenderThreadImplForTest : public RenderThreadImpl { |
| 103 public: | 103 public: |
| 104 RenderThreadImplForTest(const InProcessChildThreadParams& params, | 104 RenderThreadImplForTest( |
| 105 scoped_ptr<scheduler::RendererScheduler> scheduler, | 105 const InProcessChildThreadParams& params, |
| 106 scoped_refptr<TestTaskCounter> test_task_counter) | 106 scoped_ptr<scheduler::RendererScheduler> scheduler, |
| 107 : RenderThreadImpl(params, std::move(scheduler)), | 107 scoped_refptr<base::SingleThreadTaskRunner>& test_task_counter) |
| 108 test_task_counter_(test_task_counter) {} | 108 : RenderThreadImpl(params, std::move(scheduler), test_task_counter) { |
| 109 } |
| 109 | 110 |
| 110 ~RenderThreadImplForTest() override {} | 111 ~RenderThreadImplForTest() override {} |
| 111 | 112 |
| 112 void SetResourceDispatchTaskQueue( | |
| 113 const scoped_refptr<base::SingleThreadTaskRunner>&) override { | |
| 114 // Use our TestTaskCounter instead. | |
| 115 RenderThreadImpl::SetResourceDispatchTaskQueue(test_task_counter_); | |
| 116 } | |
| 117 | |
| 118 using ChildThreadImpl::OnMessageReceived; | 113 using ChildThreadImpl::OnMessageReceived; |
| 119 | 114 |
| 120 private: | 115 private: |
| 121 scoped_refptr<TestTaskCounter> test_task_counter_; | |
| 122 }; | 116 }; |
| 123 | 117 |
| 124 #if defined(COMPILER_MSVC) | 118 #if defined(COMPILER_MSVC) |
| 125 #pragma warning(pop) | 119 #pragma warning(pop) |
| 126 #endif | 120 #endif |
| 127 | 121 |
| 128 void QuitTask(base::MessageLoop* message_loop) { | 122 void QuitTask(base::MessageLoop* message_loop) { |
| 129 message_loop->QuitWhenIdle(); | 123 message_loop->QuitWhenIdle(); |
| 130 } | 124 } |
| 131 | 125 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) { | 172 format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) { |
| 179 if (!image_targets.empty()) | 173 if (!image_targets.empty()) |
| 180 image_targets += ","; | 174 image_targets += ","; |
| 181 image_targets += base::UintToString(GL_TEXTURE_2D); | 175 image_targets += base::UintToString(GL_TEXTURE_2D); |
| 182 } | 176 } |
| 183 cmd->AppendSwitchASCII(switches::kContentImageTextureTarget, image_targets); | 177 cmd->AppendSwitchASCII(switches::kContentImageTextureTarget, image_targets); |
| 184 | 178 |
| 185 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler = | 179 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler = |
| 186 scheduler::RendererScheduler::Create(); | 180 scheduler::RendererScheduler::Create(); |
| 187 InitializeMojo(); | 181 InitializeMojo(); |
| 182 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter( |
| 183 test_task_counter_.get()); |
| 188 thread_ = new RenderThreadImplForTest( | 184 thread_ = new RenderThreadImplForTest( |
| 189 InProcessChildThreadParams(test_helper_->GetChannelId(), | 185 InProcessChildThreadParams(test_helper_->GetChannelId(), |
| 190 test_helper_->GetIOTaskRunner(), | 186 test_helper_->GetIOTaskRunner(), |
| 191 test_helper_->GetMessagePipeHandle()), | 187 test_helper_->GetMessagePipeHandle()), |
| 192 std::move(renderer_scheduler), test_task_counter_); | 188 std::move(renderer_scheduler), test_task_counter); |
| 193 cmd->InitFromArgv(old_argv); | 189 cmd->InitFromArgv(old_argv); |
| 194 | 190 |
| 195 thread_->EnsureWebKitInitialized(); | |
| 196 | |
| 197 test_msg_filter_ = make_scoped_refptr( | 191 test_msg_filter_ = make_scoped_refptr( |
| 198 new QuitOnTestMsgFilter(test_helper_->GetMessageLoop())); | 192 new QuitOnTestMsgFilter(test_helper_->GetMessageLoop())); |
| 199 thread_->AddFilter(test_msg_filter_.get()); | 193 thread_->AddFilter(test_msg_filter_.get()); |
| 200 } | 194 } |
| 201 | 195 |
| 202 scoped_refptr<TestTaskCounter> test_task_counter_; | 196 scoped_refptr<TestTaskCounter> test_task_counter_; |
| 203 scoped_ptr<ContentClient> content_client_; | 197 scoped_ptr<ContentClient> content_client_; |
| 204 scoped_ptr<ContentBrowserClient> content_browser_client_; | 198 scoped_ptr<ContentBrowserClient> content_browser_client_; |
| 205 scoped_ptr<ContentRendererClient> content_renderer_client_; | 199 scoped_ptr<ContentRendererClient> content_renderer_client_; |
| 206 scoped_ptr<RenderThreadImplBrowserIPCTestHelper> test_helper_; | 200 scoped_ptr<RenderThreadImplBrowserIPCTestHelper> test_helper_; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 test_helper_->Sender()->Send(new WebSocketMsg_NotifyFailure(1, "")); | 237 test_helper_->Sender()->Send(new WebSocketMsg_NotifyFailure(1, "")); |
| 244 test_helper_->Sender()->Send(new TestMsg_QuitRunLoop()); | 238 test_helper_->Sender()->Send(new TestMsg_QuitRunLoop()); |
| 245 | 239 |
| 246 test_helper_->GetMessageLoop()->Run(); | 240 test_helper_->GetMessageLoop()->Run(); |
| 247 | 241 |
| 248 EXPECT_EQ(0, test_task_counter_->NumTasksPosted()); | 242 EXPECT_EQ(0, test_task_counter_->NumTasksPosted()); |
| 249 } | 243 } |
| 250 | 244 |
| 251 } // namespace | 245 } // namespace |
| 252 } // namespace content | 246 } // namespace content |
| OLD | NEW |