As discussed in our Google Code Blog post on HTML5 for Gmail Mobile, Google’s new version of Gmail for iPhone and Android-powered devices uses the Web Storage Portability Layer (WSPL) to let the same database code run on browsers that provide either Gears or HTML5 structured storage facilities. The WSPL consists of a collection of classes that provide asynchronous transactional access to both Gears and HTML5 databases and can be found on Project Hosting on Google Code.

There are five basic classes:

google.wspl.Statement – A parametrizable SQL statement class

google.wspl.Transaction – Used to execute one or more Statements with ACID properties

google.wspl.ResultSet – Arrays of JavaScript hash objects, where the hash key is the table column name

google.wspl.Database – A connection to the backing database, also provides transaction support

google.wspl.DatabaseFactory – Creates the appropriate HTML5 or Gears database implementation

Also included in the distribution is a simple note-taking application with a persistent database cache built using the WSPL library. This application (along with Gmail mobile for iPhone and Android-powered devices) is an example of the cache pattern for building offline web applications. In the cache pattern, we insert a browser-local cache into the web application to break the synchronous link between user actions in the browser and server-generated responses. Instead, as shown below, we have two data flows. First, entirely local to the device, contents flow from the cache to the UI while changes made by the user update the cache. In the second flow, the cache asynchronously forwards user changes to the web server and receives updates in response.

By using this architectural pattern, a web application can made tolerant of a flaky (or even absent) network connection!

We’ll be available at the Developer Sandbox at Google I/O to discuss the cache pattern, HTML5 development and the WSPL library. Check it out! If you have questions or comments, please visit our discussion list.

By Robert Kroeger, Software Engineer – Mobile Team


Go to Source

Related posts:

  1. The panic over free Google Apps and the need for data portability
  2. Google is phasing out Gears, phasing in HTML5
  3. Content Portability: Building an API is Not Enough
  4. Google announces big price cuts on paid extra storage for GMail, Picasa Web
  5. Report from Day 2 of the Linux Storage and Filesystem Workshop, April 6-7th, 2009

Leave a Reply

Special Offers
Blogroll

Pages
Tags