mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1448328 - Use thread-safe nsIURI in the URI API - part 2 - No teardown runnable, r=valentin
This commit is contained in:
parent
4b23deda27
commit
48bf20fde9
@ -39,23 +39,10 @@ public:
|
|||||||
return mURL;
|
return mURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIURI* URI()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
|
||||||
return mURL->GetURI();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReleaseURI()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
|
||||||
mURL = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Private destructor, to discourage deletion outside of Release():
|
|
||||||
~URLProxy()
|
~URLProxy()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!mURL);
|
NS_ReleaseOnMainThreadSystemGroup("URLMainThread", mURL.forget());
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<URLMainThread> mURL;
|
RefPtr<URLMainThread> mURL;
|
||||||
@ -279,29 +266,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TeardownURLRunnable : public Runnable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit TeardownURLRunnable(URLWorker::URLProxy* aURLProxy)
|
|
||||||
: Runnable("dom::TeardownURLRunnable")
|
|
||||||
, mURLProxy(aURLProxy)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHOD Run() override
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
|
|
||||||
mURLProxy->ReleaseURI();
|
|
||||||
mURLProxy = nullptr;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
RefPtr<URLWorker::URLProxy> mURLProxy;
|
|
||||||
};
|
|
||||||
|
|
||||||
class OriginGetterRunnable : public WorkerMainThreadRunnable
|
class OriginGetterRunnable : public WorkerMainThreadRunnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -562,20 +526,7 @@ URLWorker::Init(const nsAString& aURL, const Optional<nsAString>& aBase,
|
|||||||
mURLProxy = runnable->GetURLProxy(aRv);
|
mURLProxy = runnable->GetURLProxy(aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
URLWorker::~URLWorker()
|
URLWorker::~URLWorker() = default;
|
||||||
{
|
|
||||||
if (mURLProxy) {
|
|
||||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
||||||
|
|
||||||
RefPtr<TeardownURLRunnable> runnable =
|
|
||||||
new TeardownURLRunnable(mURLProxy);
|
|
||||||
mURLProxy = nullptr;
|
|
||||||
|
|
||||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
|
||||||
NS_ERROR("Failed to dispatch teardown runnable!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
URLWorker::GetHref(nsAString& aHref) const
|
URLWorker::GetHref(nsAString& aHref) const
|
||||||
@ -617,18 +568,7 @@ URLWorker::SetHrefInternal(const nsAString& aHref, Strategy aStrategy,
|
|||||||
aRv = NS_MutateURI(new nsStandardURL::Mutator())
|
aRv = NS_MutateURI(new nsStandardURL::Mutator())
|
||||||
.SetSpec(NS_ConvertUTF16toUTF8(aHref))
|
.SetSpec(NS_ConvertUTF16toUTF8(aHref))
|
||||||
.Finalize(mStdURL);
|
.Finalize(mStdURL);
|
||||||
if (mURLProxy) {
|
mURLProxy = nullptr;
|
||||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
||||||
|
|
||||||
RefPtr<TeardownURLRunnable> runnable =
|
|
||||||
new TeardownURLRunnable(mURLProxy);
|
|
||||||
mURLProxy = nullptr;
|
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable)))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateURLSearchParams();
|
UpdateURLSearchParams();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user