+ All Categories
Home > Technology > MunichJS - 2011-04-06

MunichJS - 2011-04-06

Date post: 12-May-2015
Category:
Upload: mike-west
View: 1,004 times
Download: 0 times
Share this document with a friend
Description:
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/
Popular Tags:
39
MunichJS: 2011-04-06 Mike West ([email protected])
Transcript
Page 1: MunichJS - 2011-04-06

MunichJS: 2011-04-06Mike West ([email protected])

Page 2: MunichJS - 2011-04-06

Hi. I'm Mike.You can email me at

[email protected], follow me onTwitter @mikewest, or visit myoutdated blog at mikewest.org.

Page 3: MunichJS - 2011-04-06

Two topics:IndexedDB (which is awesome).Chromium extension goodness.

Page 4: MunichJS - 2011-04-06

IndexedDB

Page 5: MunichJS - 2011-04-06
Page 6: MunichJS - 2011-04-06

Uxebu are awesome.I'm thrilled that they're writing

abstraction layers. Seriously, thisrocks. If you haven't read the

article, do.

Page 7: MunichJS - 2011-04-06

I'm less thrilled that they're wrong.

“But how is this betterthan localStorage? It

isn't.”

Page 8: MunichJS - 2011-04-06
Page 9: MunichJS - 2011-04-06

My thesis: IndexedDB, orsomething like it, is the way

forward.

Yes, it's complex, and the APIcould be better, but we're adults

here. We'll deal.

Page 10: MunichJS - 2011-04-06

Why IndexedDB?A short intro to Chromium

internals.

Page 11: MunichJS - 2011-04-06
Page 12: MunichJS - 2011-04-06

Chromium splits the world into onetrusted browser and many

untrusted renderers.

Page 13: MunichJS - 2011-04-06

BrowserAll I/O goes through the browser;it's the only piece of Chromium

that can make system calls, accessfiles or DBs, and display output to

the user.

Page 14: MunichJS - 2011-04-06
Page 15: MunichJS - 2011-04-06

Sandboxed RenderersRenderers run in processes with as

few permissions as possible, andonly have I/O access via IPC

messages to the browser's process.

Page 16: MunichJS - 2011-04-06
Page 17: MunichJS - 2011-04-06

I/O is a bottleneckThere's only one I/O messaging

thread on each renderer; it'scritical not to block while waiting

for a response.

Page 18: MunichJS - 2011-04-06
Page 19: MunichJS - 2011-04-06

Asynchronous APIs!The additional conceptual

complexity aside, they allow you tosmoothly continue responding to

user interactions.

Page 20: MunichJS - 2011-04-06

With that in mind...What's wrong with this code?

var x = JSON.stringify( complexObject );window.localStorage['x'] = x;window.localStorage['anotherX'] = x;

Page 21: MunichJS - 2011-04-06

Problem 1: localStorage requiresobjects be flattened via stringify,

called synchronously inuser-space.

var x = JSON.stringify( complexObject );window.localStorage['x'] = x;window.localStorage['anotherX'] = x;

Page 22: MunichJS - 2011-04-06

IndexedDB storesunserialized objectsAs far as your (single-threaded)JavaScript process is concerned,

you'll never block while processingJSON.

Page 23: MunichJS - 2011-04-06

Problem 2: localStorage itself issynchronous, which means the

assignment blocks while the writegoes through to the file system.

var x = JSON.stringify( complexObject );window.localStorage['x'] = x;window.localStorage['anotherX'] = x;

Page 24: MunichJS - 2011-04-06

IndexedDB isasynchronous.

db.transaction(store, READ_WRITE). objectStore(store). put({ ... }). addEventListener( 'onsuccess', function (e) { ... });

Page 25: MunichJS - 2011-04-06

Problem 3: There's no mechanismto ensure that both assignments gothrough successfully, nor that theyboth apply to the same baseline.

var x = JSON.stringify( complexObject );window.localStorage['x'] = x;window.localStorage['anotherX'] = x;

Page 26: MunichJS - 2011-04-06

Transactions & Locking

db.transaction(store, READ_WRITE)…db.transaction(store, READ_ONLY)…

Page 27: MunichJS - 2011-04-06
Page 28: MunichJS - 2011-04-06

Chrome Privacy

Page 29: MunichJS - 2011-04-06

Our privacy team's missionstatement.

“Chromium providesusers full transparency

and control over theinformation managed by

the browser.”

Page 30: MunichJS - 2011-04-06

The team approaches this task in anumber of ways, notably in terms

of new extension APIs.

Page 31: MunichJS - 2011-04-06
Page 32: MunichJS - 2011-04-06
Page 33: MunichJS - 2011-04-06
Page 34: MunichJS - 2011-04-06

WebNavigation EventsonBeforeNavigateonBeforeRetarget

onCommittedonCompleted

onDOMContentLoadedonErrorOccurred

Page 35: MunichJS - 2011-04-06

Done when they'redone...

WebRequest APIContentSettings API

DevTools (WebInspector,Debugger, etc.)

And more... goo.gl/Hy6Jy

Page 36: MunichJS - 2011-04-06

Stay up to datechromestatus.com and Last Week

in Chromium/Webkit(goo.gl/XWEY3) are great

resources.

HTML5Rocks.com is full of usefultutorials (and will be localized

soonish).

Page 37: MunichJS - 2011-04-06
Page 38: MunichJS - 2011-04-06
Page 39: MunichJS - 2011-04-06

[email protected]

@mikewest


Recommended