Merge branch 'master' into android-mason

Conflicts:
	gyp/mbgl-ios.gypi
	gyp/mbgl-linux.gypi
	gyp/mbgl-osx.gypi
	platform/default/caching_http_file_source.cpp
This commit is contained in:
Mike Morris
2014-12-03 13:07:49 -05:00
12 changed files with 150 additions and 72 deletions

View File

@@ -34,7 +34,7 @@ class Map : private util::noncopyable {
typedef void (*stop_callback)(void *);
public:
explicit Map(View &view);
explicit Map(View&, FileSource&);
~Map();
// Start the map render thread. It is asynchronous.
@@ -197,7 +197,7 @@ private:
Transform transform;
TransformState state;
util::ptr<FileSource> fileSource;
FileSource& fileSource;
util::ptr<Style> style;
GlyphAtlas glyphAtlas;

View File

@@ -0,0 +1,52 @@
#ifndef MBGL_STORAGE_CACHING_HTTP_FILE_SOURCE
#define MBGL_STORAGE_CACHING_HTTP_FILE_SOURCE
#include <mbgl/storage/file_source.hpp>
#include <unordered_map>
typedef struct uv_messenger_s uv_messenger_t;
namespace mbgl {
class BaseRequest;
class SQLiteStore;
class CachingHTTPFileSource : public FileSource {
public:
CachingHTTPFileSource(uv_loop_t*, const std::string &path_);
CachingHTTPFileSource(const std::string &path_);
~CachingHTTPFileSource();
// Stores and checks the libuv loop for requests
void setLoop(uv_loop_t*);
bool hasLoop();
// Stores and retrieves the base path/URL for relative requests
void setBase(const std::string &value);
const std::string &getBase() const;
std::unique_ptr<Request> request(ResourceType type, const std::string &url);
void prepare(std::function<void()> fn);
void retryAllPending();
private:
unsigned long thread_id;
// Path to the cache database.
std::string path;
// Stores a URL that is used as a base for loading resources with relative path.
std::string base;
std::unordered_map<std::string, std::weak_ptr<BaseRequest>> pending;
util::ptr<SQLiteStore> store;
uv_loop_t *loop = nullptr;
uv_messenger_t *queue = nullptr;
};
}
#endif

View File

@@ -1,48 +1,25 @@
#ifndef MBGL_STORAGE_FILE_SOURCE
#define MBGL_STORAGE_FILE_SOURCE
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/storage/resource_type.hpp>
#include <mbgl/storage/request.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <string>
#include <unordered_map>
#include <functional>
typedef struct uv_loop_s uv_loop_t;
typedef struct uv_messenger_s uv_messenger_t;
namespace mbgl {
class BaseRequest;
class SQLiteStore;
class FileSource : public util::noncopyable {
private:
public:
FileSource(uv_loop_t *loop, const std::string &path);
~FileSource();
// Stores and retrieves the base path/URL for relative requests
void setBase(const std::string &value);
const std::string &getBase() const;
std::unique_ptr<Request> request(ResourceType type, const std::string &url);
void prepare(std::function<void()> fn);
void retryAllPending();
private:
const unsigned long thread_id;
// Stores a URL that is used as a base for loading resources with relative path.
std::string base;
std::unordered_map<std::string, std::weak_ptr<BaseRequest>> pending;
util::ptr<SQLiteStore> store;
uv_loop_t *loop = nullptr;
uv_messenger_t *queue = nullptr;
virtual void setLoop(uv_loop_t*) = 0;
virtual bool hasLoop() = 0;
virtual void setBase(const std::string &value) = 0;
virtual std::unique_ptr<Request> request(ResourceType type, const std::string &url) = 0;
virtual void prepare(std::function<void()> fn) = 0;
virtual void retryAllPending() = 0;
};
}