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

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: fix memory error 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 a862886b300b263e07552ac9062c9041056cb76d..297af78c2793060f7e1e0dab6e0ae8a5a7c34e98 100644
--- a/Source/modules/serviceworkers/polyfills/cachePolyfill.js
+++ b/Source/modules/serviceworkers/polyfills/cachePolyfill.js
@@ -64,8 +64,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) {
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp ('k') | Source/modules/serviceworkers/polyfills/fetchPolyfill.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698