Thursday, August 30th, 2007
Google Gears 0.2 Developer Release
The Gears team has rev'd a new version aimed at developers. This release isn't going to propagate to end-user machines yet, as we want to time to hear from the community on the new features and APIs. Speaking of which...
What's new?
Until now, there was no way to talk past the strict same-origin security model (same protocol, same exact domain, same port). Sometimes in the real world you need to mashup data, or even talk from www.foo.com to static.foo.com. Now you can do this with a simple API that adds to WorkerPool:
-
-
int createWorker(fullScript)
-
int createWorkerFromUrl(scriptUrl) // NEW METHOD
-
void allowCrossOrigin() // NEW METHOD
-
void sendMessage(messageString, destWorkerId)
-
[write] callback onmessage(messageText, senderId, [object:{text,sender,origin}]) // NEW 3RD PARAM
-
Example
Assume mash-up.com wants to read and write tasks managed by task-list.com.
- task-list.com hosts workerpool-service.js, which it expects to be loaded by another origin. That .js code uses:
- LocalServer to make itself and any required resources available offline.
- WorkerPool to respond to sendMessage() commands like "getAllTasks"
- mash-up.com calls createWorkerFromUrl() with the workerpool-service.js URL.
- The worker can access tast-list.com resources, as it runs in that origin.
- When mash-up.com calls sendMessage('getAllTasks'), task-list.com reads the database associated with task-list.com and returns the tasks.
- Note that because only task-list.com directly accesses the database, the schema can change without requiring changes to mash-up.com.
Read more of the details.
Workers live in their own world (by design) but what if you need a worker to grab some content. You don't have access to XHR, but now you can use the new HttpRequest module that mimics XHR with a couple of differences.
The Timer module implements the WhatWG Timer specification, and makes it available in both workers and the main HTML page. This is the same timer API that is traditionally available in browsers on the window object.
I got to chat with Chris Prince, an engineer on Gears, about the new release:
Let us know your thoughts. What would you like to see? If you could create a mythical Gear, what would it do? :)












love the cross-origin implementation from the first glance looks of it… I’ve got to find some outside time for playing around with Gears, this ball is really rolling…
Thanks.Good article