diff options
Diffstat (limited to 'chromium/third_party/trace-viewer/third_party/Promises/reworked_APIs/IndexedDB/example/after.html')
-rw-r--r-- | chromium/third_party/trace-viewer/third_party/Promises/reworked_APIs/IndexedDB/example/after.html | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/chromium/third_party/trace-viewer/third_party/Promises/reworked_APIs/IndexedDB/example/after.html b/chromium/third_party/trace-viewer/third_party/Promises/reworked_APIs/IndexedDB/example/after.html deleted file mode 100644 index b278a0f239e..00000000000 --- a/chromium/third_party/trace-viewer/third_party/Promises/reworked_APIs/IndexedDB/example/after.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title></title> - <script> - "use strict"; - - // Cribbed from: - // https://hacks.mozilla.org/2012/02/storing-images-and-files-in-indexeddb/ - var DB_NAME = "example"; - var OBJ_STORE_NAME = "objects"; - var VERSION = 1.0; - var key = "thinger" - - // Note that open() now returns a Future which resolves for open success. - var f = this.indexedDB.open(DB_NAME, VERSION); - - // Upgradeneeded is still an event since it's conditional (it isn't always - // called and therefore can't be used to productively chain), so we - // register it as such. - f.onupgradeneeded = function(e) { - console.log("database creation/upgrade needed"); - console.log("creating object store:", OBJ_STORE_NAME) - e.target.result.createObjectStore(OBJ_STORE_NAME); - }; - - // Now chain each step of our open/write/read process. - f.then(function(db) { - // We can only write once the DB is opened and upgraded/created. - console.log("database opened successfully"); - console.log(db); - - // Create a new Transaction in which to write and retun a future for - // when the transaction opens. - return db.transaction([OBJ_STORE_NAME], "readwrite").open(); - }).then(function(trans) { - // Get the Object Store via the Transaction and write asynchronously - return trans.objectStore(OBJ_STORE_NAME).put({ value: "stuff" }, key); - }).then(function(transaction) { - console.log("writing successful"); - - // Read it back - return trans.objectStore(OBJ_STORE_NAME).get(key); - }).done(function(value) { console.log("reading successful:", value); }, - function(e) { console.error("Failed with error:", e); } - ); - </script> - </head> - <body></body> -</html>
\ No newline at end of file |