Commit Graph

58 Commits

Author SHA1 Message Date
John Firebaugh
e6eb6c7fe4 Use uv::async 2015-05-13 13:54:16 -07:00
John Firebaugh
386be7c0fa Remove unused
There are no longer any requests made that don't have a run loop to
dispatch back to.
2015-05-13 13:54:16 -07:00
Thiago Marcos P. Santos
19881f8b24 Cancel all pending requests before leaving
This still has the unwanted side effect off blocking the Map thread
waiting for the workers to return (because they hold a reference
to the Map thread main loop).

Maybe the only way to solve this would be having a I/O thread for
dispatching messages.

The Request is not bound anymore to the invoker thread because the workers
will request for glyphs, but the reply will arrive at the Map thread.
2015-05-05 18:35:40 +03:00
John Firebaugh
36f695b411 Write SQLite tests in terms of Impl 2015-05-01 14:31:39 -04:00
John Firebaugh
c0b75f1af7 Remove Environment::terminate and associated code
Fixes #1336
2015-04-28 09:16:26 -04:00
Konstantin Käfer
9072df709d make the request header public as the node module requires it 2015-04-17 15:23:36 +02:00
Konstantin Käfer
352ff64e06 rename SQLiteCache::Thread to SQLiteCache::Impl 2015-04-13 18:32:59 +02:00
Konstantin Käfer
452d12e6e6 make implementation files private headers 2015-04-13 18:28:18 +02:00
Konstantin Käfer
16849a341b hide Thread<> and separate the Implementation object 2015-04-13 17:57:45 +02:00
Konstantin Käfer
4c7132337f convert DefaultFileSource to use util::Thread<> 2015-04-10 22:37:27 +02:00
Konstantin Käfer
bba3d9838a add Thread<T> and RunLoop
Thread<T> is a generic thread management object that starts a thread, creates an object T in that thread and calls its .start() function. When the Thread<T> object is destructed (which must happen in the thread that created it), it'll call the object's .stop() function, and wait for thread termination. The .stop() function must somehow get the thread to terminate. Note that object T's constructor/destructor/start()/stop() must be protected/private, and Thread<T> must be declared as a friend class. All public functions may be called from any thread and are exposed through operator->().

RunLoop encapsulates a libuv runloop and has a facility of dispatching function objects to the thread. It can be used either as a worker thread class by itself, or it can be derived from. This commit converts SQLiteCache to derive from RunLoop and removes the custom code used previously for managing the cache thread.
2015-04-10 15:36:32 +02:00
Konstantin Käfer
7d58a41de5 make sqlite storage more resilient to sporadic errors
- catch SQLite exceptions and report them
- failed statements are ignored, we're really just caching here, so if it fails we're handling it gracefully elsewhere
- handle cases where the database file goes away after we opened it
- handle cases where the schema wasn't created after the database file was opened successfully
- add tests
2015-04-07 18:04:23 +02:00
Konstantin Käfer
069505fe75 fix rare issue that had the notify and cancel callbacks called in the wrong order 2015-03-13 15:30:10 +01:00
Konstantin Käfer
10d84f6be8 remove unused enum 2015-03-06 20:52:47 +01:00
Konstantin Käfer
9781785ab7 scope Requests to an Environment object for easier cancelation
we are now scoping all file requests to an environment object. The FileSource implementation treats
this as an opaque pointer, but allows canceling all Requests that are associated with that pointer.
This is necessary to abort all file requests that originated from a particular Map object. Aborting
a file request is different from canceling a file request: A canceled request doesn't have its
callback called, while an aborted request will have its callback called with an error, indicating
that the environment is going to be shut down.
2015-03-06 08:21:47 -08:00
Konstantin Käfer
8c0acecbe3 fix handling around unique_ptr releases 2015-03-06 16:17:49 +01:00
Konstantin Käfer
fe0baffe0d update uv_zip and add tests 2015-02-16 18:30:19 -08:00
Konstantin Käfer
f4e9908045 code style 2015-02-13 13:28:40 -08:00
Konstantin Käfer
aecef6da1a make sure that the async handle always gets closed 2015-02-13 13:28:40 -08:00
Konstantin Käfer
29baacf3a5 refactor makefile 2015-02-04 10:49:09 +01:00
Konstantin Käfer
12341ce0ee add missing headers 2015-02-04 10:49:08 +01:00
Konstantin Käfer
78376acea7 don't override std::hash 2015-02-04 10:49:06 +01:00
Konstantin Käfer
92a7f73bbe fixes for linux 2015-02-04 10:49:06 +01:00
Konstantin Käfer
31a0d18ca1 remove circular shared_ptr and a few other memory leaks 2015-02-04 10:49:05 +01:00
Konstantin Käfer
b9bf66e67e rewrite storage layer to be independent of the Map's event loop 2015-02-04 10:46:37 +01:00
Leith Bade
40f859e482 Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
Conflicts:
	gyp/mbgl-ios.gypi
	gyp/mbgl-osx.gypi
	platform/default/asset_request_libuv.cpp
	src/mbgl/storage/caching_http_file_source.cpp
	src/mbgl/storage/file_request.cpp
	src/mbgl/storage/file_request.hpp
	src/mbgl/storage/file_request_baton.hpp
