Permalink
Browse files

Merge pull request #15 from mook/master

this stuff needs sbDebugUtils, which means changing how the logging works.
  • Loading branch information...
2 parents 91db739 + 225b95e commit dc4d097134f3fa34cadaa6713ed2bdba11b3176e @ilikenwf ilikenwf committed Dec 9, 2011
Showing with 30 additions and 42 deletions.
  1. +22 −21 components/property/src/sbPropertyArray.cpp
  2. +8 −21 components/property/src/sbPropertyManager.cpp
@@ -65,16 +65,17 @@ NS_IMPL_CI_INTERFACE_GETTER6(sbPropertyArray, nsIArray,
sbIMutablePropertyArray,
nsIClassInfo)
sbPropertyArray::sbPropertyArray()
-: mArrayLock(nsnull),
+: mArrayLock("sbPropertyArray::mArrayLock"),
mStrict(PR_TRUE)
-{}
+{
+}
//i think mutex does this automatically
nsresult
sbPropertyArray::Init()
{
- : mArrayLock("sbPropertyArray::mArrayLock");
+ return NS_OK;
}
/**
@@ -144,7 +145,7 @@ sbPropertyArray::GetLength(PRUint32* aLength)
{
NS_ENSURE_ARG_POINTER(aLength);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
*aLength = (PRUint32)mArray.Count();
return NS_OK;
}
@@ -160,7 +161,7 @@ sbPropertyArray::QueryElementAt(PRUint32 aIndex,
NS_ENSURE_ARG(aIndex < static_cast<PRUint32>(mArray.Count()));
NS_ENSURE_ARG_POINTER(_retval);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
nsCOMPtr<nsISupports> element = mArray.ObjectAt(aIndex);
NS_ENSURE_STATE(element);
@@ -191,7 +192,7 @@ sbPropertyArray::IndexOf(PRUint32 aStartIndex,
nsCOMPtr<sbIProperty> property = do_QueryInterface(aElement, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
PRInt32 index = mArray.IndexOf(property);
NS_ENSURE_TRUE(index >= 0, NS_ERROR_NOT_AVAILABLE);
@@ -212,7 +213,7 @@ sbPropertyArray::Enumerate(nsISimpleEnumerator** _retval)
do_CreateInstance("@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
NS_ENSURE_TRUE(array, NS_ERROR_OUT_OF_MEMORY);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
PRUint32 length = mArray.Count();
for (PRUint32 i = 0; i < length; i++) {
rv = array->AppendElement(mArray.ObjectAt(i), PR_FALSE);
@@ -238,7 +239,7 @@ sbPropertyArray::AppendElement(nsISupports* aElement,
nsCOMPtr<sbIProperty> property = do_QueryInterface(aElement, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
if (mStrict) {
PRBool valid;
@@ -262,7 +263,7 @@ sbPropertyArray::RemoveElementAt(PRUint32 aIndex)
{
NS_ENSURE_ARG(aIndex < static_cast<PRUint32>(mArray.Count()));
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
PRBool success = mArray.RemoveObjectAt(aIndex);
NS_ENSURE_STATE(success);
return NS_OK;
@@ -286,7 +287,7 @@ sbPropertyArray::InsertElementAt(nsISupports* aElement,
nsCOMPtr<sbIProperty> property = do_QueryInterface(aElement, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
if (mStrict) {
PRBool valid;
@@ -320,7 +321,7 @@ sbPropertyArray::ReplaceElementAt(nsISupports* aElement,
nsCOMPtr<sbIProperty> property = do_QueryInterface(aElement, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
if (mStrict) {
PRBool valid;
@@ -342,7 +343,7 @@ sbPropertyArray::ReplaceElementAt(nsISupports* aElement,
NS_IMETHODIMP
sbPropertyArray::Clear()
{
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
mArray.Clear();
return NS_OK;
}
@@ -356,7 +357,7 @@ sbPropertyArray::AppendProperty(const nsAString& aID,
{
NS_ENSURE_TRUE(!aID.IsEmpty(), NS_ERROR_INVALID_ARG);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
if (mStrict) {
PRBool valid;
@@ -387,7 +388,7 @@ sbPropertyArray::AppendProperties(sbIPropertyArray* aPropertyArray,
PRUint32 propertyCount;
nsresult rv;
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
// If skipping duplicates, create the list of IDs of properties already in
// array.
@@ -454,7 +455,7 @@ sbPropertyArray::AppendProperties(sbIPropertyArray* aPropertyArray,
NS_IMETHODIMP
sbPropertyArray::SetStrict(PRBool aStrict)
{
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
if ((aStrict != mStrict) && mArray.Count()) {
NS_WARNING("Can't change strict setting of a non-empty sbPropertyArray!");
@@ -482,7 +483,7 @@ sbPropertyArray::GetStrict(PRBool* aStrict)
{
NS_ENSURE_ARG_POINTER(aStrict);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
*aStrict = mStrict;
return NS_OK;
@@ -498,7 +499,7 @@ sbPropertyArray::GetPropertyAt(PRUint32 aIndex,
NS_ENSURE_ARG(aIndex < static_cast<PRUint32>(mArray.Count()));
NS_ENSURE_ARG_POINTER(_retval);
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
nsCOMPtr<sbIProperty> property = mArray.ObjectAt(aIndex);
NS_ENSURE_STATE(property);
@@ -515,7 +516,7 @@ sbPropertyArray::GetPropertyValue(const nsAString& aID,
{
nsresult rv;
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
PRUint32 length = mArray.Count();
for (PRUint32 i = 0; i < length; i++) {
nsCOMPtr<sbIProperty> property = mArray.ObjectAt(i);
@@ -543,7 +544,7 @@ sbPropertyArray::ToString(nsAString& _retval)
{
nsresult rv;
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
nsAutoString buff;
buff.AssignLiteral("[");
@@ -597,7 +598,7 @@ sbPropertyArray::Read(nsIObjectInputStream* aStream)
nsresult rv;
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
rv = aStream->ReadBoolean(&mStrict);
NS_ENSURE_SUCCESS(rv, rv);
@@ -634,7 +635,7 @@ sbPropertyArray::Write(nsIObjectOutputStream* aStream)
nsresult rv;
- nsAutoLock lock(mArrayLock);
+ mozilla::MutexAutoLock lock(mArrayLock);
rv = aStream->WriteBoolean(mStrict);
NS_ENSURE_SUCCESS(rv, rv);
@@ -58,6 +58,7 @@
#include "sbStoragePropertyUnitConverter.h"
#include "sbFrequencyPropertyUnitConverter.h"
#include "sbBitratePropertyUnitConverter.h"
+#include <sbDebugUtils.h>
#include <sbLockUtils.h>
#include <sbTArrayStringEnumerator.h>
#include <sbIPropertyBuilder.h>
@@ -70,16 +71,6 @@
* * To log this module, set the following environment variable:
* * NSPR_LOG_MODULES=sbPropMan:5
* */
-#include <prlog.h>
-#ifdef PR_LOGGING
-static PRLogModuleInfo* gPropManLog = nsnull;
-#endif
-
-#define LOG(args) PR_LOG(gPropManLog, PR_LOG_WARN, args)
-#ifdef __GNUC__
-#define __FUNCTION__ __PRETTY_FUNCTION__
-#endif
-
#if !defined(SB_STRING_BUNDLE_CHROME_URL)
#define SB_STRING_BUNDLE_CHROME_URL "chrome://songbird/locale/songbird.properties"
@@ -109,19 +100,15 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(sbPropertyManager,
sbPropertyManager::sbPropertyManager()
: mPropIDsLock(nsnull)
{
-#ifdef PR_LOGGING
- if (!gPropManLog) {
- gPropManLog = PR_NewLogModule("sbPropMan");
- }
-#endif
+ SB_PRLOG_SETUP(sbPropMan);
- //PRBool SB_UNUSED_IN_RELEASE(success) = mPropInfoHashtable.Init(100);
- //NS_ASSERTION(success,
- // "sbPropertyManager::mPropInfoHashtable failed to initialize!");
+ PRBool SB_UNUSED_IN_RELEASE(success) = mPropInfoHashtable.Init(100);
+ NS_ASSERTION(success,
+ "sbPropertyManager::mPropInfoHashtable failed to initialize!");
- //success = mPropDependencyMap.Init(100);
- //NS_ASSERTION(success,
- // "sbPropertyManager::mPropInfoHashtable failed to initialize!");
+ success = mPropDependencyMap.Init(100);
+ NS_ASSERTION(success,
+ "sbPropertyManager::mPropInfoHashtable failed to initialize!");
mPropIDsLock = PR_NewLock();
NS_ASSERTION(mPropIDsLock,

0 comments on commit dc4d097

Please sign in to comment.