Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Unified Diff: content/browser/service_worker/service_worker_context_request_handler.cc

Issue 457903002: After 24 hours, bust the browser cache when checking for ServiceWorker updates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_context_request_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_context_request_handler.cc
diff --git a/content/browser/service_worker/service_worker_context_request_handler.cc b/content/browser/service_worker/service_worker_context_request_handler.cc
index 45248930d18cd3be34713d547fdf5ce6356b4532..1da3233668c4bbc4ea9442e91779c09a3cac118c 100644
--- a/content/browser/service_worker/service_worker_context_request_handler.cc
+++ b/content/browser/service_worker/service_worker_context_request_handler.cc
@@ -10,6 +10,7 @@
#include "content/browser/service_worker/service_worker_storage.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/browser/service_worker/service_worker_write_to_cache_job.h"
+#include "net/base/load_flags.h"
#include "net/url_request/url_request.h"
namespace content {
@@ -51,14 +52,28 @@ net::URLRequestJob* ServiceWorkerContextRequestHandler::MaybeCreateJob(
}
if (ShouldAddToScriptCache(request->url())) {
+ ServiceWorkerRegistration* registration =
+ context_->GetLiveRegistration(version_->registration_id());
+ DCHECK(registration); // We're registering or updating so must be there.
+
int64 response_id = context_->storage()->NewResourceId();
if (response_id == kInvalidServiceWorkerResponseId)
return NULL;
+
+ // Bypass the browser cache for initial installs and update
+ // checks after 24 hours have passed.
+ int extra_load_flags = 0;
+ base::TimeDelta time_since_last_check =
+ base::Time::Now() - registration->last_update_check();
+ if (time_since_last_check > base::TimeDelta::FromHours(24))
+ extra_load_flags = net::LOAD_BYPASS_CACHE;
+
return new ServiceWorkerWriteToCacheJob(request,
network_delegate,
resource_type_,
context_,
version_,
+ extra_load_flags,
response_id);
}
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_context_request_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698