зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1762959 - xpcom/io thread-safety annotations r=nika
Differential Revision: https://phabricator.services.mozilla.com/D142066
This commit is contained in:
Родитель
8049dd3830
Коммит
00859f1620
|
@ -55,9 +55,9 @@ class MainThreadIOLoggerImpl final : public mozilla::IOInterposeObserver {
|
|||
mozilla::TimeStamp mLogStartTime;
|
||||
const char* mFileName;
|
||||
PRThread* mIOThread;
|
||||
mozilla::IOInterposer::Monitor mMonitor MOZ_UNANNOTATED;
|
||||
bool mShutdownRequired;
|
||||
std::vector<ObservationWithStack> mObservations;
|
||||
mozilla::IOInterposer::Monitor mMonitor;
|
||||
bool mShutdownRequired GUARDED_BY(mMonitor);
|
||||
std::vector<ObservationWithStack> mObservations GUARDED_BY(mMonitor);
|
||||
};
|
||||
|
||||
static mozilla::StaticAutoPtr<MainThreadIOLoggerImpl> sImpl;
|
||||
|
|
|
@ -29,7 +29,7 @@ typedef nsTArray<nsString> WinPaths;
|
|||
static WinPaths& PathAllowlist() REQUIRES(sMutex) {
|
||||
sMutex.AssertCurrentThreadOwns();
|
||||
|
||||
static WinPaths sPaths;
|
||||
static WinPaths sPaths GUARDED_BY(sMutex);
|
||||
return sPaths;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,10 +73,10 @@ class InputStreamLengthWrapper final : public nsIAsyncInputStream,
|
|||
int64_t mLength;
|
||||
bool mConsumed;
|
||||
|
||||
mozilla::Mutex mMutex MOZ_UNANNOTATED;
|
||||
mozilla::Mutex mMutex;
|
||||
|
||||
// This is used for AsyncWait and it's protected by mutex.
|
||||
nsCOMPtr<nsIInputStreamCallback> mAsyncWaitCallback;
|
||||
nsCOMPtr<nsIInputStreamCallback> mAsyncWaitCallback GUARDED_BY(mMutex);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -84,16 +84,17 @@ class SlicedInputStream final : public nsIAsyncInputStream,
|
|||
|
||||
// These four are used for AsyncWait. They are protected by mutex because
|
||||
// touched on multiple threads.
|
||||
nsCOMPtr<nsIInputStreamCallback> mAsyncWaitCallback;
|
||||
nsCOMPtr<nsIEventTarget> mAsyncWaitEventTarget;
|
||||
uint32_t mAsyncWaitFlags;
|
||||
uint32_t mAsyncWaitRequestedCount;
|
||||
nsCOMPtr<nsIInputStreamCallback> mAsyncWaitCallback GUARDED_BY(mMutex);
|
||||
nsCOMPtr<nsIEventTarget> mAsyncWaitEventTarget GUARDED_BY(mMutex);
|
||||
uint32_t mAsyncWaitFlags GUARDED_BY(mMutex);
|
||||
uint32_t mAsyncWaitRequestedCount GUARDED_BY(mMutex);
|
||||
|
||||
// This is use for nsIAsyncInputStreamLength::AsyncWait.
|
||||
// This is protected by mutex.
|
||||
nsCOMPtr<nsIInputStreamLengthCallback> mAsyncWaitLengthCallback;
|
||||
nsCOMPtr<nsIInputStreamLengthCallback> mAsyncWaitLengthCallback
|
||||
GUARDED_BY(mMutex);
|
||||
|
||||
Mutex mMutex MOZ_UNANNOTATED;
|
||||
Mutex mMutex;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -455,7 +455,7 @@ class nsAStreamCopier : public nsIInputStreamCallback,
|
|||
return PostContinuationEvent_Locked();
|
||||
}
|
||||
|
||||
nsresult PostContinuationEvent_Locked() {
|
||||
nsresult PostContinuationEvent_Locked() REQUIRES(mLock) {
|
||||
nsresult rv = NS_OK;
|
||||
if (mEventInProcess) {
|
||||
mEventIsPending = true;
|
||||
|
@ -476,17 +476,17 @@ class nsAStreamCopier : public nsIInputStreamCallback,
|
|||
nsCOMPtr<nsIAsyncInputStream> mAsyncSource;
|
||||
nsCOMPtr<nsIAsyncOutputStream> mAsyncSink;
|
||||
nsCOMPtr<nsIEventTarget> mTarget;
|
||||
Mutex mLock MOZ_UNANNOTATED;
|
||||
Mutex mLock;
|
||||
nsAsyncCopyCallbackFun mCallback;
|
||||
nsAsyncCopyProgressFun mProgressCallback;
|
||||
void* mClosure;
|
||||
uint32_t mChunkSize;
|
||||
bool mEventInProcess;
|
||||
bool mEventIsPending;
|
||||
bool mEventInProcess GUARDED_BY(mLock);
|
||||
bool mEventIsPending GUARDED_BY(mLock);
|
||||
bool mCloseSource;
|
||||
bool mCloseSink;
|
||||
bool mCanceled;
|
||||
nsresult mCancelStatus;
|
||||
bool mCanceled GUARDED_BY(mLock);
|
||||
nsresult mCancelStatus GUARDED_BY(mLock);
|
||||
|
||||
// virtual since subclasses call superclass Release()
|
||||
virtual ~nsAStreamCopier() = default;
|
||||
|
|
|
@ -129,18 +129,20 @@ class nsStringInputStream final : public nsIStringInputStream,
|
|||
private:
|
||||
~nsStringInputStream() = default;
|
||||
|
||||
size_t Length() const { return mSource ? mSource->Data().Length() : 0; }
|
||||
size_t Length() const REQUIRES(mMon) {
|
||||
return mSource ? mSource->Data().Length() : 0;
|
||||
}
|
||||
|
||||
size_t LengthRemaining() const { return Length() - mOffset; }
|
||||
size_t LengthRemaining() const REQUIRES(mMon) { return Length() - mOffset; }
|
||||
|
||||
void Clear() { mSource = nullptr; }
|
||||
void Clear() REQUIRES(mMon) { mSource = nullptr; }
|
||||
|
||||
bool Closed() { return !mSource; }
|
||||
bool Closed() REQUIRES(mMon) { return !mSource; }
|
||||
|
||||
RefPtr<StreamBufferSource> mSource;
|
||||
size_t mOffset = 0;
|
||||
RefPtr<StreamBufferSource> mSource GUARDED_BY(mMon);
|
||||
size_t mOffset GUARDED_BY(mMon) = 0;
|
||||
|
||||
mozilla::ReentrantMonitor mMon MOZ_UNANNOTATED{"nsStringInputStream"};
|
||||
mutable mozilla::ReentrantMonitor mMon{"nsStringInputStream"};
|
||||
};
|
||||
|
||||
nsresult nsStringInputStream::Init(nsCString&& aString) {
|
||||
|
@ -519,6 +521,8 @@ nsStringInputStream::Clone(nsIInputStream** aCloneOut) {
|
|||
ReentrantMonitorAutoEnter lock(mMon);
|
||||
|
||||
RefPtr<nsStringInputStream> ref = new nsStringInputStream();
|
||||
// Nothing else can access this yet, but suppress static analysis warnings
|
||||
ReentrantMonitorAutoEnter reflock(ref->mMon);
|
||||
if (mSource && !mSource->Owning()) {
|
||||
auto data = mSource->Data();
|
||||
nsresult rv = ref->SetData(data.Elements(), data.Length());
|
||||
|
|
Загрузка…
Ссылка в новой задаче