[core] Added modified, expires information to TileData

This commit is contained in:
Bruno de Oliveira Abinader
2015-11-25 15:06:33 +02:00
parent 31fd2822f5
commit 591e0dde2f
10 changed files with 37 additions and 14 deletions

View File

@@ -181,7 +181,7 @@ VectorTileMonitor::VectorTileMonitor(const SourceInfo& source, const TileID& id,
: url(source.tileURL(id, pixelRatio)) {
}
std::unique_ptr<FileRequest> VectorTileMonitor::monitorTile(std::function<void (std::exception_ptr, std::unique_ptr<GeometryTile>)> callback) {
std::unique_ptr<FileRequest> VectorTileMonitor::monitorTile(const GeometryTileMonitor::Callback& callback) {
return util::ThreadContext::getFileSource()->request({ Resource::Kind::Tile, url }, [callback, this](Response res) {
if (res.data && data == res.data) {
// We got the same data again. Abort early.
@@ -190,18 +190,18 @@ std::unique_ptr<FileRequest> VectorTileMonitor::monitorTile(std::function<void (
if (res.error) {
if (res.error->reason == Response::Error::Reason::NotFound) {
callback(nullptr, nullptr);
callback(nullptr, nullptr, res.modified, res.expires);
return;
} else {
std::stringstream message;
message << "Failed to load [" << url << "]: " << res.error->message;
callback(std::make_exception_ptr(std::runtime_error(message.str())), nullptr);
callback(std::make_exception_ptr(std::runtime_error(message.str())), nullptr, res.modified, res.expires);
return;
}
}
data = res.data;
callback(nullptr, std::make_unique<VectorTile>(data));
callback(nullptr, std::make_unique<VectorTile>(data), res.modified, res.expires);
});
}