OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 | 1413 |
1414 void RunTest_RecursivePosts(MessageLoop::Type message_loop_type, | 1414 void RunTest_RecursivePosts(MessageLoop::Type message_loop_type, |
1415 int num_times) { | 1415 int num_times) { |
1416 MessageLoop loop(message_loop_type); | 1416 MessageLoop loop(message_loop_type); |
1417 loop.PostTask(FROM_HERE, Bind(&PostNTasksThenQuit, num_times)); | 1417 loop.PostTask(FROM_HERE, Bind(&PostNTasksThenQuit, num_times)); |
1418 loop.Run(); | 1418 loop.Run(); |
1419 } | 1419 } |
1420 | 1420 |
1421 #if defined(OS_WIN) | 1421 #if defined(OS_WIN) |
1422 | 1422 |
1423 class DispatcherImpl : public MessageLoopForUI::Dispatcher { | 1423 class DispatcherImpl : public base::MessageLoopForUI::Dispatcher { |
1424 public: | 1424 public: |
1425 DispatcherImpl() : dispatch_count_(0) {} | 1425 DispatcherImpl() : dispatch_count_(0) {} |
1426 | 1426 |
1427 virtual bool Dispatch(const NativeEvent& msg) OVERRIDE { | 1427 virtual bool Dispatch(const NativeEvent& msg) OVERRIDE { |
1428 ::TranslateMessage(&msg); | 1428 ::TranslateMessage(&msg); |
1429 ::DispatchMessage(&msg); | 1429 ::DispatchMessage(&msg); |
1430 // Do not count WM_TIMER since it is not what we post and it will cause | 1430 // Do not count WM_TIMER since it is not what we post and it will cause |
1431 // flakiness. | 1431 // flakiness. |
1432 if (msg.message != WM_TIMER) | 1432 if (msg.message != WM_TIMER) |
1433 ++dispatch_count_; | 1433 ++dispatch_count_; |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 // On Linux, the pipe buffer size is 64KiB by default. The bug caused one | 2108 // On Linux, the pipe buffer size is 64KiB by default. The bug caused one |
2109 // byte accumulated in the pipe per two posts, so we should repeat 128K | 2109 // byte accumulated in the pipe per two posts, so we should repeat 128K |
2110 // times to reproduce the bug. | 2110 // times to reproduce the bug. |
2111 const int kNumTimes = 1 << 17; | 2111 const int kNumTimes = 1 << 17; |
2112 RunTest_RecursivePosts(MessageLoop::TYPE_DEFAULT, kNumTimes); | 2112 RunTest_RecursivePosts(MessageLoop::TYPE_DEFAULT, kNumTimes); |
2113 RunTest_RecursivePosts(MessageLoop::TYPE_UI, kNumTimes); | 2113 RunTest_RecursivePosts(MessageLoop::TYPE_UI, kNumTimes); |
2114 RunTest_RecursivePosts(MessageLoop::TYPE_IO, kNumTimes); | 2114 RunTest_RecursivePosts(MessageLoop::TYPE_IO, kNumTimes); |
2115 } | 2115 } |
2116 | 2116 |
2117 } // namespace base | 2117 } // namespace base |
OLD | NEW |