bug 905410 - remove most remaining usage of nspr atomics outside of xpcom/ r=ehsan
This commit is contained in:
@@ -24,7 +24,6 @@
|
|||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsEventDispatcher.h"
|
#include "nsEventDispatcher.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "pratom.h"
|
|
||||||
|
|
||||||
#include "IDBEvents.h"
|
#include "IDBEvents.h"
|
||||||
#include "IDBFactory.h"
|
#include "IDBFactory.h"
|
||||||
@@ -46,8 +45,8 @@ namespace {
|
|||||||
|
|
||||||
mozilla::StaticRefPtr<IndexedDatabaseManager> gInstance;
|
mozilla::StaticRefPtr<IndexedDatabaseManager> gInstance;
|
||||||
|
|
||||||
int32_t gInitialized = 0;
|
mozilla::Atomic<int32_t> gInitialized(0);
|
||||||
int32_t gClosed = 0;
|
mozilla::Atomic<int32_t> gClosed(0);
|
||||||
|
|
||||||
class AsyncDeleteFileRunnable MOZ_FINAL : public nsIRunnable
|
class AsyncDeleteFileRunnable MOZ_FINAL : public nsIRunnable
|
||||||
{
|
{
|
||||||
@@ -141,7 +140,7 @@ IndexedDatabaseManager::~IndexedDatabaseManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IndexedDatabaseManager::sIsMainProcess = false;
|
bool IndexedDatabaseManager::sIsMainProcess = false;
|
||||||
int32_t IndexedDatabaseManager::sLowDiskSpaceMode = 0;
|
mozilla::Atomic<int32_t> IndexedDatabaseManager::sLowDiskSpaceMode(0);
|
||||||
|
|
||||||
// static
|
// static
|
||||||
IndexedDatabaseManager*
|
IndexedDatabaseManager*
|
||||||
@@ -180,7 +179,7 @@ IndexedDatabaseManager::GetOrCreate()
|
|||||||
nsresult rv = instance->Init();
|
nsresult rv = instance->Init();
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
|
|
||||||
if (PR_ATOMIC_SET(&gInitialized, 1)) {
|
if (gInitialized.exchange(1)) {
|
||||||
NS_ERROR("Initialized more than once?!");
|
NS_ERROR("Initialized more than once?!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +243,7 @@ IndexedDatabaseManager::Destroy()
|
|||||||
{
|
{
|
||||||
// Setting the closed flag prevents the service from being recreated.
|
// Setting the closed flag prevents the service from being recreated.
|
||||||
// Don't set it though if there's no real instance created.
|
// Don't set it though if there's no real instance created.
|
||||||
if (!!gInitialized && PR_ATOMIC_SET(&gClosed, 1)) {
|
if (!!gInitialized && gClosed.exchange(1)) {
|
||||||
NS_ERROR("Shutdown more than once?!");
|
NS_ERROR("Shutdown more than once?!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,10 +588,10 @@ IndexedDatabaseManager::Observe(nsISupports* aSubject, const char* aTopic,
|
|||||||
const nsDependentString data(aData);
|
const nsDependentString data(aData);
|
||||||
|
|
||||||
if (data.EqualsLiteral(LOW_DISK_SPACE_DATA_FULL)) {
|
if (data.EqualsLiteral(LOW_DISK_SPACE_DATA_FULL)) {
|
||||||
PR_ATOMIC_SET(&sLowDiskSpaceMode, 1);
|
sLowDiskSpaceMode = 1;
|
||||||
}
|
}
|
||||||
else if (data.EqualsLiteral(LOW_DISK_SPACE_DATA_FREE)) {
|
else if (data.EqualsLiteral(LOW_DISK_SPACE_DATA_FREE)) {
|
||||||
PR_ATOMIC_SET(&sLowDiskSpaceMode, 0);
|
sLowDiskSpaceMode = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NS_NOTREACHED("Unknown data value!");
|
NS_NOTREACHED("Unknown data value!");
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "nsIIndexedDatabaseManager.h"
|
#include "nsIIndexedDatabaseManager.h"
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
|
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
#include "nsClassHashtable.h"
|
#include "nsClassHashtable.h"
|
||||||
#include "nsHashKeys.h"
|
#include "nsHashKeys.h"
|
||||||
@@ -146,7 +147,7 @@ private:
|
|||||||
mozilla::Mutex mFileMutex;
|
mozilla::Mutex mFileMutex;
|
||||||
|
|
||||||
static bool sIsMainProcess;
|
static bool sIsMainProcess;
|
||||||
static int32_t sLowDiskSpaceMode;
|
static mozilla::Atomic<int32_t> sLowDiskSpaceMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
END_INDEXEDDB_NAMESPACE
|
END_INDEXEDDB_NAMESPACE
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "GeckoProfiler.h"
|
#include "GeckoProfiler.h"
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/dom/file/FileService.h"
|
#include "mozilla/dom/file/FileService.h"
|
||||||
#include "mozilla/dom/indexedDB/Client.h"
|
#include "mozilla/dom/indexedDB/Client.h"
|
||||||
#include "mozilla/LazyIdleThread.h"
|
#include "mozilla/LazyIdleThread.h"
|
||||||
@@ -36,7 +37,6 @@
|
|||||||
#include "nsScriptSecurityManager.h"
|
#include "nsScriptSecurityManager.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
#include "pratom.h"
|
|
||||||
#include "xpcpublic.h"
|
#include "xpcpublic.h"
|
||||||
|
|
||||||
#include "AcquireListener.h"
|
#include "AcquireListener.h"
|
||||||
@@ -260,7 +260,7 @@ END_QUOTA_NAMESPACE
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
QuotaManager* gInstance = nullptr;
|
QuotaManager* gInstance = nullptr;
|
||||||
int32_t gShutdown = 0;
|
mozilla::Atomic<uint32_t> gShutdown(0);
|
||||||
|
|
||||||
int32_t gStorageQuotaMB = DEFAULT_QUOTA_MB;
|
int32_t gStorageQuotaMB = DEFAULT_QUOTA_MB;
|
||||||
|
|
||||||
@@ -1200,7 +1200,7 @@ QuotaManager::Observe(nsISupports* aSubject,
|
|||||||
if (!strcmp(aTopic, PROFILE_BEFORE_CHANGE_OBSERVER_ID)) {
|
if (!strcmp(aTopic, PROFILE_BEFORE_CHANGE_OBSERVER_ID)) {
|
||||||
// Setting this flag prevents the service from being recreated and prevents
|
// Setting this flag prevents the service from being recreated and prevents
|
||||||
// further storagess from being created.
|
// further storagess from being created.
|
||||||
if (PR_ATOMIC_SET(&gShutdown, 1)) {
|
if (gShutdown.exchange(1)) {
|
||||||
NS_ERROR("Shutdown more than once?!");
|
NS_ERROR("Shutdown more than once?!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2171,7 +2171,7 @@ AsyncUsageRunnable::Run()
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
AsyncUsageRunnable::Cancel()
|
AsyncUsageRunnable::Cancel()
|
||||||
{
|
{
|
||||||
if (PR_ATOMIC_SET(&mCanceled, 1)) {
|
if (mCanceled.exchange(1)) {
|
||||||
NS_WARNING("Canceled more than once?!");
|
NS_WARNING("Canceled more than once?!");
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||||
|
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
|
||||||
BEGIN_QUOTA_NAMESPACE
|
BEGIN_QUOTA_NAMESPACE
|
||||||
@@ -69,7 +70,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int32_t mCanceled;
|
mozilla::Atomic<int32_t> mCanceled;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t mDatabaseUsage;
|
uint64_t mDatabaseUsage;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ using mozilla::gfx::SourceSurface;
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace layers {
|
namespace layers {
|
||||||
|
|
||||||
int32_t Image::sSerialCounter = 0;
|
Atomic<int32_t> Image::sSerialCounter(0);
|
||||||
|
|
||||||
already_AddRefed<Image>
|
already_AddRefed<Image>
|
||||||
ImageFactory::CreateImage(const ImageFormat *aFormats,
|
ImageFactory::CreateImage(const ImageFormat *aFormats,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#ifndef GFX_IMAGECONTAINER_H
|
#ifndef GFX_IMAGECONTAINER_H
|
||||||
#define GFX_IMAGECONTAINER_H
|
#define GFX_IMAGECONTAINER_H
|
||||||
|
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
#include "mozilla/ReentrantMonitor.h"
|
#include "mozilla/ReentrantMonitor.h"
|
||||||
#include "gfxASurface.h" // for gfxImageFormat
|
#include "gfxASurface.h" // for gfxImageFormat
|
||||||
@@ -13,7 +14,6 @@
|
|||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "ImageTypes.h"
|
#include "ImageTypes.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "pratom.h"
|
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
struct ID3D10Texture2D;
|
struct ID3D10Texture2D;
|
||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
Image(void* aImplData, ImageFormat aFormat) :
|
Image(void* aImplData, ImageFormat aFormat) :
|
||||||
mImplData(aImplData),
|
mImplData(aImplData),
|
||||||
mSerial(PR_ATOMIC_INCREMENT(&sSerialCounter)),
|
mSerial(++sSerialCounter),
|
||||||
mFormat(aFormat),
|
mFormat(aFormat),
|
||||||
mSent(false)
|
mSent(false)
|
||||||
{}
|
{}
|
||||||
@@ -113,7 +113,7 @@ protected:
|
|||||||
void* mImplData;
|
void* mImplData;
|
||||||
int32_t mSerial;
|
int32_t mSerial;
|
||||||
ImageFormat mFormat;
|
ImageFormat mFormat;
|
||||||
static int32_t sSerialCounter;
|
static mozilla::Atomic<int32_t> sSerialCounter;
|
||||||
bool mSent;
|
bool mSent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "RasterImage.h"
|
#include "RasterImage.h"
|
||||||
#include "DiscardTracker.h"
|
#include "DiscardTracker.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "pratom.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace image {
|
namespace image {
|
||||||
@@ -19,7 +18,7 @@ static const char* sDiscardTimeoutPref = "image.mem.min_discard_timeout_ms";
|
|||||||
/* static */ nsCOMPtr<nsITimer> DiscardTracker::sTimer;
|
/* static */ nsCOMPtr<nsITimer> DiscardTracker::sTimer;
|
||||||
/* static */ bool DiscardTracker::sInitialized = false;
|
/* static */ bool DiscardTracker::sInitialized = false;
|
||||||
/* static */ bool DiscardTracker::sTimerOn = false;
|
/* static */ bool DiscardTracker::sTimerOn = false;
|
||||||
/* static */ int32_t DiscardTracker::sDiscardRunnablePending = 0;
|
/* static */ Atomic<int32_t> DiscardTracker::sDiscardRunnablePending(0);
|
||||||
/* static */ int64_t DiscardTracker::sCurrentDecodedImageBytes = 0;
|
/* static */ int64_t DiscardTracker::sCurrentDecodedImageBytes = 0;
|
||||||
/* static */ uint32_t DiscardTracker::sMinDiscardTimeoutMs = 10000;
|
/* static */ uint32_t DiscardTracker::sMinDiscardTimeoutMs = 10000;
|
||||||
/* static */ uint32_t DiscardTracker::sMaxDecodedImageKB = 42 * 1024;
|
/* static */ uint32_t DiscardTracker::sMaxDecodedImageKB = 42 * 1024;
|
||||||
@@ -32,7 +31,7 @@ static const char* sDiscardTimeoutPref = "image.mem.min_discard_timeout_ms";
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DiscardTracker::DiscardRunnable::Run()
|
DiscardTracker::DiscardRunnable::Run()
|
||||||
{
|
{
|
||||||
PR_ATOMIC_SET(&sDiscardRunnablePending, 0);
|
sDiscardRunnablePending = 0;
|
||||||
|
|
||||||
DiscardTracker::DiscardNow();
|
DiscardTracker::DiscardNow();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@@ -294,7 +293,7 @@ DiscardTracker::MaybeDiscardSoon()
|
|||||||
if (sCurrentDecodedImageBytes > sMaxDecodedImageKB * 1024 &&
|
if (sCurrentDecodedImageBytes > sMaxDecodedImageKB * 1024 &&
|
||||||
!sDiscardableImages.isEmpty()) {
|
!sDiscardableImages.isEmpty()) {
|
||||||
// Check if the value of sDiscardRunnablePending used to be false
|
// Check if the value of sDiscardRunnablePending used to be false
|
||||||
if (!PR_ATOMIC_SET(&sDiscardRunnablePending, 1)) {
|
if (!sDiscardRunnablePending.exchange(1)) {
|
||||||
nsRefPtr<DiscardRunnable> runnable = new DiscardRunnable();
|
nsRefPtr<DiscardRunnable> runnable = new DiscardRunnable();
|
||||||
NS_DispatchToMainThread(runnable);
|
NS_DispatchToMainThread(runnable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#ifndef mozilla_imagelib_DiscardTracker_h_
|
#ifndef mozilla_imagelib_DiscardTracker_h_
|
||||||
#define mozilla_imagelib_DiscardTracker_h_
|
#define mozilla_imagelib_DiscardTracker_h_
|
||||||
|
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/LinkedList.h"
|
#include "mozilla/LinkedList.h"
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "prlock.h"
|
#include "prlock.h"
|
||||||
@@ -111,7 +112,7 @@ class DiscardTracker
|
|||||||
static nsCOMPtr<nsITimer> sTimer;
|
static nsCOMPtr<nsITimer> sTimer;
|
||||||
static bool sInitialized;
|
static bool sInitialized;
|
||||||
static bool sTimerOn;
|
static bool sTimerOn;
|
||||||
static int32_t sDiscardRunnablePending;
|
static mozilla::Atomic<int32_t> sDiscardRunnablePending;
|
||||||
static int64_t sCurrentDecodedImageBytes;
|
static int64_t sCurrentDecodedImageBytes;
|
||||||
static uint32_t sMinDiscardTimeoutMs;
|
static uint32_t sMinDiscardTimeoutMs;
|
||||||
static uint32_t sMaxDecodedImageKB;
|
static uint32_t sMaxDecodedImageKB;
|
||||||
|
|||||||
@@ -13,9 +13,6 @@
|
|||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
#include "nsCharsetAlias.h"
|
#include "nsCharsetAlias.h"
|
||||||
#include "pratom.h"
|
|
||||||
|
|
||||||
static int32_t gInstanceCount = 0;
|
|
||||||
|
|
||||||
/* Implementation file */
|
/* Implementation file */
|
||||||
NS_IMPL_ISUPPORTS1(nsScriptableUnicodeConverter, nsIScriptableUnicodeConverter)
|
NS_IMPL_ISUPPORTS1(nsScriptableUnicodeConverter, nsIScriptableUnicodeConverter)
|
||||||
@@ -23,12 +20,10 @@ NS_IMPL_ISUPPORTS1(nsScriptableUnicodeConverter, nsIScriptableUnicodeConverter)
|
|||||||
nsScriptableUnicodeConverter::nsScriptableUnicodeConverter()
|
nsScriptableUnicodeConverter::nsScriptableUnicodeConverter()
|
||||||
: mIsInternal(false)
|
: mIsInternal(false)
|
||||||
{
|
{
|
||||||
PR_ATOMIC_INCREMENT(&gInstanceCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsScriptableUnicodeConverter::~nsScriptableUnicodeConverter()
|
nsScriptableUnicodeConverter::~nsScriptableUnicodeConverter()
|
||||||
{
|
{
|
||||||
PR_ATOMIC_DECREMENT(&gInstanceCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/lazy_instance.h"
|
#include "base/lazy_instance.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
@@ -32,7 +33,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "MessagePump.h"
|
#include "MessagePump.h"
|
||||||
#include "pratom.h"
|
|
||||||
|
|
||||||
using base::Time;
|
using base::Time;
|
||||||
using base::TimeDelta;
|
using base::TimeDelta;
|
||||||
@@ -87,11 +87,11 @@ MessageLoop* MessageLoop::current() {
|
|||||||
return lazy_tls_ptr.Pointer()->Get();
|
return lazy_tls_ptr.Pointer()->Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t message_loop_id_seq = 0;
|
static mozilla::Atomic<int32_t> message_loop_id_seq(0);
|
||||||
|
|
||||||
MessageLoop::MessageLoop(Type type)
|
MessageLoop::MessageLoop(Type type)
|
||||||
: type_(type),
|
: type_(type),
|
||||||
id_(PR_ATOMIC_INCREMENT(&message_loop_id_seq)),
|
id_(++message_loop_id_seq),
|
||||||
nestable_tasks_allowed_(true),
|
nestable_tasks_allowed_(true),
|
||||||
exception_restoration_(false),
|
exception_restoration_(false),
|
||||||
state_(NULL),
|
state_(NULL),
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "pratom.h"
|
|
||||||
#include "prlog.h"
|
#include "prlog.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "netCore.h"
|
#include "netCore.h"
|
||||||
@@ -23,6 +22,7 @@
|
|||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "nsIHttpChannelInternal.h"
|
#include "nsIHttpChannelInternal.h"
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
#include "mozilla/net/PSpdyPush3.h"
|
#include "mozilla/net/PSpdyPush3.h"
|
||||||
@@ -1056,7 +1056,7 @@ public:
|
|||||||
|
|
||||||
nsLoadGroupConnectionInfo();
|
nsLoadGroupConnectionInfo();
|
||||||
private:
|
private:
|
||||||
int32_t mBlockingTransactionCount; // signed for PR_ATOMIC_*
|
Atomic<uint32_t> mBlockingTransactionCount;
|
||||||
nsAutoPtr<mozilla::net::SpdyPushCache3> mSpdyCache3;
|
nsAutoPtr<mozilla::net::SpdyPushCache3> mSpdyCache3;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1071,14 +1071,14 @@ NS_IMETHODIMP
|
|||||||
nsLoadGroupConnectionInfo::GetBlockingTransactionCount(uint32_t *aBlockingTransactionCount)
|
nsLoadGroupConnectionInfo::GetBlockingTransactionCount(uint32_t *aBlockingTransactionCount)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aBlockingTransactionCount);
|
NS_ENSURE_ARG_POINTER(aBlockingTransactionCount);
|
||||||
*aBlockingTransactionCount = static_cast<uint32_t>(mBlockingTransactionCount);
|
*aBlockingTransactionCount = mBlockingTransactionCount;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLoadGroupConnectionInfo::AddBlockingTransaction()
|
nsLoadGroupConnectionInfo::AddBlockingTransaction()
|
||||||
{
|
{
|
||||||
PR_ATOMIC_INCREMENT(&mBlockingTransactionCount);
|
mBlockingTransactionCount++;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1086,8 +1086,8 @@ NS_IMETHODIMP
|
|||||||
nsLoadGroupConnectionInfo::RemoveBlockingTransaction(uint32_t *_retval)
|
nsLoadGroupConnectionInfo::RemoveBlockingTransaction(uint32_t *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
NS_ENSURE_ARG_POINTER(_retval);
|
||||||
*_retval =
|
mBlockingTransactionCount--;
|
||||||
static_cast<uint32_t>(PR_ATOMIC_DECREMENT(&mBlockingTransactionCount));
|
*_retval = mBlockingTransactionCount;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,12 @@
|
|||||||
#include "nsAlgorithm.h"
|
#include "nsAlgorithm.h"
|
||||||
#include "nsProxyRelease.h"
|
#include "nsProxyRelease.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "TimeStamp.h"
|
#include "TimeStamp.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
|
|
||||||
#include "plbase64.h"
|
#include "plbase64.h"
|
||||||
#include "pratom.h"
|
|
||||||
#include "prmem.h"
|
#include "prmem.h"
|
||||||
#include "prnetdb.h"
|
#include "prnetdb.h"
|
||||||
#include "prbit.h"
|
#include "prbit.h"
|
||||||
@@ -424,12 +424,12 @@ public:
|
|||||||
|
|
||||||
void IncrementSessionCount()
|
void IncrementSessionCount()
|
||||||
{
|
{
|
||||||
PR_ATOMIC_INCREMENT(&mSessionCount);
|
mSessionCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecrementSessionCount()
|
void DecrementSessionCount()
|
||||||
{
|
{
|
||||||
PR_ATOMIC_DECREMENT(&mSessionCount);
|
mSessionCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SessionCount()
|
int32_t SessionCount()
|
||||||
@@ -468,7 +468,7 @@ private:
|
|||||||
|
|
||||||
// SessionCount might be decremented from the main or the socket
|
// SessionCount might be decremented from the main or the socket
|
||||||
// thread, so manage it with atomic counters
|
// thread, so manage it with atomic counters
|
||||||
int32_t mSessionCount;
|
Atomic<int32_t> mSessionCount;
|
||||||
|
|
||||||
// Queue for websockets that have not completed connecting yet.
|
// Queue for websockets that have not completed connecting yet.
|
||||||
// The first nsOpenConn with a given address will be either be
|
// The first nsOpenConn with a given address will be either be
|
||||||
|
|||||||
@@ -100,17 +100,17 @@ static PLDHashTableOps gMapOps = {
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
class nsAutoAtomic {
|
class nsAutoAtomic {
|
||||||
public:
|
public:
|
||||||
nsAutoAtomic(int32_t &i)
|
nsAutoAtomic(Atomic<int32_t> &i)
|
||||||
:mI(i) {
|
:mI(i) {
|
||||||
PR_ATOMIC_INCREMENT(&mI);
|
mI++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~nsAutoAtomic() {
|
~nsAutoAtomic() {
|
||||||
PR_ATOMIC_DECREMENT(&mI);
|
mI--;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int32_t &mI;
|
Atomic<int32_t> &mI;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsAutoAtomic(); // not accessible
|
nsAutoAtomic(); // not accessible
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
#ifndef nsSecureBrowserUIImpl_h_
|
#ifndef nsSecureBrowserUIImpl_h_
|
||||||
#define nsSecureBrowserUIImpl_h_
|
#define nsSecureBrowserUIImpl_h_
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
|
#endif
|
||||||
#include "mozilla/ReentrantMonitor.h"
|
#include "mozilla/ReentrantMonitor.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
@@ -93,7 +96,7 @@ protected:
|
|||||||
bool mOnLocationChangeSeen;
|
bool mOnLocationChangeSeen;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* related to mReentrantMonitor */
|
/* related to mReentrantMonitor */
|
||||||
int32_t mOnStateLocationChangeReentranceDetection;
|
mozilla::Atomic<int32_t> mOnStateLocationChangeReentranceDetection;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static already_AddRefed<nsISupports> ExtractSecurityInfo(nsIRequest* aRequest);
|
static already_AddRefed<nsISupports> ExtractSecurityInfo(nsIRequest* aRequest);
|
||||||
|
|||||||
@@ -18,15 +18,17 @@
|
|||||||
#include "PublicSSL.h"
|
#include "PublicSSL.h"
|
||||||
#include "ssl.h"
|
#include "ssl.h"
|
||||||
#include "nsNetCID.h"
|
#include "nsNetCID.h"
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/unused.h"
|
#include "mozilla/unused.h"
|
||||||
|
|
||||||
using mozilla::psm::SyncRunnableBase;
|
using mozilla::psm::SyncRunnableBase;
|
||||||
|
using mozilla::Atomic;
|
||||||
using mozilla::unused;
|
using mozilla::unused;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static int32_t sCertOverrideSvcExists = 0;
|
static Atomic<int32_t> sCertOverrideSvcExists(0);
|
||||||
static int32_t sCertDBExists = 0;
|
static Atomic<int32_t> sCertDBExists(0);
|
||||||
|
|
||||||
class MainThreadClearer : public SyncRunnableBase
|
class MainThreadClearer : public SyncRunnableBase
|
||||||
{
|
{
|
||||||
@@ -38,9 +40,9 @@ public:
|
|||||||
// is in progress. We want to avoid this, since they do not handle the situation well,
|
// is in progress. We want to avoid this, since they do not handle the situation well,
|
||||||
// hence the flags to avoid instantiating the services if they don't already exist.
|
// hence the flags to avoid instantiating the services if they don't already exist.
|
||||||
|
|
||||||
bool certOverrideSvcExists = (bool)PR_ATOMIC_SET(&sCertOverrideSvcExists, 0);
|
bool certOverrideSvcExists = (bool)sCertOverrideSvcExists.exchange(0);
|
||||||
if (certOverrideSvcExists) {
|
if (certOverrideSvcExists) {
|
||||||
unused << PR_ATOMIC_SET(&sCertOverrideSvcExists, 1);
|
sCertOverrideSvcExists = 1;
|
||||||
nsCOMPtr<nsICertOverrideService> icos = do_GetService(NS_CERTOVERRIDE_CONTRACTID);
|
nsCOMPtr<nsICertOverrideService> icos = do_GetService(NS_CERTOVERRIDE_CONTRACTID);
|
||||||
if (icos) {
|
if (icos) {
|
||||||
icos->ClearValidityOverride(
|
icos->ClearValidityOverride(
|
||||||
@@ -49,9 +51,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool certDBExists = (bool)PR_ATOMIC_SET(&sCertDBExists, 0);
|
bool certDBExists = (bool)sCertDBExists.exchange(0);
|
||||||
if (certDBExists) {
|
if (certDBExists) {
|
||||||
unused << PR_ATOMIC_SET(&sCertDBExists, 1);
|
sCertDBExists = 1;
|
||||||
nsCOMPtr<nsIX509CertDB> certdb = do_GetService(NS_X509CERTDB_CONTRACTID);
|
nsCOMPtr<nsIX509CertDB> certdb = do_GetService(NS_X509CERTDB_CONTRACTID);
|
||||||
if (certdb) {
|
if (certdb) {
|
||||||
nsCOMPtr<nsIRecentBadCerts> badCerts;
|
nsCOMPtr<nsIRecentBadCerts> badCerts;
|
||||||
@@ -204,13 +206,13 @@ SharedSSLState::GlobalCleanup()
|
|||||||
/*static*/ void
|
/*static*/ void
|
||||||
SharedSSLState::NoteCertOverrideServiceInstantiated()
|
SharedSSLState::NoteCertOverrideServiceInstantiated()
|
||||||
{
|
{
|
||||||
unused << PR_ATOMIC_SET(&sCertOverrideSvcExists, 1);
|
sCertOverrideSvcExists = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ void
|
/*static*/ void
|
||||||
SharedSSLState::NoteCertDBServiceInstantiated()
|
SharedSSLState::NoteCertDBServiceInstantiated()
|
||||||
{
|
{
|
||||||
unused << PR_ATOMIC_SET(&sCertDBExists, 1);
|
sCertDBExists = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -30,11 +30,11 @@
|
|||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsXPCOMStrings.h"
|
#include "nsXPCOMStrings.h"
|
||||||
#include "nsProxyRelease.h"
|
#include "nsProxyRelease.h"
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/DebugOnly.h"
|
#include "mozilla/DebugOnly.h"
|
||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
#include "pratom.h"
|
|
||||||
#include "prlog.h"
|
#include "prlog.h"
|
||||||
#include "prprf.h"
|
#include "prprf.h"
|
||||||
#include "prnetdb.h"
|
#include "prnetdb.h"
|
||||||
@@ -84,7 +84,7 @@ nsIThread* nsUrlClassifierDBService::gDbBackgroundThread = nullptr;
|
|||||||
// thread.
|
// thread.
|
||||||
static bool gShuttingDownThread = false;
|
static bool gShuttingDownThread = false;
|
||||||
|
|
||||||
static int32_t gFreshnessGuarantee = CONFIRM_AGE_DEFAULT_SEC;
|
static mozilla::Atomic<int32_t> gFreshnessGuarantee(CONFIRM_AGE_DEFAULT_SEC);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SplitTables(const nsACString& str, nsTArray<nsCString>& tables)
|
SplitTables(const nsACString& str, nsTArray<nsCString>& tables)
|
||||||
@@ -1143,7 +1143,7 @@ nsUrlClassifierDBService::Init()
|
|||||||
prefs->AddObserver(GETHASH_TABLES_PREF, this, false);
|
prefs->AddObserver(GETHASH_TABLES_PREF, this, false);
|
||||||
|
|
||||||
rv = prefs->GetIntPref(CONFIRM_AGE_PREF, &tmpint);
|
rv = prefs->GetIntPref(CONFIRM_AGE_PREF, &tmpint);
|
||||||
PR_ATOMIC_SET(&gFreshnessGuarantee, NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC);
|
gFreshnessGuarantee = NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC;
|
||||||
|
|
||||||
prefs->AddObserver(CONFIRM_AGE_PREF, this, false);
|
prefs->AddObserver(CONFIRM_AGE_PREF, this, false);
|
||||||
}
|
}
|
||||||
@@ -1460,7 +1460,7 @@ nsUrlClassifierDBService::Observe(nsISupports *aSubject, const char *aTopic,
|
|||||||
} else if (NS_LITERAL_STRING(CONFIRM_AGE_PREF).Equals(aData)) {
|
} else if (NS_LITERAL_STRING(CONFIRM_AGE_PREF).Equals(aData)) {
|
||||||
int32_t tmpint;
|
int32_t tmpint;
|
||||||
rv = prefs->GetIntPref(CONFIRM_AGE_PREF, &tmpint);
|
rv = prefs->GetIntPref(CONFIRM_AGE_PREF, &tmpint);
|
||||||
PR_ATOMIC_SET(&gFreshnessGuarantee, NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC);
|
gFreshnessGuarantee = NS_SUCCEEDED(rv) ? tmpint : CONFIRM_AGE_DEFAULT_SEC;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(aTopic, "profile-before-change") ||
|
} else if (!strcmp(aTopic, "profile-before-change") ||
|
||||||
!strcmp(aTopic, "xpcom-shutdown-threads")) {
|
!strcmp(aTopic, "xpcom-shutdown-threads")) {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "pratom.h"
|
|
||||||
#include "mozilla/Services.h"
|
#include "mozilla/Services.h"
|
||||||
|
|
||||||
// When processing the next thread event, the appshell may process native
|
// When processing the next thread event, the appshell may process native
|
||||||
@@ -62,8 +61,7 @@ nsBaseAppShell::Init()
|
|||||||
void
|
void
|
||||||
nsBaseAppShell::NativeEventCallback()
|
nsBaseAppShell::NativeEventCallback()
|
||||||
{
|
{
|
||||||
int32_t hasPending = PR_ATOMIC_SET(&mNativeEventPending, 0);
|
if (!mNativeEventPending.exchange(0))
|
||||||
if (hasPending == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If DoProcessNextNativeEvent is on the stack, then we assume that we can
|
// If DoProcessNextNativeEvent is on the stack, then we assume that we can
|
||||||
@@ -227,8 +225,7 @@ nsBaseAppShell::OnDispatchedEvent(nsIThreadInternal *thr)
|
|||||||
if (mBlockNativeEvent)
|
if (mBlockNativeEvent)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
int32_t lastVal = PR_ATOMIC_SET(&mNativeEventPending, 1);
|
if (mNativeEventPending.exchange(1))
|
||||||
if (lastVal == 1)
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
// Returns on the main thread in NativeEventCallback above
|
// Returns on the main thread in NativeEventCallback above
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#ifndef nsBaseAppShell_h__
|
#ifndef nsBaseAppShell_h__
|
||||||
#define nsBaseAppShell_h__
|
#define nsBaseAppShell_h__
|
||||||
|
|
||||||
|
#include "mozilla/Atomics.h"
|
||||||
#include "nsIAppShell.h"
|
#include "nsIAppShell.h"
|
||||||
#include "nsIThreadInternal.h"
|
#include "nsIThreadInternal.h"
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
@@ -119,7 +120,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool *mBlockedWait;
|
bool *mBlockedWait;
|
||||||
int32_t mFavorPerf;
|
int32_t mFavorPerf;
|
||||||
int32_t mNativeEventPending;
|
mozilla::Atomic<uint32_t> mNativeEventPending;
|
||||||
PRIntervalTime mStarvationDelay;
|
PRIntervalTime mStarvationDelay;
|
||||||
PRIntervalTime mSwitchTime;
|
PRIntervalTime mSwitchTime;
|
||||||
PRIntervalTime mLastNativeEventTime;
|
PRIntervalTime mLastNativeEventTime;
|
||||||
|
|||||||
Reference in New Issue
Block a user