Remove duplicated code by introduce a private doSetResponseCallback.

This commit is contained in:
Xpol Wan 2015-11-18 17:52:24 +08:00 committed by cesarpachon
parent 4bedfa4f14
commit 520aa9d351
1 changed files with 14 additions and 18 deletions

View File

@ -242,15 +242,7 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_CallFuncND pSelector)
{
// This function have duplicated body with setResponseCallback(Ref* , SEL_HttpResponse )
// You must repeat youself in that function when modified.
_pTarget = pTarget;
_pSelector = (SEL_HttpResponse)pSelector;
if (_pTarget)
{
_pTarget->retain();
}
doSetResponseCallback(pTarget, (SEL_HttpResponse)pSelector);
}
/**
@ -262,15 +254,7 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector)
{
// This function have duplicated body with setResponseCallback(Ref* , SEL_CallFuncND )
// You must repeat youself in that function.
_pTarget = pTarget;
_pSelector = pSelector;
if (_pTarget)
{
_pTarget->retain();
}
doSetResponseCallback(pTarget, pSelector);
}
/**
* Set response callback function of HttpRequest object.
@ -352,6 +336,18 @@ public:
return _headers;
}
private:
inline void doSetResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector)
{
_pTarget = pTarget;
_pSelector = pSelector;
if (_pTarget)
{
_pTarget->retain();
}
}
protected:
// properties
Type _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums