зеркало из https://github.com/mozilla/gecko-dev.git
Merge b-s to m-c
This commit is contained in:
Коммит
2426689ee4
|
@ -46,6 +46,15 @@
|
||||||
#
|
#
|
||||||
topsrcdir=$1
|
topsrcdir=$1
|
||||||
|
|
||||||
|
for _config in "$MOZCONFIG" \
|
||||||
|
"$MOZ_MYCONFIG"
|
||||||
|
do
|
||||||
|
if [ -n "$_config" ] && ! [ -f "$_config" ]; then
|
||||||
|
echo "Specified MOZCONFIG \"$_config\" does not exist!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
for _config in "$MOZCONFIG" \
|
for _config in "$MOZCONFIG" \
|
||||||
"$MOZ_MYCONFIG" \
|
"$MOZ_MYCONFIG" \
|
||||||
"$topsrcdir/.mozconfig" \
|
"$topsrcdir/.mozconfig" \
|
||||||
|
|
|
@ -2303,6 +2303,9 @@ ia64*-hpux*)
|
||||||
CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
|
CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
|
||||||
CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
|
CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
|
||||||
CXXFLAGS="$CXXFLAGS -wd4800" # disable warning "forcing value to bool"
|
CXXFLAGS="$CXXFLAGS -wd4800" # disable warning "forcing value to bool"
|
||||||
|
# make 'foo == bar;' error out
|
||||||
|
CFLAGS="$CFLAGS -we4553"
|
||||||
|
CXXFLAGS="$CXXFLAGS -we4553"
|
||||||
LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
|
LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
|
||||||
MOZ_DEBUG_FLAGS='-Zi'
|
MOZ_DEBUG_FLAGS='-Zi'
|
||||||
MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
|
MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
|
||||||
|
@ -3309,7 +3312,7 @@ esac
|
||||||
|
|
||||||
_SAVE_CFLAGS="$CFLAGS"
|
_SAVE_CFLAGS="$CFLAGS"
|
||||||
CFLAGS="$CFLAGS -D_GNU_SOURCE"
|
CFLAGS="$CFLAGS -D_GNU_SOURCE"
|
||||||
AC_CHECK_FUNCS(dladdr)
|
AC_CHECK_FUNCS(dladdr memmem)
|
||||||
CFLAGS="$_SAVE_CFLAGS"
|
CFLAGS="$_SAVE_CFLAGS"
|
||||||
|
|
||||||
if test ! "$GNU_CXX"; then
|
if test ! "$GNU_CXX"; then
|
||||||
|
|
|
@ -63,6 +63,9 @@ USING_INDEXEDDB_NAMESPACE
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
// This is just to give us some random marker in the byte stream
|
||||||
|
static const PRUint64 kTotallyRandomNumber = LL_INIT(0x286F258B, 0x177D47A9);
|
||||||
|
|
||||||
class AddHelper : public AsyncConnectionHelper
|
class AddHelper : public AsyncConnectionHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -96,7 +99,6 @@ public:
|
||||||
AsyncConnectionHelper::ReleaseMainThreadObjects();
|
AsyncConnectionHelper::ReleaseMainThreadObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult ModifyValueForNewKey();
|
|
||||||
nsresult UpdateIndexes(mozIStorageConnection* aConnection,
|
nsresult UpdateIndexes(mozIStorageConnection* aConnection,
|
||||||
PRInt64 aObjectDataId);
|
PRInt64 aObjectDataId);
|
||||||
|
|
||||||
|
@ -840,9 +842,8 @@ IDBObjectStore::DeserializeValue(JSContext* aCx,
|
||||||
JSAutoStructuredCloneBuffer& aBuffer,
|
JSAutoStructuredCloneBuffer& aBuffer,
|
||||||
jsval* aValue)
|
jsval* aValue)
|
||||||
{
|
{
|
||||||
/*
|
NS_ASSERTION(NS_IsMainThread(),
|
||||||
* This function can be called on multiple threads! Be careful!
|
"Should only be deserializing on the main thread!");
|
||||||
*/
|
|
||||||
NS_ASSERTION(aCx, "A JSContext is required!");
|
NS_ASSERTION(aCx, "A JSContext is required!");
|
||||||
|
|
||||||
if (!aBuffer.data()) {
|
if (!aBuffer.data()) {
|
||||||
|
@ -861,9 +862,8 @@ IDBObjectStore::SerializeValue(JSContext* aCx,
|
||||||
JSAutoStructuredCloneBuffer& aBuffer,
|
JSAutoStructuredCloneBuffer& aBuffer,
|
||||||
jsval aValue)
|
jsval aValue)
|
||||||
{
|
{
|
||||||
/*
|
NS_ASSERTION(NS_IsMainThread(),
|
||||||
* This function can be called on multiple threads! Be careful!
|
"Should only be serializing on the main thread!");
|
||||||
*/
|
|
||||||
NS_ASSERTION(aCx, "A JSContext is required!");
|
NS_ASSERTION(aCx, "A JSContext is required!");
|
||||||
|
|
||||||
JSAutoRequest ar(aCx);
|
JSAutoRequest ar(aCx);
|
||||||
|
@ -871,9 +871,62 @@ IDBObjectStore::SerializeValue(JSContext* aCx,
|
||||||
return aBuffer.write(aCx, aValue, nsnull);
|
return aBuffer.write(aCx, aValue, nsnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline jsdouble
|
||||||
|
SwapBytes(PRUint64 u)
|
||||||
|
{
|
||||||
|
#ifdef IS_BIG_ENDIAN
|
||||||
|
return ((u & 0x00000000000000ffLLU) << 56) |
|
||||||
|
((u & 0x000000000000ff00LLU) << 40) |
|
||||||
|
((u & 0x0000000000ff0000LLU) << 24) |
|
||||||
|
((u & 0x00000000ff000000LLU) << 8) |
|
||||||
|
((u & 0x000000ff00000000LLU) >> 8) |
|
||||||
|
((u & 0x0000ff0000000000LLU) >> 24) |
|
||||||
|
((u & 0x00ff000000000000LLU) >> 40) |
|
||||||
|
((u & 0xff00000000000000LLU) >> 56);
|
||||||
|
#else
|
||||||
|
return u;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
IDBObjectStore::ModifyValueForNewKey(JSAutoStructuredCloneBuffer& aBuffer,
|
||||||
|
Key& aKey)
|
||||||
|
{
|
||||||
|
NS_ASSERTION(IsAutoIncrement() && KeyPath().IsEmpty() && aKey.IsInt(),
|
||||||
|
"Don't call me!");
|
||||||
|
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread");
|
||||||
|
NS_ASSERTION(mKeyPathSerializationOffset, "How did this happen?");
|
||||||
|
|
||||||
|
// The minus 8 dangling off the end here is to account for the null entry
|
||||||
|
// that terminates the buffer
|
||||||
|
const PRUint32 keyPropLen = mKeyPathSerialization.nbytes() -
|
||||||
|
mKeyPathSerializationOffset - sizeof(PRUint64);
|
||||||
|
|
||||||
|
const char* location = nsCRT::memmem((char*)aBuffer.data(),
|
||||||
|
aBuffer.nbytes(),
|
||||||
|
(char*)mKeyPathSerialization.data() +
|
||||||
|
mKeyPathSerializationOffset,
|
||||||
|
keyPropLen);
|
||||||
|
NS_ASSERTION(location, "How did this happen?");
|
||||||
|
|
||||||
|
// This is a duplicate of the js engine's byte munging here
|
||||||
|
union {
|
||||||
|
jsdouble d;
|
||||||
|
PRUint64 u;
|
||||||
|
} pun;
|
||||||
|
|
||||||
|
pun.d = SwapBytes(aKey.IntValue());
|
||||||
|
|
||||||
|
memcpy(const_cast<char*>(location) + keyPropLen -
|
||||||
|
sizeof(pun.u), // We're overwriting the last 8 bytes
|
||||||
|
&pun.u, sizeof(PRUint64));
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
IDBObjectStore::IDBObjectStore()
|
IDBObjectStore::IDBObjectStore()
|
||||||
: mId(LL_MININT),
|
: mId(LL_MININT),
|
||||||
mAutoIncrement(PR_FALSE)
|
mAutoIncrement(PR_FALSE),
|
||||||
|
mKeyPathSerializationOffset(0)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||||
}
|
}
|
||||||
|
@ -932,11 +985,47 @@ IDBObjectStore::GetAddInfo(JSContext* aCx,
|
||||||
rv = GetIndexUpdateInfo(info, aCx, aValue, aUpdateInfoArray);
|
rv = GetIndexUpdateInfo(info, aCx, aValue, aUpdateInfoArray);
|
||||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
if (!IDBObjectStore::SerializeValue(aCx, aCloneBuffer, aValue)) {
|
const jschar* keyPathChars =
|
||||||
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
reinterpret_cast<const jschar*>(mKeyPath.get());
|
||||||
|
const size_t keyPathLen = mKeyPath.Length();
|
||||||
|
JSBool ok = JS_FALSE;
|
||||||
|
|
||||||
|
if (!mKeyPath.IsEmpty() && aKey.IsUnset()) {
|
||||||
|
NS_ASSERTION(mAutoIncrement, "Should have bailed earlier!");
|
||||||
|
|
||||||
|
jsval key;
|
||||||
|
ok = JS_NewNumberValue(aCx, kTotallyRandomNumber, &key);
|
||||||
|
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
|
ok = JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(aValue), keyPathChars,
|
||||||
|
keyPathLen, key, nsnull, nsnull,
|
||||||
|
JSPROP_ENUMERATE);
|
||||||
|
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
|
// From this point on we have to try to remove the property.
|
||||||
|
rv = EnsureKeyPathSerializationData(aCx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
// We guard on rv being a success because we need to run the property
|
||||||
|
// deletion code below even if we should not be serializing the value
|
||||||
|
if (NS_SUCCEEDED(rv) &&
|
||||||
|
!IDBObjectStore::SerializeValue(aCx, aCloneBuffer, aValue)) {
|
||||||
|
rv = NS_ERROR_DOM_DATA_CLONE_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
// If this fails, we lose, and the web page sees a magical property
|
||||||
|
// appear on the object :-(
|
||||||
|
jsval succeeded;
|
||||||
|
ok = JS_DeleteUCProperty2(aCx, JSVAL_TO_OBJECT(aValue), keyPathChars,
|
||||||
|
keyPathLen, &succeeded);
|
||||||
|
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
NS_ASSERTION(JSVAL_IS_BOOLEAN(succeeded), "Wtf?");
|
||||||
|
NS_ENSURE_TRUE(JSVAL_TO_BOOLEAN(succeeded),
|
||||||
|
NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -987,6 +1076,46 @@ IDBObjectStore::AddOrPut(const jsval& aValue,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
IDBObjectStore::EnsureKeyPathSerializationData(JSContext* aCx)
|
||||||
|
{
|
||||||
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread");
|
||||||
|
|
||||||
|
if (!mKeyPathSerializationOffset) {
|
||||||
|
JSBool ok;
|
||||||
|
|
||||||
|
JSAutoStructuredCloneBuffer emptyObjectBuffer;
|
||||||
|
JSAutoStructuredCloneBuffer fakeObjectBuffer;
|
||||||
|
|
||||||
|
const jschar* keyPathChars =
|
||||||
|
reinterpret_cast<const jschar*>(mKeyPath.get());
|
||||||
|
const size_t keyPathLen = mKeyPath.Length();
|
||||||
|
|
||||||
|
JSObject* object = JS_NewObject(aCx, nsnull, nsnull, nsnull);
|
||||||
|
NS_ENSURE_TRUE(object, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
|
ok = emptyObjectBuffer.write(aCx, OBJECT_TO_JSVAL(object));
|
||||||
|
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
|
jsval key;
|
||||||
|
// This is just to give us some random marker in the byte stream
|
||||||
|
ok = JS_NewNumberValue(aCx, kTotallyRandomNumber, &key);
|
||||||
|
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
|
ok = JS_DefineUCProperty(aCx, object, keyPathChars, keyPathLen,
|
||||||
|
key, nsnull, nsnull, JSPROP_ENUMERATE);
|
||||||
|
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
|
ok = fakeObjectBuffer.write(aCx, OBJECT_TO_JSVAL(object));
|
||||||
|
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
|
mKeyPathSerialization.swap(fakeObjectBuffer);
|
||||||
|
mKeyPathSerializationOffset = emptyObjectBuffer.nbytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBObjectStore)
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBObjectStore)
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBObjectStore)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBObjectStore)
|
||||||
|
@ -1721,7 +1850,7 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
||||||
// Special case where someone put an object into an autoIncrement'ing
|
// Special case where someone put an object into an autoIncrement'ing
|
||||||
// objectStore with no key in its keyPath set. We needed to figure out
|
// objectStore with no key in its keyPath set. We needed to figure out
|
||||||
// which row id we would get above before we could set that properly.
|
// which row id we would get above before we could set that properly.
|
||||||
rv = ModifyValueForNewKey();
|
rv = mObjectStore->ModifyValueForNewKey(mCloneBuffer, mKey);
|
||||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
scoper.Abandon();
|
scoper.Abandon();
|
||||||
|
@ -1777,58 +1906,6 @@ AddHelper::GetSuccessResult(JSContext* aCx,
|
||||||
return IDBObjectStore::GetJSValFromKey(mKey, aCx, aVal);
|
return IDBObjectStore::GetJSValFromKey(mKey, aCx, aVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
AddHelper::ModifyValueForNewKey()
|
|
||||||
{
|
|
||||||
NS_ASSERTION(mObjectStore->IsAutoIncrement() &&
|
|
||||||
!mObjectStore->KeyPath().IsEmpty() &&
|
|
||||||
mKey.IsInt(),
|
|
||||||
"Don't call me!");
|
|
||||||
|
|
||||||
const nsString& keyPath = mObjectStore->KeyPath();
|
|
||||||
|
|
||||||
JSContext* cx = nsnull;
|
|
||||||
nsresult rv = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
JSAutoRequest ar(cx);
|
|
||||||
|
|
||||||
jsval clone;
|
|
||||||
if (!IDBObjectStore::DeserializeValue(cx, mCloneBuffer, &clone)) {
|
|
||||||
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ASSERTION(!JSVAL_IS_PRIMITIVE(clone), "We should have an object!");
|
|
||||||
|
|
||||||
JSObject* obj = JSVAL_TO_OBJECT(clone);
|
|
||||||
JSBool ok;
|
|
||||||
|
|
||||||
const jschar* keyPathChars = reinterpret_cast<const jschar*>(keyPath.get());
|
|
||||||
const size_t keyPathLen = keyPath.Length();
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
{
|
|
||||||
jsval prop;
|
|
||||||
ok = JS_GetUCProperty(cx, obj, keyPathChars, keyPathLen, &prop);
|
|
||||||
NS_ASSERTION(ok && JSVAL_IS_VOID(prop), "Already has a key prop!");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
jsval key;
|
|
||||||
ok = JS_NewNumberValue(cx, mKey.IntValue(), &key);
|
|
||||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
ok = JS_DefineUCProperty(cx, obj, keyPathChars, keyPathLen, key, nsnull,
|
|
||||||
nsnull, JSPROP_ENUMERATE);
|
|
||||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
if (!IDBObjectStore::SerializeValue(cx, mCloneBuffer, OBJECT_TO_JSVAL(obj))) {
|
|
||||||
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
GetHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
GetHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
||||||
{
|
{
|
||||||
|
|
|
@ -157,6 +157,9 @@ public:
|
||||||
return mTransaction;
|
return mTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult ModifyValueForNewKey(JSAutoStructuredCloneBuffer& aBuffer,
|
||||||
|
Key& aKey);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IDBObjectStore();
|
IDBObjectStore();
|
||||||
~IDBObjectStore();
|
~IDBObjectStore();
|
||||||
|
@ -175,6 +178,8 @@ protected:
|
||||||
nsIIDBRequest** _retval,
|
nsIIDBRequest** _retval,
|
||||||
bool aOverwrite);
|
bool aOverwrite);
|
||||||
|
|
||||||
|
nsresult EnsureKeyPathSerializationData(JSContext* aCx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsRefPtr<IDBTransaction> mTransaction;
|
nsRefPtr<IDBTransaction> mTransaction;
|
||||||
|
|
||||||
|
@ -188,6 +193,11 @@ private:
|
||||||
PRUint32 mDatabaseId;
|
PRUint32 mDatabaseId;
|
||||||
PRUint32 mStructuredCloneVersion;
|
PRUint32 mStructuredCloneVersion;
|
||||||
|
|
||||||
|
// Used to store a serialized representation of the fake property
|
||||||
|
// entry used to handle autoincrement with keypaths.
|
||||||
|
JSAutoStructuredCloneBuffer mKeyPathSerialization;
|
||||||
|
PRUint32 mKeyPathSerializationOffset;
|
||||||
|
|
||||||
nsTArray<nsRefPtr<IDBIndex> > mCreatedIndexes;
|
nsTArray<nsRefPtr<IDBIndex> > mCreatedIndexes;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -104,7 +104,7 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aDispatchDelayed) {
|
if (!aDispatchDelayed) {
|
||||||
nsCOMPtr<nsIThreadInternal2> thread =
|
nsCOMPtr<nsIThreadInternal> thread =
|
||||||
do_QueryInterface(NS_GetCurrentThread());
|
do_QueryInterface(NS_GetCurrentThread());
|
||||||
NS_ENSURE_TRUE(thread, nsnull);
|
NS_ENSURE_TRUE(thread, nsnull);
|
||||||
|
|
||||||
|
@ -899,10 +899,7 @@ IDBTransaction::AfterProcessNextEvent(nsIThreadInternal* aThread,
|
||||||
}
|
}
|
||||||
|
|
||||||
// No longer need to observe thread events.
|
// No longer need to observe thread events.
|
||||||
nsCOMPtr<nsIThreadInternal2> thread = do_QueryInterface(aThread);
|
if(NS_FAILED(aThread->RemoveObserver(this))) {
|
||||||
NS_ASSERTION(thread, "This must never fail!");
|
|
||||||
|
|
||||||
if(NS_FAILED(thread->RemoveObserver(this))) {
|
|
||||||
NS_ERROR("Failed to remove observer!");
|
NS_ERROR("Failed to remove observer!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ using NPNVariable;
|
||||||
using base::FileDescriptor;
|
using base::FileDescriptor;
|
||||||
using mozilla::plugins::NativeThreadId;
|
using mozilla::plugins::NativeThreadId;
|
||||||
using mac_plugin_interposing::NSCursorInfo;
|
using mac_plugin_interposing::NSCursorInfo;
|
||||||
|
using nsID;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace plugins {
|
namespace plugins {
|
||||||
|
@ -105,6 +106,11 @@ child:
|
||||||
rpc NPP_GetSitesWithData()
|
rpc NPP_GetSitesWithData()
|
||||||
returns (nsCString[] sites);
|
returns (nsCString[] sites);
|
||||||
|
|
||||||
|
// Windows specific message to set up an audio session in the plugin process
|
||||||
|
async SetAudioSessionData(nsID aID,
|
||||||
|
nsString aDisplayName,
|
||||||
|
nsString aIconPath);
|
||||||
|
|
||||||
parent:
|
parent:
|
||||||
/**
|
/**
|
||||||
* This message is only used on X11 platforms.
|
* This message is only used on X11 platforms.
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
#include "COMMessageFilter.h"
|
#include "COMMessageFilter.h"
|
||||||
#include "nsWindowsDllInterceptor.h"
|
#include "nsWindowsDllInterceptor.h"
|
||||||
|
#include "mozilla/widget/AudioSession.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OS_MACOSX
|
#ifdef OS_MACOSX
|
||||||
|
@ -594,6 +595,10 @@ PluginModuleChild::AnswerNP_Shutdown(NPError *rv)
|
||||||
{
|
{
|
||||||
AssertPluginThread();
|
AssertPluginThread();
|
||||||
|
|
||||||
|
#if defined XP_WIN && MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||||
|
mozilla::widget::StopAudioSession();
|
||||||
|
#endif
|
||||||
|
|
||||||
// the PluginModuleParent shuts down this process after this RPC
|
// the PluginModuleParent shuts down this process after this RPC
|
||||||
// call pops off its stack
|
// call pops off its stack
|
||||||
|
|
||||||
|
@ -649,6 +654,25 @@ PluginModuleChild::AnswerNPP_GetSitesWithData(InfallibleTArray<nsCString>* aResu
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PluginModuleChild::RecvSetAudioSessionData(const nsID& aId,
|
||||||
|
const nsString& aDisplayName,
|
||||||
|
const nsString& aIconPath)
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
#if !defined XP_WIN || MOZ_WINSDK_TARGETVER < MOZ_NTDDI_LONGHORN
|
||||||
|
NS_RUNTIMEABORT("Not Reached!");
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
rv = mozilla::widget::RecvAudioSessionData(aId, aDisplayName, aIconPath);
|
||||||
|
NS_ENSURE_SUCCESS(rv, true); // Bail early if this fails
|
||||||
|
|
||||||
|
// Ignore failures here; we can't really do anything about them
|
||||||
|
mozilla::widget::StartAudioSession();
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PluginModuleChild::QuickExit()
|
PluginModuleChild::QuickExit()
|
||||||
{
|
{
|
||||||
|
|
|
@ -163,6 +163,11 @@ protected:
|
||||||
virtual bool
|
virtual bool
|
||||||
AnswerNPP_GetSitesWithData(InfallibleTArray<nsCString>* aResult);
|
AnswerNPP_GetSitesWithData(InfallibleTArray<nsCString>* aResult);
|
||||||
|
|
||||||
|
virtual bool
|
||||||
|
RecvSetAudioSessionData(const nsID& aId,
|
||||||
|
const nsString& aDisplayName,
|
||||||
|
const nsString& aIconPath);
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
ActorDestroy(ActorDestroyReason why);
|
ActorDestroy(ActorDestroyReason why);
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,10 @@
|
||||||
#include "nsNPAPIPlugin.h"
|
#include "nsNPAPIPlugin.h"
|
||||||
#include "nsILocalFile.h"
|
#include "nsILocalFile.h"
|
||||||
|
|
||||||
|
#ifdef XP_WIN
|
||||||
|
#include "mozilla/widget/AudioSession.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using base::KillProcess;
|
using base::KillProcess;
|
||||||
|
|
||||||
using mozilla::PluginLibrary;
|
using mozilla::PluginLibrary;
|
||||||
|
@ -750,6 +754,8 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs
|
||||||
{
|
{
|
||||||
PLUGIN_LOG_DEBUG_METHOD;
|
PLUGIN_LOG_DEBUG_METHOD;
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
mNPNIface = bFuncs;
|
mNPNIface = bFuncs;
|
||||||
|
|
||||||
if (mShutdown) {
|
if (mShutdown) {
|
||||||
|
@ -784,6 +790,18 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
|
||||||
if (!CallNP_Initialize(&mPluginThread, error))
|
if (!CallNP_Initialize(&mPluginThread, error))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
#if defined XP_WIN && MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||||
|
// Send the info needed to join the chrome process's audio session to the
|
||||||
|
// plugin process
|
||||||
|
nsID id;
|
||||||
|
nsString sessionName;
|
||||||
|
nsString iconPath;
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName,
|
||||||
|
iconPath)))
|
||||||
|
SendSetAudioSessionData(id, sessionName, iconPath);
|
||||||
|
#endif
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#include "chrome/common/ipc_message_utils.h"
|
#include "chrome/common/ipc_message_utils.h"
|
||||||
|
|
||||||
#include "prtypes.h"
|
#include "prtypes.h"
|
||||||
|
#include "nsID.h"
|
||||||
|
#include "nsMemory.h"
|
||||||
#include "nsStringGlue.h"
|
#include "nsStringGlue.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "gfx3DMatrix.h"
|
#include "gfx3DMatrix.h"
|
||||||
|
@ -687,6 +689,48 @@ struct ParamTraits<nsRect>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct ParamTraits<nsID>
|
||||||
|
{
|
||||||
|
typedef nsID paramType;
|
||||||
|
|
||||||
|
static void Write(Message* aMsg, const paramType& aParam)
|
||||||
|
{
|
||||||
|
WriteParam(aMsg, aParam.m0);
|
||||||
|
WriteParam(aMsg, aParam.m1);
|
||||||
|
WriteParam(aMsg, aParam.m2);
|
||||||
|
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(aParam.m3); i++) {
|
||||||
|
WriteParam(aMsg, aParam.m3[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||||
|
{
|
||||||
|
if(!ReadParam(aMsg, aIter, &(aResult->m0)) ||
|
||||||
|
!ReadParam(aMsg, aIter, &(aResult->m1)) ||
|
||||||
|
!ReadParam(aMsg, aIter, &(aResult->m2)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(aResult->m3); i++)
|
||||||
|
if (!ReadParam(aMsg, aIter, &(aResult->m3[i])))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Log(const paramType& aParam, std::wstring* aLog)
|
||||||
|
{
|
||||||
|
aLog->append(L"{");
|
||||||
|
aLog->append(StringPrintf(L"%8.8X-%4.4X-%4.4X-",
|
||||||
|
aParam.m0,
|
||||||
|
aParam.m1,
|
||||||
|
aParam.m2));
|
||||||
|
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(aParam.m3); i++)
|
||||||
|
aLog->append(StringPrintf(L"%2.2X", aParam.m3[i]));
|
||||||
|
aLog->append(L"}");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} /* namespace IPC */
|
} /* namespace IPC */
|
||||||
|
|
||||||
#endif /* __IPC_GLUE_IPCMESSAGEUTILS_H__ */
|
#endif /* __IPC_GLUE_IPCMESSAGEUTILS_H__ */
|
||||||
|
|
|
@ -2241,6 +2241,9 @@ ia64*-hpux*)
|
||||||
CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
|
CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
|
||||||
# MSVC warnings C4244 and C4800 are ubiquitous, useless, and annoying.
|
# MSVC warnings C4244 and C4800 are ubiquitous, useless, and annoying.
|
||||||
CXXFLAGS="$CXXFLAGS -wd4244 -wd4800"
|
CXXFLAGS="$CXXFLAGS -wd4244 -wd4800"
|
||||||
|
# make 'foo == bar;' error out
|
||||||
|
CFLAGS="$CFLAGS -we4553"
|
||||||
|
CXXFLAGS="$CXXFLAGS -we4553"
|
||||||
LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
|
LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
|
||||||
MOZ_DEBUG_FLAGS='-Zi'
|
MOZ_DEBUG_FLAGS='-Zi'
|
||||||
MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
|
MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
|
#include "nsStreamUtils.h"
|
||||||
#include "nsIHttpChannel.h"
|
#include "nsIHttpChannel.h"
|
||||||
#include "nsICachingChannel.h"
|
#include "nsICachingChannel.h"
|
||||||
#include "nsIInterfaceRequestor.h"
|
#include "nsIInterfaceRequestor.h"
|
||||||
|
@ -2167,15 +2168,6 @@ NS_IMETHODIMP imgCacheValidator::OnStopRequest(nsIRequest *aRequest, nsISupports
|
||||||
/** nsIStreamListener methods **/
|
/** nsIStreamListener methods **/
|
||||||
|
|
||||||
|
|
||||||
// XXX see bug 113959
|
|
||||||
static NS_METHOD dispose_of_data(nsIInputStream* in, void* closure,
|
|
||||||
const char* fromRawSegment, PRUint32 toOffset,
|
|
||||||
PRUint32 count, PRUint32 *writeCount)
|
|
||||||
{
|
|
||||||
*writeCount = count;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* void onDataAvailable (in nsIRequest request, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long sourceOffset, in unsigned long count); */
|
/* void onDataAvailable (in nsIRequest request, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long sourceOffset, in unsigned long count); */
|
||||||
NS_IMETHODIMP imgCacheValidator::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
|
NS_IMETHODIMP imgCacheValidator::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
|
||||||
{
|
{
|
||||||
|
@ -2191,7 +2183,7 @@ NS_IMETHODIMP imgCacheValidator::OnDataAvailable(nsIRequest *aRequest, nsISuppor
|
||||||
if (!mDestListener) {
|
if (!mDestListener) {
|
||||||
// XXX see bug 113959
|
// XXX see bug 113959
|
||||||
PRUint32 _retval;
|
PRUint32 _retval;
|
||||||
inStr->ReadSegments(dispose_of_data, nsnull, count, &_retval);
|
inStr->ReadSegments(NS_DiscardSegment, nsnull, count, &_retval);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -635,8 +635,10 @@ static void nsNetShutdown()
|
||||||
// Release DNS service reference.
|
// Release DNS service reference.
|
||||||
nsDNSPrefetch::Shutdown();
|
nsDNSPrefetch::Shutdown();
|
||||||
|
|
||||||
|
#ifdef NECKO_PROTOCOL_websocket
|
||||||
// Release the Websocket Admission Manager
|
// Release the Websocket Admission Manager
|
||||||
mozilla::net::nsWebSocketHandler::Shutdown();
|
mozilla::net::nsWebSocketHandler::Shutdown();
|
||||||
|
#endif // NECKO_PROTOCOL_websocket
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_DEFINE_NAMED_CID(NS_IOSERVICE_CID);
|
NS_DEFINE_NAMED_CID(NS_IOSERVICE_CID);
|
||||||
|
|
|
@ -168,3 +168,6 @@ _dollar=$$
|
||||||
MOZ_SOURCE_REPO = $(shell cd $(MOZILLA_DIR) && hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" -e "s/\/$(_dollar)//" )
|
MOZ_SOURCE_REPO = $(shell cd $(MOZILLA_DIR) && hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" -e "s/\/$(_dollar)//" )
|
||||||
|
|
||||||
MOZ_SOURCESTAMP_FILE = $(DIST)/$(PKG_PATH)/$(PKG_BASENAME).txt
|
MOZ_SOURCESTAMP_FILE = $(DIST)/$(PKG_PATH)/$(PKG_BASENAME).txt
|
||||||
|
|
||||||
|
# JavaScript Shell
|
||||||
|
PKG_JSSHELL = $(DIST)/jsshell-$(MOZ_PKG_PLATFORM).zip
|
||||||
|
|
|
@ -82,6 +82,21 @@ endif
|
||||||
SDK_SUFFIX = $(PKG_SUFFIX)
|
SDK_SUFFIX = $(PKG_SUFFIX)
|
||||||
SDK = $(SDK_PATH)$(PKG_BASENAME).sdk$(SDK_SUFFIX)
|
SDK = $(SDK_PATH)$(PKG_BASENAME).sdk$(SDK_SUFFIX)
|
||||||
|
|
||||||
|
# JavaScript Shell packaging
|
||||||
|
JSSHELL_BINS = \
|
||||||
|
$(DIST)/bin/js$(BIN_SUFFIX) \
|
||||||
|
$(DIST)/bin/$(LIB_PREFIX)nspr4$(DLL_SUFFIX) \
|
||||||
|
$(NULL)
|
||||||
|
ifeq ($(OS_ARCH),WINNT)
|
||||||
|
JSSHELL_BINS += $(DIST)/bin/mozcrt19$(DLL_SUFFIX)
|
||||||
|
else
|
||||||
|
JSSHELL_BINS += \
|
||||||
|
$(DIST)/bin/$(LIB_PREFIX)plds4$(DLL_SUFFIX) \
|
||||||
|
$(DIST)/bin/$(LIB_PREFIX)plc4$(DLL_SUFFIX) \
|
||||||
|
$(NULL)
|
||||||
|
endif
|
||||||
|
MAKE_JSSHELL = $(ZIP) -9j $(PKG_JSSHELL) $(JSSHELL_BINS)
|
||||||
|
|
||||||
MAKE_PACKAGE = $(error What is a $(MOZ_PKG_FORMAT) package format?);
|
MAKE_PACKAGE = $(error What is a $(MOZ_PKG_FORMAT) package format?);
|
||||||
_ABS_DIST = $(call core_abspath,$(DIST))
|
_ABS_DIST = $(call core_abspath,$(DIST))
|
||||||
JARLOG_DIR = $(call core_abspath,$(DEPTH)/jarlog/)
|
JARLOG_DIR = $(call core_abspath,$(DEPTH)/jarlog/)
|
||||||
|
@ -668,6 +683,10 @@ endif
|
||||||
ifdef MOZ_PKG_REMOVALS
|
ifdef MOZ_PKG_REMOVALS
|
||||||
$(SYSINSTALL) $(IFLAGS1) $(MOZ_PKG_REMOVALS_GEN) $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)
|
$(SYSINSTALL) $(IFLAGS1) $(MOZ_PKG_REMOVALS_GEN) $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)
|
||||||
endif # MOZ_PKG_REMOVALS
|
endif # MOZ_PKG_REMOVALS
|
||||||
|
# Package JavaScript Shell
|
||||||
|
@echo "Packaging JavaScript Shell..."
|
||||||
|
$(RM) $(PKG_JSSHELL)
|
||||||
|
$(MAKE_JSSHELL)
|
||||||
|
|
||||||
make-package: stage-package $(PACKAGE_XULRUNNER) make-sourcestamp-file
|
make-package: stage-package $(PACKAGE_XULRUNNER) make-sourcestamp-file
|
||||||
@echo "Compressing..."
|
@echo "Compressing..."
|
||||||
|
@ -778,9 +797,11 @@ UPLOAD_FILES= \
|
||||||
$(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip) \
|
$(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip) \
|
||||||
$(call QUOTED_WILDCARD,$(DIST)/$(SDK)) \
|
$(call QUOTED_WILDCARD,$(DIST)/$(SDK)) \
|
||||||
$(call QUOTED_WILDCARD,$(MOZ_SOURCESTAMP_FILE)) \
|
$(call QUOTED_WILDCARD,$(MOZ_SOURCESTAMP_FILE)) \
|
||||||
|
$(call QUOTED_WILDCARD,$(PKG_JSSHELL)) \
|
||||||
$(if $(UPLOAD_EXTRA_FILES), $(foreach f, $(UPLOAD_EXTRA_FILES), $(wildcard $(DIST)/$(f))))
|
$(if $(UPLOAD_EXTRA_FILES), $(foreach f, $(UPLOAD_EXTRA_FILES), $(wildcard $(DIST)/$(f))))
|
||||||
|
|
||||||
checksum:
|
checksum:
|
||||||
|
mkdir -p `dirname $CHECKSUM_FILE`
|
||||||
@$(PYTHON) $(MOZILLA_DIR)/build/checksums.py \
|
@$(PYTHON) $(MOZILLA_DIR)/build/checksums.py \
|
||||||
-o $(CHECKSUM_FILE) \
|
-o $(CHECKSUM_FILE) \
|
||||||
-d $(CHECKSUM_ALGORITHM) \
|
-d $(CHECKSUM_ALGORITHM) \
|
||||||
|
|
|
@ -0,0 +1,461 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
*
|
||||||
|
* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (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.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.org code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Kyle Huey <me@kylehuey.com>
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <audiopolicy.h>
|
||||||
|
#include <Mmdeviceapi.h>
|
||||||
|
|
||||||
|
#include "nsIStringBundle.h"
|
||||||
|
#include "nsIUUIDGenerator.h"
|
||||||
|
#include "nsIXULAppInfo.h"
|
||||||
|
|
||||||
|
//#include "AudioSession.h"
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsAutoPtr.h"
|
||||||
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsString.h"
|
||||||
|
#include "nsXULAppApi.h"
|
||||||
|
|
||||||
|
#include <objbase.h>
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace widget {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To take advantage of what Vista+ have to offer with respect to audio,
|
||||||
|
* we need to maintain an audio session. This class wraps IAudioSessionControl
|
||||||
|
* and implements IAudioSessionEvents (for callbacks from Windows)
|
||||||
|
*/
|
||||||
|
class AudioSession: public IAudioSessionEvents {
|
||||||
|
private:
|
||||||
|
AudioSession();
|
||||||
|
~AudioSession();
|
||||||
|
public:
|
||||||
|
static AudioSession* GetSingleton();
|
||||||
|
|
||||||
|
// COM IUnknown
|
||||||
|
STDMETHODIMP_(ULONG) AddRef();
|
||||||
|
STDMETHODIMP QueryInterface(REFIID, void**);
|
||||||
|
STDMETHODIMP_(ULONG) Release();
|
||||||
|
|
||||||
|
// IAudioSessionEvents
|
||||||
|
STDMETHODIMP OnChannelVolumeChanged(DWORD aChannelCount,
|
||||||
|
float aChannelVolumeArray[],
|
||||||
|
DWORD aChangedChannel,
|
||||||
|
LPCGUID aContext);
|
||||||
|
STDMETHODIMP OnDisplayNameChanged(LPCWSTR aDisplayName, LPCGUID aContext);
|
||||||
|
STDMETHODIMP OnGroupingParamChanged(LPCGUID aGroupingParam, LPCGUID aContext);
|
||||||
|
STDMETHODIMP OnIconPathChanged(LPCWSTR aIconPath, LPCGUID aContext);
|
||||||
|
STDMETHODIMP OnSessionDisconnected(AudioSessionDisconnectReason aReason);
|
||||||
|
STDMETHODIMP OnSimpleVolumeChanged(float aVolume,
|
||||||
|
BOOL aMute,
|
||||||
|
LPCGUID aContext);
|
||||||
|
STDMETHODIMP OnStateChanged(AudioSessionState aState);
|
||||||
|
|
||||||
|
nsresult Start();
|
||||||
|
nsresult Stop();
|
||||||
|
void StopInternal();
|
||||||
|
|
||||||
|
nsresult GetSessionData(nsID& aID,
|
||||||
|
nsString& aSessionName,
|
||||||
|
nsString& aIconPath);
|
||||||
|
|
||||||
|
nsresult SetSessionData(const nsID& aID,
|
||||||
|
const nsString& aSessionName,
|
||||||
|
const nsString& aIconPath);
|
||||||
|
|
||||||
|
enum SessionState {
|
||||||
|
UNINITIALIZED, // Has not been initialized yet
|
||||||
|
STARTED, // Started
|
||||||
|
CLONED, // SetSessionInfoCalled, Start not called
|
||||||
|
FAILED, // The autdio session failed to start
|
||||||
|
STOPPED // Stop called
|
||||||
|
};
|
||||||
|
protected:
|
||||||
|
nsRefPtr<IAudioSessionControl> mAudioSessionControl;
|
||||||
|
nsString mDisplayName;
|
||||||
|
nsString mIconPath;
|
||||||
|
nsID mSessionGroupingParameter;
|
||||||
|
SessionState mState;
|
||||||
|
|
||||||
|
nsAutoRefCnt mRefCnt;
|
||||||
|
NS_DECL_OWNINGTHREAD
|
||||||
|
|
||||||
|
static AudioSession* sService;
|
||||||
|
};
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
StartAudioSession()
|
||||||
|
{
|
||||||
|
return AudioSession::GetSingleton()->Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
StopAudioSession()
|
||||||
|
{
|
||||||
|
return AudioSession::GetSingleton()->Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
GetAudioSessionData(nsID& aID,
|
||||||
|
nsString& aSessionName,
|
||||||
|
nsString& aIconPath)
|
||||||
|
{
|
||||||
|
return AudioSession::GetSingleton()->GetSessionData(aID,
|
||||||
|
aSessionName,
|
||||||
|
aIconPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
RecvAudioSessionData(const nsID& aID,
|
||||||
|
const nsString& aSessionName,
|
||||||
|
const nsString& aIconPath)
|
||||||
|
{
|
||||||
|
return AudioSession::GetSingleton()->SetSessionData(aID,
|
||||||
|
aSessionName,
|
||||||
|
aIconPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioSession* AudioSession::sService = NULL;
|
||||||
|
|
||||||
|
AudioSession::AudioSession()
|
||||||
|
{
|
||||||
|
mState = UNINITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioSession::~AudioSession()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioSession*
|
||||||
|
AudioSession::GetSingleton()
|
||||||
|
{
|
||||||
|
if (!(AudioSession::sService)) {
|
||||||
|
nsRefPtr<AudioSession> service = new AudioSession();
|
||||||
|
service.forget(&AudioSession::sService);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't refcount AudioSession on the Gecko side, we hold one single ref
|
||||||
|
// as long as the appshell is running.
|
||||||
|
return AudioSession::sService;
|
||||||
|
}
|
||||||
|
|
||||||
|
// It appears Windows will use us on a background thread ...
|
||||||
|
NS_IMPL_THREADSAFE_ADDREF(AudioSession)
|
||||||
|
NS_IMPL_THREADSAFE_RELEASE(AudioSession)
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
AudioSession::QueryInterface(REFIID iid, void **ppv)
|
||||||
|
{
|
||||||
|
const IID IID_IAudioSessionEvents = __uuidof(IAudioSessionEvents);
|
||||||
|
if ((IID_IUnknown == iid) ||
|
||||||
|
(IID_IAudioSessionEvents == iid)) {
|
||||||
|
*ppv = static_cast<IAudioSessionEvents*>(this);
|
||||||
|
AddRef();
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once we are started Windows will hold a reference to us through our
|
||||||
|
// IAudioSessionEvents interface that will keep us alive until the appshell
|
||||||
|
// calls Stop.
|
||||||
|
nsresult
|
||||||
|
AudioSession::Start()
|
||||||
|
{
|
||||||
|
NS_ABORT_IF_FALSE(mState == UNINITIALIZED || mState == CLONED,
|
||||||
|
"State invariants violated");
|
||||||
|
|
||||||
|
const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
|
||||||
|
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
|
||||||
|
const IID IID_IAudioSessionManager = __uuidof(IAudioSessionManager);
|
||||||
|
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
if (FAILED(::CoInitialize(NULL)))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
if (mState == UNINITIALIZED) {
|
||||||
|
mState = FAILED;
|
||||||
|
|
||||||
|
// XXXkhuey implement this for content processes
|
||||||
|
if (XRE_GetProcessType() == GeckoProcessType_Content)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
NS_ABORT_IF_FALSE(XRE_GetProcessType() == GeckoProcessType_Default,
|
||||||
|
"Should only get here in a chrome process!");
|
||||||
|
|
||||||
|
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||||
|
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||||
|
NS_ENSURE_TRUE(bundleService, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIStringBundle> bundle;
|
||||||
|
bundleService->CreateBundle("chrome://branding/locale/brand.properties",
|
||||||
|
getter_AddRefs(bundle));
|
||||||
|
NS_ENSURE_TRUE(bundle, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
bundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
|
||||||
|
getter_Copies(mDisplayName));
|
||||||
|
|
||||||
|
PRUnichar *buffer;
|
||||||
|
mIconPath.GetMutableData(&buffer, MAX_PATH);
|
||||||
|
|
||||||
|
// XXXkhuey we should provide a way for a xulrunner app to specify an icon
|
||||||
|
// that's not in the product binary.
|
||||||
|
::GetModuleFileNameW(NULL, buffer, MAX_PATH);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIUUIDGenerator> uuidgen =
|
||||||
|
do_GetService("@mozilla.org/uuid-generator;1");
|
||||||
|
NS_ASSERTION(uuidgen, "No UUID-Generator?!?");
|
||||||
|
|
||||||
|
uuidgen->GenerateUUIDInPlace(&mSessionGroupingParameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
mState = FAILED;
|
||||||
|
|
||||||
|
NS_ABORT_IF_FALSE(!mDisplayName.IsEmpty() || !mIconPath.IsEmpty(),
|
||||||
|
"Should never happen ...");
|
||||||
|
|
||||||
|
nsRefPtr<IMMDeviceEnumerator> enumerator;
|
||||||
|
hr = ::CoCreateInstance(CLSID_MMDeviceEnumerator,
|
||||||
|
NULL,
|
||||||
|
CLSCTX_ALL,
|
||||||
|
IID_IMMDeviceEnumerator,
|
||||||
|
getter_AddRefs(enumerator));
|
||||||
|
if (FAILED(hr))
|
||||||
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
nsRefPtr<IMMDevice> device;
|
||||||
|
hr = enumerator->GetDefaultAudioEndpoint(EDataFlow::eRender,
|
||||||
|
ERole::eMultimedia,
|
||||||
|
getter_AddRefs(device));
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
if (hr == E_NOTFOUND)
|
||||||
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsRefPtr<IAudioSessionManager> manager;
|
||||||
|
hr = device->Activate(IID_IAudioSessionManager,
|
||||||
|
CLSCTX_ALL,
|
||||||
|
NULL,
|
||||||
|
getter_AddRefs(manager));
|
||||||
|
if (FAILED(hr))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
hr = manager->GetAudioSessionControl(NULL,
|
||||||
|
FALSE,
|
||||||
|
getter_AddRefs(mAudioSessionControl));
|
||||||
|
if (FAILED(hr))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
hr = mAudioSessionControl->SetGroupingParam((LPCGUID)&mSessionGroupingParameter,
|
||||||
|
NULL);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
StopInternal();
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = mAudioSessionControl->SetDisplayName(mDisplayName.get(), NULL);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
StopInternal();
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = mAudioSessionControl->SetIconPath(mIconPath.get(), NULL);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
StopInternal();
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = mAudioSessionControl->RegisterAudioSessionNotification(this);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
StopInternal();
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
mState = STARTED;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioSession::StopInternal()
|
||||||
|
{
|
||||||
|
static const nsID blankId = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} };
|
||||||
|
|
||||||
|
if (mAudioSessionControl) {
|
||||||
|
mAudioSessionControl->SetGroupingParam((LPCGUID)&blankId, NULL);
|
||||||
|
mAudioSessionControl->UnregisterAudioSessionNotification(this);
|
||||||
|
mAudioSessionControl = nsnull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
AudioSession::Stop()
|
||||||
|
{
|
||||||
|
NS_ABORT_IF_FALSE(mState == STARTED ||
|
||||||
|
mState == UNINITIALIZED || // XXXremove this
|
||||||
|
mState == FAILED,
|
||||||
|
"State invariants violated");
|
||||||
|
mState = STOPPED;
|
||||||
|
|
||||||
|
nsRefPtr<AudioSession> kungFuDeathGrip;
|
||||||
|
kungFuDeathGrip.swap(sService);
|
||||||
|
|
||||||
|
if (XRE_GetProcessType() != GeckoProcessType_Content)
|
||||||
|
StopInternal();
|
||||||
|
|
||||||
|
// At this point kungFuDeathGrip should be the only reference to AudioSession
|
||||||
|
|
||||||
|
::CoUninitialize();
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CopynsID(nsID& lhs, const nsID& rhs)
|
||||||
|
{
|
||||||
|
lhs.m0 = rhs.m0;
|
||||||
|
lhs.m1 = rhs.m1;
|
||||||
|
lhs.m2 = rhs.m2;
|
||||||
|
for (int i = 0; i < 8; i++ ) {
|
||||||
|
lhs.m3[i] = rhs.m3[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
AudioSession::GetSessionData(nsID& aID,
|
||||||
|
nsString& aSessionName,
|
||||||
|
nsString& aIconPath)
|
||||||
|
{
|
||||||
|
NS_ABORT_IF_FALSE(mState == FAILED ||
|
||||||
|
mState == STARTED ||
|
||||||
|
mState == CLONED,
|
||||||
|
"State invariants violated");
|
||||||
|
|
||||||
|
CopynsID(aID, mSessionGroupingParameter);
|
||||||
|
aSessionName = mDisplayName;
|
||||||
|
aIconPath = mIconPath;
|
||||||
|
|
||||||
|
if (mState == FAILED)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
AudioSession::SetSessionData(const nsID& aID,
|
||||||
|
const nsString& aSessionName,
|
||||||
|
const nsString& aIconPath)
|
||||||
|
{
|
||||||
|
NS_ABORT_IF_FALSE(mState == UNINITIALIZED,
|
||||||
|
"State invariants violated");
|
||||||
|
NS_ABORT_IF_FALSE(XRE_GetProcessType() != GeckoProcessType_Default,
|
||||||
|
"Should never get here in a chrome process!");
|
||||||
|
mState = CLONED;
|
||||||
|
|
||||||
|
CopynsID(mSessionGroupingParameter, aID);
|
||||||
|
mDisplayName = aSessionName;
|
||||||
|
mIconPath = aIconPath;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
AudioSession::OnChannelVolumeChanged(DWORD aChannelCount,
|
||||||
|
float aChannelVolumeArray[],
|
||||||
|
DWORD aChangedChannel,
|
||||||
|
LPCGUID aContext)
|
||||||
|
{
|
||||||
|
return S_OK; // NOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
AudioSession::OnDisplayNameChanged(LPCWSTR aDisplayName,
|
||||||
|
LPCGUID aContext)
|
||||||
|
{
|
||||||
|
return S_OK; // NOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
AudioSession::OnGroupingParamChanged(LPCGUID aGroupingParam,
|
||||||
|
LPCGUID aContext)
|
||||||
|
{
|
||||||
|
return S_OK; // NOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
AudioSession::OnIconPathChanged(LPCWSTR aIconPath,
|
||||||
|
LPCGUID aContext)
|
||||||
|
{
|
||||||
|
return S_OK; // NOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
AudioSession::OnSessionDisconnected(AudioSessionDisconnectReason aReason)
|
||||||
|
{
|
||||||
|
if (!mAudioSessionControl)
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
|
mAudioSessionControl->UnregisterAudioSessionNotification(this);
|
||||||
|
mAudioSessionControl = nsnull;
|
||||||
|
Start(); // If it fails there's not much we can do
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
AudioSession::OnSimpleVolumeChanged(float aVolume,
|
||||||
|
BOOL aMute,
|
||||||
|
LPCGUID aContext)
|
||||||
|
{
|
||||||
|
return S_OK; // NOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
AudioSession::OnStateChanged(AudioSessionState aState)
|
||||||
|
{
|
||||||
|
return S_OK; // NOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace widget
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // MOZ_NTDDI_LONGHORN
|
|
@ -0,0 +1,64 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
*
|
||||||
|
* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (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.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.org code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Kyle Huey <me@kylehuey.com>
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace widget {
|
||||||
|
|
||||||
|
// Start the audio session in the current process
|
||||||
|
nsresult StartAudioSession();
|
||||||
|
|
||||||
|
// Pass the information necessary to start an audio session in another process
|
||||||
|
nsresult GetAudioSessionData(nsID& aID,
|
||||||
|
nsString& aSessionName,
|
||||||
|
nsString& aIconPath);
|
||||||
|
|
||||||
|
// Receive the information necessary to start an audio session in a non-chrome
|
||||||
|
// process
|
||||||
|
nsresult RecvAudioSessionData(const nsID& aID,
|
||||||
|
const nsString& aSessionName,
|
||||||
|
const nsString& aIconPath);
|
||||||
|
|
||||||
|
// Stop the audio session in the current process
|
||||||
|
nsresult StopAudioSession();
|
||||||
|
|
||||||
|
} // namespace widget
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // MOZ_WINSK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
|
@ -73,6 +73,7 @@ CPPSRCS = \
|
||||||
JumpListItem.cpp \
|
JumpListItem.cpp \
|
||||||
GfxInfo.cpp \
|
GfxInfo.cpp \
|
||||||
WidgetTraceEvent.cpp \
|
WidgetTraceEvent.cpp \
|
||||||
|
AudioSession.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
ifdef MOZ_CRASHREPORTER
|
ifdef MOZ_CRASHREPORTER
|
||||||
|
@ -116,6 +117,8 @@ endif
|
||||||
|
|
||||||
|
|
||||||
EXPORTS = nsdefs.h WindowHook.h
|
EXPORTS = nsdefs.h WindowHook.h
|
||||||
|
EXPORTS_NAMESPACES = mozilla/widget
|
||||||
|
EXPORTS_mozilla/widget = AudioSession.h
|
||||||
|
|
||||||
LOCAL_INCLUDES = \
|
LOCAL_INCLUDES = \
|
||||||
-I. \
|
-I. \
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "WinTaskbar.h"
|
#include "WinTaskbar.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsIMM32Handler.h"
|
#include "nsIMM32Handler.h"
|
||||||
|
#include "mozilla/widget/AudioSession.h"
|
||||||
|
|
||||||
// For skidmark code
|
// For skidmark code
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -244,10 +245,20 @@ nsAppShell::Run(void)
|
||||||
{
|
{
|
||||||
LoadedModuleInfo modules[NUM_LOADEDMODULEINFO];
|
LoadedModuleInfo modules[NUM_LOADEDMODULEINFO];
|
||||||
memset(modules, 0, sizeof(modules));
|
memset(modules, 0, sizeof(modules));
|
||||||
sLoadedModules = modules;
|
sLoadedModules = modules;
|
||||||
|
|
||||||
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||||
|
// Ignore failure; failing to start the application is not exactly an
|
||||||
|
// appropriate response to failing to start an audio session.
|
||||||
|
mozilla::widget::StartAudioSession();
|
||||||
|
#endif
|
||||||
|
|
||||||
nsresult rv = nsBaseAppShell::Run();
|
nsresult rv = nsBaseAppShell::Run();
|
||||||
|
|
||||||
|
#ifdef MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||||
|
mozilla::widget::StopAudioSession();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Don't forget to null this out!
|
// Don't forget to null this out!
|
||||||
sLoadedModules = nsnull;
|
sLoadedModules = nsnull;
|
||||||
|
|
||||||
|
|
|
@ -1286,6 +1286,26 @@ nsTraceRefcntImpl::Shutdown()
|
||||||
PL_HashTableDestroy(gSerialNumbers);
|
PL_HashTableDestroy(gSerialNumbers);
|
||||||
gSerialNumbers = nsnull;
|
gSerialNumbers = nsnull;
|
||||||
}
|
}
|
||||||
|
if (gBloatLog) {
|
||||||
|
fclose(gBloatLog);
|
||||||
|
gBloatLog = nsnull;
|
||||||
|
}
|
||||||
|
if (gRefcntsLog) {
|
||||||
|
fclose(gRefcntsLog);
|
||||||
|
gRefcntsLog = nsnull;
|
||||||
|
}
|
||||||
|
if (gAllocLog) {
|
||||||
|
fclose(gAllocLog);
|
||||||
|
gAllocLog = nsnull;
|
||||||
|
}
|
||||||
|
if (gLeakyLog) {
|
||||||
|
fclose(gLeakyLog);
|
||||||
|
gLeakyLog = nsnull;
|
||||||
|
}
|
||||||
|
if (gCOMPtrLog) {
|
||||||
|
fclose(gCOMPtrLog);
|
||||||
|
gCOMPtrLog = nsnull;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,28 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* nsCRT::memmem(const char* haystack, PRUint32 haystackLen,
|
||||||
|
const char* needle, PRUint32 needleLen)
|
||||||
|
{
|
||||||
|
// Sanity checking
|
||||||
|
if (!(haystack && needle && haystackLen && needleLen &&
|
||||||
|
needleLen <= haystackLen))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
#ifdef HAVE_MEMMEM
|
||||||
|
return (const char*)::memmem(haystack, haystackLen, needle, needleLen);
|
||||||
|
#else
|
||||||
|
// No memmem means we need to roll our own. This isn't really optimized
|
||||||
|
// for performance ... if that becomes an issue we can take some inspiration
|
||||||
|
// from the js string compare code in jsstr.cpp
|
||||||
|
for (PRInt32 i = 0; i < haystackLen - needleLen; i++) {
|
||||||
|
if (!memcmp(haystack + i, needle, needleLen))
|
||||||
|
return haystack + i;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
PRUnichar* nsCRT::strdup(const PRUnichar* str)
|
PRUnichar* nsCRT::strdup(const PRUnichar* str)
|
||||||
{
|
{
|
||||||
PRUint32 len = nsCRT::strlen(str);
|
PRUint32 len = nsCRT::strlen(str);
|
||||||
|
|
|
@ -210,6 +210,12 @@ public:
|
||||||
static PRInt32 strncmp(const PRUnichar* s1, const PRUnichar* s2,
|
static PRInt32 strncmp(const PRUnichar* s1, const PRUnichar* s2,
|
||||||
PRUint32 aMaxLen);
|
PRUint32 aMaxLen);
|
||||||
|
|
||||||
|
// The GNU libc has memmem, which is strstr except for binary data
|
||||||
|
// This is our own implementation that uses memmem on platforms
|
||||||
|
// where it's available.
|
||||||
|
static const char* memmem(const char* haystack, PRUint32 haystackLen,
|
||||||
|
const char* needle, PRUint32 needleLen);
|
||||||
|
|
||||||
// You must use nsCRT::free(PRUnichar*) to free memory allocated
|
// You must use nsCRT::free(PRUnichar*) to free memory allocated
|
||||||
// by nsCRT::strdup(PRUnichar*).
|
// by nsCRT::strdup(PRUnichar*).
|
||||||
static PRUnichar* strdup(const PRUnichar* str);
|
static PRUnichar* strdup(const PRUnichar* str);
|
||||||
|
|
|
@ -45,7 +45,7 @@ interface nsIThreadEventFilter;
|
||||||
* The XPCOM thread object implements this interface, which allows a consumer
|
* The XPCOM thread object implements this interface, which allows a consumer
|
||||||
* to observe dispatch activity on the thread.
|
* to observe dispatch activity on the thread.
|
||||||
*/
|
*/
|
||||||
[scriptable, uuid(f89b5063-b06d-42f8-bf23-4dfcf2d80d6a)]
|
[scriptable, uuid(e0d35c22-53d5-4b48-8627-93e05b94cf2c)]
|
||||||
interface nsIThreadInternal : nsIThread
|
interface nsIThreadInternal : nsIThread
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -76,6 +76,28 @@ interface nsIThreadInternal : nsIThread
|
||||||
* events remaining in the queue are appended to the elder queue.
|
* events remaining in the queue are appended to the elder queue.
|
||||||
*/
|
*/
|
||||||
void popEventQueue();
|
void popEventQueue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current recursion depth, 0 when no events are running, 1 when a single
|
||||||
|
* event is running, and higher when nested events are running. Must only be
|
||||||
|
* called on the target thread.
|
||||||
|
*/
|
||||||
|
readonly attribute unsigned long recursionDepth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an observer that will *only* receive onProcessNextEvent and
|
||||||
|
* afterProcessNextEvent callbacks. Always called on the target thread, and
|
||||||
|
* the implementation does not have to be threadsafe. Order of callbacks is
|
||||||
|
* not guaranteed (i.e. afterProcessNextEvent may be called first depending on
|
||||||
|
* whether or not the observer is added in a nested loop). Holds a strong ref.
|
||||||
|
*/
|
||||||
|
void addObserver(in nsIThreadObserver observer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove an observer added via the addObserver call. Once removed the
|
||||||
|
* observer will never be called again by the thread.
|
||||||
|
*/
|
||||||
|
void removeObserver(in nsIThreadObserver observer);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,32 +188,3 @@ interface nsIThreadEventFilter : nsISupports
|
||||||
*/
|
*/
|
||||||
[notxpcom] boolean acceptEvent(in nsIRunnable event);
|
[notxpcom] boolean acceptEvent(in nsIRunnable event);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Temporary interface, will be merged into nsIThreadInternal.
|
|
||||||
*/
|
|
||||||
[scriptable, uuid(4531f101-fddc-4d36-80e7-35260a2f3afe)]
|
|
||||||
interface nsIThreadInternal2 : nsIThreadInternal
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The current recursion depth, 0 when no events are running, 1 when a single
|
|
||||||
* event is running, and higher when nested events are running. Must only be
|
|
||||||
* called on the target thread.
|
|
||||||
*/
|
|
||||||
readonly attribute unsigned long recursionDepth;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an observer that will *only* receive onProcessNextEvent and
|
|
||||||
* afterProcessNextEvent callbacks. Always called on the target thread, and
|
|
||||||
* the implementation does not have to be threadsafe. Order of callbacks is
|
|
||||||
* not guaranteed (i.e. afterProcessNextEvent may be called first depending on
|
|
||||||
* whether or not the observer is added in a nested loop). Holds a strong ref.
|
|
||||||
*/
|
|
||||||
void addObserver(in nsIThreadObserver observer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove an observer added via the addObserver call. Once removed the
|
|
||||||
* observer will never be called again by the thread.
|
|
||||||
*/
|
|
||||||
void removeObserver(in nsIThreadObserver observer);
|
|
||||||
};
|
|
||||||
|
|
|
@ -159,7 +159,6 @@ NS_IMPL_THREADSAFE_RELEASE(nsThread)
|
||||||
NS_INTERFACE_MAP_BEGIN(nsThread)
|
NS_INTERFACE_MAP_BEGIN(nsThread)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIThread)
|
NS_INTERFACE_MAP_ENTRY(nsIThread)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIThreadInternal)
|
NS_INTERFACE_MAP_ENTRY(nsIThreadInternal)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIThreadInternal2)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIEventTarget)
|
NS_INTERFACE_MAP_ENTRY(nsIEventTarget)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
|
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIThread)
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIThread)
|
||||||
|
@ -745,9 +744,6 @@ nsThread::nsChainedEventQueue::PutEvent(nsIRunnable *event)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// nsIThreadInternal2
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThread::GetRecursionDepth(PRUint32 *depth)
|
nsThread::GetRecursionDepth(PRUint32 *depth)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,14 +48,13 @@
|
||||||
#include "nsTObserverArray.h"
|
#include "nsTObserverArray.h"
|
||||||
|
|
||||||
// A native thread
|
// A native thread
|
||||||
class nsThread : public nsIThreadInternal2, public nsISupportsPriority
|
class nsThread : public nsIThreadInternal, public nsISupportsPriority
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIEVENTTARGET
|
NS_DECL_NSIEVENTTARGET
|
||||||
NS_DECL_NSITHREAD
|
NS_DECL_NSITHREAD
|
||||||
NS_DECL_NSITHREADINTERNAL
|
NS_DECL_NSITHREADINTERNAL
|
||||||
NS_DECL_NSITHREADINTERNAL2
|
|
||||||
NS_DECL_NSISUPPORTSPRIORITY
|
NS_DECL_NSISUPPORTSPRIORITY
|
||||||
|
|
||||||
nsThread();
|
nsThread();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче