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 "base/callback.h" | 5 #include "base/callback.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/memory/discardable_memory.h" | 8 #include "base/memory/discardable_memory.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "components/scheduler/renderer/renderer_scheduler.h" |
13 #include "content/common/in_process_child_thread_params.h" | 14 #include "content/common/in_process_child_thread_params.h" |
14 #include "content/common/resource_messages.h" | 15 #include "content/common/resource_messages.h" |
15 #include "content/common/websocket_messages.h" | 16 #include "content/common/websocket_messages.h" |
16 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
17 #include "content/public/common/content_client.h" | 18 #include "content/public/common/content_client.h" |
18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
19 #include "content/public/renderer/content_renderer_client.h" | 20 #include "content/public/renderer/content_renderer_client.h" |
20 #include "content/renderer/render_process_impl.h" | 21 #include "content/renderer/render_process_impl.h" |
21 #include "content/renderer/render_thread_impl.h" | 22 #include "content/renderer/render_thread_impl.h" |
22 #include "content/test/mock_render_process.h" | 23 #include "content/test/mock_render_process.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 85 |
85 #if defined(COMPILER_MSVC) | 86 #if defined(COMPILER_MSVC) |
86 // See explanation for other RenderViewHostImpl which is the same issue. | 87 // See explanation for other RenderViewHostImpl which is the same issue. |
87 #pragma warning(push) | 88 #pragma warning(push) |
88 #pragma warning(disable: 4250) | 89 #pragma warning(disable: 4250) |
89 #endif | 90 #endif |
90 | 91 |
91 class RenderThreadImplForTest : public RenderThreadImpl { | 92 class RenderThreadImplForTest : public RenderThreadImpl { |
92 public: | 93 public: |
93 RenderThreadImplForTest(const InProcessChildThreadParams& params, | 94 RenderThreadImplForTest(const InProcessChildThreadParams& params, |
| 95 scoped_ptr<scheduler::RendererScheduler> scheduler, |
94 scoped_refptr<TestTaskCounter> test_task_counter) | 96 scoped_refptr<TestTaskCounter> test_task_counter) |
95 : RenderThreadImpl(params), test_task_counter_(test_task_counter) {} | 97 : RenderThreadImpl(params, scheduler.Pass()), |
| 98 test_task_counter_(test_task_counter) {} |
96 | 99 |
97 ~RenderThreadImplForTest() override {} | 100 ~RenderThreadImplForTest() override {} |
98 | 101 |
99 void SetResourceDispatchTaskQueue( | 102 void SetResourceDispatchTaskQueue( |
100 const scoped_refptr<base::SingleThreadTaskRunner>&) override { | 103 const scoped_refptr<base::SingleThreadTaskRunner>&) override { |
101 // Use our TestTaskCounter instead. | 104 // Use our TestTaskCounter instead. |
102 RenderThreadImpl::SetResourceDispatchTaskQueue(test_task_counter_); | 105 RenderThreadImpl::SetResourceDispatchTaskQueue(test_task_counter_); |
103 } | 106 } |
104 | 107 |
105 using ChildThreadImpl::OnMessageReceived; | 108 using ChildThreadImpl::OnMessageReceived; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 test_task_counter_ = make_scoped_refptr(new TestTaskCounter()); | 159 test_task_counter_ = make_scoped_refptr(new TestTaskCounter()); |
157 | 160 |
158 // RenderThreadImpl expects the browser to pass these flags. | 161 // RenderThreadImpl expects the browser to pass these flags. |
159 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 162 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
160 base::CommandLine::StringVector old_argv = cmd->argv(); | 163 base::CommandLine::StringVector old_argv = cmd->argv(); |
161 | 164 |
162 cmd->AppendSwitchASCII(switches::kNumRasterThreads, "1"); | 165 cmd->AppendSwitchASCII(switches::kNumRasterThreads, "1"); |
163 cmd->AppendSwitchASCII(switches::kContentImageTextureTarget, | 166 cmd->AppendSwitchASCII(switches::kContentImageTextureTarget, |
164 base::UintToString(GL_TEXTURE_2D)); | 167 base::UintToString(GL_TEXTURE_2D)); |
165 | 168 |
| 169 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler = |
| 170 scheduler::RendererScheduler::Create(); |
166 thread_ = new RenderThreadImplForTest( | 171 thread_ = new RenderThreadImplForTest( |
167 InProcessChildThreadParams(test_helper_->GetChannelId(), | 172 InProcessChildThreadParams(test_helper_->GetChannelId(), |
168 test_helper_->GetIOTaskRunner()), | 173 test_helper_->GetIOTaskRunner()), |
169 test_task_counter_); | 174 renderer_scheduler.Pass(), test_task_counter_); |
170 cmd->InitFromArgv(old_argv); | 175 cmd->InitFromArgv(old_argv); |
171 | 176 |
172 thread_->EnsureWebKitInitialized(); | 177 thread_->EnsureWebKitInitialized(); |
173 | 178 |
174 test_msg_filter_ = make_scoped_refptr( | 179 test_msg_filter_ = make_scoped_refptr( |
175 new QuitOnTestMsgFilter(test_helper_->GetMessageLoop())); | 180 new QuitOnTestMsgFilter(test_helper_->GetMessageLoop())); |
176 thread_->AddFilter(test_msg_filter_.get()); | 181 thread_->AddFilter(test_msg_filter_.get()); |
177 } | 182 } |
178 | 183 |
179 scoped_refptr<TestTaskCounter> test_task_counter_; | 184 scoped_refptr<TestTaskCounter> test_task_counter_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 test_helper_->Sender()->Send(new WebSocketMsg_NotifyFailure(1, "")); | 225 test_helper_->Sender()->Send(new WebSocketMsg_NotifyFailure(1, "")); |
221 test_helper_->Sender()->Send(new TestMsg_QuitRunLoop()); | 226 test_helper_->Sender()->Send(new TestMsg_QuitRunLoop()); |
222 | 227 |
223 test_helper_->GetMessageLoop()->Run(); | 228 test_helper_->GetMessageLoop()->Run(); |
224 | 229 |
225 EXPECT_EQ(0, test_task_counter_->NumTasksPosted()); | 230 EXPECT_EQ(0, test_task_counter_->NumTasksPosted()); |
226 } | 231 } |
227 | 232 |
228 } // namespace | 233 } // namespace |
229 } // namespace content | 234 } // namespace content |
OLD | NEW |