Initial NSURLSession implementation
First incomplete implementation based on NSURLSession
This commit is contained in:
@@ -13,28 +13,98 @@
|
||||
#if wxUSE_WEBREQUEST_URLSESSION
|
||||
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(NSURLSession);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(NSURLTask);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(NSURLSessionTask);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(wxWebSessionDelegte);
|
||||
|
||||
class wxWebSessionURLSession;
|
||||
class wxWebResponseURLSession;
|
||||
|
||||
class WXDLLIMPEXP_NET wxWebResponseURLSession: public wxWebResponse
|
||||
{
|
||||
public:
|
||||
wxWebResponseURLSession(wxWebRequest& request, WX_NSURLSessionTask task);
|
||||
|
||||
~wxWebResponseURLSession();
|
||||
|
||||
wxInt64 GetContentLength() const wxOVERRIDE;
|
||||
|
||||
wxString GetURL() const wxOVERRIDE;
|
||||
|
||||
wxString GetHeader(const wxString& name) const wxOVERRIDE;
|
||||
|
||||
int GetStatus() const wxOVERRIDE;
|
||||
|
||||
wxString GetStatusText() const wxOVERRIDE;
|
||||
|
||||
wxString GetSuggestedFileName() const wxOVERRIDE;
|
||||
|
||||
void HandleData(WX_NSData data);
|
||||
|
||||
private:
|
||||
WX_NSURLSessionTask m_task;
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_NET wxWebRequestURLSession: public wxWebRequest
|
||||
{
|
||||
public:
|
||||
wxWebRequestURLSession(wxWebSessionURLSession& session, const wxString& url, int id);
|
||||
|
||||
~wxWebRequestURLSession();
|
||||
|
||||
void Start() wxOVERRIDE;
|
||||
|
||||
void Cancel() wxOVERRIDE;
|
||||
|
||||
wxWebResponse* GetResponse() const wxOVERRIDE
|
||||
{ return m_response.get(); }
|
||||
|
||||
wxWebAuthChallenge* GetAuthChallenge() const wxOVERRIDE;
|
||||
|
||||
wxFileOffset GetBytesSent() const wxOVERRIDE;
|
||||
|
||||
wxFileOffset GetBytesExpectedToSend() const wxOVERRIDE;
|
||||
|
||||
wxFileOffset GetBytesReceived() const wxOVERRIDE;
|
||||
|
||||
wxFileOffset GetBytesExpectedToReceive() const wxOVERRIDE;
|
||||
|
||||
void HandleCompletion();
|
||||
|
||||
private:
|
||||
wxString m_url;
|
||||
WX_NSURLSessionTask m_task;
|
||||
wxScopedPtr<wxWebResponseURLSession> m_response;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxWebRequestURLSession);
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_NET wxWebSessionURLSession: public wxWebSession
|
||||
{
|
||||
public:
|
||||
wxWebSessionURLSession();
|
||||
wxWebSessionURLSession();
|
||||
|
||||
~wxWebSessionURLSession();
|
||||
~wxWebSessionURLSession();
|
||||
|
||||
wxWebRequest* CreateRequest(const wxString& url, int id = wxID_ANY) wxOVERRIDE;
|
||||
wxWebRequest* CreateRequest(const wxString& url, int id = wxID_ANY) wxOVERRIDE;
|
||||
|
||||
wxVersionInfo GetLibraryVersionInfo() wxOVERRIDE;
|
||||
|
||||
WX_NSURLSession GetSession() { return m_session; }
|
||||
|
||||
WX_wxWebSessionDelegte GetDelegate() { return m_delegate; }
|
||||
|
||||
private:
|
||||
WX_NSURLSession m_session;
|
||||
WX_NSURLSession m_session;
|
||||
WX_wxWebSessionDelegte m_delegate;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxWebSessionURLSession);
|
||||
wxDECLARE_NO_COPY_CLASS(wxWebSessionURLSession);
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_NET wxWebSessionFactoryURLSession: public wxWebSessionFactory
|
||||
{
|
||||
public:
|
||||
wxWebSession* Create() wxOVERRIDE
|
||||
{ return new wxWebSessionURLSession(); }
|
||||
wxWebSession* Create() wxOVERRIDE
|
||||
{ return new wxWebSessionURLSession(); }
|
||||
};
|
||||
|
||||
#endif // wxUSE_WEBREQUEST_URLSESSION
|
||||
|
Reference in New Issue
Block a user