Commit c9d7048a authored by Christian Fremerey's avatar Christian Fremerey Committed by Commit Bot

[Video Capture Service] Improve UMA

This CL is part of the Mojo Video Capture work.
Design doc for dev work [1].
Design doc for launch [2].

After this CL we differentiate in the UMA logging between
enumeration-only usages of the service and usages that include actual capture.

BUG:584797,721812

[1] https://docs.google.com/a/chromium.org/document/d/1Qw7rw1AJy0QHXjha36jZNiEuxsxWslJ_X-zpOhijvI8/edit?usp=sharing
[2] https://docs.google.com/document/d/1RLlgEdvqRA_NQfSPMJLn5KR-ygVzZ2MRgIy9yd6CdFA/edit?usp=sharing

Change-Id: If6fd5fd1480edf18cce861f6c880d811a2f9a58c
Reviewed-on: https://chromium-review.googlesource.com/572220
Commit-Queue: Christian Fremerey <chfremer@chromium.org>
Reviewed-by: default avatarEmircan Uysaler <emircan@chromium.org>
Reviewed-by: default avatarJesse Doherty <jwd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488319}
parent 6878e9af
......@@ -13,7 +13,8 @@
namespace content {
ServiceVideoCaptureProvider::ServiceVideoCaptureProvider() {
ServiceVideoCaptureProvider::ServiceVideoCaptureProvider()
: has_created_device_launcher_(false) {
sequence_checker_.DetachFromSequence();
DCHECK(BrowserThread::CurrentlyOn(content::BrowserThread::UI));
connector_ =
......@@ -42,6 +43,7 @@ std::unique_ptr<VideoCaptureDeviceLauncher>
ServiceVideoCaptureProvider::CreateDeviceLauncher() {
DCHECK(sequence_checker_.CalledOnValidSequence());
LazyConnectToService();
has_created_device_launcher_ = true;
return base::MakeUnique<ServiceVideoCaptureDeviceLauncher>(&device_factory_);
}
......@@ -52,10 +54,16 @@ void ServiceVideoCaptureProvider::LazyConnectToService() {
video_capture::uma::LogVideoCaptureServiceEvent(
video_capture::uma::BROWSER_CONNECTING_TO_SERVICE);
if (time_of_last_uninitialize_ != base::TimeTicks()) {
video_capture::uma::LogDurationUntilReconnect(base::TimeTicks::Now() -
time_of_last_uninitialize_);
if (has_created_device_launcher_) {
video_capture::uma::LogDurationUntilReconnectAfterCapture(
base::TimeTicks::Now() - time_of_last_uninitialize_);
} else {
video_capture::uma::LogDurationUntilReconnectAfterEnumerationOnly(
base::TimeTicks::Now() - time_of_last_uninitialize_);
}
}
has_created_device_launcher_ = false;
time_of_last_connect_ = base::TimeTicks::Now();
connector_->BindInterface(video_capture::mojom::kServiceName,
......@@ -86,10 +94,21 @@ void ServiceVideoCaptureProvider::UninitializeInternal(
switch (reason) {
case ReasonForUninitialize::kShutdown:
case ReasonForUninitialize::kClientRequest:
video_capture::uma::LogVideoCaptureServiceEvent(
video_capture::uma::BROWSER_CLOSING_CONNECTION_TO_SERVICE);
video_capture::uma::LogDurationFromLastConnectToClosingConnection(
duration_since_last_connect);
if (has_created_device_launcher_) {
video_capture::uma::LogVideoCaptureServiceEvent(
video_capture::uma::
BROWSER_CLOSING_CONNECTION_TO_SERVICE_AFTER_CAPTURE);
video_capture::uma::
LogDurationFromLastConnectToClosingConnectionAfterCapture(
duration_since_last_connect);
} else {
video_capture::uma::LogVideoCaptureServiceEvent(
video_capture::uma::
BROWSER_CLOSING_CONNECTION_TO_SERVICE_AFTER_ENUMERATION_ONLY);
video_capture::uma::
LogDurationFromLastConnectToClosingConnectionAfterEnumerationOnly(
duration_since_last_connect);
}
break;
case ReasonForUninitialize::kConnectionLost:
video_capture::uma::LogVideoCaptureServiceEvent(
......
......@@ -49,6 +49,7 @@ class CONTENT_EXPORT ServiceVideoCaptureProvider : public VideoCaptureProvider {
video_capture::mojom::DeviceFactoryPtr device_factory_;
base::SequenceChecker sequence_checker_;
bool has_created_device_launcher_;
base::TimeTicks time_of_last_connect_;
base::TimeTicks time_of_last_uninitialize_;
};
......
......@@ -12,24 +12,48 @@ namespace uma {
void LogVideoCaptureServiceEvent(VideoCaptureServiceEvent event) {
UMA_HISTOGRAM_ENUMERATION("Media.VideoCaptureService.Event", event,
NUM_VIDEO_CAPTURE_SERVICE_EVENT);
DVLOG(4) << "Logged VideoCaptureServiceEvent " << event;
}
void LogDurationFromLastConnectToClosingConnection(base::TimeDelta duration) {
void LogDurationFromLastConnectToClosingConnectionAfterEnumerationOnly(
base::TimeDelta duration) {
UMA_HISTOGRAM_CUSTOM_TIMES(
"Media.VideoCaptureService.DurationFromLastConnectToClosingConnection",
duration, base::TimeDelta(), base::TimeDelta::FromDays(7), 50);
"Media.VideoCaptureService."
"DurationFromLastConnectToClosingConnectionAfterEnumerationOnly",
duration, base::TimeDelta(), base::TimeDelta::FromMinutes(1), 50);
DVLOG(4) << "Logged "
"DurationFromLastConnectToClosingConnectionAfterEnumerationOnl"
"y";
}
void LogDurationFromLastConnectToClosingConnectionAfterCapture(
base::TimeDelta duration) {
UMA_HISTOGRAM_CUSTOM_TIMES(
"Media.VideoCaptureService."
"DurationFromLastConnectToClosingConnectionAfterCapture",
duration, base::TimeDelta(), base::TimeDelta::FromDays(21), 50);
DVLOG(4) << "Logged DurationFromLastConnectToClosingConnectionAfterCapture";
}
void LogDurationFromLastConnectToConnectionLost(base::TimeDelta duration) {
UMA_HISTOGRAM_CUSTOM_TIMES(
"Media.VideoCaptureService.DurationFromLastConnectToConnectionLost",
duration, base::TimeDelta(), base::TimeDelta::FromDays(21), 50);
DVLOG(4) << "Logged DurationFromLastConnectToConnectionLost";
}
void LogDurationUntilReconnectAfterEnumerationOnly(base::TimeDelta duration) {
UMA_HISTOGRAM_CUSTOM_TIMES(
"Media.VideoCaptureService.DurationUntilReconnectAfterEnumerationOnly",
duration, base::TimeDelta(), base::TimeDelta::FromDays(7), 50);
DVLOG(4) << "Logged DurationUntilReconnectAfterEnumerationOnly";
}
void LogDurationUntilReconnect(base::TimeDelta duration) {
UMA_HISTOGRAM_CUSTOM_TIMES("Media.VideoCaptureService.DurationUntilReconnect",
duration, base::TimeDelta(),
base::TimeDelta::FromDays(7), 50);
void LogDurationUntilReconnectAfterCapture(base::TimeDelta duration) {
UMA_HISTOGRAM_CUSTOM_TIMES(
"Media.VideoCaptureService.DurationUntilReconnectAfterCapture", duration,
base::TimeDelta(), base::TimeDelta::FromDays(7), 50);
DVLOG(4) << "Logged DurationUntilReconnectAfterCapture";
}
} // namespace uma
......
......@@ -18,18 +18,25 @@ enum VideoCaptureServiceEvent {
BROWSER_USING_LEGACY_CAPTURE = 0,
BROWSER_CONNECTING_TO_SERVICE = 1,
SERVICE_STARTED = 2,
SERVICE_CLOSING_BECAUSE_NO_CLIENT = 3,
SERVICE_SHUTTING_DOWN_BECAUSE_NO_CLIENT = 3,
SERVICE_LOST_CONNECTION_TO_BROWSER = 4,
BROWSER_LOST_CONNECTION_TO_SERVICE = 5,
BROWSER_CLOSING_CONNECTION_TO_SERVICE = 6,
BROWSER_CLOSING_CONNECTION_TO_SERVICE = 6, // No longer in use
BROWSER_CLOSING_CONNECTION_TO_SERVICE_AFTER_ENUMERATION_ONLY = 7,
BROWSER_CLOSING_CONNECTION_TO_SERVICE_AFTER_CAPTURE = 8,
SERVICE_SHUTDOWN_TIMEOUT_CANCELED = 9,
NUM_VIDEO_CAPTURE_SERVICE_EVENT
};
void LogVideoCaptureServiceEvent(VideoCaptureServiceEvent event);
void LogDurationFromLastConnectToClosingConnection(base::TimeDelta duration);
void LogDurationFromLastConnectToClosingConnectionAfterEnumerationOnly(
base::TimeDelta duration);
void LogDurationFromLastConnectToClosingConnectionAfterCapture(
base::TimeDelta duration);
void LogDurationFromLastConnectToConnectionLost(base::TimeDelta duration);
void LogDurationUntilReconnect(base::TimeDelta duration);
void LogDurationUntilReconnectAfterEnumerationOnly(base::TimeDelta duration);
void LogDurationUntilReconnectAfterCapture(base::TimeDelta duration);
} // namespace uma
} // namespace video_capture
......
......@@ -94,8 +94,11 @@ void ServiceImpl::MaybeRequestQuit() {
DCHECK(ref_factory_);
if (ref_factory_->HasNoRefs()) {
video_capture::uma::LogVideoCaptureServiceEvent(
video_capture::uma::SERVICE_CLOSING_BECAUSE_NO_CLIENT);
video_capture::uma::SERVICE_SHUTTING_DOWN_BECAUSE_NO_CLIENT);
context()->RequestQuit();
} else {
video_capture::uma::LogVideoCaptureServiceEvent(
video_capture::uma::SERVICE_SHUTDOWN_TIMEOUT_CANCELED);
}
}
......
......@@ -38239,10 +38239,18 @@ from previous Chrome versions.
<int value="1" label="Browser connecting to video capture service"/>
<int value="2" label="Video capture service started"/>
<int value="3"
label="Video capture service closing because last client disconnected"/>
label="Video capture service shutting down because last client
disconnected"/>
<int value="4" label="Video capture service lost connection to Browser"/>
<int value="5" label="Browser lost connection to video capture service"/>
<int value="6" label="Browser closing connection to video capture service"/>
<int value="7"
label="Browser closing connection to video capture service after
enumerating devices only"/>
<int value="8"
label="Browser closing connection to video capture service after video
capture session"/>
<int value="9" label="Video capture service timeout canceled"/>
</enum>
<enum name="VideoCodec">
......@@ -31457,6 +31457,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram
name="Media.VideoCaptureService.DurationFromLastConnectToClosingConnection"
units="ms">
<obsolete>
Deprecated 07/2017 in favor of the more differentiated durations.
</obsolete>
<owner>chfremer@chromium.org</owner>
<summary>
Measures the duration from the time the Browser connected to the video
......@@ -31464,6 +31467,30 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram
name="Media.VideoCaptureService.DurationFromLastConnectToClosingConnectionAfterCapture"
units="ms">
<owner>chfremer@chromium.org</owner>
<summary>
Measures the duration from the time the Browser connected to the video
capture service to the time it closed the connection. Entries are only
logged if the service was used for creating an actual capture session as
opposed to enumerating devices only.
</summary>
</histogram>
<histogram
name="Media.VideoCaptureService.DurationFromLastConnectToClosingConnectionAfterEnumerationOnly"
units="ms">
<owner>chfremer@chromium.org</owner>
<summary>
Measures the duration from the time the Browser connected to the video
capture service to the time it closed the connection. Entries are only
logged if the service was used for enumerating devices only, but not for
creating an actual capture session.
</summary>
</histogram>
<histogram
name="Media.VideoCaptureService.DurationFromLastConnectToConnectionLost"
units="ms">
......@@ -31475,6 +31502,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</histogram>
<histogram name="Media.VideoCaptureService.DurationUntilReconnect" units="ms">
<obsolete>
Deprecated 07/2017 in favor of the more differentiated durations.
</obsolete>
<owner>chfremer@chromium.org</owner>
<summary>
Measures the duration from the time the Browser last closed or lost
......@@ -31482,6 +31512,29 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="Media.VideoCaptureService.DurationUntilReconnectAfterCapture"
units="ms">
<owner>chfremer@chromium.org</owner>
<summary>
Measures the duration from the time the Browser last closed or lost
connection to the video capture service to the time it reconnects. This
duration only gets logged for reconnects after usage of the service for
capture (as opposed to enumeration-only usage).
</summary>
</histogram>
<histogram
name="Media.VideoCaptureService.DurationUntilReconnectAfterEnumerationOnly"
units="ms">
<owner>chfremer@chromium.org</owner>
<summary>
Measures the duration from the time the Browser last closed or lost
connection to the video capture service to the time it reconnects. This
duration only gets logged for reconnects after enumeration-only usage of the
service.
</summary>
</histogram>
<histogram name="Media.VideoCaptureService.Event"
enum="VideoCaptureServiceEvent">
<owner>chfremer@chromium.org</owner>
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