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 <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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 MessageLoop::current()->QuitWhenIdle(); | 418 MessageLoop::current()->QuitWhenIdle(); |
419 } | 419 } |
420 } | 420 } |
421 | 421 |
422 #if defined(OS_WIN) | 422 #if defined(OS_WIN) |
423 | 423 |
424 class DispatcherImpl : public MessagePumpDispatcher { | 424 class DispatcherImpl : public MessagePumpDispatcher { |
425 public: | 425 public: |
426 DispatcherImpl() : dispatch_count_(0) {} | 426 DispatcherImpl() : dispatch_count_(0) {} |
427 | 427 |
428 virtual uint32_t Dispatch(const NativeEvent& msg) override { | 428 uint32_t Dispatch(const NativeEvent& msg) override { |
429 ::TranslateMessage(&msg); | 429 ::TranslateMessage(&msg); |
430 ::DispatchMessage(&msg); | 430 ::DispatchMessage(&msg); |
431 // Do not count WM_TIMER since it is not what we post and it will cause | 431 // Do not count WM_TIMER since it is not what we post and it will cause |
432 // flakiness. | 432 // flakiness. |
433 if (msg.message != WM_TIMER) | 433 if (msg.message != WM_TIMER) |
434 ++dispatch_count_; | 434 ++dispatch_count_; |
435 // We treat WM_LBUTTONUP as the last message. | 435 // We treat WM_LBUTTONUP as the last message. |
436 return msg.message == WM_LBUTTONUP ? POST_DISPATCH_QUIT_LOOP | 436 return msg.message == WM_LBUTTONUP ? POST_DISPATCH_QUIT_LOOP |
437 : POST_DISPATCH_NONE; | 437 : POST_DISPATCH_NONE; |
438 } | 438 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 RunLoop run_loop(&dispatcher); | 482 RunLoop run_loop(&dispatcher); |
483 run_loop.Run(); | 483 run_loop.Run(); |
484 ASSERT_EQ(1, dispatcher.dispatch_count_); | 484 ASSERT_EQ(1, dispatcher.dispatch_count_); |
485 UnhookWindowsHookEx(msg_hook); | 485 UnhookWindowsHookEx(msg_hook); |
486 } | 486 } |
487 | 487 |
488 class TestIOHandler : public MessageLoopForIO::IOHandler { | 488 class TestIOHandler : public MessageLoopForIO::IOHandler { |
489 public: | 489 public: |
490 TestIOHandler(const wchar_t* name, HANDLE signal, bool wait); | 490 TestIOHandler(const wchar_t* name, HANDLE signal, bool wait); |
491 | 491 |
492 virtual void OnIOCompleted(MessageLoopForIO::IOContext* context, | 492 void OnIOCompleted(MessageLoopForIO::IOContext* context, |
493 DWORD bytes_transfered, DWORD error); | 493 DWORD bytes_transfered, |
| 494 DWORD error) override; |
494 | 495 |
495 void Init(); | 496 void Init(); |
496 void WaitForIO(); | 497 void WaitForIO(); |
497 OVERLAPPED* context() { return &context_.overlapped; } | 498 OVERLAPPED* context() { return &context_.overlapped; } |
498 DWORD size() { return sizeof(buffer_); } | 499 DWORD size() { return sizeof(buffer_); } |
499 | 500 |
500 private: | 501 private: |
501 char buffer_[48]; | 502 char buffer_[48]; |
502 MessageLoopForIO::IOContext context_; | 503 MessageLoopForIO::IOContext context_; |
503 HANDLE signal_; | 504 HANDLE signal_; |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 | 1006 |
1006 ASSERT_TRUE(PostMessage(message_hwnd, kSignalMsg, 0, 1)); | 1007 ASSERT_TRUE(PostMessage(message_hwnd, kSignalMsg, 0, 1)); |
1007 | 1008 |
1008 loop.Run(); | 1009 loop.Run(); |
1009 | 1010 |
1010 ASSERT_TRUE(UnregisterClass(MAKEINTATOM(atom), instance)); | 1011 ASSERT_TRUE(UnregisterClass(MAKEINTATOM(atom), instance)); |
1011 } | 1012 } |
1012 #endif // defined(OS_WIN) | 1013 #endif // defined(OS_WIN) |
1013 | 1014 |
1014 } // namespace base | 1015 } // namespace base |
OLD | NEW |