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

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: 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
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..046f6d4439316f4bcfb9fe7ebafb5e09b7836cc4 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)
+ has_stopped_activities = false;
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 &&
+ has_stopped_activities) {
perkj_chrome 2016/06/28 08:59:26 Suggest rename |has_stopped_activities| to |applic
ResumeDevices();
+ has_stopped_activities = false;
} else if (state == base::android::APPLICATION_STATE_HAS_STOPPED_ACTIVITIES) {
ReleaseDevices();
+ has_stopped_activities = true;
}
}
@@ -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;

Powered by Google App Engine
This is Rietveld 408576698