Commit f8df1ab6 authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

Record a success stat for each Windows touch drag drop.

This stat will be used by the team working on the WebUI
tab strip to determine how much of a real world problem
failure of touch drag of tabs in the tab strip is.

Failure is detected by ::DoDragDrop blocking for more than one second
and only calling QueryContinueDrag once.

Bug: 1126230
Change-Id: I75b9d3a95912b8ef2ec049fcd32ed4700e4ca51d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437485
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812685}
parent 2dc7f1dc
......@@ -292,6 +292,22 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="Windows.TouchDrag.Success" units="BooleanSuccess"
expires_after="2021-03-01">
<owner>davidbienvenu@chromium.org</owner>
<owner>dfried@chromium.org</owner>
<summary>
Recorded each time the user starts a Windows touch drag drop of web
contents. This is currently only used by the WebUI tab strip, where touch
drag drop is enabled, to count the number of touch drags attempted.
::DoDragDrop occasionally blocks waiting for a right mouse button down
followed by a move, which is detected by ::DoDragDrop not calling
QueryContinueDrag for more than a second. This will be recorded as false.
This stat will be used to determine how much of a real world problem this
is.
</summary>
</histogram>
</histograms>
</histogram-configuration>
......@@ -16,6 +16,7 @@ DragSourceWin::DragSourceWin() : cancel_drag_(false), data_(nullptr) {
}
HRESULT DragSourceWin::QueryContinueDrag(BOOL escape_pressed, DWORD key_state) {
num_query_continues_++;
if (cancel_drag_)
return DRAGDROP_S_CANCEL;
......
......@@ -42,6 +42,10 @@ class DragSourceWin
cancel_drag_ = true;
}
// This is used to tell if the drag drop actually started, for generating
// a BooleanSuccess histogram.
int num_query_continues() const { return num_query_continues_; }
// IDropSource implementation:
HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed,
DWORD key_state) override;
......@@ -63,6 +67,12 @@ class DragSourceWin
const OSExchangeData* data_;
// The number of times for this drag that Windows asked if the drag should
// continue. This is used in DesktopDragDropClientWin::StartDragAndDrop to
// detect if touch drag drop started successfully. See comment there for much
// more info.
int num_query_continues_ = 0;
DISALLOW_COPY_AND_ASSIGN(DragSourceWin);
};
......
......@@ -6,6 +6,7 @@
#include <memory>
#include "base/metrics/histogram_macros.h"
#include "base/threading/hang_watcher.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/drag_source_win.h"
......@@ -72,12 +73,32 @@ int DesktopDragDropClientWin::StartDragAndDrop(
// Disable hang watching until the end of the function since the user can take
// unbounded time to complete the drag. (http://crbug.com/806174)
base::HangWatchScopeDisabled disabler;
base::TimeTicks start_time = base::TimeTicks::Now();
HRESULT result = ::DoDragDrop(
ui::OSExchangeDataProviderWin::GetIDataObject(*data.get()),
drag_source_.Get(),
ui::DragDropTypes::DragOperationToDropEffect(operation), &effect);
if (alive && source == ui::mojom::DragEventSource::kTouch) {
// In a normal drag drop, ::DoDragDrop calls QueryContinueDrag every time
// it gets a mouse or keyboard event. The windows doc
// https://docs.microsoft.com/en-us/windows/win32/api/oleidl/nf-oleidl-idropsource-querycontinuedrag
// says "every time it detects a change in keyboard or mouse button state"
// but empirically, on a Yoga laptop with a touch screen running Windows 10,
// it's called when it gets a mouse move event as well. (::DoDragDrop
// doesn't support touch, so Chrome synthesizes mouse events from touch
// events during drag drop.)
// In the touch failure case, when ::DoDragDrop blocks waiting for a right
// mouse button down event to start the drag, it only calls
// QueryContinueDrag once, when it gets an event that terminates the blocked
// drag drop, e.g., a swipe gesture from outside the Chrome window. So, we
// detect the failure case when a drag drop lasts more than one second, and
// QueryContinueDrag was not called more than once.
// See crbug.com/1126230.
UMA_HISTOGRAM_BOOLEAN("Windows.TouchDrag.Success",
drag_source_->num_query_continues() > 1 ||
(base::TimeTicks::Now() - start_time <
base::TimeDelta::FromSeconds(1)));
desktop_host_->SetInTouchDrag(false);
}
drag_source_copy->set_data(nullptr);
......
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