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

Unified Diff: Source/modules/serviceworkers/polyfills/cachePolyfill.js

Issue 311343003: ServiceWorker polyfill Fetch implementation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase only 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/serviceworkers/polyfills/cachePolyfill.js
diff --git a/Source/modules/serviceworkers/polyfills/cachePolyfill.js b/Source/modules/serviceworkers/polyfills/cachePolyfill.js
index 1c90a0348942248916cf88abffda633f8c9cad1a..381867e9ab95130eab1c0d19616b88b44bd57955 100644
--- a/Source/modules/serviceworkers/polyfills/cachePolyfill.js
+++ b/Source/modules/serviceworkers/polyfills/cachePolyfill.js
@@ -60,8 +60,17 @@
});
};
- // FIXME: Implement this.
- Cache.prototype.add = Promise.reject.bind(Promise, 'Cache.prototype.add() not implemented.');
+ Cache.prototype.add = function(request) {
+ var that = this;
+ request = _castToRequest(request);
+ return new Promise(function (resolve, reject) {
+ fetch(request).then(
+ function(response) {
+ that.put(request, response).then(resolve);
+ },
+ reject);
+ });
+ };
// FIXME: Add QueryParams argument.
Cache.prototype.delete = function (request) {

Powered by Google App Engine
This is Rietveld 408576698