Presentation to Munich JS on 2011-04-06: covers the Munich Chrome team's privacy efforts, and argues that IndexedDB is a better mechanism than localStorage for applications of any real complexity.
HTML version up at http://20110406-munichjs.appspot.com/
12. Chromium splits the world into one
trusted browser and many
untrusted renderers.
13. Browser
All I/O goes through the browser;
it's the only piece of Chromium
that can make system calls, access
鍖les or DBs, and display output to
the user.
15. Sandboxed Renderers
Renderers run in processes with as
few permissions as possible, and
only have I/O access via IPC
messages to the browser's process.
17. I/O is a bottleneck
There's only one I/O messaging
thread on each renderer; it's
critical not to block while waiting
for a response.
19. Asynchronous APIs!
The additional conceptual
complexity aside, they allow you to
smoothly continue responding to
user interactions.
20. With that in mind...
What's wrong with this code?
var x = JSON.stringify( complexObject );
window.localStorage['x'] = x;
window.localStorage['anotherX'] = x;
21. Problem 1: localStorage requires
objects be 鍖attened via stringify,
called synchronously in
user-space.
var x = JSON.stringify( complexObject );
window.localStorage['x'] = x;
window.localStorage['anotherX'] = x;
22. IndexedDB stores
unserialized objects
As far as your (single-threaded)
JavaScript process is concerned,
you'll never block while processing
JSON.
23. Problem 2: localStorage itself is
synchronous, which means the
assignment blocks while the write
goes through to the 鍖le system.
var x = JSON.stringify( complexObject );
window.localStorage['x'] = x;
window.localStorage['anotherX'] = x;
24. IndexedDB is
asynchronous.
db.transaction(store, READ_WRITE).
objectStore(store).
put({ ... }).
addEventListener(
'onsuccess',
function (e) { ... });
25. Problem 3: There's no mechanism
to ensure that both assignments go
through successfully, nor that they
both apply to the same baseline.
var x = JSON.stringify( complexObject );
window.localStorage['x'] = x;
window.localStorage['anotherX'] = x;
35. Done when they're
done...
WebRequest API
ContentSettings API
DevTools (WebInspector,
Debugger, etc.)
And more... goo.gl/Hy6Jy
36. Stay up to date
chromestatus.com and Last Week
in Chromium/Webkit
(goo.gl/XWEY3) are great
resources.
HTML5Rocks.com is full of useful
tutorials (and will be localized
soonish).