Move wxStringWebSessionFactoryMap out of the header
Define wxWebSession::ms_defaultSession and ms_factoryMap in the implementation file to avoid having to make the otherwise unnecessary wxStringWebSessionFactoryMap type public. No real changes.
This commit is contained in:
@@ -215,8 +215,6 @@ public:
|
|||||||
virtual ~wxWebSessionFactory() { }
|
virtual ~wxWebSessionFactory() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxWebSessionFactory>, wxStringWebSessionFactoryMap);
|
|
||||||
|
|
||||||
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[];
|
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[];
|
||||||
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[];
|
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[];
|
||||||
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[];
|
extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[];
|
||||||
@@ -242,8 +240,6 @@ public:
|
|||||||
|
|
||||||
static wxWebSession& GetDefault();
|
static wxWebSession& GetDefault();
|
||||||
|
|
||||||
static void DestroyDefault();
|
|
||||||
|
|
||||||
static wxWebSession* New(const wxString& backend = wxWebSessionBackendDefault);
|
static wxWebSession* New(const wxString& backend = wxWebSessionBackendDefault);
|
||||||
|
|
||||||
static void RegisterFactory(const wxString& backend,
|
static void RegisterFactory(const wxString& backend,
|
||||||
@@ -258,9 +254,6 @@ private:
|
|||||||
wxWebRequestHeaderMap m_headers;
|
wxWebRequestHeaderMap m_headers;
|
||||||
wxString m_tempDir;
|
wxString m_tempDir;
|
||||||
|
|
||||||
static wxScopedPtr<wxWebSession> ms_defaultSession;
|
|
||||||
static wxStringWebSessionFactoryMap ms_factoryMap;
|
|
||||||
|
|
||||||
static void InitFactoryMap();
|
static void InitFactoryMap();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -395,8 +395,15 @@ void wxWebResponse::Finalize()
|
|||||||
// wxWebSession
|
// wxWebSession
|
||||||
//
|
//
|
||||||
|
|
||||||
wxScopedPtr<wxWebSession> wxWebSession::ms_defaultSession;
|
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxWebSessionFactory>, wxStringWebSessionFactoryMap);
|
||||||
wxStringWebSessionFactoryMap wxWebSession::ms_factoryMap;
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
wxScopedPtr<wxWebSession> gs_defaultSession;
|
||||||
|
wxStringWebSessionFactoryMap gs_factoryMap;
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
wxWebSession::wxWebSession()
|
wxWebSession::wxWebSession()
|
||||||
{
|
{
|
||||||
@@ -417,25 +424,20 @@ wxString wxWebSession::GetTempDir() const
|
|||||||
// static
|
// static
|
||||||
wxWebSession& wxWebSession::GetDefault()
|
wxWebSession& wxWebSession::GetDefault()
|
||||||
{
|
{
|
||||||
if ( ms_defaultSession == NULL )
|
if ( gs_defaultSession == NULL )
|
||||||
ms_defaultSession.reset(wxWebSession::New());
|
gs_defaultSession.reset(wxWebSession::New());
|
||||||
|
|
||||||
return *ms_defaultSession;
|
return *gs_defaultSession;
|
||||||
}
|
|
||||||
|
|
||||||
void wxWebSession::DestroyDefault()
|
|
||||||
{
|
|
||||||
ms_defaultSession.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
wxWebSession* wxWebSession::New(const wxString& backend)
|
wxWebSession* wxWebSession::New(const wxString& backend)
|
||||||
{
|
{
|
||||||
if ( ms_factoryMap.empty() )
|
if ( gs_factoryMap.empty() )
|
||||||
InitFactoryMap();
|
InitFactoryMap();
|
||||||
|
|
||||||
wxStringWebSessionFactoryMap::iterator factory = ms_factoryMap.find(backend);
|
wxStringWebSessionFactoryMap::iterator factory = gs_factoryMap.find(backend);
|
||||||
if ( factory != ms_factoryMap.end() )
|
if ( factory != gs_factoryMap.end() )
|
||||||
return factory->second->Create();
|
return factory->second->Create();
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -446,7 +448,7 @@ void
|
|||||||
wxWebSession::RegisterFactory(const wxString& backend,
|
wxWebSession::RegisterFactory(const wxString& backend,
|
||||||
const wxSharedPtr<wxWebSessionFactory>& factory)
|
const wxSharedPtr<wxWebSessionFactory>& factory)
|
||||||
{
|
{
|
||||||
ms_factoryMap[backend] = factory;
|
gs_factoryMap[backend] = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@@ -469,11 +471,11 @@ void wxWebSession::InitFactoryMap()
|
|||||||
// static
|
// static
|
||||||
bool wxWebSession::IsBackendAvailable(const wxString& backend)
|
bool wxWebSession::IsBackendAvailable(const wxString& backend)
|
||||||
{
|
{
|
||||||
if ( ms_factoryMap.empty() )
|
if ( gs_factoryMap.empty() )
|
||||||
InitFactoryMap();
|
InitFactoryMap();
|
||||||
|
|
||||||
wxStringWebSessionFactoryMap::iterator factory = ms_factoryMap.find(backend);
|
wxStringWebSessionFactoryMap::iterator factory = gs_factoryMap.find(backend);
|
||||||
return factory != ms_factoryMap.end();
|
return factory != gs_factoryMap.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -494,7 +496,8 @@ public:
|
|||||||
|
|
||||||
virtual void OnExit() wxOVERRIDE
|
virtual void OnExit() wxOVERRIDE
|
||||||
{
|
{
|
||||||
wxWebSession::DestroyDefault();
|
gs_factoryMap.clear();
|
||||||
|
gs_defaultSession.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user