forked from owncloud/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbandwidthmanager.h
More file actions
106 lines (79 loc) · 3 KB
/
Copy pathbandwidthmanager.h
File metadata and controls
106 lines (79 loc) · 3 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Copyright (C) by Markus Goetz <markus@woboq.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef BANDWIDTHMANAGER_H
#define BANDWIDTHMANAGER_H
#include <QObject>
#include <QTimer>
#include <QIODevice>
#include <list>
namespace OCC {
class UploadDevice;
class GETJob;
class OwncloudPropagator;
/**
* @brief The BandwidthManager class
* @ingroup libsync
*/
class BandwidthManager : public QObject
{
Q_OBJECT
public:
BandwidthManager(OwncloudPropagator *p);
~BandwidthManager() override;
bool usingAbsoluteUploadLimit() { return _currentUploadLimit > 0; }
bool usingRelativeUploadLimit() { return _currentUploadLimit < 0; }
bool usingAbsoluteDownloadLimit() { return _currentDownloadLimit > 0; }
bool usingRelativeDownloadLimit() { return _currentDownloadLimit < 0; }
public slots:
void registerUploadDevice(UploadDevice *);
void unregisterUploadDevice(QObject *);
void registerDownloadJob(GETJob *);
void unregisterDownloadJob(QObject *);
void absoluteLimitTimerExpired();
void switchingTimerExpired();
void relativeUploadMeasuringTimerExpired();
void relativeUploadDelayTimerExpired();
void relativeDownloadMeasuringTimerExpired();
void relativeDownloadDelayTimerExpired();
private:
// for switching between absolute and relative bw limiting
QTimer _switchingTimer;
// FIXME this timer and this variable should be replaced
// by the propagator emitting the changed limit values to us as signal
OwncloudPropagator *_propagator;
// for absolute up/down bw limiting
QTimer _absoluteLimitTimer;
// FIXME merge these two lists
std::list<UploadDevice *> _absoluteUploadDeviceList;
std::list<UploadDevice *> _relativeUploadDeviceList;
QTimer _relativeUploadMeasuringTimer;
// for relative bw limiting, we need to wait this amount before measuring again
QTimer _relativeUploadDelayTimer;
// the device measured
UploadDevice *_relativeLimitCurrentMeasuredDevice;
// for measuring how much progress we made at start
qint64 _relativeUploadLimitProgressAtMeasuringRestart;
qint64 _currentUploadLimit;
std::list<GETJob *> _downloadJobList;
QTimer _relativeDownloadMeasuringTimer;
// for relative bw limiting, we need to wait this amount before measuring again
QTimer _relativeDownloadDelayTimer;
// the device measured
GETJob *_relativeLimitCurrentMeasuredJob;
// for measuring how much progress we made at start
qint64 _relativeDownloadLimitProgressAtMeasuringRestart;
qint64 _currentDownloadLimit;
};
}
#endif