2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Use crl::time/now instead of TimeMs/getms.

This commit is contained in:
John Preston
2019-02-19 10:57:53 +04:00
parent d208236994
commit fe618bd652
310 changed files with 1133 additions and 1141 deletions

View File

@@ -27,8 +27,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace MTP {
namespace {
constexpr auto kConfigBecomesOldIn = 2 * 60 * TimeMs(1000);
constexpr auto kConfigBecomesOldForBlockedIn = 8 * TimeMs(1000);
constexpr auto kConfigBecomesOldIn = 2 * 60 * crl::time(1000);
constexpr auto kConfigBecomesOldForBlockedIn = 8 * crl::time(1000);
} // namespace
@@ -85,7 +85,7 @@ public:
SecureRequest &&request,
RPCResponseHandler &&callbacks,
ShiftedDcId shiftedDcId,
TimeMs msCanWait,
crl::time msCanWait,
bool needsLayer,
mtpRequestId afterRequestId);
void registerRequest(mtpRequestId requestId, ShiftedDcId shiftedDcId);
@@ -145,7 +145,7 @@ private:
void applyDomainIps(
const QString &host,
const QStringList &ips,
TimeMs expireAt);
crl::time expireAt);
void logoutGuestDcs();
bool logoutGuestDone(mtpRequestId requestId);
@@ -188,8 +188,8 @@ private:
std::unique_ptr<DomainResolver> _domainResolver;
QString _userPhone;
mtpRequestId _cdnConfigLoadRequestId = 0;
TimeMs _lastConfigLoadedTime = 0;
TimeMs _configExpiresAt = 0;
crl::time _lastConfigLoadedTime = 0;
crl::time _configExpiresAt = 0;
std::map<DcId, AuthKeyPtr> _keysForWrite;
mutable QReadWriteLock _keysForWriteLock;
@@ -209,7 +209,7 @@ private:
std::map<mtpRequestId, SecureRequest> _requestMap;
QReadWriteLock _requestMapLock;
std::deque<std::pair<mtpRequestId, TimeMs>> _delayedRequests;
std::deque<std::pair<mtpRequestId, crl::time>> _delayedRequests;
std::map<mtpRequestId, int> _requestsDelays;
@@ -298,7 +298,7 @@ void Instance::Private::resolveProxyDomain(const QString &host) {
_domainResolver = std::make_unique<DomainResolver>([=](
const QString &host,
const QStringList &ips,
TimeMs expireAt) {
crl::time expireAt) {
applyDomainIps(host, ips, expireAt);
});
}
@@ -308,7 +308,7 @@ void Instance::Private::resolveProxyDomain(const QString &host) {
void Instance::Private::applyDomainIps(
const QString &host,
const QStringList &ips,
TimeMs expireAt) {
crl::time expireAt) {
const auto applyToProxy = [&](ProxyData &proxy) {
if (!proxy.tryCustomResolve() || proxy.host != host) {
return false;
@@ -430,16 +430,16 @@ void Instance::Private::requestConfigIfOld() {
const auto timeout = Global::BlockedMode()
? kConfigBecomesOldForBlockedIn
: kConfigBecomesOldIn;
if (getms(true) - _lastConfigLoadedTime >= timeout) {
if (crl::now() - _lastConfigLoadedTime >= timeout) {
requestConfig();
}
}
void Instance::Private::requestConfigIfExpired() {
const auto requestIn = (_configExpiresAt - getms(true));
const auto requestIn = (_configExpiresAt - crl::now());
if (requestIn > 0) {
App::CallDelayed(
std::min(requestIn, 3600 * TimeMs(1000)),
std::min(requestIn, 3600 * crl::time(1000)),
_instance,
[=] { requestConfigIfExpired(); });
} else {
@@ -745,7 +745,7 @@ void Instance::Private::configLoadDone(const MTPConfig &result) {
Expects(result.type() == mtpc_config);
_configLoader.reset();
_lastConfigLoadedTime = getms(true);
_lastConfigLoadedTime = crl::now();
const auto &data = result.c_config();
DEBUG_LOG(("MTP Info: got config, chat_size_max: %1, date: %2, test_mode: %3, this_dc: %4, dc_options.length: %5").arg(data.vchat_size_max.v).arg(data.vdate.v).arg(mtpIsTrue(data.vtest_mode)).arg(data.vthis_dc.v).arg(data.vdc_options.v.size()));
@@ -806,8 +806,8 @@ void Instance::Private::configLoadDone(const MTPConfig &result) {
}
Local::writeSettings();
_configExpiresAt = getms(true)
+ (data.vexpires.v - unixtime()) * TimeMs(1000);
_configExpiresAt = crl::now()
+ (data.vexpires.v - unixtime()) * crl::time(1000);
requestConfigIfExpired();
emit _instance->configLoaded();
@@ -848,7 +848,7 @@ std::optional<ShiftedDcId> Instance::Private::changeRequestByDc(
}
void Instance::Private::checkDelayedRequests() {
auto now = getms(true);
auto now = crl::now();
while (!_delayedRequests.empty() && now >= _delayedRequests.front().second) {
auto requestId = _delayedRequests.front().first;
_delayedRequests.pop_front();
@@ -885,7 +885,7 @@ void Instance::Private::sendRequest(
SecureRequest &&request,
RPCResponseHandler &&callbacks,
ShiftedDcId shiftedDcId,
TimeMs msCanWait,
crl::time msCanWait,
bool needsLayer,
mtpRequestId afterRequestId) {
const auto session = getSession(shiftedDcId);
@@ -901,7 +901,7 @@ void Instance::Private::sendRequest(
if (afterRequestId) {
request->after = getRequest(afterRequestId);
}
request->msDate = getms(true); // > 0 - can send without container
request->msDate = crl::now(); // > 0 - can send without container
request->needsLayer = needsLayer;
session->sendPrepared(request, msCanWait);
@@ -1294,7 +1294,7 @@ bool Instance::Private::onErrorDefault(mtpRequestId requestId, const RPCError &e
secs = m.captured(1).toInt();
// if (secs >= 60) return false;
}
auto sendAt = getms(true) + secs * 1000 + 10;
auto sendAt = crl::now() + secs * 1000 + 10;
auto it = _delayedRequests.begin(), e = _delayedRequests.end();
for (; it != e; ++it) {
if (it->first == requestId) return true;
@@ -1737,7 +1737,7 @@ void Instance::sendRequest(
SecureRequest &&request,
RPCResponseHandler &&callbacks,
ShiftedDcId shiftedDcId,
TimeMs msCanWait,
crl::time msCanWait,
bool needsLayer,
mtpRequestId afterRequestId) {
return _private->sendRequest(
@@ -1750,7 +1750,7 @@ void Instance::sendRequest(
afterRequestId);
}
void Instance::sendAnything(ShiftedDcId shiftedDcId, TimeMs msCanWait) {
void Instance::sendAnything(ShiftedDcId shiftedDcId, crl::time msCanWait) {
const auto session = _private->getSession(shiftedDcId);
session->sendAnything(msCanWait);
}