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