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/memory/discardable_memory.h" | 7 #include "base/memory/discardable_memory.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "content/common/resource_messages.h" | 10 #include "content/common/resource_messages.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return count_; | 70 return count_; |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 ~TestTaskCounter() override {} | 74 ~TestTaskCounter() override {} |
75 | 75 |
76 mutable base::Lock lock_; | 76 mutable base::Lock lock_; |
77 int count_; | 77 int count_; |
78 }; | 78 }; |
79 | 79 |
| 80 #if defined(COMPILER_MSVC) |
| 81 // See explanation for other RenderViewHostImpl which is the same issue. |
| 82 #pragma warning(push) |
| 83 #pragma warning(disable: 4250) |
| 84 #endif |
| 85 |
80 class RenderThreadImplForTest : public RenderThreadImpl { | 86 class RenderThreadImplForTest : public RenderThreadImpl { |
81 public: | 87 public: |
82 RenderThreadImplForTest(const std::string& channel_id, | 88 RenderThreadImplForTest(const std::string& channel_id, |
83 scoped_refptr<TestTaskCounter> test_task_counter) | 89 scoped_refptr<TestTaskCounter> test_task_counter) |
84 : RenderThreadImpl(channel_id), test_task_counter_(test_task_counter) {} | 90 : RenderThreadImpl(channel_id), test_task_counter_(test_task_counter) {} |
85 | 91 |
86 ~RenderThreadImplForTest() override {} | 92 ~RenderThreadImplForTest() override {} |
87 | 93 |
88 void SetResourceDispatchTaskQueue( | 94 void SetResourceDispatchTaskQueue( |
89 const scoped_refptr<base::SingleThreadTaskRunner>&) override { | 95 const scoped_refptr<base::SingleThreadTaskRunner>&) override { |
90 // Use our TestTaskCounter instead. | 96 // Use our TestTaskCounter instead. |
91 RenderThreadImpl::SetResourceDispatchTaskQueue(test_task_counter_); | 97 RenderThreadImpl::SetResourceDispatchTaskQueue(test_task_counter_); |
92 } | 98 } |
93 | 99 |
94 using ChildThread::OnMessageReceived; | 100 using ChildThreadImpl::OnMessageReceived; |
95 | 101 |
96 private: | 102 private: |
97 scoped_refptr<TestTaskCounter> test_task_counter_; | 103 scoped_refptr<TestTaskCounter> test_task_counter_; |
98 }; | 104 }; |
99 | 105 |
| 106 #if defined(COMPILER_MSVC) |
| 107 #pragma warning(pop) |
| 108 #endif |
| 109 |
100 void QuitTask(base::MessageLoop* message_loop) { | 110 void QuitTask(base::MessageLoop* message_loop) { |
101 message_loop->QuitWhenIdle(); | 111 message_loop->QuitWhenIdle(); |
102 } | 112 } |
103 | 113 |
104 class QuitOnTestMsgFilter : public IPC::MessageFilter { | 114 class QuitOnTestMsgFilter : public IPC::MessageFilter { |
105 public: | 115 public: |
106 explicit QuitOnTestMsgFilter(base::MessageLoop* message_loop) | 116 explicit QuitOnTestMsgFilter(base::MessageLoop* message_loop) |
107 : message_loop_(message_loop) {} | 117 : message_loop_(message_loop) {} |
108 | 118 |
109 // IPC::MessageFilter overrides: | 119 // IPC::MessageFilter overrides: |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 test_helper_->Sender()->Send(new WebSocketMsg_NotifyFailure(1, "")); | 241 test_helper_->Sender()->Send(new WebSocketMsg_NotifyFailure(1, "")); |
232 test_helper_->Sender()->Send(new TestMsg_QuitRunLoop()); | 242 test_helper_->Sender()->Send(new TestMsg_QuitRunLoop()); |
233 | 243 |
234 test_helper_->GetMessageLoop()->Run(); | 244 test_helper_->GetMessageLoop()->Run(); |
235 | 245 |
236 EXPECT_EQ(0, test_task_counter_->NumTasksPosted()); | 246 EXPECT_EQ(0, test_task_counter_->NumTasksPosted()); |
237 } | 247 } |
238 | 248 |
239 } // namespace | 249 } // namespace |
240 } // namespace content | 250 } // namespace content |
OLD | NEW |