Bug 969165 - Convert Atomic<T> where T != bool but is used as a bool over to Atomic<bool>, now that it's supported, in dom/. r=bent

--HG--
extra : rebase_source : 7cf60c3e3091328ab8590dde4432fa566c303232
This commit is contained in:
Jeff Walden 2014-02-06 22:17:07 -08:00
parent 2e98cbd7d0
commit f356b9014d
5 changed files with 19 additions and 19 deletions

View File

@ -107,8 +107,8 @@ namespace {
mozilla::StaticRefPtr<IndexedDatabaseManager> gDBManager;
mozilla::Atomic<int32_t> gInitialized(0);
mozilla::Atomic<int32_t> gClosed(0);
mozilla::Atomic<bool> gInitialized(false);
mozilla::Atomic<bool> gClosed(false);
class AsyncDeleteFileRunnable MOZ_FINAL : public nsIRunnable
{
@ -191,7 +191,7 @@ IndexedDatabaseManager::~IndexedDatabaseManager()
}
bool IndexedDatabaseManager::sIsMainProcess = false;
mozilla::Atomic<int32_t> IndexedDatabaseManager::sLowDiskSpaceMode(0);
mozilla::Atomic<bool> IndexedDatabaseManager::sLowDiskSpaceMode(false);
// static
IndexedDatabaseManager*
@ -214,7 +214,7 @@ IndexedDatabaseManager::GetOrCreate()
if (watcher) {
bool isDiskFull;
if (NS_SUCCEEDED(watcher->GetIsDiskFull(&isDiskFull))) {
sLowDiskSpaceMode = isDiskFull ? 1 : 0;
sLowDiskSpaceMode = isDiskFull;
}
else {
NS_WARNING("GetIsDiskFull failed!");
@ -230,7 +230,7 @@ IndexedDatabaseManager::GetOrCreate()
nsresult rv = instance->Init();
NS_ENSURE_SUCCESS(rv, nullptr);
if (gInitialized.exchange(1)) {
if (gInitialized.exchange(true)) {
NS_ERROR("Initialized more than once?!");
}
@ -294,7 +294,7 @@ IndexedDatabaseManager::Destroy()
{
// Setting the closed flag prevents the service from being recreated.
// Don't set it though if there's no real instance created.
if (!!gInitialized && gClosed.exchange(1)) {
if (gInitialized && gClosed.exchange(true)) {
NS_ERROR("Shutdown more than once?!");
}
@ -450,7 +450,7 @@ IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx,
bool
IndexedDatabaseManager::IsClosed()
{
return !!gClosed;
return gClosed;
}
#ifdef DEBUG
@ -472,7 +472,7 @@ IndexedDatabaseManager::InLowDiskSpaceMode()
NS_ASSERTION(gDBManager,
"InLowDiskSpaceMode() called before indexedDB has been "
"initialized!");
return !!sLowDiskSpaceMode;
return sLowDiskSpaceMode;
}
#endif
@ -686,10 +686,10 @@ IndexedDatabaseManager::Observe(nsISupports* aSubject, const char* aTopic,
const nsDependentString data(aData);
if (data.EqualsLiteral(LOW_DISK_SPACE_DATA_FULL)) {
sLowDiskSpaceMode = 1;
sLowDiskSpaceMode = true;
}
else if (data.EqualsLiteral(LOW_DISK_SPACE_DATA_FREE)) {
sLowDiskSpaceMode = 0;
sLowDiskSpaceMode = false;
}
else {
NS_NOTREACHED("Unknown data value!");

View File

@ -166,7 +166,7 @@ private:
mozilla::Mutex mFileMutex;
static bool sIsMainProcess;
static mozilla::Atomic<int32_t> sLowDiskSpaceMode;
static mozilla::Atomic<bool> sLowDiskSpaceMode;
};
END_INDEXEDDB_NAMESPACE

View File

@ -494,7 +494,7 @@ static const float kDefaultSmartLimitRatio = .4f;
#endif
QuotaManager* gInstance = nullptr;
mozilla::Atomic<uint32_t> gShutdown(0);
mozilla::Atomic<bool> gShutdown(false);
int32_t gStorageQuotaMB = kDefaultQuotaMB;
@ -1000,7 +1000,7 @@ QuotaManager::FactoryCreate()
bool
QuotaManager::IsShuttingDown()
{
return !!gShutdown;
return gShutdown;
}
nsresult
@ -2383,7 +2383,7 @@ QuotaManager::Observe(nsISupports* aSubject,
if (!strcmp(aTopic, PROFILE_BEFORE_CHANGE_OBSERVER_ID)) {
// Setting this flag prevents the service from being recreated and prevents
// further storagess from being created.
if (gShutdown.exchange(1)) {
if (gShutdown.exchange(true)) {
NS_ERROR("Shutdown more than once?!");
}
@ -3780,7 +3780,7 @@ AsyncUsageRunnable::Run()
NS_IMETHODIMP
AsyncUsageRunnable::Cancel()
{
if (mCanceled.exchange(1)) {
if (mCanceled.exchange(true)) {
NS_WARNING("Canceled more than once?!");
return NS_ERROR_UNEXPECTED;
}

View File

@ -18,7 +18,7 @@ class UsageInfo
{
public:
UsageInfo()
: mCanceled(0), mDatabaseUsage(0), mFileUsage(0)
: mCanceled(false), mDatabaseUsage(0), mFileUsage(0)
{ }
virtual ~UsageInfo()
@ -70,7 +70,7 @@ public:
}
protected:
mozilla::Atomic<int32_t> mCanceled;
mozilla::Atomic<bool> mCanceled;
private:
uint64_t mDatabaseUsage;

View File

@ -12,10 +12,10 @@ BEGIN_WORKERS_NAMESPACE
JSPrincipals*
GetWorkerPrincipal()
{
static Atomic<uint32_t> sInitialized(0);
static Atomic<bool> sInitialized(false);
static JSPrincipals sPrincipal;
uint32_t isInitialized = sInitialized.exchange(1);
bool isInitialized = sInitialized.exchange(true);
if (!isInitialized) {
sPrincipal.refcount = 1;
#ifdef DEBUG