Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: base/message_loop/message_pump_win.cc

Issue 830423008: Revert of Further instrumentations to find jank in Windows message processing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/win/hwnd_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 314
315 state_->delegate->DoDelayedWork(&delayed_work_time_); 315 state_->delegate->DoDelayedWork(&delayed_work_time_);
316 if (!delayed_work_time_.is_null()) { 316 if (!delayed_work_time_.is_null()) {
317 // A bit gratuitous to set delayed_work_time_ again, but oh well. 317 // A bit gratuitous to set delayed_work_time_ again, but oh well.
318 ScheduleDelayedWork(delayed_work_time_); 318 ScheduleDelayedWork(delayed_work_time_);
319 } 319 }
320 } 320 }
321 321
322 bool MessagePumpForUI::ProcessNextWindowsMessage() { 322 bool MessagePumpForUI::ProcessNextWindowsMessage() {
323 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. 323 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed.
324 tracked_objects::ScopedTracker tracking_profile1( 324 tracked_objects::ScopedTracker tracking_profile(
325 FROM_HERE_WITH_EXPLICIT_FUNCTION( 325 FROM_HERE_WITH_EXPLICIT_FUNCTION(
326 "440919 MessagePumpForUI::ProcessNextWindowsMessage1")); 326 "440919 <<MessagePumpForUI::ProcessNextWindowsMessage>>"));
327 327
328 // If there are sent messages in the queue then PeekMessage internally 328 // If there are sent messages in the queue then PeekMessage internally
329 // dispatches the message and returns false. We return true in this 329 // dispatches the message and returns false. We return true in this
330 // case to ensure that the message loop peeks again instead of calling 330 // case to ensure that the message loop peeks again instead of calling
331 // MsgWaitForMultipleObjectsEx again. 331 // MsgWaitForMultipleObjectsEx again.
332 bool sent_messages_in_queue = false; 332 bool sent_messages_in_queue = false;
333 DWORD queue_status = GetQueueStatus(QS_SENDMESSAGE); 333 DWORD queue_status = GetQueueStatus(QS_SENDMESSAGE);
334 if (HIWORD(queue_status) & QS_SENDMESSAGE) 334 if (HIWORD(queue_status) & QS_SENDMESSAGE)
335 sent_messages_in_queue = true; 335 sent_messages_in_queue = true;
336 336
337 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed.
338 tracked_objects::ScopedTracker tracking_profile2(
339 FROM_HERE_WITH_EXPLICIT_FUNCTION(
340 "440919 MessagePumpForUI::ProcessNextWindowsMessage2"));
341
342 MSG msg; 337 MSG msg;
343 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != FALSE) 338 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != FALSE)
344 return ProcessMessageHelper(msg); 339 return ProcessMessageHelper(msg);
345 340
346 return sent_messages_in_queue; 341 return sent_messages_in_queue;
347 } 342 }
348 343
349 bool MessagePumpForUI::ProcessMessageHelper(const MSG& msg) { 344 bool MessagePumpForUI::ProcessMessageHelper(const MSG& msg) {
350 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. 345 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed.
351 tracked_objects::ScopedTracker tracking_profile1( 346 tracked_objects::ScopedTracker tracking_profile(
352 FROM_HERE_WITH_EXPLICIT_FUNCTION( 347 FROM_HERE_WITH_EXPLICIT_FUNCTION(
353 "440919 MessagePumpForUI::ProcessMessageHelper1")); 348 "440919 MessagePumpForUI::ProcessMessageHelper"));
354 349
355 TRACE_EVENT1("base", "MessagePumpForUI::ProcessMessageHelper", 350 TRACE_EVENT1("base", "MessagePumpForUI::ProcessMessageHelper",
356 "message", msg.message); 351 "message", msg.message);
357 if (WM_QUIT == msg.message) { 352 if (WM_QUIT == msg.message) {
358 // Repost the QUIT message so that it will be retrieved by the primary 353 // Repost the QUIT message so that it will be retrieved by the primary
359 // GetMessage() loop. 354 // GetMessage() loop.
360 state_->should_quit = true; 355 state_->should_quit = true;
361 PostQuitMessage(static_cast<int>(msg.wParam)); 356 PostQuitMessage(static_cast<int>(msg.wParam));
362 return false; 357 return false;
363 } 358 }
364 359
365 // While running our main message pump, we discard kMsgHaveWork messages. 360 // While running our main message pump, we discard kMsgHaveWork messages.
366 if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_) 361 if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_)
367 return ProcessPumpReplacementMessage(); 362 return ProcessPumpReplacementMessage();
368 363
369 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed.
370 tracked_objects::ScopedTracker tracking_profile2(
371 FROM_HERE_WITH_EXPLICIT_FUNCTION(
372 "440919 MessagePumpForUI::ProcessMessageHelper2"));
373
374 if (CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode)) 364 if (CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode))
375 return true; 365 return true;
376 366
377 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed.
378 tracked_objects::ScopedTracker tracking_profile3(
379 FROM_HERE_WITH_EXPLICIT_FUNCTION(
380 "440919 MessagePumpForUI::ProcessMessageHelper3"));
381
382 uint32_t action = MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT; 367 uint32_t action = MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT;
383 if (state_->dispatcher) 368 if (state_->dispatcher)
384 action = state_->dispatcher->Dispatch(msg); 369 action = state_->dispatcher->Dispatch(msg);
385 if (action & MessagePumpDispatcher::POST_DISPATCH_QUIT_LOOP) 370 if (action & MessagePumpDispatcher::POST_DISPATCH_QUIT_LOOP)
386 state_->should_quit = true; 371 state_->should_quit = true;
387 if (action & MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT) { 372 if (action & MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT) {
388 TranslateMessage(&msg); 373 TranslateMessage(&msg);
389 DispatchMessage(&msg); 374 DispatchMessage(&msg);
390 } 375 }
391 376
392 return true; 377 return true;
393 } 378 }
394 379
395 bool MessagePumpForUI::ProcessPumpReplacementMessage() { 380 bool MessagePumpForUI::ProcessPumpReplacementMessage() {
396 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed.
397 tracked_objects::ScopedTracker tracking_profile(
398 FROM_HERE_WITH_EXPLICIT_FUNCTION(
399 "440919 MessagePumpForUI::ProcessPumpReplacementMessage"));
400
401 // When we encounter a kMsgHaveWork message, this method is called to peek 381 // When we encounter a kMsgHaveWork message, this method is called to peek
402 // and process a replacement message, such as a WM_PAINT or WM_TIMER. The 382 // and process a replacement message, such as a WM_PAINT or WM_TIMER. The
403 // goal is to make the kMsgHaveWork as non-intrusive as possible, even though 383 // goal is to make the kMsgHaveWork as non-intrusive as possible, even though
404 // a continuous stream of such messages are posted. This method carefully 384 // a continuous stream of such messages are posted. This method carefully
405 // peeks a message while there is no chance for a kMsgHaveWork to be pending, 385 // peeks a message while there is no chance for a kMsgHaveWork to be pending,
406 // then resets the have_work_ flag (allowing a replacement kMsgHaveWork to 386 // then resets the have_work_ flag (allowing a replacement kMsgHaveWork to
407 // possibly be posted), and finally dispatches that peeked replacement. Note 387 // possibly be posted), and finally dispatches that peeked replacement. Note
408 // that the re-post of kMsgHaveWork may be asynchronous to this thread!! 388 // that the re-post of kMsgHaveWork may be asynchronous to this thread!!
409 389
410 bool have_message = false; 390 bool have_message = false;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 638
659 // static 639 // static
660 MessagePumpForIO::IOHandler* MessagePumpForIO::KeyToHandler( 640 MessagePumpForIO::IOHandler* MessagePumpForIO::KeyToHandler(
661 ULONG_PTR key, 641 ULONG_PTR key,
662 bool* has_valid_io_context) { 642 bool* has_valid_io_context) {
663 *has_valid_io_context = ((key & 1) == 0); 643 *has_valid_io_context = ((key & 1) == 0);
664 return reinterpret_cast<IOHandler*>(key & ~static_cast<ULONG_PTR>(1)); 644 return reinterpret_cast<IOHandler*>(key & ~static_cast<ULONG_PTR>(1));
665 } 645 }
666 646
667 } // namespace base 647 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/win/hwnd_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698