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

Unified Diff: content/renderer/media/media_stream_impl.cc

Issue 446553002: Add histogram WebRTC.UserMediaRequest.NoResultState to track user media requests with no result. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b399835
Patch Set: Diffbase https://codereview.chromium.org/427713004/ Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_impl.cc
diff --git a/content/renderer/media/media_stream_impl.cc b/content/renderer/media/media_stream_impl.cc
index 145da08becaafff25debdbd4808dcbf1316e1c20..d9ca1f0857a5a0716fdd00c99cd8289b0b3fac71 100644
--- a/content/renderer/media/media_stream_impl.cc
+++ b/content/renderer/media/media_stream_impl.cc
@@ -199,6 +199,9 @@ void MediaStreamImpl::cancelUserMediaRequest(
// We can't abort the stream generation process.
// Instead, erase the request. Once the stream is generated we will stop the
// stream if the request does not exist.
+ LogUserMediaRequestWithNoResult(true,
vrk (LEFT CHROMIUM) 2014/08/05 19:05:40 In general, boolean parameters are not good practi
andresp-chromium 2014/08/06 10:13:56 Done.
+ request->generated,
+ request->HasPendingSources());
DeleteUserMediaRequestInfo(request);
}
}
@@ -273,23 +276,8 @@ void MediaStreamImpl::OnStreamGenerated(
UserMediaRequestInfo* request_info = FindUserMediaRequestInfo(request_id);
if (!request_info) {
- // This can happen if the request is canceled or the frame reloads while
- // MediaStreamDispatcher is processing the request.
- // Only stop the device if the device is not used in another MediaStream.
- for (StreamDeviceInfoArray::const_iterator device_it = audio_array.begin();
- device_it != audio_array.end(); ++device_it) {
- if (!FindLocalSource(*device_it))
- media_stream_dispatcher_->StopStreamDevice(*device_it);
- }
-
- for (StreamDeviceInfoArray::const_iterator device_it = video_array.begin();
- device_it != video_array.end(); ++device_it) {
- if (!FindLocalSource(*device_it))
- media_stream_dispatcher_->StopStreamDevice(*device_it);
- }
-
DVLOG(1) << "Request ID not found";
- return;
+ return OnStreamGeneratedForCancelledRequest(audio_array, video_array);
vrk (LEFT CHROMIUM) 2014/08/05 19:05:40 Why did you make this into its own function? Also
andresp-chromium 2014/08/06 10:13:56 This was re factoring when reading the code. Origi
}
request_info->generated = true;
@@ -332,6 +320,26 @@ void MediaStreamImpl::OnStreamGenerated(
weak_factory_.GetWeakPtr()));
}
+// This can happen if the request is canceled or the frame reloads while
+// MediaStreamDispatcher is processing the request.
+// Only stop the device if the device is not used in another MediaStream.
+void MediaStreamImpl::OnStreamGeneratedForCancelledRequest(
+ const StreamDeviceInfoArray& audio_array,
+ const StreamDeviceInfoArray& video_array) {
+ for (StreamDeviceInfoArray::const_iterator device_it = audio_array.begin();
+ device_it != audio_array.end(); ++device_it) {
+ if (!FindLocalSource(*device_it))
+ media_stream_dispatcher_->StopStreamDevice(*device_it);
+ }
+
+ for (StreamDeviceInfoArray::const_iterator device_it = video_array.begin();
+ device_it != video_array.end(); ++device_it) {
+ if (!FindLocalSource(*device_it))
+ media_stream_dispatcher_->StopStreamDevice(*device_it);
+ }
+}
+
vrk (LEFT CHROMIUM) 2014/08/05 19:05:40 nit: extra line
andresp-chromium 2014/08/06 10:13:56 Done.
+
// Callback from MediaStreamDispatcher.
// The requested stream failed to be generated.
void MediaStreamImpl::OnStreamGenerationFailed(
@@ -701,6 +709,26 @@ void MediaStreamImpl::DeleteUserMediaRequestInfo(
NOTREACHED();
}
+void MediaStreamImpl::DeleteAllUserMediaRequests() {
+ UserMediaRequests::iterator request_it = user_media_requests_.begin();
+ while (request_it != user_media_requests_.end()) {
+ DVLOG(1) << "MediaStreamImpl@" << this << "::DeleteAllUserMediaRequests: "
+ << "Cancel user media request " << (*request_it)->request_id;
+ // If the request is not generated, it means that a request
+ // has been sent to the MediaStreamDispatcher to generate a stream
+ // but MediaStreamDispatcher has not yet responded and we need to cancel
+ // the request.
+ if (!(*request_it)->generated) {
+ media_stream_dispatcher_->CancelGenerateStream(
+ (*request_it)->request_id, weak_factory_.GetWeakPtr());
+ }
+ LogUserMediaRequestWithNoResult(false,
vrk (LEFT CHROMIUM) 2014/08/05 19:05:40 As stated elsewhere, this call should instead look
andresp-chromium 2014/08/06 10:13:56 Done. I liked this suggestion.
+ (*request_it)->generated,
+ (*request_it)->HasPendingSources());
+ request_it = user_media_requests_.erase(request_it);
+ }
+}
+
MediaStreamImpl::MediaDevicesRequestInfo*
MediaStreamImpl::FindMediaDevicesRequestInfo(
int request_id) {
@@ -748,20 +776,7 @@ void MediaStreamImpl::CancelAndDeleteMediaDevicesRequest(
void MediaStreamImpl::FrameWillClose() {
// Cancel all outstanding UserMediaRequests.
- UserMediaRequests::iterator request_it = user_media_requests_.begin();
- while (request_it != user_media_requests_.end()) {
- DVLOG(1) << "MediaStreamImpl@" << this << "::FrameWillClose: "
- << "Cancel user media request " << (*request_it)->request_id;
- // If the request is not generated, it means that a request
- // has been sent to the MediaStreamDispatcher to generate a stream
- // but MediaStreamDispatcher has not yet responded and we need to cancel
- // the request.
- if (!(*request_it)->generated) {
- media_stream_dispatcher_->CancelGenerateStream(
- (*request_it)->request_id, weak_factory_.GetWeakPtr());
- }
- request_it = user_media_requests_.erase(request_it);
- }
+ DeleteAllUserMediaRequests();
vrk (LEFT CHROMIUM) 2014/08/05 19:05:40 Why did you move this into its own function?
andresp-chromium 2014/08/06 10:13:56 Re-factoring when reading the code. I wanted to is
// Loop through all current local sources and stop the sources.
LocalStreamSources::iterator sources_it = local_sources_.begin();

Powered by Google App Engine
This is Rietveld 408576698