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

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

Issue 937293002: Unify request failure handling in content::UserMediaClientImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed remaining breaks + updated unit test code Created 5 years, 10 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/user_media_client_impl.cc
diff --git a/content/renderer/media/user_media_client_impl.cc b/content/renderer/media/user_media_client_impl.cc
index 316d62ae7bba279dcc6bb3fdfc90ca31dd3cd028..756f3a251ea169c5e1cb1007cf0b78c66cfd8831 100644
--- a/content/renderer/media/user_media_client_impl.cc
+++ b/content/renderer/media/user_media_client_impl.cc
@@ -499,7 +499,7 @@ void UserMediaClientImpl::OnStreamGenerationFailed(
return;
}
- GetUserMediaRequestFailed(&request_info->request, result);
+ GetUserMediaRequestFailed(&request_info->request, result, "");
DeleteUserMediaRequestInfo(request_info);
}
@@ -654,9 +654,7 @@ void UserMediaClientImpl::OnCreateNativeTracksCompleted(
if (result == content::MEDIA_DEVICE_OK)
GetUserMediaRequestSucceeded(request->web_stream, &request->request);
else
- GetUserMediaRequestTrackStartedFailed(&request->request,
- result,
- result_name);
+ GetUserMediaRequestFailed(&request->request, result, result_name);
DeleteUserMediaRequestInfo(request);
}
@@ -724,59 +722,53 @@ void UserMediaClientImpl::GetUserMediaRequestSucceeded(
void UserMediaClientImpl::GetUserMediaRequestFailed(
blink::WebUserMediaRequest* request_info,
- MediaStreamRequestResult result) {
+ MediaStreamRequestResult result,
+ const blink::WebString& result_name) {
LogUserMediaRequestResult(result);
switch (result) {
case MEDIA_DEVICE_OK:
+ case NUM_MEDIA_REQUEST_RESULTS:
NOTREACHED();
- break;
+ return;
case MEDIA_DEVICE_PERMISSION_DENIED:
request_info->requestDenied();
- break;
+ return;
case MEDIA_DEVICE_PERMISSION_DISMISSED:
request_info->requestFailedUASpecific("PermissionDismissedError");
- break;
+ return;
case MEDIA_DEVICE_INVALID_STATE:
request_info->requestFailedUASpecific("InvalidStateError");
- break;
+ return;
case MEDIA_DEVICE_NO_HARDWARE:
request_info->requestFailedUASpecific("DevicesNotFoundError");
- break;
+ return;
case MEDIA_DEVICE_INVALID_SECURITY_ORIGIN:
request_info->requestFailedUASpecific("InvalidSecurityOriginError");
- break;
+ return;
case MEDIA_DEVICE_TAB_CAPTURE_FAILURE:
request_info->requestFailedUASpecific("TabCaptureError");
- break;
+ return;
case MEDIA_DEVICE_SCREEN_CAPTURE_FAILURE:
request_info->requestFailedUASpecific("ScreenCaptureError");
- break;
+ return;
case MEDIA_DEVICE_CAPTURE_FAILURE:
request_info->requestFailedUASpecific("DeviceCaptureError");
- break;
- default:
- NOTREACHED();
- request_info->requestFailed();
- break;
- }
-}
-
-void UserMediaClientImpl::GetUserMediaRequestTrackStartedFailed(
- blink::WebUserMediaRequest* request_info,
- MediaStreamRequestResult result,
- const blink::WebString& result_name) {
- switch (result) {
+ return;
case MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED:
request_info->requestFailedConstraint(result_name);
- break;
+ return;
case MEDIA_DEVICE_TRACK_START_FAILURE:
request_info->requestFailedUASpecific("TrackStartError");
- break;
- default:
- NOTREACHED();
- request_info->requestFailed();
- break;
+ return;
+ case MEDIA_DEVICE_NOT_SUPPORTED:
+ request_info->requestFailedUASpecific("MediaDeviceNotSupported");
+ return;
+ case MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN:
+ request_info->requestFailedUASpecific("MediaDeviceFailedDueToShutdown");
+ return;
}
+ NOTREACHED();
+ request_info->requestFailed();
}
void UserMediaClientImpl::EnumerateDevicesSucceded(
« no previous file with comments | « content/renderer/media/user_media_client_impl.h ('k') | content/renderer/media/user_media_client_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698