mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 1257725 part 6. Get rid of ThreadsafeAutoJSContext. r=bholley
This commit is contained in:
parent
ede5a13ec4
commit
08a17f586c
@ -851,28 +851,6 @@ AutoJSContext::operator JSContext*() const
|
||||
return mCx;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext::ThreadsafeAutoJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
mCx = nullptr;
|
||||
mAutoJSContext.emplace();
|
||||
} else {
|
||||
mCx = mozilla::dom::workers::GetCurrentThreadJSContext();
|
||||
mRequest.emplace(mCx);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext::operator JSContext*() const
|
||||
{
|
||||
if (mCx) {
|
||||
return mCx;
|
||||
} else {
|
||||
return *mAutoJSContext;
|
||||
}
|
||||
}
|
||||
|
||||
AutoSafeJSContext::AutoSafeJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)
|
||||
: AutoJSAPI()
|
||||
{
|
||||
|
@ -444,22 +444,6 @@ protected:
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
/**
|
||||
* Use ThreadsafeAutoJSContext when you want an AutoJSContext but might be
|
||||
* running on a worker thread.
|
||||
*/
|
||||
class MOZ_RAII ThreadsafeAutoJSContext {
|
||||
public:
|
||||
explicit ThreadsafeAutoJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
|
||||
operator JSContext*() const;
|
||||
|
||||
private:
|
||||
JSContext* mCx; // Used on workers. Null means mainthread.
|
||||
Maybe<JSAutoRequest> mRequest; // Used on workers.
|
||||
Maybe<AutoJSContext> mAutoJSContext; // Used on main thread.
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
/**
|
||||
* AutoSafeJSContext is similar to AutoJSContext but will only return the safe
|
||||
* JS context. That means it will never call nsContentUtils::GetCurrentJSContext().
|
||||
|
Loading…
Reference in New Issue
Block a user