From da3f6b77acce8bd4670d64c188d9c00c2724abcd Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Fri, 24 Jun 2011 17:23:04 +0200 Subject: [PATCH] Revert to changeset a87ee7550f6a due to incomplete backout --- build/autoconf/mozconfig-find | 9 - configure.in | 5 +- dom/indexedDB/IDBObjectStore.cpp | 205 ++++------- dom/indexedDB/IDBObjectStore.h | 10 - dom/plugins/ipc/PPluginModule.ipdl | 6 - dom/plugins/ipc/PluginModuleChild.cpp | 24 -- dom/plugins/ipc/PluginModuleChild.h | 5 - dom/plugins/ipc/PluginModuleParent.cpp | 18 - js/src/configure.in | 3 - modules/libpr0n/src/imgLoader.cpp | 12 +- widget/src/windows/AudioSession.cpp | 461 ------------------------- widget/src/windows/AudioSession.h | 64 ---- xpcom/base/nsTraceRefcntImpl.cpp | 20 -- xpcom/ds/nsCRT.cpp | 22 -- xpcom/ds/nsCRT.h | 6 - 15 files changed, 75 insertions(+), 795 deletions(-) delete mode 100644 widget/src/windows/AudioSession.cpp delete mode 100644 widget/src/windows/AudioSession.h diff --git a/build/autoconf/mozconfig-find b/build/autoconf/mozconfig-find index 31f5b71b58e2..2e9d79517c5a 100755 --- a/build/autoconf/mozconfig-find +++ b/build/autoconf/mozconfig-find @@ -46,15 +46,6 @@ # 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" \ "$MOZ_MYCONFIG" \ "$topsrcdir/.mozconfig" \ diff --git a/configure.in b/configure.in index e2f33dabb1ce..7848087cde73 100644 --- a/configure.in +++ b/configure.in @@ -2303,9 +2303,6 @@ ia64*-hpux*) CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)" CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)" 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" MOZ_DEBUG_FLAGS='-Zi' MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV' @@ -3312,7 +3309,7 @@ esac _SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -D_GNU_SOURCE" -AC_CHECK_FUNCS(dladdr memmem) +AC_CHECK_FUNCS(dladdr) CFLAGS="$_SAVE_CFLAGS" if test ! "$GNU_CXX"; then diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index 7462566f9ed4..3f8b1ba95583 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -63,9 +63,6 @@ USING_INDEXEDDB_NAMESPACE namespace { -// This is just to give us some random marker in the byte stream -static const PRUint64 kTotallyRandomNumber = 0x286F258B177D47A9; - class AddHelper : public AsyncConnectionHelper { public: @@ -99,6 +96,7 @@ public: AsyncConnectionHelper::ReleaseMainThreadObjects(); } + nsresult ModifyValueForNewKey(); nsresult UpdateIndexes(mozIStorageConnection* aConnection, PRInt64 aObjectDataId); @@ -842,8 +840,9 @@ IDBObjectStore::DeserializeValue(JSContext* aCx, JSAutoStructuredCloneBuffer& aBuffer, jsval* aValue) { - NS_ASSERTION(NS_IsMainThread(), - "Should only be deserializing on the main thread!"); + /* + * This function can be called on multiple threads! Be careful! + */ NS_ASSERTION(aCx, "A JSContext is required!"); if (!aBuffer.data()) { @@ -862,8 +861,9 @@ IDBObjectStore::SerializeValue(JSContext* aCx, JSAutoStructuredCloneBuffer& aBuffer, jsval aValue) { - NS_ASSERTION(NS_IsMainThread(), - "Should only be serializing on the main thread!"); + /* + * This function can be called on multiple threads! Be careful! + */ NS_ASSERTION(aCx, "A JSContext is required!"); JSAutoRequest ar(aCx); @@ -871,62 +871,9 @@ IDBObjectStore::SerializeValue(JSContext* aCx, 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(location) + keyPropLen - - sizeof(pun.u), // We're overwriting the last 8 bytes - &pun.u, sizeof(PRUint64)); - return NS_OK; -} - IDBObjectStore::IDBObjectStore() : mId(LL_MININT), - mAutoIncrement(PR_FALSE), - mKeyPathSerializationOffset(0) + mAutoIncrement(PR_FALSE) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); } @@ -985,47 +932,11 @@ IDBObjectStore::GetAddInfo(JSContext* aCx, rv = GetIndexUpdateInfo(info, aCx, aValue, aUpdateInfoArray); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - const jschar* keyPathChars = - reinterpret_cast(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); + if (!IDBObjectStore::SerializeValue(aCx, aCloneBuffer, aValue)) { + return NS_ERROR_DOM_DATA_CLONE_ERR; } - // 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; + return NS_OK; } nsresult @@ -1076,46 +987,6 @@ IDBObjectStore::AddOrPut(const jsval& aValue, 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(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_TRAVERSE_BEGIN(IDBObjectStore) @@ -1850,7 +1721,7 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) // Special case where someone put an object into an autoIncrement'ing // 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. - rv = mObjectStore->ModifyValueForNewKey(mCloneBuffer, mKey); + rv = ModifyValueForNewKey(); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); scoper.Abandon(); @@ -1906,6 +1777,58 @@ AddHelper::GetSuccessResult(JSContext* aCx, 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(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 GetHelper::DoDatabaseWork(mozIStorageConnection* aConnection) { diff --git a/dom/indexedDB/IDBObjectStore.h b/dom/indexedDB/IDBObjectStore.h index 50ee4c539db4..cbbaeeb0de90 100644 --- a/dom/indexedDB/IDBObjectStore.h +++ b/dom/indexedDB/IDBObjectStore.h @@ -157,9 +157,6 @@ public: return mTransaction; } - nsresult ModifyValueForNewKey(JSAutoStructuredCloneBuffer& aBuffer, - Key& aKey); - protected: IDBObjectStore(); ~IDBObjectStore(); @@ -178,8 +175,6 @@ protected: nsIIDBRequest** _retval, bool aOverwrite); - nsresult EnsureKeyPathSerializationData(JSContext* aCx); - private: nsRefPtr mTransaction; @@ -193,11 +188,6 @@ private: PRUint32 mDatabaseId; PRUint32 mStructuredCloneVersion; - // Used to store a serialized representation of the fake property - // entry used to handle autoincrement with keypaths. - JSAutoStructuredCloneBuffer mKeyPathSerialization; - PRUint32 mKeyPathSerializationOffset; - nsTArray > mCreatedIndexes; }; diff --git a/dom/plugins/ipc/PPluginModule.ipdl b/dom/plugins/ipc/PPluginModule.ipdl index fbb6e722f4f0..30ca01417a9b 100644 --- a/dom/plugins/ipc/PPluginModule.ipdl +++ b/dom/plugins/ipc/PPluginModule.ipdl @@ -48,7 +48,6 @@ using NPNVariable; using base::FileDescriptor; using mozilla::plugins::NativeThreadId; using mac_plugin_interposing::NSCursorInfo; -using nsID; namespace mozilla { namespace plugins { @@ -106,11 +105,6 @@ child: rpc NPP_GetSitesWithData() 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: /** * This message is only used on X11 platforms. diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index 424c5523325e..a7d1e4d204ad 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -71,7 +71,6 @@ #ifdef XP_WIN #include "COMMessageFilter.h" #include "nsWindowsDllInterceptor.h" -#include "mozilla/widget/AudioSession.h" #endif #ifdef OS_MACOSX @@ -595,10 +594,6 @@ PluginModuleChild::AnswerNP_Shutdown(NPError *rv) { AssertPluginThread(); -#if defined XP_WIN && MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN - mozilla::widget::StopAudioSession(); -#endif - // the PluginModuleParent shuts down this process after this RPC // call pops off its stack @@ -654,25 +649,6 @@ PluginModuleChild::AnswerNPP_GetSitesWithData(InfallibleTArray* aResu 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 PluginModuleChild::QuickExit() { diff --git a/dom/plugins/ipc/PluginModuleChild.h b/dom/plugins/ipc/PluginModuleChild.h index 3ed2d35fbd17..559a168d44ea 100644 --- a/dom/plugins/ipc/PluginModuleChild.h +++ b/dom/plugins/ipc/PluginModuleChild.h @@ -163,11 +163,6 @@ protected: virtual bool AnswerNPP_GetSitesWithData(InfallibleTArray* aResult); - virtual bool - RecvSetAudioSessionData(const nsID& aId, - const nsString& aDisplayName, - const nsString& aIconPath); - virtual void ActorDestroy(ActorDestroyReason why); diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 5316eccbbc8c..c93c706f7c27 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -66,10 +66,6 @@ #include "nsNPAPIPlugin.h" #include "nsILocalFile.h" -#ifdef XP_WIN -#include "mozilla/widget/AudioSession.h" -#endif - using base::KillProcess; using mozilla::PluginLibrary; @@ -754,8 +750,6 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs { PLUGIN_LOG_DEBUG_METHOD; - nsresult rv; - mNPNIface = bFuncs; if (mShutdown) { @@ -790,18 +784,6 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) if (!CallNP_Initialize(&mPluginThread, error)) 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; } #endif diff --git a/js/src/configure.in b/js/src/configure.in index e8c03b1086e5..505581eb0128 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -2241,9 +2241,6 @@ ia64*-hpux*) CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)" # MSVC warnings C4244 and C4800 are ubiquitous, useless, and annoying. 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" MOZ_DEBUG_FLAGS='-Zi' MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV' diff --git a/modules/libpr0n/src/imgLoader.cpp b/modules/libpr0n/src/imgLoader.cpp index d5d7af7b03c6..363aa6b4d4a2 100644 --- a/modules/libpr0n/src/imgLoader.cpp +++ b/modules/libpr0n/src/imgLoader.cpp @@ -52,7 +52,6 @@ #include "nsCOMPtr.h" #include "nsNetUtil.h" -#include "nsStreamUtils.h" #include "nsIHttpChannel.h" #include "nsICachingChannel.h" #include "nsIInterfaceRequestor.h" @@ -2168,6 +2167,15 @@ NS_IMETHODIMP imgCacheValidator::OnStopRequest(nsIRequest *aRequest, nsISupports /** 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); */ NS_IMETHODIMP imgCacheValidator::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { @@ -2183,7 +2191,7 @@ NS_IMETHODIMP imgCacheValidator::OnDataAvailable(nsIRequest *aRequest, nsISuppor if (!mDestListener) { // XXX see bug 113959 PRUint32 _retval; - inStr->ReadSegments(NS_DiscardSegment, nsnull, count, &_retval); + inStr->ReadSegments(dispose_of_data, nsnull, count, &_retval); return NS_OK; } diff --git a/widget/src/windows/AudioSession.cpp b/widget/src/windows/AudioSession.cpp deleted file mode 100644 index 54120abd6406..000000000000 --- a/widget/src/windows/AudioSession.cpp +++ /dev/null @@ -1,461 +0,0 @@ -/* -*- 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 - * 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 -#include -#include - -#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 - -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 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 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(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 bundleService = - do_GetService(NS_STRINGBUNDLE_CONTRACTID); - NS_ENSURE_TRUE(bundleService, NS_ERROR_FAILURE); - - nsCOMPtr 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 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 enumerator; - hr = ::CoCreateInstance(CLSID_MMDeviceEnumerator, - NULL, - CLSCTX_ALL, - IID_IMMDeviceEnumerator, - getter_AddRefs(enumerator)); - if (FAILED(hr)) - return NS_ERROR_NOT_AVAILABLE; - - nsRefPtr 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 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 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 diff --git a/widget/src/windows/AudioSession.h b/widget/src/windows/AudioSession.h deleted file mode 100644 index f9245d0b48b4..000000000000 --- a/widget/src/windows/AudioSession.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- 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 - * 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 diff --git a/xpcom/base/nsTraceRefcntImpl.cpp b/xpcom/base/nsTraceRefcntImpl.cpp index dc063c84dd95..797fe21ba0cb 100644 --- a/xpcom/base/nsTraceRefcntImpl.cpp +++ b/xpcom/base/nsTraceRefcntImpl.cpp @@ -1286,26 +1286,6 @@ nsTraceRefcntImpl::Shutdown() PL_HashTableDestroy(gSerialNumbers); 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 } diff --git a/xpcom/ds/nsCRT.cpp b/xpcom/ds/nsCRT.cpp index eb90c2a59a2c..ca1f49997b5d 100644 --- a/xpcom/ds/nsCRT.cpp +++ b/xpcom/ds/nsCRT.cpp @@ -163,28 +163,6 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n) { 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) { PRUint32 len = nsCRT::strlen(str); diff --git a/xpcom/ds/nsCRT.h b/xpcom/ds/nsCRT.h index c9790b977b1c..f2ed31eab54a 100644 --- a/xpcom/ds/nsCRT.h +++ b/xpcom/ds/nsCRT.h @@ -210,12 +210,6 @@ public: static PRInt32 strncmp(const PRUnichar* s1, const PRUnichar* s2, 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 // by nsCRT::strdup(PRUnichar*). static PRUnichar* strdup(const PRUnichar* str);