From dac76a0f9269a580706e52b730a98f9b1430bcdf Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 25 Nov 2014 14:18:47 -0500 Subject: [PATCH] break out FileSource as an abstract class add CachingHTTPFileSource implementation --- gyp/mbgl-headless.gypi | 20 +++++++ gyp/mbgl-ios.gypi | 1 + gyp/mbgl-linux.gypi | 1 + gyp/mbgl-osx.gypi | 1 + include/mbgl/map/map.hpp | 4 +- .../default/caching_http_file_source.hpp | 52 ++++++++++++++++ include/mbgl/storage/file_source.hpp | 37 +++--------- ios/mapbox-gl-cocoa | 2 +- linux/main.cpp | 4 +- macosx/main.mm | 4 +- .../default/caching_http_file_source.cpp | 59 +++++++++++++------ src/map/map.cpp | 35 +++++------ test/headless.cpp | 4 +- 13 files changed, 151 insertions(+), 73 deletions(-) create mode 100644 include/mbgl/platform/default/caching_http_file_source.hpp rename src/storage/file_source.cpp => platform/default/caching_http_file_source.cpp (56%) diff --git a/gyp/mbgl-headless.gypi b/gyp/mbgl-headless.gypi index 08ac21181..da11c8781 100644 --- a/gyp/mbgl-headless.gypi +++ b/gyp/mbgl-headless.gypi @@ -4,12 +4,32 @@ 'product_name': 'mbgl-headless', 'type': 'static_library', 'standalone_static_library': 1, + 'variables': { + 'cflags_cc': [ + '<@(uv_cflags)', + ], + 'cflags': [ + '<@(uv_cflags)', + ], + }, 'include_dirs': [ '../include', ], + 'conditions': [ + ['OS == "mac"', { + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ], + 'OTHER_CFLAGS': [ '<@(cflags)' ], + } + }, { + 'cflags_cc': [ '<@(cflags_cc)' ], + 'cflags': [ '<@(cflags)' ], + }] + ], 'sources': [ '../platform/default/headless_view.cpp', '../platform/default/headless_display.cpp', + '../platform/default/caching_http_file_source.cpp', ], }, ], diff --git a/gyp/mbgl-ios.gypi b/gyp/mbgl-ios.gypi index dd1c9c0c2..c26e72849 100644 --- a/gyp/mbgl-ios.gypi +++ b/gyp/mbgl-ios.gypi @@ -36,6 +36,7 @@ '../platform/darwin/string_nsstring.mm', '../platform/darwin/http_request_baton_cocoa.mm', '../platform/darwin/image.mm', + '../platform/default/caching_http_file_source.cpp', ], 'include_dirs': [ '../include', diff --git a/gyp/mbgl-linux.gypi b/gyp/mbgl-linux.gypi index 9d979ddf1..510703140 100644 --- a/gyp/mbgl-linux.gypi +++ b/gyp/mbgl-linux.gypi @@ -35,6 +35,7 @@ '../platform/default/image_reader.cpp', '../platform/default/png_reader.cpp', '../platform/default/jpeg_reader.cpp', + '../platform/default/caching_http_file_source.cpp', ], 'include_dirs': [ '../include', diff --git a/gyp/mbgl-osx.gypi b/gyp/mbgl-osx.gypi index 76c22f5ad..015ee13ab 100644 --- a/gyp/mbgl-osx.gypi +++ b/gyp/mbgl-osx.gypi @@ -11,6 +11,7 @@ '../platform/darwin/string_nsstring.mm', '../platform/darwin/http_request_baton_cocoa.mm', '../platform/darwin/image.mm', + '../platform/default/caching_http_file_source.cpp', ], 'include_dirs': [ '../include', diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index e97c63138..718efbf14 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -32,7 +32,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. @@ -177,7 +177,7 @@ private: Transform transform; TransformState state; - util::ptr fileSource; + FileSource& fileSource; util::ptr