google gears system requirements firefox 1.5+,internet explorer 6.0+ or safari 3.1.1+ windows...
TRANSCRIPT
Google Gears
System RequirementsFirefox 1.5+,Internet Explorer 6.0+ or Safari 3.1.1+
Windows XP/Vista, Windows Mobile 5+, Mac (Firefox, Safari), Linux and Android.
What is Google Gears
Open Source Project Enables more powerful web applications. Helps to access and store information on user
system in a secure way. Gives Javascript more flexibility and power.
Components of Gears
Database module WorkerPool module LocalServer module Desktop module Geolocation module
Database module
Provides relational data storage to JavaScript web application.
Uses open-source SQLite database. Browser Javascript have access to view/insert
data. Data Files are stored on User using the same-
origin security policy.
Gears Database Example
var db = google.gears.factory.create('beta.database');
db.open('database-test');
db.execute('create table if not exists Test' + ' (Phrase text, Timestamp int)');
db.execute('insert into Test values (?, ?)', ['Monkey!', new Date().getTime()]);
var rs = db.execute('select * from Test order by Timestamp desc');
while (rs.isValidRow())
{
alert(rs.field(0) + '@' + rs.field(1));
rs.next();
}
rs.close();
WorkerPool Module
Injects multi-threading capability in Javascript. Workers (threads) behaves like processes
which do not share any execution state. Workers interact each other by sending
message.
WorkerPool Example
// main.js var workerPool = google.gears.factory.create('beta.workerpool');workerPool.onmessage = function(a, b, message){
alert('Received message from worker ' + message.sender + ': \n' + message.body);
};var childWorkerId = workerPool.createWorkerFromUrl('worker.js');workerPool.sendMessage(["3..2..", 1, {helloWorld: "Hello world!"}],
childWorkerId);
WorkerPool Example (Contd.)
// worker.js
var wp = google.gears.workerPool;
wp.onmessage = function(a, b, message)
{
var reply = message.body[0] + message.body[1] + "... " + message.body[2].helloWorld;
wp.sendMessage(reply, message.sender);
}
LocalServer module
Cache and serve its HTTP resources locally, without a network connection.
The LocalServer intercepts HTTP/HTTPS requests and serves them from the cache.
Two types of LocalServer Management classes are ResourceStore and ManagedResourceStore
LocalServer ResourceStore
Contents and cache are never updated automatically unless user calls capture().
Example
var add_localServer = google.gears.factory.create("beta.localserver","1.0");
var resourceStore = add_localServer.createStore(STORE_NAME);
resourceStore.capture(URL, ADDURLCALLBACK);
LocalServer ManagedResourceStore
ManagedResourceStore are determined by the URLs listed in a manifest file.
LocalServer checks for an updated resources periodically via manifest file.
Example:var localServer = google.gears.factory.create('beta.localserver');
var store = localServer.createManagedStore('test-store');
store.manifestUrl = 'site-manifest.txt';
store.checkForUpdate();
Other APIs
Desktop module: It provides an interface for accessing desktop related functionality, such as creating shortcuts.
Geolocation module: Obtain the user's current position, and watch the user's position as it changes over time.
HttpRequest: provides HttpRequest object to the workers as they don’t have access to brower’s XmlHttpRequest Object.
Timer: provides timer capabilities to workers and parent.