Commit d1224786 authored by Alexander Dunaev's avatar Alexander Dunaev Committed by Commit Bot

[ozone/wayland] Introduced the histogram to track time on data transfer.

When data is dragged from another application into Chromium, there is a
delay between mouse pointer crossing the window border and the actual
OnDragEnter() called on the window.  The delay happens because the
drag drop controller has to get the data, which implies at least one
request to the Wayland server (the actual number of requests equals
number of MIME types available in the data offer).

Here a histogram is introduced to know what the real delays will be
there in the wild.

Bug: 1147413
Change-Id: I2f3acc067f718ccb29d98ea1bf98b9f03efc2f7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2552864Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Commit-Queue: Alexander Dunaev <adunaev@igalia.com>
Cr-Commit-Position: refs/heads/master@{#831251}
parent 6450f019
......@@ -1640,6 +1640,16 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="Event.WaylandDragDrop.IncomingDataTransferTime" units="ms"
expires_after="M90">
<owner>adunaev@igalia.com</owner>
<owner>rjkroege@chromium.org</owner>
<summary>
Delay between the drag coming into the window and the window is actually
notified.
</summary>
</histogram>
<histogram base="true" name="EventLatency" units="microseconds"
expires_after="2021-05-09">
<owner>mohsen@chromium.org</owner>
......
......@@ -7,6 +7,7 @@
#include <cstdint>
#include "base/check.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/clipboard_constants.h"
......@@ -160,7 +161,7 @@ void WaylandDataDragController::OnDragEnter(WaylandWindow* window,
received_data_ = std::make_unique<OSExchangeData>(
std::make_unique<OSExchangeDataProviderNonBacked>());
last_drag_location_ = location;
HandleUnprocessedMimeTypes();
HandleUnprocessedMimeTypes(base::TimeTicks::Now());
}
}
......@@ -281,21 +282,23 @@ void WaylandDataDragController::CreateIconSurfaceIfNeeded(
// more unprocessed mime types on the |unprocessed_mime_types_| queue. Once this
// process is finished, OnDataTransferFinished is called to deliver the
// |received_data_| to the drop handler.
void WaylandDataDragController::HandleUnprocessedMimeTypes() {
void WaylandDataDragController::HandleUnprocessedMimeTypes(
base::TimeTicks start_time) {
DCHECK_EQ(state_, State::kTransferring);
std::string mime_type = GetNextUnprocessedMimeType();
if (mime_type.empty() || is_leave_pending_) {
OnDataTransferFinished(std::move(received_data_));
OnDataTransferFinished(start_time, std::move(received_data_));
} else {
DCHECK(data_offer_);
data_device_->RequestData(
data_offer_.get(), mime_type,
base::BindOnce(&WaylandDataDragController::OnMimeTypeDataTransferred,
weak_factory_.GetWeakPtr()));
weak_factory_.GetWeakPtr(), start_time));
}
}
void WaylandDataDragController::OnMimeTypeDataTransferred(
base::TimeTicks start_time,
PlatformClipboard::Data contents) {
DCHECK_EQ(state_, State::kTransferring);
DCHECK(contents);
......@@ -306,10 +309,11 @@ void WaylandDataDragController::OnMimeTypeDataTransferred(
unprocessed_mime_types_.pop_front();
// Continue reading data for other negotiated mime types.
HandleUnprocessedMimeTypes();
HandleUnprocessedMimeTypes(start_time);
}
void WaylandDataDragController::OnDataTransferFinished(
base::TimeTicks start_time,
std::unique_ptr<OSExchangeData> received_data) {
unprocessed_mime_types_.clear();
state_ = State::kIdle;
......@@ -329,6 +333,9 @@ void WaylandDataDragController::OnDataTransferFinished(
return;
}
UMA_HISTOGRAM_TIMES("Event.WaylandDragDrop.IncomingDataTransferTime",
base::TimeTicks::Now() - start_time);
PropagateOnDragEnter(last_drag_location_, std::move(received_data));
}
......
......@@ -105,9 +105,11 @@ class WaylandDataDragController : public WaylandDataDevice::DragDelegate,
void Offer(const OSExchangeData& data, int operation);
void CreateIconSurfaceIfNeeded(const OSExchangeData& data);
void HandleUnprocessedMimeTypes();
void OnMimeTypeDataTransferred(PlatformClipboard::Data contents);
void HandleUnprocessedMimeTypes(base::TimeTicks start_time);
void OnMimeTypeDataTransferred(base::TimeTicks start_time,
PlatformClipboard::Data contents);
void OnDataTransferFinished(
base::TimeTicks start_time,
std::unique_ptr<ui::OSExchangeData> received_data);
std::string GetNextUnprocessedMimeType();
// Calls the window's OnDragEnter with the given location and data,
......
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