зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1536744 - Rename NS_NewURIOnAnyThread to NS_NewURI. r=baku
The only protocol that can't be created off the main thread at the moment is moz-extension, and that can be handled at a later time. Differential Revision: https://phabricator.services.mozilla.com/D30713 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
89c55d7dfe
Коммит
124a1062f6
|
@ -5845,7 +5845,7 @@ nsresult nsContentUtils::GetThreadSafeASCIIOrigin(nsIURI* aURI,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURIOnAnyThread(getter_AddRefs(uri), path);
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), path);
|
||||
if (rv == NS_ERROR_UNKNOWN_PROTOCOL) {
|
||||
return NS_ERROR_UNKNOWN_PROTOCOL;
|
||||
}
|
||||
|
|
|
@ -412,8 +412,8 @@ void URLWorker::Init(const nsAString& aURL, const Optional<nsAString>& aBase,
|
|||
bool useProxy = false;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
if (aBase.WasPassed()) {
|
||||
rv = NS_NewURIOnAnyThread(getter_AddRefs(baseURI),
|
||||
NS_ConvertUTF16toUTF8(aBase.Value()));
|
||||
rv = NS_NewURI(getter_AddRefs(baseURI),
|
||||
NS_ConvertUTF16toUTF8(aBase.Value()));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (rv != NS_ERROR_UNKNOWN_PROTOCOL) {
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(aBase.Value());
|
||||
|
@ -426,8 +426,8 @@ void URLWorker::Init(const nsAString& aURL, const Optional<nsAString>& aBase,
|
|||
// Let's see if we can parse aURI on this thread.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (!useProxy) {
|
||||
rv = NS_NewURIOnAnyThread(getter_AddRefs(uri), NS_ConvertUTF16toUTF8(aURL),
|
||||
nullptr, baseURI);
|
||||
rv = NS_NewURI(getter_AddRefs(uri), NS_ConvertUTF16toUTF8(aURL), nullptr,
|
||||
baseURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (rv != NS_ERROR_UNKNOWN_PROTOCOL) {
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(aURL);
|
||||
|
|
|
@ -1621,15 +1621,6 @@ nsresult NS_ReadInputStreamToString(nsIInputStream* aInputStream,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_NewURI(
|
||||
nsIURI** result, const nsACString& spec,
|
||||
const char* charset /* = nullptr */, nsIURI* baseURI /* = nullptr */,
|
||||
nsIIOService*
|
||||
ioService /* = nullptr */) // pass in nsIIOService to optimize callers
|
||||
{
|
||||
return NS_NewURIOnAnyThread(result, spec, charset, baseURI, ioService);
|
||||
}
|
||||
|
||||
nsresult NS_NewURI(
|
||||
nsIURI** result, const nsACString& spec, NotNull<const Encoding*> encoding,
|
||||
nsIURI* baseURI /* = nullptr */,
|
||||
|
@ -1709,10 +1700,10 @@ class TlsAutoIncrement {
|
|||
T& mVar;
|
||||
};
|
||||
|
||||
nsresult NS_NewURIOnAnyThread(nsIURI** aURI, const nsACString& aSpec,
|
||||
const char* aCharset /* = nullptr */,
|
||||
nsIURI* aBaseURI /* = nullptr */,
|
||||
nsIIOService* aIOService /* = nullptr */) {
|
||||
nsresult NS_NewURI(nsIURI** aURI, const nsACString& aSpec,
|
||||
const char* aCharset /* = nullptr */,
|
||||
nsIURI* aBaseURI /* = nullptr */,
|
||||
nsIIOService* aIOService /* = nullptr */) {
|
||||
TlsAutoIncrement<decltype(gTlsURLRecursionCount)> inc(gTlsURLRecursionCount);
|
||||
if (inc.value() >= MAX_RECURSION_COUNT) {
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
|
|
|
@ -101,19 +101,6 @@ nsresult NS_NewURI(nsIURI** result, const char* spec, nsIURI* baseURI = nullptr,
|
|||
nsIIOService* ioService =
|
||||
nullptr); // pass in nsIIOService to optimize callers
|
||||
|
||||
// This function attempts to create an nsIURI on any thread. This implies we
|
||||
// can't instantiate a protcol handler, since protocol handers may have a JS
|
||||
// implementation so they can't work off-main-thread.
|
||||
// When called off the main thread, if the nsIURI can't be created without
|
||||
// instantiating protocol handlers, the method will return
|
||||
// NS_ERROR_UNKNOWN_PROTOCOL. The caller may retry on the main thread.
|
||||
// When called on the main thread, this function will fall back on calling
|
||||
// nsIProtocolHandler.newURI
|
||||
nsresult NS_NewURIOnAnyThread(nsIURI** aResult, const nsACString& aSpec,
|
||||
const char* aCharset = nullptr,
|
||||
nsIURI* aBaseURI = nullptr,
|
||||
nsIIOService* aIOService = nullptr);
|
||||
|
||||
nsresult NS_NewFileURI(
|
||||
nsIURI** result, nsIFile* spec,
|
||||
nsIIOService* ioService =
|
||||
|
|
|
@ -149,7 +149,7 @@ nsresult nsAboutProtocolHandler::CreateNewURI(const nsACString& aSpec,
|
|||
spec.InsertLiteral("moz-safe-about:", 0);
|
||||
|
||||
nsCOMPtr<nsIURI> inner;
|
||||
rv = NS_NewURIOnAnyThread(getter_AddRefs(inner), spec);
|
||||
rv = NS_NewURI(getter_AddRefs(inner), spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> base(aBaseURI);
|
||||
|
|
|
@ -103,7 +103,7 @@ TEST(TestURIMutator, Mutator)
|
|||
|
||||
extern MOZ_THREAD_LOCAL(uint32_t) gTlsURLRecursionCount;
|
||||
|
||||
TEST(TestURIMutator, NS_NewURIOnAnyThread)
|
||||
TEST(TestURIMutator, OnAnyThread)
|
||||
{
|
||||
nsCOMPtr<nsIThreadPool> pool = new nsThreadPool();
|
||||
pool->SetThreadLimit(60);
|
||||
|
@ -111,10 +111,10 @@ TEST(TestURIMutator, NS_NewURIOnAnyThread)
|
|||
pool = new nsThreadPool();
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
nsCOMPtr<nsIRunnable> task =
|
||||
NS_NewRunnableFunction("gtest-NS_NewURIOnAnyThread", []() {
|
||||
NS_NewRunnableFunction("gtest-OnAnyThread", []() {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURIOnAnyThread(
|
||||
getter_AddRefs(uri), NS_LITERAL_CSTRING("http://example.com"));
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri),
|
||||
NS_LITERAL_CSTRING("http://example.com"));
|
||||
ASSERT_EQ(rv, NS_OK);
|
||||
nsAutoCString out;
|
||||
ASSERT_EQ(uri->GetSpec(out), NS_OK);
|
||||
|
@ -126,8 +126,8 @@ TEST(TestURIMutator, NS_NewURIOnAnyThread)
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURIOnAnyThread(getter_AddRefs(uri),
|
||||
NS_LITERAL_CSTRING("http://example.com"));
|
||||
nsresult rv =
|
||||
NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("http://example.com"));
|
||||
ASSERT_EQ(rv, NS_OK);
|
||||
nsAutoCString out;
|
||||
ASSERT_EQ(uri->GetSpec(out), NS_OK);
|
||||
|
|
Загрузка…
Ссылка в новой задаче