Replace StateEventProcessor used in wxWebRequest code with lambda
No real changes, just simplify the code now that we can use C++11. This commit is best viewed with Git --color-moved option.
This commit is contained in:
parent
065ff2d2d8
commit
db486eae2e
2 changed files with 12 additions and 32 deletions
|
|
@ -106,15 +106,6 @@ public:
|
|||
|
||||
wxEvtHandler* GetHandler() const { return m_handler; }
|
||||
|
||||
// Called to notify about the state change in the main thread by SetState()
|
||||
// (which can itself be called from a different one).
|
||||
//
|
||||
// It also releases a reference added when switching to the active state by
|
||||
// SetState() when leaving it.
|
||||
//
|
||||
// TODO-C++11: make private when we don't need StateEventProcessor any more.
|
||||
void ProcessStateEvent(wxWebRequest::State state, const wxString& failMsg);
|
||||
|
||||
protected:
|
||||
wxString m_method;
|
||||
wxWebRequest::Storage m_storage;
|
||||
|
|
@ -138,6 +129,14 @@ private:
|
|||
// Called from public Cancel() at most once per object.
|
||||
virtual void DoCancel() = 0;
|
||||
|
||||
// Called to notify about the state change in the main thread by SetState()
|
||||
// (which can itself be called from a different one).
|
||||
//
|
||||
// It also releases a reference added when switching to the active state by
|
||||
// SetState() when leaving it.
|
||||
void ProcessStateEvent(wxWebRequest::State state, const wxString& failMsg);
|
||||
|
||||
|
||||
wxWebSession& m_session;
|
||||
wxEvtHandler* const m_handler;
|
||||
const int m_id;
|
||||
|
|
|
|||
|
|
@ -165,28 +165,6 @@ wxFileOffset wxWebRequestImpl::GetBytesExpectedToReceive() const
|
|||
namespace
|
||||
{
|
||||
|
||||
// Functor used with CallAfter() below.
|
||||
//
|
||||
// TODO-C++11: Replace with a lambda.
|
||||
struct StateEventProcessor
|
||||
{
|
||||
StateEventProcessor(wxWebRequestImpl& request,
|
||||
wxWebRequest::State state,
|
||||
const wxString& failMsg)
|
||||
: m_request(request), m_state(state), m_failMsg(failMsg)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
m_request.ProcessStateEvent(m_state, m_failMsg);
|
||||
}
|
||||
|
||||
wxWebRequestImpl& m_request;
|
||||
const wxWebRequest::State m_state;
|
||||
const wxString m_failMsg;
|
||||
};
|
||||
|
||||
#if wxUSE_LOG_TRACE
|
||||
|
||||
// Tiny helper to log states as strings rather than meaningless numbers.
|
||||
|
|
@ -242,7 +220,10 @@ void wxWebRequestImpl::SetState(wxWebRequest::State state, const wxString & fail
|
|||
}
|
||||
else
|
||||
{
|
||||
m_handler->CallAfter(StateEventProcessor(*this, state, failMsg));
|
||||
m_handler->CallAfter([this, state, failMsg]()
|
||||
{
|
||||
ProcessStateEvent(state, failMsg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue