Commit 96fd1f6b authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Minor cleanups in MediaStreamCaptureIndicator.

Fixed IsCapturingUserMedia() and IsBeingMirrored() to use WebContents pointer
to identify tabs.


Review URL: https://chromiumcodereview.appspot.com/13355003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192512 0039d316-1c4b-4281-b951-d872f2087c98
parent 877e261f
......@@ -274,7 +274,7 @@ void MediaStreamCaptureIndicator::CaptureDevicesOpened(
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&MediaStreamCaptureIndicator::DoDevicesOpenedOnUIThread,
base::Bind(&MediaStreamCaptureIndicator::AddCaptureDevices,
this, render_process_id, render_view_id, devices,
close_callback));
}
......@@ -288,57 +288,28 @@ void MediaStreamCaptureIndicator::CaptureDevicesClosed(
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&MediaStreamCaptureIndicator::DoDevicesClosedOnUIThread,
base::Bind(&MediaStreamCaptureIndicator::RemoveCaptureDevices,
this, render_process_id, render_view_id, devices));
}
bool MediaStreamCaptureIndicator::IsCapturingUserMedia(
int render_process_id, int render_view_id) const {
content::WebContents* web_contents) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
WebContents* const web_contents =
LookUpByKnownAlias(render_process_id, render_view_id);
if (!web_contents)
return false;
UsageMap::const_iterator it = usage_map_.find(web_contents);
return (it != usage_map_.end() &&
(it->second->IsCapturingAudio() || it->second->IsCapturingVideo()));
}
bool MediaStreamCaptureIndicator::IsBeingMirrored(
int render_process_id, int render_view_id) const {
content::WebContents* web_contents) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
WebContents* const web_contents =
LookUpByKnownAlias(render_process_id, render_view_id);
if (!web_contents)
return false;
UsageMap::const_iterator it = usage_map_.find(web_contents);
return it != usage_map_.end() && it->second->IsMirroring();
}
void MediaStreamCaptureIndicator::DoDevicesOpenedOnUIThread(
int render_process_id,
int render_view_id,
const content::MediaStreamDevices& devices,
const base::Closure& close_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
AddCaptureDevices(render_process_id, render_view_id, devices, close_callback);
}
void MediaStreamCaptureIndicator::DoDevicesClosedOnUIThread(
int render_process_id,
int render_view_id,
const content::MediaStreamDevices& devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
RemoveCaptureDevices(render_process_id, render_view_id, devices);
}
void MediaStreamCaptureIndicator::MaybeCreateStatusTrayIcon() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (status_icon_)
......
......@@ -54,13 +54,13 @@ class MediaStreamCaptureIndicator
int render_view_id,
const content::MediaStreamDevices& devices);
// Returns true if the render view is capturing user media (e.g., webcam
// or microphone input).
bool IsCapturingUserMedia(int render_process_id, int render_view_id) const;
// Returns true if the |web_contents| is capturing user media (e.g., webcam or
// microphone input).
bool IsCapturingUserMedia(content::WebContents* web_contents) const;
// Returns true if the render view itself is being mirrored (e.g., a source of
// media for remote broadcast).
bool IsBeingMirrored(int render_process_id, int render_view_id) const;
// Returns true if the |web_contents| itself is being mirrored (e.g., a source
// of media for remote broadcast).
bool IsBeingMirrored(content::WebContents* web_contents) const;
private:
class WebContentsDeviceUsage;
......@@ -68,15 +68,6 @@ class MediaStreamCaptureIndicator
friend class base::RefCountedThreadSafe<MediaStreamCaptureIndicator>;
virtual ~MediaStreamCaptureIndicator();
// Called by the public functions, executed on UI thread.
void DoDevicesOpenedOnUIThread(int render_process_id,
int render_view_id,
const content::MediaStreamDevices& devices,
const base::Closure& close_callback);
void DoDevicesClosedOnUIThread(int render_process_id,
int render_view_id,
const content::MediaStreamDevices& devices);
// Following functions/variables are executed/accessed only on UI thread.
// Creates and shows the status tray icon if it has not been created and is
......
......@@ -14,25 +14,21 @@
namespace chrome {
bool ShouldShowProjectingIndicator(content::WebContents* contents) {
int render_process_id = contents->GetRenderProcessHost()->GetID();
int render_view_id = contents->GetRenderViewHost()->GetRoutingID();
scoped_refptr<MediaStreamCaptureIndicator> indicator =
MediaCaptureDevicesDispatcher::GetInstance()->
GetMediaStreamCaptureIndicator();
return indicator->IsBeingMirrored(render_process_id, render_view_id);
return indicator->IsBeingMirrored(contents);
}
bool ShouldShowRecordingIndicator(content::WebContents* contents) {
int render_process_id = contents->GetRenderProcessHost()->GetID();
int render_view_id = contents->GetRenderViewHost()->GetRoutingID();
scoped_refptr<MediaStreamCaptureIndicator> indicator =
MediaCaptureDevicesDispatcher::GetInstance()->
GetMediaStreamCaptureIndicator();
// The projecting indicator takes precedence over the recording indicator, but
// if we are projecting and we don't handle the projecting case we want to
// still show the recording indicator.
return indicator->IsCapturingUserMedia(render_process_id, render_view_id) ||
indicator->IsBeingMirrored(render_process_id, render_view_id);
return indicator->IsCapturingUserMedia(contents) ||
indicator->IsBeingMirrored(contents);
}
bool IsPlayingAudio(content::WebContents* contents) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment