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

Side by Side Diff: Source/modules/serviceworkers/polyfills/cachePolyfill.js

Issue 311343003: ServiceWorker polyfill Fetch implementation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: clean up and add FIXMEs Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 var entriesByUrl = entriesByMethod[request.method]; 77 var entriesByUrl = entriesByMethod[request.method];
78 entriesByUrl[request.url] = response; 78 entriesByUrl[request.url] = response;
79 79
80 resolve(); 80 resolve();
81 }); 81 });
82 }; 82 };
83 83
84 Cache.prototype.add = function(request) { 84 Cache.prototype.add = function(request) {
85 // FIXME: Implement this. 85 var scope = this;
86 request = _castToRequest(request);
jsbell 2014/06/05 17:48:02 _castToRequest isn't exposed, and you probably wan
jsbell 2014/06/05 17:50:50 Ah, sorry, I didn't see that there was a local cop
86 return new Promise(function (resolve, reject) { 87 return new Promise(function (resolve, reject) {
87 reject("Cache.add not implemented."); 88 Fetch(request).then(
89 function(response) {
90 scope.set(request, response).then(resolve);
91 },
92 reject);
88 }); 93 });
89 }; 94 };
90 95
91 Cache.prototype.delete = function(request) { 96 Cache.prototype.delete = function(request) {
92 request = _castToRequest(request); 97 request = _castToRequest(request);
93 98
94 var entriesByMethod = this.entriesByMethod; 99 var entriesByMethod = this.entriesByMethod;
95 return new Promise(function (resolve, reject) { 100 return new Promise(function (resolve, reject) {
96 var entriesByUrl = entriesByMethod[request.method]; 101 var entriesByUrl = entriesByMethod[request.method];
97 102
(...skipping 21 matching lines...) Expand all
119 var entry = entriesByUrl[request.url]; 124 var entry = entriesByUrl[request.url];
120 if (entry == undefined) { 125 if (entry == undefined) {
121 reject("not found"); 126 reject("not found");
122 } 127 }
123 resolve(entry); 128 resolve(entry);
124 }); 129 });
125 }; 130 };
126 131
127 return Cache; 132 return Cache;
128 })(); 133 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698