Make the FileSource available from the ThreadContext

For now we set the FileSource for the Worker context
but in the future after fixing #1664 we can assert()
that FileSource are set only for the Map thread context.
This commit is contained in:
Thiago Marcos P. Santos
2015-06-24 18:40:46 +03:00
parent b56c356de7
commit be4cb6786b
13 changed files with 51 additions and 32 deletions

View File

@@ -1,6 +1,5 @@
#include <mbgl/map/source.hpp>
#include <mbgl/map/map_data.hpp>
#include <mbgl/map/environment.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/map/tile.hpp>
#include <mbgl/renderer/painter.hpp>
@@ -11,6 +10,7 @@
#include <mbgl/util/math.hpp>
#include <mbgl/util/box.hpp>
#include <mbgl/util/mapbox.hpp>
#include <mbgl/storage/file_source.hpp>
#include <mbgl/style/style_layer.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/util/uv_detail.hpp>
@@ -120,7 +120,7 @@ Source::Source() {}
Source::~Source() {
if (req) {
Environment::Get().cancelRequest(req);
util::ThreadContext::getFileSource()->cancel(req);
}
}
@@ -147,7 +147,8 @@ void Source::load() {
return;
}
req = Environment::Get().request({ Resource::Kind::Source, info.url }, [this](const Response &res) {
FileSource* fs = util::ThreadContext::getFileSource();
req = fs->request({ Resource::Kind::Source, info.url }, util::RunLoop::current.get()->get(), [this](const Response &res) {
req = nullptr;
if (res.status != Response::Successful) {