diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-01-08 13:03:47 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-01-13 13:38:12 -0800 |
commit | e9eb29719b6ef99810ef6615c09beb3993880cac (patch) | |
tree | a39203a52d43f46b782c67794f51007e2745dd40 | |
parent | dd3ca81589d1cc990e3bbb951853d6c85a1a9ac1 (diff) | |
download | qtlocation-mapboxgl-e9eb29719b6ef99810ef6615c09beb3993880cac.tar.gz |
[core] Simplify logic for notification with pre-existing response
We already had a condition that checks if a response is immediately available for an incoming request. Call the callback there, rather than in addObserver.
-rw-r--r-- | platform/default/online_file_source.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/platform/default/online_file_source.cpp b/platform/default/online_file_source.cpp index 6a65bb44e5..755c5e590d 100644 --- a/platform/default/online_file_source.cpp +++ b/platform/default/online_file_source.cpp @@ -200,11 +200,10 @@ void OnlineFileSource::Impl::add(Resource resource, FileRequest* req, Callback c if (request.getResponse()) { // We've at least obtained a cache value, potentially we also got a final response. - // The observers have been notified already; send what we have to the new one as well. - // Before returning the existing response, make sure that it is still fresh, or update the // `stale` flag. request.checkResponseFreshness(); + callback(*request.getResponse()); if (request.getResponse()->stale && !request.realRequest) { // We've returned a stale response; now make sure the requester also gets a fresh @@ -334,11 +333,6 @@ OnlineFileRequestImpl::~OnlineFileRequestImpl() { void OnlineFileRequestImpl::addObserver(FileRequest* req, Callback callback) { observers.emplace(req, callback); - - if (response) { - // We've got a response, so send the (potentially stale) response to the requester. - callback(*response); - } } void OnlineFileRequestImpl::removeObserver(FileRequest* req) { |