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

Side by Side Diff: content/browser/service_worker/service_worker_context_request_handler.cc

Issue 2575523002: Prerender: Confirm ServiceWorkers are invoked for NoState Prefetch (Closed)
Patch Set: drop prefetch url request Created 3 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_context_request_handler. h" 5 #include "content/browser/service_worker/service_worker_context_request_handler. h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/browser/service_worker/service_worker_context_core.h" 8 #include "content/browser/service_worker/service_worker_context_core.h"
9 #include "content/browser/service_worker/service_worker_provider_host.h" 9 #include "content/browser/service_worker/service_worker_provider_host.h"
10 #include "content/browser/service_worker/service_worker_read_from_cache_job.h" 10 #include "content/browser/service_worker/service_worker_read_from_cache_job.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // We only use the script cache for main script loading and 48 // We only use the script cache for main script loading and
49 // importScripts(), even if a cached script is xhr'd, we don't 49 // importScripts(), even if a cached script is xhr'd, we don't
50 // retrieve it from the script cache. 50 // retrieve it from the script cache.
51 // TODO(michaeln): Get the desired behavior clarified in the spec, 51 // TODO(michaeln): Get the desired behavior clarified in the spec,
52 // and make tweak the behavior here to match. 52 // and make tweak the behavior here to match.
53 if (resource_type_ != RESOURCE_TYPE_SERVICE_WORKER && 53 if (resource_type_ != RESOURCE_TYPE_SERVICE_WORKER &&
54 resource_type_ != RESOURCE_TYPE_SCRIPT) { 54 resource_type_ != RESOURCE_TYPE_SCRIPT) {
55 return NULL; 55 return NULL;
56 } 56 }
57 57
58 // TODO(mattcary): still not clear if this is correct or not.
59 // Skip creation if job is prefetch.
60 if (request->load_flags() & net::LOAD_PREFETCH) {
61 return NULL;
falken 2016/12/27 01:27:00 Returning null here just means that SW machinery w
62 }
63
58 if (ShouldAddToScriptCache(request->url())) { 64 if (ShouldAddToScriptCache(request->url())) {
59 ServiceWorkerRegistration* registration = 65 ServiceWorkerRegistration* registration =
60 context_->GetLiveRegistration(version_->registration_id()); 66 context_->GetLiveRegistration(version_->registration_id());
61 DCHECK(registration); // We're registering or updating so must be there. 67 DCHECK(registration); // We're registering or updating so must be there.
62 68
63 int64_t resource_id = context_->storage()->NewResourceId(); 69 int64_t resource_id = context_->storage()->NewResourceId();
64 if (resource_id == kInvalidServiceWorkerResourceId) 70 if (resource_id == kInvalidServiceWorkerResourceId)
65 return NULL; 71 return NULL;
66 72
67 // Bypass the browser cache for initial installs and update 73 // Bypass the browser cache for initial installs and update
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 int64_t* resource_id_out) { 125 int64_t* resource_id_out) {
120 // We don't read from the script cache until the version is INSTALLED. 126 // We don't read from the script cache until the version is INSTALLED.
121 if (version_->status() == ServiceWorkerVersion::NEW || 127 if (version_->status() == ServiceWorkerVersion::NEW ||
122 version_->status() == ServiceWorkerVersion::INSTALLING) 128 version_->status() == ServiceWorkerVersion::INSTALLING)
123 return false; 129 return false;
124 *resource_id_out = version_->script_cache_map()->LookupResourceId(url); 130 *resource_id_out = version_->script_cache_map()->LookupResourceId(url);
125 return *resource_id_out != kInvalidServiceWorkerResourceId; 131 return *resource_id_out != kInvalidServiceWorkerResourceId;
126 } 132 }
127 133
128 } // namespace content 134 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698