Bug 833521 - forward "recording-device-events" event to parent process, r=dougt

This commit is contained in:
Sotaro Ikeda 2013-01-24 21:45:36 -05:00
parent 505b2f34e8
commit c511765584
8 changed files with 55 additions and 1 deletions

View File

@ -7,9 +7,12 @@
#include "nsDOMClassInfo.h"
#include "jsapi.h"
#include "nsThread.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/Services.h"
#include "mozilla/unused.h"
#include "nsIObserverService.h"
#include "nsIDOMDeviceStorage.h"
#include "nsXULAppAPI.h"
#include "DOMCameraManager.h"
#include "DOMCameraCapabilities.h"
#include "DOMCameraControl.h"
@ -259,6 +262,11 @@ nsDOMCameraControl::StartRecording(const JS::Value& aOptions, nsIDOMDeviceStorag
obs->NotifyObservers(nullptr,
"recording-device-events",
NS_LITERAL_STRING("starting").get());
// Forward recording events to parent process.
// The events are gathered in chrome process and used for recording indicator
if (XRE_GetProcessType() != GeckoProcessType_Default) {
unused << ContentChild::GetSingleton()->SendRecordingDeviceEvents(NS_LITERAL_STRING("starting"));
}
#ifdef MOZ_B2G
if (!mAudioChannelAgent) {
@ -291,6 +299,11 @@ nsDOMCameraControl::StopRecording()
obs->NotifyObservers(nullptr,
"recording-device-events",
NS_LITERAL_STRING("shutdown").get());
// Forward recording events to parent process.
// The events are gathered in chrome process and used for recording indicator
if (XRE_GetProcessType() != GeckoProcessType_Default) {
unused << ContentChild::GetSingleton()->SendRecordingDeviceEvents(NS_LITERAL_STRING("shutdown"));
}
#ifdef MOZ_B2G
if (mAudioChannelAgent) {

View File

@ -1230,6 +1230,18 @@ ContentParent::RecvBroadcastVolume(const nsString& aVolumeName)
#endif
}
bool
ContentParent::RecvRecordingDeviceEvents(const nsString& aRecordingStatus)
{
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(nullptr, "recording-device-events", aRecordingStatus.get());
} else {
NS_WARNING("Could not get the Observer service for ContentParent::RecvRecordingDeviceEvents.");
}
return true;
}
NS_IMPL_THREADSAFE_ISUPPORTS3(ContentParent,
nsIObserver,
nsIThreadObserver,

View File

@ -344,6 +344,8 @@ private:
virtual bool RecvBroadcastVolume(const nsString& aVolumeName);
virtual bool RecvRecordingDeviceEvents(const nsString& aRecordingStatus);
virtual void ProcessingError(Result what) MOZ_OVERRIDE;
GeckoChildProcessHost* mSubprocess;

View File

@ -437,6 +437,8 @@ parent:
// get nsIVolumeService to broadcast volume information
async BroadcastVolume(nsString volumeName);
async RecordingDeviceEvents(nsString recordingStatus);
both:
AsyncMessage(nsString aMessage, ClonedMessageData aData);
};

View File

@ -56,4 +56,5 @@ TEST_DIRS += \
$(NULL)
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk

View File

@ -29,6 +29,10 @@
namespace mozilla {
#ifdef LOG
#undef LOG
#endif
#ifdef PR_LOGGING
PRLogModuleInfo*
GetMediaManagerLog()

View File

@ -3,7 +3,9 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MediaEngine.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/Services.h"
#include "mozilla/unused.h"
#include "nsIMediaManager.h"
#include "nsHashKeys.h"
@ -14,6 +16,7 @@
#include "nsPIDOMWindow.h"
#include "nsIDOMNavigatorUserMedia.h"
#include "nsXULAppAPI.h"
#include "mozilla/Attributes.h"
#include "mozilla/StaticPtr.h"
#include "prlog.h"
@ -49,10 +52,20 @@ class GetUserMediaNotificationEvent: public nsRunnable
obs->NotifyObservers(nullptr,
"recording-device-events",
NS_LITERAL_STRING("starting").get());
// Forward recording events to parent process.
// The events are gathered in chrome process and used for recording indicator
if (XRE_GetProcessType() != GeckoProcessType_Default) {
unused << mozilla::dom::ContentChild::GetSingleton()->SendRecordingDeviceEvents(NS_LITERAL_STRING("starting"));
}
} else {
obs->NotifyObservers(nullptr,
"recording-device-events",
NS_LITERAL_STRING("shutdown").get());
// Forward recording events to parent process.
// The events are gathered in chrome process and used for recording indicator
if (XRE_GetProcessType() != GeckoProcessType_Default) {
unused << mozilla::dom::ContentChild::GetSingleton()->SendRecordingDeviceEvents(NS_LITERAL_STRING("shutdown"));
}
}
return NS_OK;
}

View File

@ -4,7 +4,14 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
// undef the GetCurrentTime macro defined in WinBase.h from the MS Platform SDK
%{C++
#ifdef GetCurrentTime
#undef GetCurrentTime
#endif
%}
[scriptable, builtinclass, uuid(f37c2871-4cb7-4672-bb28-c2d601f7cc9e)]
interface nsIDOMMediaStream : nsISupports
{