mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changesets 720a36d92d37 and c24da899172a (bug 926746) for frequent timeouts/hangs in test_dataChannel_basicAudio.html.
This commit is contained in:
parent
778588d21c
commit
7e2a39a422
@ -284,16 +284,13 @@ MediaEngineWebRTCAudioSource::Init()
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef MOZ_B2G
|
||||
// Because of the permission mechanism of B2G, we need to skip the status
|
||||
// check here.
|
||||
bool avail = false;
|
||||
ptrVoEHw->GetRecordingDeviceStatus(avail);
|
||||
ptrVoEHw->Release();
|
||||
if (!avail) {
|
||||
return;
|
||||
}
|
||||
#endif // MOZ_B2G
|
||||
|
||||
// Set "codec" to PCM, 32kHz on 1 channel
|
||||
webrtc::VoECodec* ptrVoECodec;
|
||||
webrtc::CodecInst codec;
|
||||
|
@ -2,10 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include "GonkPermission.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#endif // MOZ_WIDGET_GONK
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsIContentPermissionPrompt.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -18,7 +14,6 @@
|
||||
|
||||
using mozilla::unused; // <snicker>
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla;
|
||||
|
||||
nsContentPermissionRequestProxy::nsContentPermissionRequestProxy()
|
||||
{
|
||||
@ -135,14 +130,6 @@ nsContentPermissionRequestProxy::Allow()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (mType.Equals("audio-capture")) {
|
||||
GonkPermissionService::GetInstance()->addGrantInfo(
|
||||
"android.permission.RECORD_AUDIO",
|
||||
static_cast<TabParent*>(mParent->Manager())->Manager()->Pid());
|
||||
}
|
||||
#endif
|
||||
|
||||
unused << ContentPermissionRequestParent::Send__delete__(mParent, true);
|
||||
mParent = nullptr;
|
||||
return NS_OK;
|
||||
|
@ -182,34 +182,49 @@ CreateRecordingDeviceEventsSubject(nsPIDOMWindow* aWindow,
|
||||
return props.forget();
|
||||
}
|
||||
|
||||
ErrorCallbackRunnable::ErrorCallbackRunnable(
|
||||
already_AddRefed<nsIDOMGetUserMediaSuccessCallback> aSuccess,
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> aError,
|
||||
const nsAString& aErrorMsg, uint64_t aWindowID)
|
||||
: mSuccess(aSuccess)
|
||||
, mError(aError)
|
||||
, mErrorMsg(aErrorMsg)
|
||||
, mWindowID(aWindowID)
|
||||
, mManager(MediaManager::GetInstance()) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ErrorCallbackRunnable::Run()
|
||||
/**
|
||||
* Send an error back to content. The error is the form a string.
|
||||
* Do this only on the main thread. The success callback is also passed here
|
||||
* so it can be released correctly.
|
||||
*/
|
||||
class ErrorCallbackRunnable : public nsRunnable
|
||||
{
|
||||
// Only run if the window is still active.
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
public:
|
||||
ErrorCallbackRunnable(
|
||||
already_AddRefed<nsIDOMGetUserMediaSuccessCallback> aSuccess,
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> aError,
|
||||
const nsAString& aErrorMsg, uint64_t aWindowID)
|
||||
: mSuccess(aSuccess)
|
||||
, mError(aError)
|
||||
, mErrorMsg(aErrorMsg)
|
||||
, mWindowID(aWindowID)
|
||||
, mManager(MediaManager::GetInstance()) {}
|
||||
|
||||
nsCOMPtr<nsIDOMGetUserMediaSuccessCallback> success(mSuccess);
|
||||
nsCOMPtr<nsIDOMGetUserMediaErrorCallback> error(mError);
|
||||
NS_IMETHOD
|
||||
Run()
|
||||
{
|
||||
// Only run if the window is still active.
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
if (!(mManager->IsWindowStillActive(mWindowID))) {
|
||||
nsCOMPtr<nsIDOMGetUserMediaSuccessCallback> success(mSuccess);
|
||||
nsCOMPtr<nsIDOMGetUserMediaErrorCallback> error(mError);
|
||||
|
||||
if (!(mManager->IsWindowStillActive(mWindowID))) {
|
||||
return NS_OK;
|
||||
}
|
||||
// This is safe since we're on main-thread, and the windowlist can only
|
||||
// be invalidated from the main-thread (see OnNavigation)
|
||||
error->OnError(mErrorMsg);
|
||||
return NS_OK;
|
||||
}
|
||||
// This is safe since we're on main-thread, and the windowlist can only
|
||||
// be invalidated from the main-thread (see OnNavigation)
|
||||
error->OnError(mErrorMsg);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
already_AddRefed<nsIDOMGetUserMediaSuccessCallback> mSuccess;
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> mError;
|
||||
const nsString mErrorMsg;
|
||||
uint64_t mWindowID;
|
||||
nsRefPtr<MediaManager> mManager; // get ref to this when creating the runnable
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoke the "onSuccess" callback in content. The callback will take a
|
||||
@ -619,8 +634,7 @@ public:
|
||||
nsRefPtr<MediaOperationRunnable> runnable(
|
||||
new MediaOperationRunnable(MEDIA_START, mListener, trackunion,
|
||||
tracksAvailableCallback,
|
||||
mAudioSource, mVideoSource, false, mWindowID,
|
||||
mError.forget()));
|
||||
mAudioSource, mVideoSource, false, mWindowID));
|
||||
mediaThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
|
||||
|
||||
#ifdef MOZ_WEBRTC
|
||||
@ -1768,7 +1782,7 @@ GetUserMediaCallbackMediaStreamListener::Invalidate()
|
||||
runnable = new MediaOperationRunnable(MEDIA_STOP,
|
||||
this, nullptr, nullptr,
|
||||
mAudioSource, mVideoSource,
|
||||
mFinished, mWindowID, nullptr);
|
||||
mFinished, mWindowID);
|
||||
mMediaThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
|
@ -212,11 +212,9 @@ class GetUserMediaNotificationEvent: public nsRunnable
|
||||
GetUserMediaNotificationEvent(GetUserMediaStatus aStatus,
|
||||
already_AddRefed<DOMMediaStream> aStream,
|
||||
DOMMediaStream::OnTracksAvailableCallback* aOnTracksAvailableCallback,
|
||||
bool aIsAudio, bool aIsVideo, uint64_t aWindowID,
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> aError)
|
||||
bool aIsAudio, bool aIsVideo, uint64_t aWindowID)
|
||||
: mStream(aStream), mOnTracksAvailableCallback(aOnTracksAvailableCallback),
|
||||
mStatus(aStatus), mIsAudio(aIsAudio), mIsVideo(aIsVideo), mWindowID(aWindowID),
|
||||
mError(aError) {}
|
||||
mStatus(aStatus), mIsAudio(aIsAudio), mIsVideo(aIsVideo), mWindowID(aWindowID) {}
|
||||
virtual ~GetUserMediaNotificationEvent()
|
||||
{
|
||||
|
||||
@ -232,7 +230,6 @@ class GetUserMediaNotificationEvent: public nsRunnable
|
||||
bool mIsAudio;
|
||||
bool mIsVideo;
|
||||
uint64_t mWindowID;
|
||||
nsRefPtr<nsIDOMGetUserMediaErrorCallback> mError;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@ -240,42 +237,6 @@ typedef enum {
|
||||
MEDIA_STOP
|
||||
} MediaOperation;
|
||||
|
||||
class MediaManager;
|
||||
|
||||
/**
|
||||
* Send an error back to content. The error is the form a string.
|
||||
* Do this only on the main thread. The success callback is also passed here
|
||||
* so it can be released correctly.
|
||||
*/
|
||||
class ErrorCallbackRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ErrorCallbackRunnable(
|
||||
already_AddRefed<nsIDOMGetUserMediaSuccessCallback> aSuccess,
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> aError,
|
||||
const nsAString& aErrorMsg, uint64_t aWindowID);
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
already_AddRefed<nsIDOMGetUserMediaSuccessCallback> mSuccess;
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> mError;
|
||||
const nsString mErrorMsg;
|
||||
uint64_t mWindowID;
|
||||
nsRefPtr<MediaManager> mManager; // get ref to this when creating the runnable
|
||||
};
|
||||
|
||||
class ReleaseMediaOperationResource : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ReleaseMediaOperationResource(already_AddRefed<DOMMediaStream> aStream,
|
||||
DOMMediaStream::OnTracksAvailableCallback* aOnTracksAvailableCallback):
|
||||
mStream(aStream),
|
||||
mOnTracksAvailableCallback(aOnTracksAvailableCallback) {}
|
||||
NS_IMETHOD Run() MOZ_OVERRIDE {return NS_OK;}
|
||||
private:
|
||||
nsRefPtr<DOMMediaStream> mStream;
|
||||
nsAutoPtr<DOMMediaStream::OnTracksAvailableCallback> mOnTracksAvailableCallback;
|
||||
};
|
||||
|
||||
// Generic class for running long media operations like Start off the main
|
||||
// thread, and then (because nsDOMMediaStreams aren't threadsafe),
|
||||
// ProxyReleases mStream since it's cycle collected.
|
||||
@ -290,8 +251,7 @@ public:
|
||||
MediaEngineSource* aAudioSource,
|
||||
MediaEngineSource* aVideoSource,
|
||||
bool aNeedsFinish,
|
||||
uint64_t aWindowID,
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> aError)
|
||||
uint64_t aWindowID)
|
||||
: mType(aType)
|
||||
, mStream(aStream)
|
||||
, mOnTracksAvailableCallback(aOnTracksAvailableCallback)
|
||||
@ -300,27 +260,13 @@ public:
|
||||
, mListener(aListener)
|
||||
, mFinish(aNeedsFinish)
|
||||
, mWindowID(aWindowID)
|
||||
, mError(aError)
|
||||
{}
|
||||
{}
|
||||
|
||||
~MediaOperationRunnable()
|
||||
{
|
||||
// MediaStreams can be released on any thread.
|
||||
}
|
||||
|
||||
nsresult returnAndCallbackError(nsresult rv, const char* errorLog)
|
||||
{
|
||||
MM_LOG(("%s , rv=%d", errorLog, rv));
|
||||
NS_DispatchToMainThread(new ReleaseMediaOperationResource(mStream.forget(),
|
||||
mOnTracksAvailableCallback.forget()));
|
||||
nsString log;
|
||||
|
||||
log.AssignASCII(errorLog, strlen(errorLog));
|
||||
NS_DispatchToMainThread(new ErrorCallbackRunnable(nullptr, mError.forget(),
|
||||
log, mWindowID));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Run() MOZ_OVERRIDE
|
||||
{
|
||||
@ -344,7 +290,7 @@ public:
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
expectedTracks |= DOMMediaStream::HINT_CONTENTS_AUDIO;
|
||||
} else {
|
||||
return returnAndCallbackError(rv, "Starting audio failed");
|
||||
MM_LOG(("Starting audio failed, rv=%d",rv));
|
||||
}
|
||||
}
|
||||
if (mVideoSource) {
|
||||
@ -352,7 +298,7 @@ public:
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
expectedTracks |= DOMMediaStream::HINT_CONTENTS_VIDEO;
|
||||
} else {
|
||||
return returnAndCallbackError(rv, "Starting video failed");
|
||||
MM_LOG(("Starting video failed, rv=%d",rv));
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,7 +314,7 @@ public:
|
||||
mOnTracksAvailableCallback.forget(),
|
||||
mAudioSource != nullptr,
|
||||
mVideoSource != nullptr,
|
||||
mWindowID, mError.forget());
|
||||
mWindowID);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
break;
|
||||
@ -415,7 +361,6 @@ private:
|
||||
nsRefPtr<GetUserMediaCallbackMediaStreamListener> mListener; // threadsafe
|
||||
bool mFinish;
|
||||
uint64_t mWindowID;
|
||||
nsRefPtr<nsIDOMGetUserMediaErrorCallback> mError;
|
||||
};
|
||||
|
||||
typedef nsTArray<nsRefPtr<GetUserMediaCallbackMediaStreamListener> > StreamListeners;
|
||||
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <binder/IPCThreadState.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <binder/IServiceManager.h>
|
||||
#include <binder/IPermissionController.h>
|
||||
#include <private/android_filesystem_config.h>
|
||||
#include "GonkPermission.h"
|
||||
|
||||
#undef LOG
|
||||
#include <android/log.h>
|
||||
#define ALOGE(args...) __android_log_print(ANDROID_LOG_ERROR, "gonkperm" , ## args)
|
||||
|
||||
using namespace android;
|
||||
using namespace mozilla;
|
||||
|
||||
bool
|
||||
GonkPermissionService::checkPermission(const String16& permission, int32_t pid,
|
||||
int32_t uid)
|
||||
{
|
||||
if (0 == uid)
|
||||
return true;
|
||||
|
||||
// Camera/audio record permissions are only for apps with the
|
||||
// "camera" permission. These apps are also the only apps granted
|
||||
// the AID_SDCARD_RW supplemental group (bug 785592)
|
||||
|
||||
if (uid < AID_APP) {
|
||||
ALOGE("%s for pid=%d,uid=%d denied: not an app",
|
||||
String8(permission).string(), pid, uid);
|
||||
return false;
|
||||
}
|
||||
|
||||
String8 perm8(permission);
|
||||
|
||||
if (perm8 != "android.permission.CAMERA" &&
|
||||
perm8 != "android.permission.RECORD_AUDIO") {
|
||||
ALOGE("%s for pid=%d,uid=%d denied: unsupported permission",
|
||||
String8(permission).string(), pid, uid);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Users granted the permission through a prompt dialog.
|
||||
// Before permission managment of gUM is done, app cannot remember the
|
||||
// permission.
|
||||
PermissionGrant permGrant(perm8.string(), pid);
|
||||
if (nsTArray<PermissionGrant>::NoIndex != mGrantArray.IndexOf(permGrant)) {
|
||||
mGrantArray.RemoveElement(permGrant);
|
||||
return true;
|
||||
}
|
||||
|
||||
char filename[32];
|
||||
snprintf(filename, sizeof(filename), "/proc/%d/status", pid);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
ALOGE("%s for pid=%d,uid=%d denied: unable to open %s",
|
||||
String8(permission).string(), pid, uid, filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
char line[80];
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
char *save;
|
||||
char *name = strtok_r(line, "\t", &save);
|
||||
if (!name)
|
||||
continue;
|
||||
|
||||
if (strcmp(name, "Groups:"))
|
||||
continue;
|
||||
char *group;
|
||||
while ((group = strtok_r(NULL, " \n", &save))) {
|
||||
#define _STR(x) #x
|
||||
#define STR(x) _STR(x)
|
||||
if (!strcmp(group, STR(AID_SDCARD_RW))) {
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
ALOGE("%s for pid=%d,uid=%d denied: missing group",
|
||||
String8(permission).string(), pid, uid);
|
||||
return false;
|
||||
}
|
||||
|
||||
static GonkPermissionService* gGonkPermissionService = NULL;
|
||||
|
||||
/* static */
|
||||
void
|
||||
GonkPermissionService::instantiate()
|
||||
{
|
||||
defaultServiceManager()->addService(String16(getServiceName()),
|
||||
GetInstance());
|
||||
}
|
||||
|
||||
/* static */
|
||||
GonkPermissionService*
|
||||
GonkPermissionService::GetInstance()
|
||||
{
|
||||
if (!gGonkPermissionService) {
|
||||
gGonkPermissionService = new GonkPermissionService();
|
||||
}
|
||||
return gGonkPermissionService;
|
||||
}
|
||||
|
||||
void
|
||||
GonkPermissionService::addGrantInfo(const char* permission, int32_t pid)
|
||||
{
|
||||
mGrantArray.AppendElement(PermissionGrant(permission, pid));
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef GONKPERMISSION_H
|
||||
#define GONKPERMISSION_H
|
||||
|
||||
#include <binder/BinderService.h>
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
class PermissionGrant
|
||||
{
|
||||
public:
|
||||
PermissionGrant(const char* perm, int32_t p) : mPid(p)
|
||||
{
|
||||
mPermission.Assign(perm);
|
||||
}
|
||||
|
||||
PermissionGrant(const nsACString& permission, int32_t pid) : mPid(pid),
|
||||
mPermission(permission)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const PermissionGrant& other) const
|
||||
{
|
||||
return (mPid == other.pid() && mPermission.Equals(other.permission()));
|
||||
}
|
||||
|
||||
int32_t pid() const
|
||||
{
|
||||
return mPid;
|
||||
}
|
||||
|
||||
const nsACString& permission() const
|
||||
{
|
||||
return mPermission;
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t mPid;
|
||||
nsCString mPermission;
|
||||
};
|
||||
|
||||
class PermissionGrant;
|
||||
|
||||
class GonkPermissionService :
|
||||
public android::BinderService<GonkPermissionService>,
|
||||
public android::BnPermissionController
|
||||
{
|
||||
public:
|
||||
virtual ~GonkPermissionService() {}
|
||||
static GonkPermissionService* GetInstance();
|
||||
static const char *getServiceName() {
|
||||
return "permission";
|
||||
}
|
||||
|
||||
static void instantiate();
|
||||
|
||||
virtual android::status_t dump(int fd, const android::Vector<android::String16>& args) {
|
||||
return android::NO_ERROR;
|
||||
}
|
||||
virtual bool checkPermission(const android::String16& permission, int32_t pid,
|
||||
int32_t uid);
|
||||
|
||||
void addGrantInfo(const char* permission, int32_t pid);
|
||||
private:
|
||||
GonkPermissionService(): android::BnPermissionController() {}
|
||||
nsTArray<PermissionGrant> mGrantArray;
|
||||
};
|
||||
} // namespace mozilla
|
||||
#endif // GONKPERMISSION_H
|
@ -15,7 +15,6 @@
|
||||
# limitations under the License.
|
||||
|
||||
EXPORTS += [
|
||||
'GonkPermission.h',
|
||||
'OrientationObserver.h',
|
||||
]
|
||||
|
||||
@ -47,7 +46,6 @@ SOURCES += [
|
||||
'Framebuffer.cpp',
|
||||
'GfxInfo.cpp',
|
||||
'GonkMemoryPressureMonitoring.cpp',
|
||||
'GonkPermission.cpp',
|
||||
'HwcComposer2D.cpp',
|
||||
'HwcUtils.cpp',
|
||||
'nsAppShell.cpp',
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "GonkPermission.h"
|
||||
#include "nscore.h"
|
||||
#ifdef MOZ_OMX_DECODER
|
||||
#include "MediaResourceManagerService.h"
|
||||
@ -759,7 +758,6 @@ nsAppShell::Init()
|
||||
#if ANDROID_VERSION >= 18
|
||||
android::FakeSurfaceComposer::instantiate();
|
||||
#endif
|
||||
GonkPermissionService::instantiate();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsServ = GetObserverService();
|
||||
|
Loading…
Reference in New Issue
Block a user