2014-12-18 12:39:36 +11:00
Konstantin Käfer
b5e9998b15 change file:// to asset:// to indicate that they aren't arbitrary files
refs #579
2014-12-17 14:59:05 +01:00
Konstantin Käfer
936e096514 Make file request overridable by platform implementations
refs #579: Android can now rename AssetRequest to FileRequest and implement it differently
2014-12-17 12:14:32 +01:00
Leith Bade
93ab4036e9 Fix commit 2014-12-06 00:50:23 +11:00
Leith Bade
de9eb00276 Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
Conflicts:
	.gitignore
	gyp/mbgl-ios.gypi
	gyp/mbgl-linux.gypi
	gyp/mbgl-osx.gypi
	include/mbgl/map/map.hpp
	src/mbgl/map/map.cpp
	src/mbgl/storage/caching_http_file_source.cpp
2014-12-05 23:16:49 +11:00
John Firebaugh
ff640132de Move setAccessToken to CachingHTTPFileSource 2014-12-04 17:03:23 -08:00
John Firebaugh
36500b9f95 Add CachingHTTPFileSource::clearLoop()
So loop state can be cleaned up in the appropriate thread.
This is a hack; loop needs to be externalized from Map.

Fixes #686
2014-12-04 15:26:54 -08:00
John Firebaugh
16fe8e64c4 Move setReachability to CachingHTTPFileSource 2014-12-04 15:14:40 -08:00
Konstantin Käfer
1e3fb3a423 remove usage of relative paths 2014-12-04 20:02:51 +01:00
Konstantin Käfer
abafb52f37 make most headers private 2014-12-04 20:02:50 +01:00
John Firebaugh
97d7f065d6 Add virtual destructor for FileSource 2014-12-04 10:52:26 -08:00
Leith Bade
1c0396690e Fixup after merge 2014-12-04 22:39:38 +11:00
Leith Bade
8f1754cf0a Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
Conflicts:
	include/mbgl/storage/base_request.hpp
	include/mbgl/storage/file_request_baton.hpp
	include/mbgl/storage/http_request.hpp
	include/mbgl/storage/http_request_baton.hpp
	include/mbgl/util/uv_detail.hpp
	platform/darwin/http_request_baton_cocoa.mm
	platform/default/caching_http_file_source.cpp
	platform/default/http_request_baton_curl.cpp
	src/map/map.cpp
	src/storage/base_request.cpp
	src/storage/file_request.cpp
	src/storage/file_request_baton.cpp
	src/storage/http_request.cpp
	src/storage/http_request_baton.cpp
2014-12-04 22:19:46 +11:00
John Firebaugh
57249ca32c Prefer stdlib to libuv (fixes #688) 2014-12-03 17:38:10 -08:00
Leith Bade
991a74774e Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
Conflicts:
	gyp/mbgl-ios.gypi
	gyp/mbgl-linux.gypi
	gyp/mbgl-osx.gypi
	platform/default/caching_http_file_source.cpp
2014-12-04 08:02:57 +11:00
Mike Morris
dac76a0f92 break out FileSource as an abstract class
add CachingHTTPFileSource implementation
2014-12-03 12:25:11 -05:00
Leith Bade
08ce7157f1 Fix debug build 2014-12-03 22:58:33 +11:00
Leith Bade
f090d6b264 Use uv::async and various other fixes 2014-12-03 21:57:55 +11:00
Leith Bade
2b86522412 Share asset_request between platforms 2014-12-02 19:41:50 +11:00
John Firebaugh
a3ec4cf17e Use noncopyable 2014-11-21 14:25:12 -08:00
Konstantin Käfer
a9039cf5d7 move file request baton to its own file 2014-09-30 17:29:09 +02:00
Konstantin Käfer
9e44c0eae8 add reachability 2014-09-29 14:02:42 +02:00
Konstantin Käfer
135f68e249 add retries in case of connection failures 2014-09-29 13:18:50 +02:00
Konstantin Käfer
46e06bf378 don't pass the loop through all function calls 2014-09-29 12:27:34 +02:00
Konstantin Käfer
b9628c8654 add etag support and if-none-match/if-modified-since to cocoa http handling 2014-09-26 16:10:39 +02:00