Commit Graph

28 Commits

Author SHA1 Message Date
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
John Firebaugh
1c21d0fd4c [core] Use better types for modified / expires / etag 2016-01-21 11:22:11 -08:00
John Firebaugh
c33ed50c98 [core] Eliminate Response::stale and inline Response::isExpired()
Response::isExpired() had subtle and potentially confusing behavior around Seconds::zero(). It's best to inline it and comment why.
2016-01-21 11:22:11 -08:00
John Firebaugh
0066637e58 [core] Let SQLiteCache decide when store or refresh responses 2016-01-14 13:46:03 -08:00
John Firebaugh
2ee1fe4178 [core] std::shared_ptr<const Response> ⇢ const Response& 2016-01-14 13:46:03 -08:00
John Firebaugh
7fb5e973ed [core] Eliminate FileCache interface
There is only one implementation and we're unlikely to add more.
2016-01-14 13:46:03 -08:00
Konstantin Käfer
13fbf8b39b [test] Fix test case comments
Follow up to a06f28ddb7
2016-01-11 11:14:29 +01:00
Konstantin Käfer
a06f28ddb7 [core] only cache successful or NotFound responses
We don't want other types of error end up in our cache, since it'll likely evict perfectly good content.
2016-01-08 16:25:54 +01: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
Thiago Marcos P. Santos
cb06526b10 [tests] Remove libuv dependency from the tests 2015-12-01 11:49:02 +02:00
Bruno de Oliveira Abinader
31fd2822f5 [core] Replace time_t with std::chrono::seconds
Added aliases for std::chrono typedefs (eg. 'Seconds' for
std::chrono::seconds). These aliases are used together with templated
helper functions to replace time_t with std::chrono::seconds for most
cases, in particular for 'modified' and 'expires' values in Response.
2015-11-27 17:47:02 +02:00
John Firebaugh
7137239cbd [core] Use std::unique_ptr for FileSource request 2015-11-16 12:25:47 -08:00
John Firebaugh
1caf89c32b [core] Pass a value to response callback, not a reference 2015-11-16 12:25:47 -08:00
Thiago Marcos P. Santos
36581f3d30 [core] Do not pass uv_loop_t around
This should be abstracted by util::RunLoop
2015-11-16 12:25:47 -08:00
Konstantin Käfer
4d5c6333be [core] move retry logic to DefaultFileSource 2015-11-02 17:24:40 +01:00
Konstantin Käfer
5173bf1bb8 [core] Make response data shared to avoid excessive copying 2015-10-26 15:54:27 +01:00
Konstantin Käfer
6a7334b882 [core] add support for stale responses
We're now returning stale responses from cache. Those responses will have the `stale` flag set to true. Currently, all requesters in the core code discard stale responses, and cancel the request immediately after they got a non-stale response.
2015-10-26 15:54:27 +01:00
Konstantin Käfer
94a5ac857f [core] all requests have to be canceled explicitly now
By not automatically destroying Request objects after the result has been delivered, we are making sure that we can potentially fire the callback multiple times without adverse effects. This means that you have to hold on to the result of fs->request(), can explicitly cancel it if you don't want to be notified of data changes anymore. Not doing so will monitor the request indefinitely and will prevent the app from exiting.
2015-10-26 15:54:27 +01:00
John Firebaugh
c0b75f1af7 Remove Environment::terminate and associated code
Fixes #1336
2015-04-28 09:16:26 -04: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
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
29baacf3a5 refactor makefile 2015-02-04 10:49:09 +01:00
Konstantin Käfer
4a985e09f2 asset:// URLs are local to the executable path now 2015-02-04 10:49:06 +01:00
Konstantin Käfer
aa09aa321b rearrange tests and make more robust 2015-02-04 10:49:06 +01:00
Konstantin Käfer
8a1fce547e rearrange tests and add storage tests 2015-02-04 10:49:05 +01:00