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

Unified Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 2086603002: video_capture_manager: filter out unexpected app state changes on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 6 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
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/video_capture_manager.cc
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index b4e9a5c6362f099852b6a5cf9d04f058bc7d3f01..f91f3f8b1c94384ad59222eb32487aa896401104 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -252,6 +252,7 @@ void VideoCaptureManager::Register(
listener_ = listener;
device_task_runner_ = device_task_runner;
#if defined(OS_ANDROID)
+ application_state_has_running_activities_ = true;
app_status_listener_.reset(new base::android::ApplicationStatusListener(
base::Bind(&VideoCaptureManager::OnApplicationStateChange,
base::Unretained(this))));
@@ -1081,10 +1082,15 @@ void VideoCaptureManager::OnApplicationStateChange(
base::android::ApplicationState state) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) {
+ // Only release/resume devices when the Application state changes from
+ // RUNNING->STOPPED->RUNNING.
+ if (state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES &&
+ !application_state_has_running_activities_) {
ResumeDevices();
+ application_state_has_running_activities_ = true;
} else if (state == base::android::APPLICATION_STATE_HAS_STOPPED_ACTIVITIES) {
ReleaseDevices();
+ application_state_has_running_activities_ = false;
}
}
@@ -1105,11 +1111,7 @@ void VideoCaptureManager::ResumeDevices() {
for (auto& entry : devices_) {
// Do not resume Content Video Capture devices, e.g. Tab or Screen capture.
- // Do not try to restart already running devices. A device will be running
- // if the Application state changes from
- // APPLICATION_STATE_HAS_RUNNING_ACTIVITIES
- // ->APPLICATION_STATE_HAS_PAUSED_ACTIVITIES
- // ->APPLICATION_STATE_HAS_RUNNING_ACTIVITIES
+ // Do not try to restart already running devices.
if (entry->stream_type != MEDIA_DEVICE_VIDEO_CAPTURE ||
entry->video_capture_device())
continue;
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698