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 "base/message_loop/message_pump_win.h" | 5 #include "base/message_loop/message_pump_win.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 "440919 MessagePumpForUI::ProcessNextWindowsMessage2")); | 345 "440919 MessagePumpForUI::ProcessNextWindowsMessage2")); |
346 | 346 |
347 MSG msg; | 347 MSG msg; |
348 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != FALSE) | 348 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != FALSE) |
349 return ProcessMessageHelper(msg); | 349 return ProcessMessageHelper(msg); |
350 | 350 |
351 return sent_messages_in_queue; | 351 return sent_messages_in_queue; |
352 } | 352 } |
353 | 353 |
354 bool MessagePumpForUI::ProcessMessageHelper(const MSG& msg) { | 354 bool MessagePumpForUI::ProcessMessageHelper(const MSG& msg) { |
| 355 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
| 356 tracked_objects::ScopedTracker tracking_profile1( |
| 357 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 358 "440919 MessagePumpForUI::ProcessMessageHelper1")); |
| 359 |
355 TRACE_EVENT1("base", "MessagePumpForUI::ProcessMessageHelper", | 360 TRACE_EVENT1("base", "MessagePumpForUI::ProcessMessageHelper", |
356 "message", msg.message); | 361 "message", msg.message); |
357 if (WM_QUIT == msg.message) { | 362 if (WM_QUIT == msg.message) { |
358 // Repost the QUIT message so that it will be retrieved by the primary | 363 // Repost the QUIT message so that it will be retrieved by the primary |
359 // GetMessage() loop. | 364 // GetMessage() loop. |
360 state_->should_quit = true; | 365 state_->should_quit = true; |
361 PostQuitMessage(static_cast<int>(msg.wParam)); | 366 PostQuitMessage(static_cast<int>(msg.wParam)); |
362 return false; | 367 return false; |
363 } | 368 } |
364 | 369 |
365 // While running our main message pump, we discard kMsgHaveWork messages. | 370 // While running our main message pump, we discard kMsgHaveWork messages. |
366 if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_) | 371 if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_) |
367 return ProcessPumpReplacementMessage(); | 372 return ProcessPumpReplacementMessage(); |
368 | 373 |
369 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. | 374 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
370 tracked_objects::ScopedTracker tracking_profile2( | 375 tracked_objects::ScopedTracker tracking_profile2( |
371 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 376 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
372 "440919 MessagePumpForUI::ProcessMessageHelper2")); | 377 "440919 MessagePumpForUI::ProcessMessageHelper2")); |
373 | 378 |
374 if (CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode)) | 379 if (CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode)) |
375 return true; | 380 return true; |
376 | 381 |
377 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. | 382 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
378 tracked_objects::ScopedTracker tracking_profile3( | 383 tracked_objects::ScopedTracker tracking_profile3( |
379 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 384 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
380 "440919 MessagePumpForUI::ProcessMessageHelper3")); | 385 "440919 MessagePumpForUI::ProcessMessageHelper3")); |
381 | 386 |
382 uint32_t action = MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT; | 387 uint32_t action = MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT; |
383 if (state_->dispatcher) | 388 if (state_->dispatcher) { |
| 389 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
| 390 tracked_objects::ScopedTracker tracking_profile4( |
| 391 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 392 "440919 MessagePumpForUI::ProcessMessageHelper4")); |
| 393 |
384 action = state_->dispatcher->Dispatch(msg); | 394 action = state_->dispatcher->Dispatch(msg); |
| 395 } |
385 if (action & MessagePumpDispatcher::POST_DISPATCH_QUIT_LOOP) | 396 if (action & MessagePumpDispatcher::POST_DISPATCH_QUIT_LOOP) |
386 state_->should_quit = true; | 397 state_->should_quit = true; |
387 if (action & MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT) { | 398 if (action & MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT) { |
| 399 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
| 400 tracked_objects::ScopedTracker tracking_profile5( |
| 401 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 402 "440919 MessagePumpForUI::ProcessMessageHelper5")); |
| 403 |
388 TranslateMessage(&msg); | 404 TranslateMessage(&msg); |
| 405 |
| 406 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
| 407 tracked_objects::ScopedTracker tracking_profile6( |
| 408 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 409 "440919 MessagePumpForUI::ProcessMessageHelper6")); |
| 410 |
389 DispatchMessage(&msg); | 411 DispatchMessage(&msg); |
390 } | 412 } |
391 | 413 |
392 return true; | 414 return true; |
393 } | 415 } |
394 | 416 |
395 bool MessagePumpForUI::ProcessPumpReplacementMessage() { | 417 bool MessagePumpForUI::ProcessPumpReplacementMessage() { |
396 // When we encounter a kMsgHaveWork message, this method is called to peek | 418 // When we encounter a kMsgHaveWork message, this method is called to peek |
397 // and process a replacement message, such as a WM_PAINT or WM_TIMER. The | 419 // and process a replacement message, such as a WM_PAINT or WM_TIMER. The |
398 // goal is to make the kMsgHaveWork as non-intrusive as possible, even though | 420 // goal is to make the kMsgHaveWork as non-intrusive as possible, even though |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 | 675 |
654 // static | 676 // static |
655 MessagePumpForIO::IOHandler* MessagePumpForIO::KeyToHandler( | 677 MessagePumpForIO::IOHandler* MessagePumpForIO::KeyToHandler( |
656 ULONG_PTR key, | 678 ULONG_PTR key, |
657 bool* has_valid_io_context) { | 679 bool* has_valid_io_context) { |
658 *has_valid_io_context = ((key & 1) == 0); | 680 *has_valid_io_context = ((key & 1) == 0); |
659 return reinterpret_cast<IOHandler*>(key & ~static_cast<ULONG_PTR>(1)); | 681 return reinterpret_cast<IOHandler*>(key & ~static_cast<ULONG_PTR>(1)); |
660 } | 682 } |
661 | 683 |
662 } // namespace base | 684 } // namespace base |
OLD | NEW |