| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/user_media_client_impl.h" | 5 #include "content/renderer/media/user_media_client_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 media_stream_dispatcher_(std::move(media_stream_dispatcher)), | 180 media_stream_dispatcher_(std::move(media_stream_dispatcher)), |
| 181 weak_factory_(this) { | 181 weak_factory_(this) { |
| 182 DCHECK(dependency_factory_); | 182 DCHECK(dependency_factory_); |
| 183 DCHECK(media_stream_dispatcher_.get()); | 183 DCHECK(media_stream_dispatcher_.get()); |
| 184 } | 184 } |
| 185 | 185 |
| 186 UserMediaClientImpl::~UserMediaClientImpl() { | 186 UserMediaClientImpl::~UserMediaClientImpl() { |
| 187 // Force-close all outstanding user media requests and local sources here, | 187 // Force-close all outstanding user media requests and local sources here, |
| 188 // before the outstanding WeakPtrs are invalidated, to ensure a clean | 188 // before the outstanding WeakPtrs are invalidated, to ensure a clean |
| 189 // shutdown. | 189 // shutdown. |
| 190 FrameWillClose(); | 190 WillCommitProvisionalLoad(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void UserMediaClientImpl::requestUserMedia( | 193 void UserMediaClientImpl::requestUserMedia( |
| 194 const blink::WebUserMediaRequest& user_media_request) { | 194 const blink::WebUserMediaRequest& user_media_request) { |
| 195 // Save histogram data so we can see how much GetUserMedia is used. | 195 // Save histogram data so we can see how much GetUserMedia is used. |
| 196 // The histogram counts the number of calls to the JS API | 196 // The histogram counts the number of calls to the JS API |
| 197 // webGetUserMedia. | 197 // webGetUserMedia. |
| 198 UpdateWebRTCMethodCount(WEBKIT_GET_USER_MEDIA); | 198 UpdateWebRTCMethodCount(WEBKIT_GET_USER_MEDIA); |
| 199 DCHECK(CalledOnValidThread()); | 199 DCHECK(CalledOnValidThread()); |
| 200 | 200 |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 media_stream_dispatcher_->StopEnumerateDevices( | 1021 media_stream_dispatcher_->StopEnumerateDevices( |
| 1022 request->audio_output_request_id, weak_factory_.GetWeakPtr()); | 1022 request->audio_output_request_id, weak_factory_.GetWeakPtr()); |
| 1023 | 1023 |
| 1024 media_devices_requests_.erase(it); | 1024 media_devices_requests_.erase(it); |
| 1025 return; | 1025 return; |
| 1026 } | 1026 } |
| 1027 } | 1027 } |
| 1028 NOTREACHED(); | 1028 NOTREACHED(); |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 void UserMediaClientImpl::FrameWillClose() { | 1031 void UserMediaClientImpl::WillCommitProvisionalLoad() { |
| 1032 // Cancel all outstanding UserMediaRequests. | 1032 // Cancel all outstanding UserMediaRequests. |
| 1033 DeleteAllUserMediaRequests(); | 1033 DeleteAllUserMediaRequests(); |
| 1034 | 1034 |
| 1035 // Loop through all current local sources and stop the sources. | 1035 // Loop through all current local sources and stop the sources. |
| 1036 LocalStreamSources::iterator sources_it = local_sources_.begin(); | 1036 LocalStreamSources::iterator sources_it = local_sources_.begin(); |
| 1037 while (sources_it != local_sources_.end()) { | 1037 while (sources_it != local_sources_.end()) { |
| 1038 StopLocalSource(*sources_it, true); | 1038 StopLocalSource(*sources_it, true); |
| 1039 sources_it = local_sources_.erase(sources_it); | 1039 sources_it = local_sources_.erase(sources_it); |
| 1040 } | 1040 } |
| 1041 } | 1041 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 | 1176 |
| 1177 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { | 1177 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { |
| 1178 return !sources_waiting_for_callback_.empty(); | 1178 return !sources_waiting_for_callback_.empty(); |
| 1179 } | 1179 } |
| 1180 | 1180 |
| 1181 void UserMediaClientImpl::OnDestruct() { | 1181 void UserMediaClientImpl::OnDestruct() { |
| 1182 delete this; | 1182 delete this; |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 } // namespace content | 1185 } // namespace content |
| OLD | NEW |