Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD...
Transcript of Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD...
![Page 1: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/1.jpg)
Introduction to Gears
Brad NeubergGoogle
![Page 2: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/2.jpg)
HTML
CSS
JavaScript
What is Gears?
![Page 3: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/3.jpg)
HTML
CSS
JavaScript
What is Gears?
![Page 4: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/4.jpg)
HTML
CSS
JavaScript
What is Gears?
![Page 5: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/5.jpg)
HTML
CSS
JavaScript
What is Gears?
![Page 6: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/6.jpg)
HTML
CSS
JavaScript
What is Gears?
HTML 5
![Page 7: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/7.jpg)
HTML
CSS
JavaScript
What is Gears?
HTML 5
![Page 8: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/8.jpg)
HTML
CSS
JavaScript
Ajax++
![Page 9: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/9.jpg)
HTML
CSS
JavaScriptDatabase
Ajax++
![Page 10: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/10.jpg)
HTML
CSS
JavaScriptDatabase
Ajax++
Client-Side Search
![Page 11: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/11.jpg)
HTML
CSS
JavaScriptDatabase
Worker Pool
Ajax++
Client-Side Search
![Page 12: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/12.jpg)
HTML
CSS
JavaScriptDatabase
Worker Pool
Desktop API
Ajax++
Client-Side Search
![Page 13: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/13.jpg)
HTML
CSS
JavaScriptDatabase
Local Server
Worker Pool
Desktop API
Ajax++
Client-Side Search
![Page 14: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/14.jpg)
HTML
CSS
JavaScriptDatabase
Local Server
Worker Pool
Desktop API
Ajax++
Client-Side Search
Blobs
![Page 15: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/15.jpg)
HTML
CSS
JavaScript
Ajax++
![Page 16: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/16.jpg)
HTML
CSS
JavaScript
Ajax++
File System API
![Page 17: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/17.jpg)
HTML
CSS
JavaScript
Ajax++
Geolocation
File System API
![Page 18: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/18.jpg)
Database
![Page 19: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/19.jpg)
Database
• Local SQL storage
• SQLite: Open source, mature, small (343K), fast
• Full-featured relational database
• Gigabytes of storage capacity
• Strict same-origin security model
![Page 20: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/20.jpg)
Database Code
![Page 21: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/21.jpg)
Database Codevar db = google.gears.factory.create('beta.database');
![Page 22: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/22.jpg)
Database Codevar db = google.gears.factory.create('beta.database');
db.open('database-test');
![Page 23: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/23.jpg)
Database Codevar db = google.gears.factory.create('beta.database');
db.open('database-test');
db.execute('CREATE TABLE IF NOT EXISTS Test' +
![Page 24: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/24.jpg)
Database Codevar db = google.gears.factory.create('beta.database');
db.open('database-test');
db.execute('CREATE TABLE IF NOT EXISTS Test' + ' (Phrase TEXT, Timestamp INT)');
![Page 25: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/25.jpg)
Database Codevar 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!',
![Page 26: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/26.jpg)
Database Codevar 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()]);
![Page 27: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/27.jpg)
Database Code
![Page 28: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/28.jpg)
Database Codevar rs;
![Page 29: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/29.jpg)
Database Codevar rs;
try {
![Page 30: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/30.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
![Page 31: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/31.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
while (rs.isValidRow()) {
![Page 32: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/32.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
while (rs.isValidRow()) { console.log(rs.fieldByName(‘Phrase’) + '@'
![Page 33: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/33.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
while (rs.isValidRow()) { console.log(rs.fieldByName(‘Phrase’) + '@'
+ rs.fieldByName(‘Timestamp’));
![Page 34: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/34.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
while (rs.isValidRow()) { console.log(rs.fieldByName(‘Phrase’) + '@'
+ rs.fieldByName(‘Timestamp’)); rs.next();
![Page 35: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/35.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
while (rs.isValidRow()) { console.log(rs.fieldByName(‘Phrase’) + '@'
+ rs.fieldByName(‘Timestamp’)); rs.next();}
![Page 36: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/36.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
while (rs.isValidRow()) { console.log(rs.fieldByName(‘Phrase’) + '@'
+ rs.fieldByName(‘Timestamp’)); rs.next();}
} finally {
![Page 37: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/37.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
while (rs.isValidRow()) { console.log(rs.fieldByName(‘Phrase’) + '@'
+ rs.fieldByName(‘Timestamp’)); rs.next();}
} finally {rs.close();
![Page 38: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/38.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
while (rs.isValidRow()) { console.log(rs.fieldByName(‘Phrase’) + '@'
+ rs.fieldByName(‘Timestamp’)); rs.next();}
} finally {rs.close();db.close();
![Page 39: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/39.jpg)
Database Codevar rs;
try {rs = db.execute('SELECT * FROM Test ORDER BY Timestamp DESC');
while (rs.isValidRow()) { console.log(rs.fieldByName(‘Phrase’) + '@'
+ rs.fieldByName(‘Timestamp’)); rs.next();}
} finally {rs.close();db.close();
}
![Page 40: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/40.jpg)
Demo:
MySpace Messaging + Gears
![Page 41: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/41.jpg)
Full-Text Search
![Page 42: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/42.jpg)
Full Text Search• Gears added FTS2 to SQLite
• Create the databasedb.execute('CREATE VIRTUAL TABLE recipe USING fts2(dish, ingredients)');
• Search the databasedb.execute('SELECT dish FROM recipe WHERE recipe MATCH ?', ['tomatoes']);
Fun queries: dish:stew tomatoes Find rows with 'stew' in the dish field, and 'tomatoes' in any field.
![Page 43: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/43.jpg)
Demo:
PubTools Search
![Page 44: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/44.jpg)
Local Server
![Page 45: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/45.jpg)
Local Server
• Run web applications offline
• Capture UI: HTML, JavaScript, CSS
• Serves locally even when connected
![Page 46: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/46.jpg)
Local Server
• ResourceStore
• Capture individual URLs
• ManagedResourceStore
• Capture manifest of resources
![Page 47: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/47.jpg)
Local Server Code// site-manifest.js{ "betaManifestVersion": 1, "version": "1.1", "entries": [ { "url": "site.html" }, { "url": "gears_init.js" } ]}
![Page 48: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/48.jpg)
Local Server Code
![Page 49: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/49.jpg)
Local Server Codevar localServer = google.gears.factory.create
![Page 50: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/50.jpg)
Local Server Codevar localServer = google.gears.factory.create
('beta.localserver');
![Page 51: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/51.jpg)
Local Server Codevar localServer = google.gears.factory.create
('beta.localserver');
var store = localServer.openManagedStore(‘test-store’)
![Page 52: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/52.jpg)
Local Server Codevar localServer = google.gears.factory.create
('beta.localserver');
var store = localServer.openManagedStore(‘test-store’)| localServer.createManagedStore('test-store');
![Page 53: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/53.jpg)
Local Server Codevar localServer = google.gears.factory.create
('beta.localserver');
var store = localServer.openManagedStore(‘test-store’)| localServer.createManagedStore('test-store');
store.manifestUrl = 'site-manifest.js';
![Page 54: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/54.jpg)
Local Server Codevar localServer = google.gears.factory.create
('beta.localserver');
var store = localServer.openManagedStore(‘test-store’)| localServer.createManagedStore('test-store');
store.manifestUrl = 'site-manifest.js';
store.checkForUpdate();
![Page 55: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/55.jpg)
Demo:
WordPress
![Page 56: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/56.jpg)
Worker Pool
![Page 57: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/57.jpg)
Worker PoolJavaScript needs threads after all? Brendan!
Browser JavaScript Engine
WorkerPool
WorkerPool
window, document no access
![Page 58: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/58.jpg)
• Demo
Worker Pool
![Page 59: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/59.jpg)
Worker Pool Codevar pool = google.gears.factory.create('beta.workerpool');
pool.onmessage = function(message) { console.log('next prime is: ' + message);}
function nextPrime(n) { // TODO: Prime-finding algorithm goes here. google.gears.workerPool.sendMessage(result);}
var runMe = String(nextPrime) + '; nextPrime()';
var worker = pool.createWorker(runMe);
![Page 60: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/60.jpg)
Desktop API
![Page 61: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/61.jpg)
DesktopShortcuts
var desktop = google.gears.factory.create('beta.desktop');desktop.createShortcut("Test Application", "http://www.test.com/index.html", {"16x16": "http://www.test.com/icon16x16.png", "32x32": "http://www.test.com/icon32x32.png", "48x48": "http://www.test.com/icon48x48.png", "128x128": "http://www.test.com/icon128x128.png"});
![Page 62: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/62.jpg)
File System
![Page 63: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/63.jpg)
File System
• Uploading multiple files is incredibly tedious!
• Native OS look-and-feel
• Access does not persist
• User has full control
![Page 64: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/64.jpg)
File Systeminterface FileSystem { File[] loadFiles(FileLoadOptions)}
interface FileLoadOptions { string accept // MIME types bool multiFile // default is true}
interface File { string name // no path, for privacy Blob content}
![Page 65: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/65.jpg)
Blob
![Page 66: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/66.jpg)
What is a Blob?!
• Generic way to pass around binary data
• Just a handle
• Gears APIs can accept Blobs
• HttpRequest
• WorkerPool
![Page 67: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/67.jpg)
Blobs
• Semantics:
• Blobs are immutable
• APIs can return a new Blob
interface Blob { integer length Blob slice(start, length)}
![Page 68: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/68.jpg)
Fixing large uploads(“Connection aborted” after 500 MBs... not fun!)
![Page 69: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/69.jpg)
Resumable Upload “API”
• No new API necessary!
• Blob.slice() + HttpRequest.send(blob)
![Page 70: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/70.jpg)
Resumable Upload “API”
var CHUNK_BYTES = 1000000; // 1 MB (arbitrary)
function ResumableUpload(blob, httpRequest) { var bytesDone = 0; while (bytes_done <= blob.length) { httpRequest.send(blob.slice(bytesDone, CHUNK_BYTES)); // On success, increment bytesDone. // On failure, resume at current offset. }}
![Page 71: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/71.jpg)
Demo:
uploadmovietool.appspot.com
![Page 72: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/72.jpg)
Geolocation API
![Page 73: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/73.jpg)
Geolocation API
• Hands back lat, long, accuracy
• Will use best provider
• GPS, Wifi IDs, Cell IDs, IP address
• Pluggable service providers
![Page 74: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/74.jpg)
Geolocation APIinterface Geolocation { Position lastPosition // zero delay void getCurrentPosition(PositionCallback, optional PositionOptions) integer watchPosition(PositionCallback, // returns id optional PositionOptions) void clearWatch(id)}
interface Position { readonly double latitude // degrees readonly double longitude readonly double altitude // meters readonly double horizontalAccuracy readonly double verticalAccuracy readonly Date timestamp // when location established}
![Page 75: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/75.jpg)
Geolocation APIvar geo = google.gears.factory.create('beta.geolocation');
// Get the latest position.geo.getCurrentPosition(function(position) { UpdateMap(position.latitude, position.longitude);});
// Watch the position over time.var watchId = geo.watchPosition(function(position) { UpdateMap(position.latitude, position.longitude);});geo.clearWatch(watchId);
![Page 77: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/77.jpg)
Questions?
• Google Gears is an open source plugin that aims to push the Web forward
• The components are simple to use
• http://code.google.com/apis/gears/• http://gears.google.com/
• Thanks for your time!
![Page 78: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/78.jpg)
Download Slides
![Page 79: Introduction to Gears - Brad Neubergcodinginparadise.org/presentations/Intro to Gears GDD 2008.pdf · Database • Local SQL storage • SQLite: Open source, mature, small (343K),](https://reader030.fdocuments.in/reader030/viewer/2022013022/5f7c2b4bfcddac398c736f89/html5/thumbnails/79.jpg)
Introduction to Gears
Brad NeubergGoogle