Commit 86708713 authored by vadimt's avatar vadimt Committed by Commit bot

Not counting nested loops as time spent in a task.

While in a nested loop, Chrome is not blocked, keeps updating the client area and is responding to user actions.
Subtracting the time in nested loops from the task in which it happens, so that we don't diagnose this task as a source of jank.

BUG=401560, 440919

Review URL: https://codereview.chromium.org/788883004

Cr-Commit-Position: refs/heads/master@{#308218}
parent c9db4db7
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/i18n/rtl.h" #include "base/i18n/rtl.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/tracked_objects.h"
#include "base/win/metro.h" #include "base/win/metro.h"
#include "base/win/win_util.h" #include "base/win/win_util.h"
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
...@@ -222,8 +223,15 @@ void ShowSystemMenuAtPoint(HWND window, const Point& point) { ...@@ -222,8 +223,15 @@ void ShowSystemMenuAtPoint(HWND window, const Point& point) {
if (base::i18n::IsRTL()) if (base::i18n::IsRTL())
flags |= TPM_RIGHTALIGN; flags |= TPM_RIGHTALIGN;
HMENU menu = GetSystemMenu(window, FALSE); HMENU menu = GetSystemMenu(window, FALSE);
// Use task stopwatch to exclude the time while the context menu is open from
// the current task, if any.
tracked_objects::TaskStopwatch stopwatch;
stopwatch.Start();
const int command = const int command =
TrackPopupMenu(menu, flags, point.x(), point.y(), 0, window, NULL); TrackPopupMenu(menu, flags, point.x(), point.y(), 0, window, NULL);
stopwatch.Stop();
if (command) if (command)
SendMessage(window, WM_SYSCOMMAND, command, 0); SendMessage(window, WM_SYSCOMMAND, command, 0);
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h"
#include "base/tracked_objects.h"
#include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/drag_source_win.h" #include "ui/base/dragdrop/drag_source_win.h"
#include "ui/base/dragdrop/drop_target_event.h" #include "ui/base/dragdrop/drop_target_event.h"
...@@ -36,9 +37,14 @@ int DesktopDragDropClientWin::StartDragAndDrop( ...@@ -36,9 +37,14 @@ int DesktopDragDropClientWin::StartDragAndDrop(
drag_source_ = new ui::DragSourceWin; drag_source_ = new ui::DragSourceWin;
DWORD effect; DWORD effect;
// Use task stopwatch to exclude the drag-drop time current task, if any.
tracked_objects::TaskStopwatch stopwatch;
stopwatch.Start();
HRESULT result = DoDragDrop( HRESULT result = DoDragDrop(
ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_.get(), ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_.get(),
ui::DragDropTypes::DragOperationToDropEffect(operation), &effect); ui::DragDropTypes::DragOperationToDropEffect(operation), &effect);
stopwatch.Stop();
drag_drop_in_progress_ = false; drag_drop_in_progress_ = false;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "base/tracked_objects.h"
#include "base/win/scoped_gdi_object.h" #include "base/win/scoped_gdi_object.h"
#include "base/win/win_util.h" #include "base/win/win_util.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
...@@ -2126,9 +2127,20 @@ void HWNDMessageHandler::OnSysCommand(UINT notification_code, ...@@ -2126,9 +2127,20 @@ void HWNDMessageHandler::OnSysCommand(UINT notification_code,
// with the mouse/touch/keyboard, we flag as being in a size loop. // with the mouse/touch/keyboard, we flag as being in a size loop.
if ((notification_code & sc_mask) == SC_SIZE) if ((notification_code & sc_mask) == SC_SIZE)
in_size_loop_ = true; in_size_loop_ = true;
const bool runs_nested_loop = ((notification_code & sc_mask) == SC_SIZE) ||
((notification_code & sc_mask) == SC_MOVE);
base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr());
// Use task stopwatch to exclude the time spend in the move/resize loop from
// the current task, if any.
tracked_objects::TaskStopwatch stopwatch;
if (runs_nested_loop)
stopwatch.Start();
DefWindowProc(hwnd(), WM_SYSCOMMAND, notification_code, DefWindowProc(hwnd(), WM_SYSCOMMAND, notification_code,
MAKELPARAM(point.x(), point.y())); MAKELPARAM(point.x(), point.y()));
if (runs_nested_loop)
stopwatch.Stop();
if (!ref.get()) if (!ref.get())
return; return;
in_size_loop_ = false; in_size_loop_ = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment