SlideShare a Scribd company logo
1 of 39
Download to read offline
MunichJS: 2011-04-06
  Mike West (mkwst@google.com)
Hi. I'm Mike.
      You can email me at
mkwst@google.com, follow me on
 Twitter @mikewest, or visit my
 outdated blog at mikewest.org.
Two topics:
IndexedDB (which is awesome).
Chromium extension goodness.
IndexedDB
Uxebu are awesome.
 I'm thrilled that they're writing
abstraction layers. Seriously, this
  rocks. If you haven't read the
            article, do.
“But how is this better
    than localStorage? It
            isn't.”

I'm less thrilled that they're wrong.
My thesis: IndexedDB, or
  something like it, is the way
          forward.
 Yes, it's complex, and the API
could be better, but we're adults
         here. We'll deal.
Why IndexedDB?
A short intro to Chromium
         internals.
Chromium splits the world into one
    trusted browser and many
       untrusted renderers.
Browser
 All I/O goes through the browser;
  it's the only piece of Chromium
that can make system calls, access
 files or DBs, and display output to
               the user.
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.
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.
Asynchronous APIs!
   The additional conceptual
complexity aside, they allow you to
 smoothly continue responding to
        user interactions.
With that in mind...
    What's wrong with this code?

var x = JSON.stringify( complexObject );
window.localStorage['x'] = x;
window.localStorage['anotherX'] = x;
Problem 1: localStorage requires
 objects be flattened via stringify,
       called synchronously in
             user-space.

var x = JSON.stringify( complexObject );
window.localStorage['x'] = x;
window.localStorage['anotherX'] = x;
IndexedDB stores
 unserialized objects
  As far as your (single-threaded)
 JavaScript process is concerned,
you'll never block while processing
               JSON.
Problem 2: localStorage itself is
   synchronous, which means the
 assignment blocks while the write
  goes through to the file system.

var x = JSON.stringify( complexObject );
window.localStorage['x'] = x;
window.localStorage['anotherX'] = x;
IndexedDB is
    asynchronous.
db.transaction(store, READ_WRITE).
    objectStore(store).
    put({ ... }).
    addEventListener(
        'onsuccess',
        function (e) { ... });
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;
Transactions & Locking
 db.transaction(store, READ_WRITE)…
 db.transaction(store, READ_ONLY)…
Chrome Privacy
“Chromium provides
 users full transparency
  and control over the
information managed by
     the browser.”

Our privacy team's mission
        statement.
The team approaches this task in a
 number of ways, notably in terms
      of new extension APIs.
WebNavigation Events
     onBeforeNavigate
     onBeforeRetarget
        onCommitted
        onCompleted
    onDOMContentLoaded
     onErrorOccurred
Done when they're
     done...
     WebRequest API
  ContentSettings API
 DevTools (WebInspector,
      Debugger, etc.)
 And more... goo.gl/Hy6Jy
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).
Questions?
mkwst@google.com
   @mikewest

More Related Content

Viewers also liked (7)

Intro to IndexedDB (Beta)
Intro to IndexedDB (Beta)Intro to IndexedDB (Beta)
Intro to IndexedDB (Beta)
 
Mitigate Maliciousness -- jQuery Europe 2013
Mitigate Maliciousness -- jQuery Europe 2013Mitigate Maliciousness -- jQuery Europe 2013
Mitigate Maliciousness -- jQuery Europe 2013
 
comparatives
comparativescomparatives
comparatives
 
Indexed db
Indexed dbIndexed db
Indexed db
 
2nd Conditional
2nd Conditional2nd Conditional
2nd Conditional
 
Love The Terminal
Love The TerminalLove The Terminal
Love The Terminal
 
Webquest Template0[1]
Webquest Template0[1]Webquest Template0[1]
Webquest Template0[1]
 

Similar to MunichJS - 2011-04-06

Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007
Stephan Chenette
 
The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010
Mario Heiderich
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java Programming
Katy Allen
 
Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise Middleware
Behrad Zari
 
