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

Side by Side Diff: content/test/data/service_worker/fetch_event_response_via_cache.js

Issue 1750333002: Reland of Pipe response_time from FetchManager to CacheStorage and ServiceWorkerURLRequestJob. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 this.onfetch = function(event) {
6 var CACHE_NAME = 'cache_name';
7 var cache = undefined;
8 var url = event.request.url;
9 event.respondWith(
10 caches.open(CACHE_NAME)
11 .then(function(c) {
12 cache = c;
13 return cache.match(url);
14 })
15 .then(function(response) {
16 if (response)
17 return response;
18 var cloned_response = undefined;
19 return fetch(url)
20 .then(function(res) {
21 cloned_response = res.clone();
22 return cache.put(url, res);
23 })
24 .then(function() {
25 return cloned_response;
26 });
27 }));
28 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698