summaryrefslogtreecommitdiff
path: root/replay/cl_sessionblockdownloader.h
blob: 354ef3fba10dbdac3bf56b719bf5827157c33739 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//----------------------------------------------------------------------------------------

#ifndef CL_SESSIONBLOCKDOWNLOADER_H
#define CL_SESSIONBLOCKDOWNLOADER_H
#ifdef _WIN32
#pragma once
#endif

//----------------------------------------------------------------------------------------

#include "utllinkedlist.h"
#include "cl_downloader.h"
#include "basethinker.h"
#include "replay/replayhandle.h"

//----------------------------------------------------------------------------------------

class CClientRecordingSession;

//----------------------------------------------------------------------------------------

//
// Downloads multiple session blocks concurrently and updates their status.
//
class CSessionBlockDownloader : public CBaseThinker,
								public IDownloadHandler
{
public:
	CSessionBlockDownloader();

	void				Shutdown();
	void				Think();

	// If pSession is NULL, all remaining downloads will affected.
	void				AbortDownloadsAndCleanup( CClientRecordingSession *pSession );

private:
	bool				AtMaxConcurrentDownloads() const;

	//
	// CBaseThinker
	//
	virtual float		GetNextThinkTime() const;

	//
	// IDownloadHandler
	//
	virtual void		OnConnecting( CHttpDownloader *pDownloader );
	virtual void		OnFetch( CHttpDownloader *pDownloader );
	virtual void		OnDownloadComplete( CHttpDownloader *pDownloader, const unsigned char *pData );

	static int			sm_nNumCurrentDownloads;

	CUtlLinkedList< CHttpDownloader	*, int > m_lstDownloaders;
	int					m_nMaxBlock;

	friend class CErrorSystem;
};

//----------------------------------------------------------------------------------------

#endif // CL_SESSIONBLOCKDOWNLOADER_H