summaryrefslogtreecommitdiff
path: root/platform/default
diff options
context:
space:
mode:
Diffstat (limited to 'platform/default')
-rw-r--r--platform/default/asset_request_fs.cpp6
-rw-r--r--platform/default/asset_request_zip.cpp3
-rw-r--r--platform/default/http_request_curl.cpp8
-rw-r--r--platform/default/sqlite_cache.cpp12
-rw-r--r--platform/default/sqlite_cache_impl.hpp3
5 files changed, 17 insertions, 15 deletions
diff --git a/platform/default/asset_request_fs.cpp b/platform/default/asset_request_fs.cpp
index c169abf2b8..955f8d8020 100644
--- a/platform/default/asset_request_fs.cpp
+++ b/platform/default/asset_request_fs.cpp
@@ -130,12 +130,12 @@ void AssetRequest::fileStated(uv_fs_t *req) {
self->response = std::make_unique<Response>();
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
#ifdef __APPLE__
- self->response->modified = stat->st_mtimespec.tv_sec;
+ self->response->modified = Seconds(stat->st_mtimespec.tv_sec);
#else
- self->response->modified = stat->st_mtime;
+ self->response->modified = Seconds(stat->st_mtime);
#endif
#else
- self->response->modified = stat->st_mtim.tv_sec;
+ self->response->modified = Seconds(stat->st_mtim.tv_sec);
#endif
self->response->etag = util::toString(stat->st_ino);
const auto size = (unsigned int)(stat->st_size);
diff --git a/platform/default/asset_request_zip.cpp b/platform/default/asset_request_zip.cpp
index 2c0c54b6a0..b8007b5693 100644
--- a/platform/default/asset_request_zip.cpp
+++ b/platform/default/asset_request_zip.cpp
@@ -3,6 +3,7 @@
#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/response.hpp>
#include <mbgl/platform/log.hpp>
+#include <mbgl/util/chrono.hpp>
#include <mbgl/util/util.hpp>
#include <mbgl/util/uv.hpp>
@@ -187,7 +188,7 @@ void AssetRequest::fileStated(uv_zip_t *zip) {
// Get the modification time in case we have one.
if (zip->stat->valid & ZIP_STAT_MTIME) {
- response->modified = zip->stat->mtime;
+ response->modified = Seconds(zip->stat->mtime);
}
if (zip->stat->valid & ZIP_STAT_INDEX) {
diff --git a/platform/default/http_request_curl.cpp b/platform/default/http_request_curl.cpp
index 6d4011dd2b..eead6872ae 100644
--- a/platform/default/http_request_curl.cpp
+++ b/platform/default/http_request_curl.cpp
@@ -425,9 +425,9 @@ HTTPCURLRequest::HTTPCURLRequest(HTTPCURLContext* context_, const Resource& reso
if (!existingResponse->etag.empty()) {
const std::string header = std::string("If-None-Match: ") + existingResponse->etag;
headers = curl_slist_append(headers, header.c_str());
- } else if (existingResponse->modified) {
+ } else if (existingResponse->modified != Seconds::zero()) {
const std::string time =
- std::string("If-Modified-Since: ") + util::rfc1123(existingResponse->modified);
+ std::string("If-Modified-Since: ") + util::rfc1123(existingResponse->modified.count());
headers = curl_slist_append(headers, time.c_str());
}
}
@@ -525,7 +525,7 @@ size_t HTTPCURLRequest::headerCallback(char *const buffer, const size_t size, co
// Always overwrite the modification date; We might already have a value here from the
// Date header, but this one is more accurate.
const std::string value { buffer + begin, length - begin - 2 }; // remove \r\n
- baton->response->modified = curl_getdate(value.c_str(), nullptr);
+ baton->response->modified = Seconds(curl_getdate(value.c_str(), nullptr));
} else if ((begin = headerMatches("etag: ", buffer, length)) != std::string::npos) {
baton->response->etag = { buffer + begin, length - begin - 2 }; // remove \r\n
} else if ((begin = headerMatches("cache-control: ", buffer, length)) != std::string::npos) {
@@ -533,7 +533,7 @@ size_t HTTPCURLRequest::headerCallback(char *const buffer, const size_t size, co
baton->response->expires = parseCacheControl(value.c_str());
} else if ((begin = headerMatches("expires: ", buffer, length)) != std::string::npos) {
const std::string value { buffer + begin, length - begin - 2 }; // remove \r\n
- baton->response->expires = curl_getdate(value.c_str(), nullptr);
+ baton->response->expires = Seconds(curl_getdate(value.c_str(), nullptr));
}
return length;
diff --git a/platform/default/sqlite_cache.cpp b/platform/default/sqlite_cache.cpp
index 126e915e9b..1ca278b8f5 100644
--- a/platform/default/sqlite_cache.cpp
+++ b/platform/default/sqlite_cache.cpp
@@ -118,9 +118,9 @@ void SQLiteCache::Impl::get(const Resource &resource, Callback callback) {
// Status codes > 1 indicate an error
response->error = std::make_unique<Response::Error>(Response::Error::Reason(status));
}
- response->modified = getStmt->get<int64_t>(1);
+ response->modified = Seconds(getStmt->get<Seconds::rep>(1));
response->etag = getStmt->get<std::string>(2);
- response->expires = getStmt->get<int64_t>(3);
+ response->expires = Seconds(getStmt->get<Seconds::rep>(3));
response->data = std::make_shared<std::string>(std::move(getStmt->get<std::string>(4)));
if (getStmt->get<int>(5)) { // == compressed
response->data = std::make_shared<std::string>(std::move(util::decompress(*response->data)));
@@ -177,9 +177,9 @@ void SQLiteCache::Impl::put(const Resource& resource, std::shared_ptr<const Resp
putStmt->bind(2 /* status */, 1 /* success */);
}
putStmt->bind(3 /* kind */, int(resource.kind));
- putStmt->bind(4 /* modified */, response->modified);
+ putStmt->bind(4 /* modified */, response->modified.count());
putStmt->bind(5 /* etag */, response->etag.c_str());
- putStmt->bind(6 /* expires */, response->expires);
+ putStmt->bind(6 /* expires */, response->expires.count());
std::string data;
if (resource.kind != Resource::SpriteImage && response->data) {
@@ -208,7 +208,7 @@ void SQLiteCache::Impl::put(const Resource& resource, std::shared_ptr<const Resp
}
}
-void SQLiteCache::Impl::refresh(const Resource& resource, int64_t expires) {
+void SQLiteCache::Impl::refresh(const Resource& resource, Seconds expires) {
try {
if (!db) {
createDatabase();
@@ -226,7 +226,7 @@ void SQLiteCache::Impl::refresh(const Resource& resource, int64_t expires) {
}
const auto canonicalURL = util::mapbox::canonicalURL(resource.url);
- refreshStmt->bind(1, int64_t(expires));
+ refreshStmt->bind(1, expires.count());
refreshStmt->bind(2, canonicalURL.c_str());
refreshStmt->run();
} catch (mapbox::sqlite::Exception& ex) {
diff --git a/platform/default/sqlite_cache_impl.hpp b/platform/default/sqlite_cache_impl.hpp
index 700771f2e8..f557666e3f 100644
--- a/platform/default/sqlite_cache_impl.hpp
+++ b/platform/default/sqlite_cache_impl.hpp
@@ -2,6 +2,7 @@
#define MBGL_STORAGE_DEFAULT_SQLITE_CACHE_IMPL
#include <mbgl/storage/sqlite_cache.hpp>
+#include <mbgl/util/chrono.hpp>
namespace mapbox {
namespace sqlite {
@@ -19,7 +20,7 @@ public:
void get(const Resource&, Callback);
void put(const Resource& resource, std::shared_ptr<const Response> response);
- void refresh(const Resource& resource, int64_t expires);
+ void refresh(const Resource& resource, Seconds expires);
private:
void createDatabase();