UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DownloadService.fake.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
7#include "Async/Async.h"
8#include "Async/Future.h"
10
11#if WITH_DEV_AUTOMATION_TESTS
12
13#include "Data/ChunkData.h"
14
15namespace BuildPatchServices
16{
19 {
20 public:
22
23 public:
26 {
27 }
28
30 {
32 }
33
34 public:
35 void StartService()
36 {
37 ThreadLock.Lock();
38 bRunDownloadThread = true;
39 ThreadLock.Unlock();
40 TFunction<void()> Task = [this]()
41 {
42 bool bKeepRunning = true;
45 while (bKeepRunning)
46 {
47 ThreadLock.Lock();
48 for (int32 Idx = IndicesTaken; Idx < RxRequestFile.Num(); ++Idx)
49 {
51 if (TxRequestFile.Num() > 0)
52 {
53 Responses.Add(RxToBeProcessed.Last().Get<1>(), TxRequestFile[0]);
54 TxRequestFile.RemoveAt(0);
55 }
56 else
57 {
58 Responses.Add(RxToBeProcessed.Last().Get<1>(), FTxRequestFile(0.0f, true, EHttpResponseCodes::Ok, DefaultChunkHeader));
59 }
60 IndicesTaken = Idx + 1;
61 }
62 ThreadLock.Unlock();
64 const double TimeNow = FStatsCollector::GetSeconds();
65 for (int32 Idx = 0; Idx < RxToConsider.Num(); ++Idx)
66 {
67 FRequestFile& RequestFile = RxToConsider[Idx];
68 FTxRequestFile& ResponseFile = Responses[RequestFile.Get<1>()];
69 const double Elapsed = TimeNow - RequestFile.Get<0>();
70 const double Desired = ResponseFile.Get<0>();
71 if (Elapsed >= Desired)
72 {
74 MockDownload->bSuccess = ResponseFile.Get<1>();
75 if (MockDownload->bSuccess)
76 {
77 MockDownload->ResponseCode = ResponseFile.Get<2>();
79 Ar << ResponseFile.Get<3>();
80 Ar.Close();
81 MockDownload->Data.AddUninitialized(ResponseFile.Get<3>().DataSizeCompressed);
82 RequestFile.Get<4>().ExecuteIfBound(RequestFile.Get<1>(), MockDownload->Data.Num() / 3);
83 RequestFile.Get<4>().ExecuteIfBound(RequestFile.Get<1>(), MockDownload->Data.Num() / 2);
84 RequestFile.Get<4>().ExecuteIfBound(RequestFile.Get<1>(), MockDownload->Data.Num());
85 }
86 else
87 {
88 MockDownload->ResponseCode = EHttpResponseCodes::Unknown;
89 }
90 RequestFile.Get<3>().ExecuteIfBound(RequestFile.Get<1>(), MakeShareable(MockDownload));
91 }
92 else
93 {
94 RxToBeProcessed.Push(MoveTemp(RequestFile));
95 }
96 }
97 FPlatformProcess::Sleep(0.0f);
98 ThreadLock.Lock();
100 ThreadLock.Unlock();
101 }
102 };
104 }
105
106 void StopService()
107 {
108 ThreadLock.Lock();
109 bRunDownloadThread = false;
110 ThreadLock.Unlock();
111 if (Future.IsValid())
112 {
113 Future.Wait();
114 }
115 }
116
117 public:
119 TFuture<void> Future;
123 };
124}
125
126#endif //WITH_DEV_AUTOMATION_TESTS
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
SharedPointerInternals::TRawPtrProxy< ObjectType > MakeShareable(ObjectType *InObject)
Definition SharedPointer.h:1947
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition MemoryWriter.h:101
Definition Array.h:670
UE_NODEBUG UE_FORCEINLINE_HINT void Push(ElementType &&Item)
Definition Array.h:1224
Definition AndroidPlatformMisc.h:14
Definition Future.h:393
Definition UnrealString.h.inl:34
Definition BuildPatchFileConstructor.h:28
@ false
Definition radaudio_common.h:23
Definition AudioWaveFormatParser.h:25
Definition Tuple.h:652