Commit Graph

35 Commits

Author SHA1 Message Date
Ivo van Dongen
5cf0fc0f8b [core] default file source - ensure thread safety for cached values 2017-05-27 10:05:36 +03:00
Ivo van Dongen
89129379f1 [core] default file source - ensure thread safety for local file and asset requests 2017-05-27 10:05:36 +03:00
Ivo van Dongen
6b0e0a9055 [core] allow filesource url transform reset 2017-05-12 14:55:40 +03:00
Konstantin Käfer
197f0ca6b4 [android] use AAssetManager instead of libzip 2017-04-24 10:42:10 +02:00
Jesse Bounds
e1546644b5 [core] Cache file source base URL and access token
This caches the base URL and access token values when they are set
so that they can still be retrieved even when the thread is paused.
2017-03-01 08:25:44 -08:00
Thiago Marcos P. Santos
4c2e720b15 [core] Add a pause/resume API to the DefaultFileSource
It will halt the networking thread completely. Expired and error'ed
tiles won't get re-requested until resume() is called again.
2017-02-25 14:03:38 +02:00
Konstantin Käfer
e2d8a83664 [core] add ability to transform URLs before they're requested from the Internet 2017-02-20 14:36:27 +01:00
Konstantin Käfer
62ea1f2185 [core] remove trailing whitespace, add trailing newlines, add space after // 2017-01-27 11:44:16 +01:00
Konstantin Käfer
e76de05402 [build] move logging to util 2016-11-22 20:58:51 +01:00
Ivo van Dongen
1bf12e20a6 [core] LocalFileSource implementation and tests 2016-09-30 14:57:26 +02:00
Molly Lloyd
598f7c6ad5 [core] allow offline region metadata to be updated (#6338) 2016-09-20 17:43:00 +02:00
Tobrun
9ef65440b6 [core] [android] - public api configurable base endpoint (#6309)
add runloop to test
2016-09-15 22:01:09 -07:00
John Firebaugh
030234c7a6 [core] Rework invokeWithCallback so that the callback is last 2016-09-08 16:36:47 -07:00
John Firebaugh
646528bc53 [core] Simplify Thread::invokeSync (#6128) 2016-08-24 09:36:11 -07:00
Konstantin Käfer
8ee222c45e [core] allow creating optional requests
Introduces "optional" requests. These should be fulfilled by the FileSource only there's a low-cost/easy way to obtain the data (e.g. from a local cache). If the data for an optional request cannot be found, it *must* return a Response object with a NotFound error.

Traditional "required" requests still work the same way, with one change: If you set any prior* field in the Resource (i.e. priorModified, priorEtag, or priorExpires), the DefaultFileSource assumes that you already have the cache value and will not consult the cache before performing the request. If a prior cache lookup didn't turn up any data, and you therefore don't have an Etag or Modified value, you can still skip the cache by setting priorExpires. This will of course always result in a non-conditional HTTP request.
2016-05-18 12:40:22 +02:00
Konstantin Käfer
3bde525711 [core] remove indirection via Task object in DefaultFileSource 2016-05-12 15:13:21 +02:00
John Firebaugh
6e78eabfff [core] Clean up ThreadContext vestiges 2016-04-15 09:56:18 -07:00
John Firebaugh
5eda74a514 Merge branch 'release-ios-3.2.0-android-4.0.0' 2016-03-30 17:43:37 -07:00
John Firebaugh
169755e89a [core] Unify FileRequest and WorkRequest 2016-03-24 10:54:32 -07:00
John Firebaugh
967b6c7248 [core] Stop any OfflineDownload before deleting a region
No progress events should be processed after deleting a region.
2016-03-21 12:41:17 -07:00
Thiago Marcos P. Santos
672727f773 [core] Make OnlineFileSource respect the NetworkStatus
The user can now force the Offline mode and set it back
to Online, triggering the requests waiting for network connection.
2016-03-08 10:31:01 -03:00
Thiago Marcos P. Santos
b8b283588f [core] Remove goOffline() from DefaultFileSource
Use the newly added NetworkStatus::Set().
2016-03-08 10:31:01 -03:00
John Firebaugh
065cda83fa [core] Limit total number of offline Mapbox tiles 2016-02-24 13:38:14 -08:00
John Firebaugh
a9e0c1b99a [core] Eliminate maximumCacheEntrySize
Instead, the eviction policy accounts for the actual size needed for an incoming put.
2016-02-10 15:40:20 -08:00
John Firebaugh
db3620c58f [core] Implement an eviction policy for OfflineDatabase
When inserting an cached resource, or removing a region, remove least-recently used resources and tiles, not used by offline regions, until the used database size, as calculated by multiplying the number of in-use pages by the page size, is less than the maximum cache size minus 5 times the page size.

In addition, OfflineDatabase may be configured to ignore cache puts of individual resources larger than a certain size.

This policy is similar but not identical to the former SQLiteCache policy:

* It accounts for offline, by exempting resources required by offline regions from eviction.
* It must delete from two tables (resources and tiles), rather than one. Currently the strategy is naive: evict 50 rows at a time from each table.
* It makes maximumCacheSize and maximumCacheEntrySize completely independent. The SQLiteCache implementation evicted when `usedSize > maximumCacheSize - 2 * maximumCacheEntrySize`. This evicts when `usedSize > maximumCacheSize - 5 * pageSize`.
* It uses a non-unlimited default value for maximumCacheSize: 50 MB. We should have always had a limit in place; "a cache without an eviction policy is a resource leak".
2016-02-10 15:40:20 -08:00
John Firebaugh
5d42321b73 [core] Make {Default,Online}FileSource::Impl more similar 2016-02-10 15:40:20 -08:00
John Firebaugh
c3c4c7b9a6 [core] Interface and implementation for offline 2016-02-10 15:40:20 -08:00
John Firebaugh
cdedb66387 [core] Reimplement existing caching within an offline-capable database schema 2016-02-10 15:40:20 -08:00
John Firebaugh
dbb8e58aea [core] Moving caching logic to DefaultFileSource
This results in OnlineFileSource containing precisely the logic we want for reuse by OfflineFileSource, and no more.
2016-02-10 15:40:20 -08:00
Konstantin Käfer
8939a7b706 [core] move SharedSQLiteCache::get to SQLiteCache::getShared 2016-01-15 10:38:09 +01:00
John Firebaugh
5a7d2fd60e [core] Eliminate platform::assetRoot()
I regenerated assets.zip so that all file paths have an `assets/` prefix, as the Android AssetFileSource implementation asserts, and removed `TEST_DATA` from the paths.
2016-01-13 13:40:31 -08:00
John Firebaugh
86c8446d3a [core] Simplify asset:// implementation
* Move asset:// URL handling to DefaultFileSource.
* AssetFileSource implements FileSource interface and follows familiar implementation patterns.
* Move default implementation to platform/default, zip implementation to platform/android.
* Don't bother with modified / expires / etag -- assets are not cached so it doesn't matter.
* Don't bother with interleaving individual IO calls on the implementation thread. That adds a lot of complexity for very little benefit.
2016-01-13 13:40:31 -08:00
John Firebaugh
e7b0b31d58 [core] Privatize SQLiteCache 2016-01-08 12:31:13 -08:00
John Firebaugh
7a6076ea9d [tests] Test with OnlineFileSource
When we introduce OfflineFileSource, the behavior of existing tests should
not change.
2015-12-23 14:55:12 -08:00
John Firebaugh
ab0efe5d00 [core] Move OnlineFileSource to platform
Preparation for OfflineFileSource which depends on SQLite
2015-12-22 12:09:14 -08:00