Remove wxWebSessionBackendDefault and just use empty string

There doesn't seem to be any reason to have this constant, so don't
define it and just interpret empty value of backend as meaning to choose
the default one in wxWebSession::New().
This commit is contained in:
Vadim Zeitlin
2021-01-12 02:16:14 +01:00
parent 3b87af5738
commit d3b93a48b3
2 changed files with 14 additions and 11 deletions

View File

@@ -193,7 +193,6 @@ private:
wxWebRequestImplPtr m_impl;
};
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[];
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[];
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[];
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendCURL[];
@@ -213,7 +212,7 @@ public:
// factory functions to get access to them.
static wxWebSession& GetDefault();
static wxWebSession New(const wxString& backend = wxWebSessionBackendDefault);
static wxWebSession New(const wxString& backend = wxString());
// Can be used to check if the given backend is available without actually
// creating a session using it.

View File

@@ -43,14 +43,6 @@ extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[] = "wxWebSes
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[] = "wxWebSessionBackendURLSession";
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendCURL[] = "wxWebSessionBackendCURL";
#if wxUSE_WEBREQUEST_WINHTTP
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendWinHTTP";
#elif wxUSE_WEBREQUEST_URLSESSION
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendURLSession";
#elif wxUSE_WEBREQUEST_CURL
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendCURL";
#endif
wxDEFINE_EVENT(wxEVT_WEBREQUEST_STATE, wxWebRequestEvent);
wxDEFINE_EVENT(wxEVT_WEBREQUEST_DATA, wxWebRequestEvent);
@@ -824,11 +816,23 @@ wxWebSession& wxWebSession::GetDefault()
}
// static
wxWebSession wxWebSession::New(const wxString& backend)
wxWebSession wxWebSession::New(const wxString& backendOrig)
{
if ( gs_factoryMap.empty() )
InitFactoryMap();
wxString backend = backendOrig;
if ( backend.empty() )
{
#if wxUSE_WEBREQUEST_WINHTTP
backend = wxWebSessionBackendWinHTTP;
#elif wxUSE_WEBREQUEST_URLSESSION
backend = wxWebSessionBackendURLSession;
#elif wxUSE_WEBREQUEST_CURL
backend = wxWebSessionBackendCURL;
#endif
}
wxStringWebSessionFactoryMap::iterator factory = gs_factoryMap.find(backend);
wxWebSessionImplPtr impl;