JS Libraries and jQuery Overview
JS Libraries and jQuery OverviewJS Libraries and jQuery Overview
JS Libraries and jQuery Overview
Aleksandr Motsjonov
 
Douglas - Real JavaScript
Douglas - Real JavaScriptDouglas - Real JavaScript
Douglas - Real JavaScript
d0nn9n
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0Locking the Throneroom 2.0
Locking the Throneroom 2.0
Mario Heiderich
 
The Ultimate Deobfuscator - ToorCON San Diego 2008
The Ultimate Deobfuscator - ToorCON San Diego 2008The Ultimate Deobfuscator - ToorCON San Diego 2008
The Ultimate Deobfuscator - ToorCON San Diego 2008
Stephan Chenette
 

Similar to MunichJS - 2011-04-06 (20)

Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007
 
Sandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession LearnedSandboxing JS and HTML. A lession Learned
Sandboxing JS and HTML. A lession Learned
 
The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010
 
Real World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case StudyReal World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case Study
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java Programming
 
Thug: a new low-interaction honeyclient
Thug: a new low-interaction honeyclientThug: a new low-interaction honeyclient
Thug: a new low-interaction honeyclient
 
"Scala in Goozy", Alexey Zlobin
"Scala in Goozy", Alexey Zlobin "Scala in Goozy", Alexey Zlobin
"Scala in Goozy", Alexey Zlobin
 
(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe
 
Dojo - from web page to web apps
Dojo - from web page to web appsDojo - from web page to web apps
Dojo - from web page to web apps
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise Middleware
 
JS Libraries and jQuery Overview
JS Libraries and jQuery OverviewJS Libraries and jQuery Overview
JS Libraries and jQuery Overview
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
HTML5
HTML5HTML5
HTML5
 
Douglas - Real JavaScript
Douglas - Real JavaScriptDouglas - Real JavaScript
Douglas - Real JavaScript
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0Locking the Throneroom 2.0
Locking the Throneroom 2.0
 
The Ultimate Deobfuscator - ToorCON San Diego 2008
The Ultimate Deobfuscator - ToorCON San Diego 2008The Ultimate Deobfuscator - ToorCON San Diego 2008
The Ultimate Deobfuscator - ToorCON San Diego 2008
 
Microservice pitfalls
Microservice pitfalls Microservice pitfalls
Microservice pitfalls
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

MunichJS - 2011-04-06

  • 1. MunichJS: 2011-04-06 Mike West (mkwst@google.com)
  • 2. Hi. I'm Mike. You can email me at mkwst@google.com, follow me on Twitter @mikewest, or visit my outdated blog at mikewest.org.
  • 3. Two topics: IndexedDB (which is awesome). Chromium extension goodness.
  • 5.
  • 6. Uxebu are awesome. I'm thrilled that they're writing abstraction layers. Seriously, this rocks. If you haven't read the article, do.
  • 7. “But how is this better than localStorage? It isn't.” I'm less thrilled that they're wrong.
  • 8.
  • 9. My thesis: IndexedDB, or something like it, is the way forward. Yes, it's complex, and the API could be better, but we're adults here. We'll deal.
  • 10. Why IndexedDB? A short intro to Chromium internals.
  • 11.
  • 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 files or DBs, and display output to the user.
  • 14.
  • 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.
  • 16.
  • 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.
  • 18.
  • 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 flattened 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 file 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;
  • 26. Transactions & Locking db.transaction(store, READ_WRITE)… db.transaction(store, READ_ONLY)…
  • 27.
  • 29. “Chromium provides users full transparency and control over the information managed by the browser.” Our privacy team's mission statement.
  • 30. The team approaches this task in a number of ways, notably in terms of new extension APIs.
  • 31.
  • 32.
  • 33.
  • 34. WebNavigation Events onBeforeNavigate onBeforeRetarget onCommitted onCompleted onDOMContentLoaded onErrorOccurred
  • 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).
  • 37.
  • 38.