Process event about the request becoming active synchronously
This is required in order to allow doing something with the request when it already have a valid native handle, but hasn't actually started yet.
This commit is contained in:
@@ -137,7 +137,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
State_Unauthorized,
|
State_Unauthorized,
|
||||||
|
|
||||||
/// The request has been started and is transferring data
|
/**
|
||||||
|
The request is about to start.
|
||||||
|
|
||||||
|
An event notifying about the switch to this state is generated when
|
||||||
|
Start() is called (unless an error occurs, in which case the state
|
||||||
|
becomes State_Failed instead). Handling this event allows to do
|
||||||
|
something right before the asynchronous request actually starts.
|
||||||
|
*/
|
||||||
State_Active,
|
State_Active,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -222,6 +229,11 @@ public:
|
|||||||
- For CURL backend, this is a @c CURL struct pointer.
|
- For CURL backend, this is a @c CURL struct pointer.
|
||||||
- For macOS backend, this is @c NSURLSessionTask object pointer.
|
- For macOS backend, this is @c NSURLSessionTask object pointer.
|
||||||
|
|
||||||
|
Note that this function returns a valid value only after the request is
|
||||||
|
started successfully using Start(). Notably, it is guaranteed to return
|
||||||
|
a valid value when handling wxWebRequestEvent corresponding to the
|
||||||
|
switch to @c State_Active.
|
||||||
|
|
||||||
@see wxWebSession::GetNativeHandle()
|
@see wxWebSession::GetNativeHandle()
|
||||||
*/
|
*/
|
||||||
wxWebRequestHandle GetNativeHandle() const;
|
wxWebRequestHandle GetNativeHandle() const;
|
||||||
|
@@ -208,8 +208,21 @@ void wxWebRequestImpl::SetState(wxWebRequest::State state, const wxString & fail
|
|||||||
|
|
||||||
m_state = state;
|
m_state = state;
|
||||||
|
|
||||||
// Trigger the event in the main thread
|
// Trigger the event in the main thread except when switching to the active
|
||||||
m_handler->CallAfter(StateEventProcessor(*this, state, failMsg));
|
// state because this always happens in the main thread anyhow and it's
|
||||||
|
// important to process it synchronously, before the request actually
|
||||||
|
// starts (this gives the possibility to modify the request using native
|
||||||
|
// functions, for example, as its GetNativeHandle() is already valid).
|
||||||
|
if ( state == wxWebRequest::State_Active )
|
||||||
|
{
|
||||||
|
wxASSERT( wxIsMainThread() );
|
||||||
|
|
||||||
|
ProcessStateEvent(state, failMsg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_handler->CallAfter(StateEventProcessor(*this, state, failMsg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWebRequestImpl::ReportDataReceived(size_t sizeReceived)
|
void wxWebRequestImpl::ReportDataReceived(size_t sizeReceived)
|
||||||
|
Reference in New Issue
Block a user