forked from mirrors/gecko-dev
Bug 1877522 - [1/3] Drive-by cleanup: standardize header-inclusion dance r=xpcom-reviewers,barret
Convert the unusual "#if !defined" header-guard form used in some xpcom/threads files to the equivalent "#ifndef" form recognized by most tools -- including our formatter. Reformat accordingly. Since we're doing that anyway, also switch to the current header-guard naming standard (per coding_style_cpp.rst). No functional changes. Differential Revision: https://phabricator.services.mozilla.com/D200059
This commit is contained in:
parent
6c5b91a611
commit
aeb85bd929
5 changed files with 121 additions and 121 deletions
|
|
@ -4,14 +4,14 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#if !defined(AbstractThread_h_)
|
||||
# define AbstractThread_h_
|
||||
#ifndef XPCOM_THREADS_ABSTRACTTHREAD_H_
|
||||
#define XPCOM_THREADS_ABSTRACTTHREAD_H_
|
||||
|
||||
# include "mozilla/AlreadyAddRefed.h"
|
||||
# include "mozilla/ThreadLocal.h"
|
||||
# include "nscore.h"
|
||||
# include "nsISerialEventTarget.h"
|
||||
# include "nsISupports.h"
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/ThreadLocal.h"
|
||||
#include "nscore.h"
|
||||
#include "nsISerialEventTarget.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIEventTarget;
|
||||
class nsIRunnable;
|
||||
|
|
|
|||
|
|
@ -4,44 +4,44 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#if !defined(MozPromise_h_)
|
||||
# define MozPromise_h_
|
||||
#ifndef XPCOM_THREADS_MOZPROMISE_H_
|
||||
#define XPCOM_THREADS_MOZPROMISE_H_
|
||||
|
||||
# include <type_traits>
|
||||
# include <utility>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
# include "mozilla/ErrorNames.h"
|
||||
# include "mozilla/Logging.h"
|
||||
# include "mozilla/Maybe.h"
|
||||
# include "mozilla/Monitor.h"
|
||||
# include "mozilla/Mutex.h"
|
||||
# include "mozilla/RefPtr.h"
|
||||
# include "mozilla/UniquePtr.h"
|
||||
# include "mozilla/Variant.h"
|
||||
# include "nsIDirectTaskDispatcher.h"
|
||||
# include "nsISerialEventTarget.h"
|
||||
# include "nsTArray.h"
|
||||
# include "nsThreadUtils.h"
|
||||
#include "mozilla/ErrorNames.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/Variant.h"
|
||||
#include "nsIDirectTaskDispatcher.h"
|
||||
#include "nsISerialEventTarget.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
# ifdef MOZ_WIDGET_ANDROID
|
||||
# include "mozilla/jni/GeckoResultUtils.h"
|
||||
# endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
# include "mozilla/jni/GeckoResultUtils.h"
|
||||
#endif
|
||||
|
||||
# if MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
# define PROMISE_DEBUG
|
||||
# endif
|
||||
#if MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
# define PROMISE_DEBUG
|
||||
#endif
|
||||
|
||||
# ifdef PROMISE_DEBUG
|
||||
# define PROMISE_ASSERT MOZ_RELEASE_ASSERT
|
||||
# else
|
||||
# define PROMISE_ASSERT(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
# endif
|
||||
#ifdef PROMISE_DEBUG
|
||||
# define PROMISE_ASSERT MOZ_RELEASE_ASSERT
|
||||
#else
|
||||
# define PROMISE_ASSERT(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
# if DEBUG
|
||||
# include "nsPrintfCString.h"
|
||||
# endif
|
||||
#if DEBUG
|
||||
# include "nsPrintfCString.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
|
@ -51,8 +51,8 @@ class Promise;
|
|||
|
||||
extern LazyLogModule gMozPromiseLog;
|
||||
|
||||
# define PROMISE_LOG(x, ...) \
|
||||
MOZ_LOG(gMozPromiseLog, mozilla::LogLevel::Debug, (x, ##__VA_ARGS__))
|
||||
#define PROMISE_LOG(x, ...) \
|
||||
MOZ_LOG(gMozPromiseLog, mozilla::LogLevel::Debug, (x, ##__VA_ARGS__))
|
||||
|
||||
namespace detail {
|
||||
template <typename F>
|
||||
|
|
@ -235,10 +235,10 @@ class MozPromise : public MozPromiseBase {
|
|||
mMutex("MozPromise Mutex"),
|
||||
mHaveRequest(false),
|
||||
mIsCompletionPromise(aIsCompletionPromise)
|
||||
# ifdef PROMISE_DEBUG
|
||||
#ifdef PROMISE_DEBUG
|
||||
,
|
||||
mMagic4(&mMutex)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
PROMISE_LOG("%s creating MozPromise (%p)", mCreationSite, this);
|
||||
}
|
||||
|
|
@ -501,12 +501,12 @@ class MozPromise : public MozPromiseBase {
|
|||
MOZ_ASSERT(aResponseTarget);
|
||||
}
|
||||
|
||||
# ifdef PROMISE_DEBUG
|
||||
#ifdef PROMISE_DEBUG
|
||||
~ThenValueBase() {
|
||||
mMagic1 = 0;
|
||||
mMagic2 = 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void AssertIsDead() {
|
||||
PROMISE_ASSERT(mMagic1 == sMagic && mMagic2 == sMagic);
|
||||
|
|
@ -520,7 +520,7 @@ class MozPromise : public MozPromiseBase {
|
|||
if (MozPromiseBase* p = CompletionPromise()) {
|
||||
p->AssertIsDead();
|
||||
} else {
|
||||
# ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
if (MOZ_UNLIKELY(!Request::mDisconnected)) {
|
||||
MOZ_CRASH_UNSAFE_PRINTF(
|
||||
"MozPromise::ThenValue created from '%s' destroyed without being "
|
||||
|
|
@ -529,7 +529,7 @@ class MozPromise : public MozPromiseBase {
|
|||
mDispatchRv ? GetStaticErrorName(*mDispatchRv)
|
||||
: "not dispatched");
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -620,23 +620,23 @@ class MozPromise : public MozPromiseBase {
|
|||
}
|
||||
|
||||
void SetDispatchRv(nsresult aRv) {
|
||||
# ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
mDispatchRv = Some(aRv);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISerialEventTarget>
|
||||
mResponseTarget; // May be released on any thread.
|
||||
# ifdef PROMISE_DEBUG
|
||||
#ifdef PROMISE_DEBUG
|
||||
uint32_t mMagic1 = sMagic;
|
||||
# endif
|
||||
#endif
|
||||
const char* mCallSite;
|
||||
# ifdef PROMISE_DEBUG
|
||||
#ifdef PROMISE_DEBUG
|
||||
uint32_t mMagic2 = sMagic;
|
||||
# endif
|
||||
# ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
#endif
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
Maybe<nsresult> mDispatchRv;
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -1088,7 +1088,7 @@ class MozPromise : public MozPromiseBase {
|
|||
}
|
||||
}
|
||||
|
||||
# ifdef MOZ_WIDGET_ANDROID
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// Creates a C++ MozPromise from its Java counterpart, GeckoResult.
|
||||
[[nodiscard]] static RefPtr<MozPromise> FromGeckoResult(
|
||||
java::GeckoResult::Param aGeckoResult) {
|
||||
|
|
@ -1103,7 +1103,7 @@ class MozPromise : public MozPromiseBase {
|
|||
aGeckoResult->NativeThen(resolve, reject);
|
||||
return p;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Note we expose the function AssertIsDead() instead of IsDead() since
|
||||
// checking IsDead() is a data race in the situation where the request is not
|
||||
|
|
@ -1165,12 +1165,12 @@ class MozPromise : public MozPromiseBase {
|
|||
MOZ_ASSERT(mThenValues.IsEmpty());
|
||||
MOZ_ASSERT(mChainedPromises.IsEmpty());
|
||||
}
|
||||
# ifdef PROMISE_DEBUG
|
||||
#ifdef PROMISE_DEBUG
|
||||
mMagic1 = 0;
|
||||
mMagic2 = 0;
|
||||
mMagic3 = 0;
|
||||
mMagic4 = nullptr;
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const char* mCreationSite; // For logging
|
||||
|
|
@ -1179,24 +1179,24 @@ class MozPromise : public MozPromiseBase {
|
|||
bool mUseSynchronousTaskDispatch = false;
|
||||
bool mUseDirectTaskDispatch = false;
|
||||
uint32_t mPriority = nsIRunnablePriority::PRIORITY_NORMAL;
|
||||
# ifdef PROMISE_DEBUG
|
||||
#ifdef PROMISE_DEBUG
|
||||
uint32_t mMagic1 = sMagic;
|
||||
# endif
|
||||
#endif
|
||||
// Try shows we never have more than 3 elements when IsExclusive is false.
|
||||
// So '3' is a good value to avoid heap allocation in most cases.
|
||||
AutoTArray<RefPtr<ThenValueBase>, IsExclusive ? 1 : 3> mThenValues;
|
||||
# ifdef PROMISE_DEBUG
|
||||
#ifdef PROMISE_DEBUG
|
||||
uint32_t mMagic2 = sMagic;
|
||||
# endif
|
||||
#endif
|
||||
nsTArray<RefPtr<Private>> mChainedPromises;
|
||||
# ifdef PROMISE_DEBUG
|
||||
#ifdef PROMISE_DEBUG
|
||||
uint32_t mMagic3 = sMagic;
|
||||
# endif
|
||||
#endif
|
||||
bool mHaveRequest;
|
||||
const bool mIsCompletionPromise;
|
||||
# ifdef PROMISE_DEBUG
|
||||
#ifdef PROMISE_DEBUG
|
||||
void* mMagic4;
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename ResolveValueT, typename RejectValueT, bool IsExclusive>
|
||||
|
|
@ -1718,9 +1718,9 @@ static auto InvokeAsync(nsISerialEventTarget* aTarget, const char* aCallerName,
|
|||
return p;
|
||||
}
|
||||
|
||||
# undef PROMISE_LOG
|
||||
# undef PROMISE_ASSERT
|
||||
# undef PROMISE_DEBUG
|
||||
#undef PROMISE_LOG
|
||||
#undef PROMISE_ASSERT
|
||||
#undef PROMISE_DEBUG
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
|||
|
|
@ -4,22 +4,22 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#if !defined(StateMirroring_h_)
|
||||
# define StateMirroring_h_
|
||||
#ifndef XPCOM_THREADS_STATEMIRRORING_H_
|
||||
#define XPCOM_THREADS_STATEMIRRORING_H_
|
||||
|
||||
# include <cstddef>
|
||||
# include "mozilla/AbstractThread.h"
|
||||
# include "mozilla/AlreadyAddRefed.h"
|
||||
# include "mozilla/Assertions.h"
|
||||
# include "mozilla/Logging.h"
|
||||
# include "mozilla/Maybe.h"
|
||||
# include "mozilla/RefPtr.h"
|
||||
# include "mozilla/StateWatching.h"
|
||||
# include "nsCOMPtr.h"
|
||||
# include "nsIRunnable.h"
|
||||
# include "nsISupports.h"
|
||||
# include "nsTArray.h"
|
||||
# include "nsThreadUtils.h"
|
||||
#include <cstddef>
|
||||
#include "mozilla/AbstractThread.h"
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/StateWatching.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
/*
|
||||
* The state-mirroring machinery allows pieces of interesting state to be
|
||||
|
|
@ -51,9 +51,9 @@ namespace mozilla {
|
|||
// Mirror<T> and Canonical<T> inherit WatchTarget, so we piggy-back on the
|
||||
// logging that WatchTarget already does. Given that, it makes sense to share
|
||||
// the same log module.
|
||||
# define MIRROR_LOG(x, ...) \
|
||||
MOZ_ASSERT(gStateWatchingLog); \
|
||||
MOZ_LOG(gStateWatchingLog, LogLevel::Debug, (x, ##__VA_ARGS__))
|
||||
#define MIRROR_LOG(x, ...) \
|
||||
MOZ_ASSERT(gStateWatchingLog); \
|
||||
MOZ_LOG(gStateWatchingLog, LogLevel::Debug, (x, ##__VA_ARGS__))
|
||||
|
||||
template <typename T>
|
||||
class AbstractMirror;
|
||||
|
|
@ -335,9 +335,9 @@ class Mirror {
|
|||
|
||||
void ConnectedOnCanonicalThread(AbstractCanonical<T>* aCanonical) override {
|
||||
MOZ_ASSERT(aCanonical->OwnerThread()->IsCurrentThreadIn());
|
||||
# ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
++mIncomingConnects;
|
||||
# endif
|
||||
#endif
|
||||
OwnerThread()->DispatchStateChange(
|
||||
NewRunnableMethod<StoreRefPtrPassByPtr<AbstractCanonical<T>>>(
|
||||
"Mirror::Impl::SetCanonical", this, &Impl::SetCanonical,
|
||||
|
|
@ -349,9 +349,9 @@ class Mirror {
|
|||
aCanonical);
|
||||
MOZ_ASSERT(OwnerThread()->IsCurrentThreadIn());
|
||||
MOZ_ASSERT(!IsConnected());
|
||||
# ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
--mIncomingConnects;
|
||||
# endif
|
||||
#endif
|
||||
mCanonical = aCanonical;
|
||||
}
|
||||
|
||||
|
|
@ -413,9 +413,9 @@ class Mirror {
|
|||
private:
|
||||
T mValue;
|
||||
RefPtr<AbstractCanonical<T>> mCanonical;
|
||||
# ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
std::atomic<size_t> mIncomingConnects = 0;
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
@ -446,7 +446,7 @@ class Mirror {
|
|||
RefPtr<Impl> mImpl;
|
||||
};
|
||||
|
||||
# undef MIRROR_LOG
|
||||
#undef MIRROR_LOG
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#if !defined(StateWatching_h_)
|
||||
# define StateWatching_h_
|
||||
#ifndef XPCOM_THREADS_STATEWATCHING_H_
|
||||
#define XPCOM_THREADS_STATEWATCHING_H_
|
||||
|
||||
# include <cstddef>
|
||||
# include <new>
|
||||
# include <utility>
|
||||
# include "mozilla/AbstractThread.h"
|
||||
# include "mozilla/Assertions.h"
|
||||
# include "mozilla/Logging.h"
|
||||
# include "mozilla/RefPtr.h"
|
||||
# include "nsISupports.h"
|
||||
# include "nsTArray.h"
|
||||
# include "nsThreadUtils.h"
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
#include <utility>
|
||||
#include "mozilla/AbstractThread.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
/*
|
||||
* The state-watching machinery automates the process of responding to changes
|
||||
|
|
@ -62,8 +62,8 @@ namespace mozilla {
|
|||
|
||||
extern LazyLogModule gStateWatchingLog;
|
||||
|
||||
# define WATCH_LOG(x, ...) \
|
||||
MOZ_LOG(gStateWatchingLog, LogLevel::Debug, (x, ##__VA_ARGS__))
|
||||
#define WATCH_LOG(x, ...) \
|
||||
MOZ_LOG(gStateWatchingLog, LogLevel::Debug, (x, ##__VA_ARGS__))
|
||||
|
||||
/*
|
||||
* AbstractWatcher is a superclass from which all watchers must inherit.
|
||||
|
|
@ -295,7 +295,7 @@ class WatchManager {
|
|||
RefPtr<AbstractThread> mOwnerThread;
|
||||
};
|
||||
|
||||
# undef WATCH_LOG
|
||||
#undef WATCH_LOG
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#if !defined(TaskDispatcher_h_)
|
||||
# define TaskDispatcher_h_
|
||||
#ifndef XPCOM_THREADS_TASKDISPATCHER_H_
|
||||
#define XPCOM_THREADS_TASKDISPATCHER_H_
|
||||
|
||||
# include <queue>
|
||||
#include <queue>
|
||||
|
||||
# include "mozilla/AbstractThread.h"
|
||||
# include "mozilla/Maybe.h"
|
||||
# include "mozilla/ProfilerRunnable.h"
|
||||
# include "mozilla/UniquePtr.h"
|
||||
# include "nsIDirectTaskDispatcher.h"
|
||||
# include "nsISupportsImpl.h"
|
||||
# include "nsTArray.h"
|
||||
# include "nsThreadUtils.h"
|
||||
#include "mozilla/AbstractThread.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/ProfilerRunnable.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsIDirectTaskDispatcher.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue