Loading netwerk/base/src/nsPACMan.cpp +35 −19 Original line number Diff line number Diff line Loading @@ -21,6 +21,19 @@ using namespace mozilla; using namespace mozilla::net; #include "prlog.h" #if defined(PR_LOGGING) static PRLogModuleInfo * GetProxyLog() { static PRLogModuleInfo *sLog; if (!sLog) sLog = PR_NewLogModule("proxy"); return sLog; } #endif #define LOG(args) PR_LOG(GetProxyLog(), PR_LOG_DEBUG, args) // The PAC thread does evaluations of both PAC files and // nsISystemProxySettings because they can both block the calling thread and we // don't want that on the main thread Loading Loading @@ -269,16 +282,6 @@ nsPACMan::~nsPACMan() NS_DispatchToMainThread(runnable, NS_DISPATCH_NORMAL); } } if (!NS_IsMainThread()) { nsCOMPtr<nsIThread> mainThread; NS_GetMainThread(getter_AddRefs(mainThread)); if (mPACURI) { nsIURI *forgettable; mPACURI.forget(&forgettable); NS_ProxyRelease(mainThread, forgettable, false); } } NS_ASSERTION(mLoader == nullptr, "pac man not shutdown properly"); NS_ASSERTION(mPendingQ.isEmpty(), "pac man not shutdown properly"); Loading @@ -302,9 +305,9 @@ nsPACMan::AsyncGetProxyForURI(nsIURI *uri, nsPACManCallback *callback, return NS_ERROR_NOT_AVAILABLE; // Maybe Reload PAC if (mPACURI && !mScheduledReload.IsNull() && if (!mPACURISpec.IsEmpty() && !mScheduledReload.IsNull() && TimeStamp::Now() > mScheduledReload) LoadPACFromURI(nullptr); LoadPACFromURI(EmptyCString()); nsRefPtr<PendingPACQuery> query = new PendingPACQuery(this, uri, callback, mainThreadResponse); Loading Loading @@ -336,10 +339,10 @@ nsPACMan::PostQuery(PendingPACQuery *query) } nsresult nsPACMan::LoadPACFromURI(nsIURI *pacURI) nsPACMan::LoadPACFromURI(const nsCString &spec) { NS_ENSURE_STATE(!mShutdown); NS_ENSURE_ARG(pacURI || mPACURI); NS_ENSURE_ARG(!spec.IsEmpty() || !mPACURISpec.IsEmpty()); nsCOMPtr<nsIStreamLoader> loader = do_CreateInstance(NS_STREAMLOADER_CONTRACTID); Loading @@ -363,9 +366,8 @@ nsPACMan::LoadPACFromURI(nsIURI *pacURI) CancelExistingLoad(); mLoader = loader; if (pacURI) { mPACURI = pacURI; mPACURI->GetSpec(mPACURISpec); if (!spec.IsEmpty()) { mPACURISpec = spec; mLoadFailureCount = 0; // reset } Loading @@ -391,9 +393,17 @@ nsPACMan::StartLoading() nsCOMPtr<nsIIOService> ios = do_GetIOService(); if (ios) { nsCOMPtr<nsIChannel> channel; nsCOMPtr<nsIURI> pacURI; NS_NewURI(getter_AddRefs(pacURI), mPACURISpec); // NOTE: This results in GetProxyForURI being called ios->NewChannelFromURI(mPACURI, getter_AddRefs(channel)); if (pacURI) { ios->NewChannelFromURI(pacURI, getter_AddRefs(channel)); } else { LOG(("nsPACMan::StartLoading Failed pacspec uri conversion %s\n", mPACURISpec.get())); } if (channel) { channel->SetLoadFlags(nsIRequest::LOAD_BYPASS_CACHE); Loading Loading @@ -642,8 +652,14 @@ nsPACMan::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsIChannel *newChannel, uint32_t flags, nsIAsyncVerifyRedirectCallback *callback) { NS_ABORT_IF_FALSE(NS_IsMainThread(), "wrong thread"); nsresult rv = NS_OK; if (NS_FAILED((rv = newChannel->GetURI(getter_AddRefs(mPACURI))))) nsCOMPtr<nsIURI> pacURI; if (NS_FAILED((rv = newChannel->GetURI(getter_AddRefs(pacURI))))) return rv; rv = pacURI->GetSpec(mPACURISpec); if (NS_FAILED(rv)) return rv; callback->OnRedirectVerifyCallback(NS_OK); Loading netwerk/base/src/nsPACMan.h +13 −11 Original line number Diff line number Diff line Loading @@ -115,11 +115,11 @@ public: * the PAC file, any asynchronous PAC queries will be queued up to be * processed once the PAC file finishes loading. * * @param pacURI * The nsIURI of the PAC file to load. If this parameter is null, * then the previous PAC URI is simply reloaded. * @param pacSpec * The non normalized uri spec of this URI used for comparison with * system proxy settings to determine if the PAC uri has changed. */ nsresult LoadPACFromURI(nsIURI *pacURI); nsresult LoadPACFromURI(const nsCString &pacSpec); /** * Returns true if we are currently loading the PAC file. Loading @@ -130,14 +130,17 @@ public: * Returns true if the given URI matches the URI of our PAC file. */ bool IsPACURI(nsIURI *uri) { bool result; return mPACURI && NS_SUCCEEDED(mPACURI->Equals(uri, &result)) && result; if (mPACURISpec.IsEmpty()) return false; nsAutoCString tmp; uri->GetSpec(tmp); return IsPACURI(tmp); } bool IsPACURI(nsACString &spec) bool IsPACURI(const nsACString &spec) { nsAutoCString tmp; return (mPACURI && NS_SUCCEEDED(mPACURI->GetSpec(tmp)) && tmp.Equals(spec)); return mPACURISpec.Equals(spec); } NS_HIDDEN_(nsresult) Init(nsISystemProxySettings *); Loading Loading @@ -198,8 +201,7 @@ private: mozilla::LinkedList<PendingPACQuery> mPendingQ; /* pac thread only */ nsCOMPtr<nsIURI> mPACURI; nsCString mPACURISpec; // for use off main thread nsCString mPACURISpec; // Not an nsIRUI for use off main thread nsCOMPtr<nsIStreamLoader> mLoader; bool mLoadPending; bool mShutdown; Loading netwerk/base/src/nsProtocolProxyService.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -896,17 +896,12 @@ nsProtocolProxyService::ConfigureFromPAC(const nsCString &spec, { SetupPACThread(); nsCOMPtr<nsIURI> pacURI; nsresult rv = NS_NewURI(getter_AddRefs(pacURI), spec); if (NS_FAILED(rv)) return rv; if (mPACMan->IsPACURI(pacURI) && !forceReload) if (mPACMan->IsPACURI(spec) && !forceReload) return NS_OK; mFailedProxies.Clear(); return mPACMan->LoadPACFromURI(pacURI); return mPACMan->LoadPACFromURI(spec); } void Loading Loading
netwerk/base/src/nsPACMan.cpp +35 −19 Original line number Diff line number Diff line Loading @@ -21,6 +21,19 @@ using namespace mozilla; using namespace mozilla::net; #include "prlog.h" #if defined(PR_LOGGING) static PRLogModuleInfo * GetProxyLog() { static PRLogModuleInfo *sLog; if (!sLog) sLog = PR_NewLogModule("proxy"); return sLog; } #endif #define LOG(args) PR_LOG(GetProxyLog(), PR_LOG_DEBUG, args) // The PAC thread does evaluations of both PAC files and // nsISystemProxySettings because they can both block the calling thread and we // don't want that on the main thread Loading Loading @@ -269,16 +282,6 @@ nsPACMan::~nsPACMan() NS_DispatchToMainThread(runnable, NS_DISPATCH_NORMAL); } } if (!NS_IsMainThread()) { nsCOMPtr<nsIThread> mainThread; NS_GetMainThread(getter_AddRefs(mainThread)); if (mPACURI) { nsIURI *forgettable; mPACURI.forget(&forgettable); NS_ProxyRelease(mainThread, forgettable, false); } } NS_ASSERTION(mLoader == nullptr, "pac man not shutdown properly"); NS_ASSERTION(mPendingQ.isEmpty(), "pac man not shutdown properly"); Loading @@ -302,9 +305,9 @@ nsPACMan::AsyncGetProxyForURI(nsIURI *uri, nsPACManCallback *callback, return NS_ERROR_NOT_AVAILABLE; // Maybe Reload PAC if (mPACURI && !mScheduledReload.IsNull() && if (!mPACURISpec.IsEmpty() && !mScheduledReload.IsNull() && TimeStamp::Now() > mScheduledReload) LoadPACFromURI(nullptr); LoadPACFromURI(EmptyCString()); nsRefPtr<PendingPACQuery> query = new PendingPACQuery(this, uri, callback, mainThreadResponse); Loading Loading @@ -336,10 +339,10 @@ nsPACMan::PostQuery(PendingPACQuery *query) } nsresult nsPACMan::LoadPACFromURI(nsIURI *pacURI) nsPACMan::LoadPACFromURI(const nsCString &spec) { NS_ENSURE_STATE(!mShutdown); NS_ENSURE_ARG(pacURI || mPACURI); NS_ENSURE_ARG(!spec.IsEmpty() || !mPACURISpec.IsEmpty()); nsCOMPtr<nsIStreamLoader> loader = do_CreateInstance(NS_STREAMLOADER_CONTRACTID); Loading @@ -363,9 +366,8 @@ nsPACMan::LoadPACFromURI(nsIURI *pacURI) CancelExistingLoad(); mLoader = loader; if (pacURI) { mPACURI = pacURI; mPACURI->GetSpec(mPACURISpec); if (!spec.IsEmpty()) { mPACURISpec = spec; mLoadFailureCount = 0; // reset } Loading @@ -391,9 +393,17 @@ nsPACMan::StartLoading() nsCOMPtr<nsIIOService> ios = do_GetIOService(); if (ios) { nsCOMPtr<nsIChannel> channel; nsCOMPtr<nsIURI> pacURI; NS_NewURI(getter_AddRefs(pacURI), mPACURISpec); // NOTE: This results in GetProxyForURI being called ios->NewChannelFromURI(mPACURI, getter_AddRefs(channel)); if (pacURI) { ios->NewChannelFromURI(pacURI, getter_AddRefs(channel)); } else { LOG(("nsPACMan::StartLoading Failed pacspec uri conversion %s\n", mPACURISpec.get())); } if (channel) { channel->SetLoadFlags(nsIRequest::LOAD_BYPASS_CACHE); Loading Loading @@ -642,8 +652,14 @@ nsPACMan::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsIChannel *newChannel, uint32_t flags, nsIAsyncVerifyRedirectCallback *callback) { NS_ABORT_IF_FALSE(NS_IsMainThread(), "wrong thread"); nsresult rv = NS_OK; if (NS_FAILED((rv = newChannel->GetURI(getter_AddRefs(mPACURI))))) nsCOMPtr<nsIURI> pacURI; if (NS_FAILED((rv = newChannel->GetURI(getter_AddRefs(pacURI))))) return rv; rv = pacURI->GetSpec(mPACURISpec); if (NS_FAILED(rv)) return rv; callback->OnRedirectVerifyCallback(NS_OK); Loading
netwerk/base/src/nsPACMan.h +13 −11 Original line number Diff line number Diff line Loading @@ -115,11 +115,11 @@ public: * the PAC file, any asynchronous PAC queries will be queued up to be * processed once the PAC file finishes loading. * * @param pacURI * The nsIURI of the PAC file to load. If this parameter is null, * then the previous PAC URI is simply reloaded. * @param pacSpec * The non normalized uri spec of this URI used for comparison with * system proxy settings to determine if the PAC uri has changed. */ nsresult LoadPACFromURI(nsIURI *pacURI); nsresult LoadPACFromURI(const nsCString &pacSpec); /** * Returns true if we are currently loading the PAC file. Loading @@ -130,14 +130,17 @@ public: * Returns true if the given URI matches the URI of our PAC file. */ bool IsPACURI(nsIURI *uri) { bool result; return mPACURI && NS_SUCCEEDED(mPACURI->Equals(uri, &result)) && result; if (mPACURISpec.IsEmpty()) return false; nsAutoCString tmp; uri->GetSpec(tmp); return IsPACURI(tmp); } bool IsPACURI(nsACString &spec) bool IsPACURI(const nsACString &spec) { nsAutoCString tmp; return (mPACURI && NS_SUCCEEDED(mPACURI->GetSpec(tmp)) && tmp.Equals(spec)); return mPACURISpec.Equals(spec); } NS_HIDDEN_(nsresult) Init(nsISystemProxySettings *); Loading Loading @@ -198,8 +201,7 @@ private: mozilla::LinkedList<PendingPACQuery> mPendingQ; /* pac thread only */ nsCOMPtr<nsIURI> mPACURI; nsCString mPACURISpec; // for use off main thread nsCString mPACURISpec; // Not an nsIRUI for use off main thread nsCOMPtr<nsIStreamLoader> mLoader; bool mLoadPending; bool mShutdown; Loading
netwerk/base/src/nsProtocolProxyService.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -896,17 +896,12 @@ nsProtocolProxyService::ConfigureFromPAC(const nsCString &spec, { SetupPACThread(); nsCOMPtr<nsIURI> pacURI; nsresult rv = NS_NewURI(getter_AddRefs(pacURI), spec); if (NS_FAILED(rv)) return rv; if (mPACMan->IsPACURI(pacURI) && !forceReload) if (mPACMan->IsPACURI(spec) && !forceReload) return NS_OK; mFailedProxies.Clear(); return mPACMan->LoadPACFromURI(pacURI); return mPACMan->LoadPACFromURI(spec); } void Loading