From 877141ff945b7c541f48db24e6bdba93289a1eef Mon Sep 17 00:00:00 2001 From: hillin Date: Thu, 2 Mar 2017 11:26:48 +0800 Subject: [PATCH] remove the redundant HTTPRequest ticker --- .../JavascriptHttp/JavascriptHttpRequest.cpp | 41 ++----------------- Source/JavascriptHttp/JavascriptHttpRequest.h | 12 +++--- 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/Source/JavascriptHttp/JavascriptHttpRequest.cpp b/Source/JavascriptHttp/JavascriptHttpRequest.cpp index 9160d180..b37a7bae 100644 --- a/Source/JavascriptHttp/JavascriptHttpRequest.cpp +++ b/Source/JavascriptHttp/JavascriptHttpRequest.cpp @@ -2,38 +2,6 @@ #include "JavascriptHttpRequest.h" #include "JavascriptContext.h" -#if WITH_EDITOR -#include "TickableEditorObject.h" -typedef FTickableEditorObject FTickableRequest; -#else -#include "Tickable.h" -typedef FTickableGameObject FTickableRequest; -#endif - -struct FHttpProcessor : public FTickableRequest -{ -public: - FHttpProcessor(TSharedPtr InRef) - : Ref(InRef) - {} - - TSharedPtr Ref; - - virtual void Tick(float DeltaTime) override - { - Ref->Tick(DeltaTime); - } - - virtual bool IsTickable() const override - { - return true; - } - - virtual TStatId GetStatId() const override - { - RETURN_QUICK_DECLARE_CYCLE_STAT(JavascriptHttpRequest, STATGROUP_Tickables); - } -}; UJavascriptHttpRequest::UJavascriptHttpRequest(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -48,7 +16,7 @@ void UJavascriptHttpRequest::BeginDestroy() { Super::BeginDestroy(); - if (IsProcessing()) + if (GetIsProcessing()) { EndProcessing(); } @@ -58,14 +26,11 @@ void UJavascriptHttpRequest::BeginDestroy() void UJavascriptHttpRequest::BeginProcessing() { - Processor = new FHttpProcessor(Request); + IsProcessing = true; } void UJavascriptHttpRequest::EndProcessing() { - delete Processor; - Processor = nullptr; - Request->OnProcessRequestComplete().Unbind(); Request->OnRequestProgress().Unbind(); } @@ -104,7 +69,7 @@ void UJavascriptHttpRequest::SetHeader(const FString& HeaderName, const FString& bool UJavascriptHttpRequest::ProcessRequest() { - if (IsProcessing()) return false; + if (GetIsProcessing()) return false; Request->OnProcessRequestComplete().BindLambda([&](FHttpRequestPtr, FHttpResponsePtr, bool status){ OnComplete.ExecuteIfBound(status); diff --git a/Source/JavascriptHttp/JavascriptHttpRequest.h b/Source/JavascriptHttp/JavascriptHttpRequest.h index 77aff56d..62223701 100644 --- a/Source/JavascriptHttp/JavascriptHttpRequest.h +++ b/Source/JavascriptHttp/JavascriptHttpRequest.h @@ -21,8 +21,6 @@ namespace EJavascriptHttpRequestStatus }; } -struct FHttpProcessor; - /** * */ @@ -31,6 +29,10 @@ class JAVASCRIPTHTTP_API UJavascriptHttpRequest : public UObject { GENERATED_UCLASS_BODY() +private: + + bool IsProcessing; + public: TSharedPtr Request; @@ -169,10 +171,8 @@ class JAVASCRIPTHTTP_API UJavascriptHttpRequest : public UObject float GetElapsedTime(); virtual void BeginDestroy() override; - - FHttpProcessor* Processor{nullptr}; - - bool IsProcessing() { return Processor != nullptr; } + + bool GetIsProcessing() const { return IsProcessing; } void BeginProcessing(); void EndProcessing();