From 71d5729171dbba04c60f04556aae52d18a831fda Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 27 Dec 2020 00:40:16 +0100 Subject: [PATCH] Make wxWebSessionFactory private Having wxWebSessionFactory part of the public API implies keeping compatibility with the possible ways of implementing it which is too restrictive for no good reason, so move this class to the private header and don't document it nor wxWebSession::RegisterFactory() (which is now private). --- include/wx/msw/private/webrequest_winhttp.h | 2 ++ .../wx/osx/private/webrequest_urlsession.h | 2 ++ include/wx/private/webrequest.h | 25 ++++++++++++++ include/wx/private/webrequest_curl.h | 2 ++ include/wx/webrequest.h | 15 +++----- interface/wx/webrequest.h | 34 ------------------- src/common/webrequest.cpp | 2 ++ 7 files changed, 37 insertions(+), 45 deletions(-) create mode 100644 include/wx/private/webrequest.h diff --git a/include/wx/msw/private/webrequest_winhttp.h b/include/wx/msw/private/webrequest_winhttp.h index 7dd322eb3f..58bfcc52bd 100644 --- a/include/wx/msw/private/webrequest_winhttp.h +++ b/include/wx/msw/private/webrequest_winhttp.h @@ -10,6 +10,8 @@ #ifndef _WX_MSW_WEBREQUEST_WINHTTP_H #define _WX_MSW_WEBREQUEST_WINHTTP_H +#include "wx/private/webrequest.h" + #include "wx/msw/wrapwin.h" #include #include "wx/buffer.h" diff --git a/include/wx/osx/private/webrequest_urlsession.h b/include/wx/osx/private/webrequest_urlsession.h index 06745fb9a4..4d6f3721fa 100644 --- a/include/wx/osx/private/webrequest_urlsession.h +++ b/include/wx/osx/private/webrequest_urlsession.h @@ -12,6 +12,8 @@ #if wxUSE_WEBREQUEST_URLSESSION +#include "wx/private/webrequest.h" + DECLARE_WXCOCOA_OBJC_CLASS(NSURLSession); DECLARE_WXCOCOA_OBJC_CLASS(NSURLSessionTask); DECLARE_WXCOCOA_OBJC_CLASS(wxWebSessionDelegate); diff --git a/include/wx/private/webrequest.h b/include/wx/private/webrequest.h new file mode 100644 index 0000000000..c4746f7fe9 --- /dev/null +++ b/include/wx/private/webrequest.h @@ -0,0 +1,25 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/private/webrequest.h +// Purpose: wxWebRequest implementation classes +// Author: Vadim Zeitlin +// Created: 2020-12-26 +// Copyright: (c) 2020 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_PRIVATE_WEBREQUEST_H_ +#define _WX_PRIVATE_WEBREQUEST_H_ + +// ---------------------------------------------------------------------------- +// wxWebSessionFactory +// ---------------------------------------------------------------------------- + +class wxWebSessionFactory +{ +public: + virtual wxWebSession* Create() = 0; + + virtual ~wxWebSessionFactory() { } +}; + +#endif // _WX_PRIVATE_WEBREQUEST_H_ diff --git a/include/wx/private/webrequest_curl.h b/include/wx/private/webrequest_curl.h index f3659866db..c88e1d16db 100644 --- a/include/wx/private/webrequest_curl.h +++ b/include/wx/private/webrequest_curl.h @@ -12,6 +12,8 @@ #if wxUSE_WEBREQUEST_CURL +#include "wx/private/webrequest.h" + #include "wx/thread.h" #include "wx/vector.h" diff --git a/include/wx/webrequest.h b/include/wx/webrequest.h index 7cc8417bdc..8195d99a91 100644 --- a/include/wx/webrequest.h +++ b/include/wx/webrequest.h @@ -26,6 +26,7 @@ class wxWebResponse; class wxWebSession; +class wxWebSessionFactory; class wxWebAuthChallenge; WX_DECLARE_STRING_HASH_MAP(wxString, wxWebRequestHeaderMap); @@ -195,14 +196,6 @@ private: wxDECLARE_NO_COPY_CLASS(wxWebAuthChallenge); }; -class WXDLLIMPEXP_NET wxWebSessionFactory -{ -public: - virtual wxWebSession* Create() = 0; - - virtual ~wxWebSessionFactory() { } -}; - extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[]; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[]; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[]; @@ -228,9 +221,6 @@ public: static wxWebSession* New(const wxString& backend = wxWebSessionBackendDefault); - static void RegisterFactory(const wxString& backend, - const wxSharedPtr& factory); - static bool IsBackendAvailable(const wxString& backend); protected: @@ -239,6 +229,9 @@ protected: const wxWebRequestHeaderMap& GetHeaders() const { return m_headers; } private: + static void RegisterFactory(const wxString& backend, + const wxSharedPtr& factory); + // Make it a friend to allow accessing our m_headers. friend class wxWebRequest; diff --git a/interface/wx/webrequest.h b/interface/wx/webrequest.h index 8172458560..76ea78de21 100644 --- a/interface/wx/webrequest.h +++ b/interface/wx/webrequest.h @@ -507,17 +507,6 @@ public: */ static wxWebSession* New(const wxString& backend = wxWebSessionBackendDefault); - /** - Allows the registering of new backend for wxWebSession. - - backend can be used as an argument to New(). - - @param backend The name for the new backend to be registered under - @param factory A shared pointer to the factory which creates the appropriate backend. - */ - static void RegisterFactory(const wxString& backend, - const wxSharedPtr& factory); - /** Allows to check if the specified backend is available at runtime. @@ -527,29 +516,6 @@ public: static bool IsBackendAvailable(const wxString& backend); }; -/** - @class wxWebSessionFactory - - An abstract factory class for creation wxWebSession backends. - - Each implementation of wxWebSession should have its own factory. - - @since 3.1.5 - - @library{wxnet} - @category{net} - - @see wxWebSession -*/ -class wxWebSessionFactory -{ -public: - /** - Creates a new web session object. - */ - virtual wxWebSession* Create(); -}; - /** @class wxWebRequestEvent diff --git a/src/common/webrequest.cpp b/src/common/webrequest.cpp index ecd4e4d7b5..3f6b02cdb1 100644 --- a/src/common/webrequest.cpp +++ b/src/common/webrequest.cpp @@ -27,6 +27,8 @@ #include "wx/utils.h" #endif +#include "wx/private/webrequest.h" + #if wxUSE_WEBREQUEST_WINHTTP #include "wx/msw/private/webrequest_winhttp.h" #endif