Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5>2008-09-24 17:02:05 (GMT)
committer dave@33eels.com <dave@33eels.com@4eb1ac78-321c-0410-a911-ec516a8615a5>2008-09-24 17:02:05 (GMT)
commit084a0234fe7398b6b3aa5666a370355de994d9d9 (patch)
tree892cc2e89fac4fb25d77762a545905f398cd0218
parent4970bf7d03f5eb6d5e662fa26c5d783410c14a55 (diff)
Fix for bug 759 ("Browser Freeze after closing Add-ons Window"):
I have disabled the "on-the-run" committing (e.g. when you close the extensions manager) in favour of just committing when the browser exits. git-svn-id: http://svn.mozilla.org/addons/trunk@18559 4eb1ac78-321c-0410-a911-ec516a8615a5
-rw-r--r--bandwagon/components/bandwagon-service.js29
-rw-r--r--bandwagon/content/scripts/bandwagon.js2
-rw-r--r--bandwagon/content/scripts/factory/feedFactory.js110
-rw-r--r--bandwagon/content/ui/feedsPaneController.js6
-rw-r--r--bandwagon/content/ui/overlays/browserOverlayController.js3
-rw-r--r--bandwagon/content/ui/settingsController.js3
6 files changed, 88 insertions, 65 deletions
diff --git a/bandwagon/components/bandwagon-service.js b/bandwagon/components/bandwagon-service.js
index ab141af..975a174 100644
--- a/bandwagon/components/bandwagon-service.js
+++ b/bandwagon/components/bandwagon-service.js
@@ -47,6 +47,7 @@ const Timer = Cc["@mozilla.org/timer;1"];
const ExtensionsManager = Cc["@mozilla.org/extensions/manager;1"];
const Storage = Cc["@mozilla.org/storage/service;1"];
const DirectoryService = Cc["@mozilla.org/file/directory_service;1"];
+const ObserverService = Cc["@mozilla.org/observer-service;1"];
const nsIWindowMediator = Ci.nsIWindowMediator;
const nsITimer = Ci.nsITimer;
@@ -54,6 +55,7 @@ const nsIExtensionManager = Ci.nsIExtensionManager;
const mozIStorageService = Ci.mozIStorageService;
const nsIProperties = Ci.nsIProperties;
const nsIFile = Ci.nsIFile;
+const nsIObserverService = Ci.nsIObserverService;
var Bandwagon;
@@ -75,7 +77,7 @@ BandwagonService.prototype = {
_storageConnection: null,
_feedFactory: null,
_feedUpdateTimer: null,
- _nsUpdateNotifier: null,
+ _bwObserver: null,
init: function()
{
@@ -130,7 +132,7 @@ BandwagonService.prototype = {
// start the update timer
- this._nsUpdateNotifier =
+ this._bwObserver =
{
observe: function(aSubject, aTopic, aData)
{
@@ -138,25 +140,35 @@ BandwagonService.prototype = {
{
bandwagonService.checkAllForUpdates();
}
- else if (aTopic == "xpcom-shutdown")
+ else if (aTopic == "quit-application")
{
- bandwagonService._feedUpdateTimer = null;
+ bandwagonService.uninit();
}
}
};
this._feedUpdateTimer = Timer.createInstance(nsITimer);
this._feedUpdateTimer.init(
- this._nsUpdateNotifier,
+ this._bwObserver,
(Bandwagon.Preferences.getPreference("debug")?30*1000:Bandwagon.FEED_UPDATE_TIMER_DELAY*1000),
nsITimer.TYPE_REPEATING_SLACK
);
+ // observe when the app shuts down so we can uninit
+
+ ObserverService.getService(nsIObserverService).addObserver(this._bwObserver, "quit-application", false);
+
this._initialized = true;
Bandwagon.Logger.info("Bandwagon has been initialized");
},
+ uninit: function()
+ {
+ this._feedUpdateTimer = null;
+ this.commitAll();
+ },
+
_getFeedObserver: function(event)
{
Bandwagon.Logger.info("in _getFeedObserver()");
@@ -389,7 +401,9 @@ BandwagonService.prototype = {
feed.showNotifications = false;
this.feeds[feed.url] = feed;
- this.commit(feed);
+
+ if (Bandwagon.COMMIT_NOW)
+ this.commit(feed);
this.forceCheckForUpdates(feed);
},
@@ -502,7 +516,8 @@ BandwagonService.prototype = {
// commit the feed
- bandwagonService.commit(feed);
+ if (Bandwagon.COMMIT_NOW)
+ bandwagonService.commit(feed);
},
_initStorage: function()
diff --git a/bandwagon/content/scripts/bandwagon.js b/bandwagon/content/scripts/bandwagon.js
index 558aec4..55039b1 100644
--- a/bandwagon/content/scripts/bandwagon.js
+++ b/bandwagon/content/scripts/bandwagon.js
@@ -52,3 +52,5 @@ Bandwagon.FEEDSPANE_DO_SUBSCRIBE_URL = "http://www.google.com/search?hl=en&q=ban
Bandwagon.MAGIC_ADD_FEED_COOKIE_HOST = "www.33eels.com"; // TODO
Bandwagon.MAGIC_ADD_FEED_COOKIE_NAME = "bandwagon_addfeed";
+Bandwagon.COMMIT_NOW = 0; // 1=commit on the fly. 0=commit when browser exit.
+
diff --git a/bandwagon/content/scripts/factory/feedFactory.js b/bandwagon/content/scripts/factory/feedFactory.js
index d6835d7..b58823b 100644
--- a/bandwagon/content/scripts/factory/feedFactory.js
+++ b/bandwagon/content/scripts/factory/feedFactory.js
@@ -398,46 +398,46 @@ Bandwagon.Factory.FeedFactory.prototype._commitFeedItem = function(feed, feedIte
statement.reset();
}
- statement = this.connection.createStatement("REPLACE INTO addons VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15)");
+ var statement2 = this.connection.createStatement("REPLACE INTO addons VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15)");
try
{
if (addonid != null)
{
// addon already exists (in another feed, or from previous commit of this feed)
- statement.bindInt32Parameter(0, addonid);
+ statement2.bindInt32Parameter(0, addonid);
}
else if (feedItem.id != -1)
{
// addon doesn't already exist, but exists from a previous commit of this feed (?)
- statement.bindInt32Parameter(0, feedItem.id);
+ statement2.bindInt32Parameter(0, feedItem.id);
}
else
{
// new addon
- statement.bindNullParameter(0)
+ statement2.bindNullParameter(0)
}
- statement.bindUTF8StringParameter(1, feedItem.guid);
- statement.bindUTF8StringParameter(2, feedItem.name);
- statement.bindInt32Parameter(3, feedItem.type);
- statement.bindUTF8StringParameter(4, feedItem.version);
- statement.bindInt32Parameter(5, feedItem.status);
- statement.bindUTF8StringParameter(6, feedItem.summary);
- statement.bindUTF8StringParameter(7, feedItem.description);
- statement.bindUTF8StringParameter(8, feedItem.icon);
- statement.bindUTF8StringParameter(9, feedItem.eula);
- statement.bindUTF8StringParameter(10, feedItem.thumbnail);
- statement.bindUTF8StringParameter(11, feedItem.learnmore);
- statement.bindUTF8StringParameter(12, feedItem.author);
- statement.bindUTF8StringParameter(13, feedItem.category);
- statement.bindUTF8StringParameter(14, feedItem.dateAdded.getTime()/1000);
+ statement2.bindUTF8StringParameter(1, feedItem.guid);
+ statement2.bindUTF8StringParameter(2, feedItem.name);
+ statement2.bindInt32Parameter(3, feedItem.type);
+ statement2.bindUTF8StringParameter(4, feedItem.version);
+ statement2.bindInt32Parameter(5, feedItem.status);
+ statement2.bindUTF8StringParameter(6, feedItem.summary);
+ statement2.bindUTF8StringParameter(7, feedItem.description);
+ statement2.bindUTF8StringParameter(8, feedItem.icon);
+ statement2.bindUTF8StringParameter(9, feedItem.eula);
+ statement2.bindUTF8StringParameter(10, feedItem.thumbnail);
+ statement2.bindUTF8StringParameter(11, feedItem.learnmore);
+ statement2.bindUTF8StringParameter(12, feedItem.author);
+ statement2.bindUTF8StringParameter(13, feedItem.category);
+ statement2.bindUTF8StringParameter(14, feedItem.dateAdded.getTime()/1000);
- statement.execute();
+ statement2.execute();
}
finally
{
- statement.reset();
+ statement2.reset();
}
if (feedItem.id == -1 && addonid == null)
@@ -469,28 +469,28 @@ Bandwagon.Factory.FeedFactory.prototype._commitFeedItem = function(feed, feedIte
// add the feedItem connector
- statement = this.connection.createStatement("REPLACE INTO feedItems VALUES (?1, ?2, ?3, ?4)");
+ var statement3 = this.connection.createStatement("REPLACE INTO feedItems VALUES (?1, ?2, ?3, ?4)");
try
{
if (feedItem.feedItemId == -1)
{
- statement.bindNullParameter(0);
+ statement3.bindNullParameter(0);
}
else
{
- statement.bindInt32Parameter(0, feedItem.feedItemId);
+ statement3.bindInt32Parameter(0, feedItem.feedItemId);
}
- statement.bindInt32Parameter(1, feed.id);
- statement.bindInt32Parameter(2, addonid);
- statement.bindInt32Parameter(3, (feedItem.read?1:0));
+ statement3.bindInt32Parameter(1, feed.id);
+ statement3.bindInt32Parameter(2, addonid);
+ statement3.bindInt32Parameter(3, (feedItem.read?1:0));
- statement.execute();
+ statement3.execute();
}
finally
{
- statement.reset();
+ statement3.reset();
}
if (feedItem.feedItemId == -1)
@@ -515,22 +515,22 @@ Bandwagon.Factory.FeedFactory.prototype._commitAddonCompatibleApplication = func
statement.reset();
}
- statement = this.connection.createStatement("INSERT INTO addonCompatibleApplications VALUES (?1, ?2, ?3, ?4, ?5, ?6)");
+ var statement2 = this.connection.createStatement("INSERT INTO addonCompatibleApplications VALUES (?1, ?2, ?3, ?4, ?5, ?6)");
try
{
- statement.bindInt32Parameter(0, addonid);
- statement.bindUTF8StringParameter(1, application.name);
- statement.bindInt32Parameter(2, application.applicationId);
- statement.bindUTF8StringParameter(3, application.minVersion);
- statement.bindUTF8StringParameter(4, application.maxVersion);
- statement.bindUTF8StringParameter(5, application.guid);
+ statement2.bindInt32Parameter(0, addonid);
+ statement2.bindUTF8StringParameter(1, application.name);
+ statement2.bindInt32Parameter(2, application.applicationId);
+ statement2.bindUTF8StringParameter(3, application.minVersion);
+ statement2.bindUTF8StringParameter(4, application.maxVersion);
+ statement2.bindUTF8StringParameter(5, application.guid);
- statement.execute();
+ statement2.execute();
}
finally
{
- statement.reset();
+ statement2.reset();
}
}
@@ -548,18 +548,18 @@ Bandwagon.Factory.FeedFactory.prototype._commitAddonCompatibleOS = function(addo
statement.reset();
}
- statement = this.connection.createStatement("INSERT INTO addonCompatibleOS VALUES (?1, ?2)");
+ var statement2 = this.connection.createStatement("INSERT INTO addonCompatibleOS VALUES (?1, ?2)");
try
{
- statement.bindInt32Parameter(0, addonid);
- statement.bindUTF8StringParameter(1, os);
+ statement2.bindInt32Parameter(0, addonid);
+ statement2.bindUTF8StringParameter(1, os);
- statement.execute();
+ statement2.execute();
}
finally
{
- statement.reset();
+ statement2.reset();
}
}
@@ -577,20 +577,20 @@ Bandwagon.Factory.FeedFactory.prototype._commitAddonInstall = function(addonid,
statement.reset();
}
- statement = this.connection.createStatement("INSERT INTO addonInstalls VALUES (?1, ?2, ?3, ?4)");
+ var statement2 = this.connection.createStatement("INSERT INTO addonInstalls VALUES (?1, ?2, ?3, ?4)");
try
{
- statement.bindInt32Parameter(0, addonid);
- statement.bindUTF8StringParameter(1, install.url);
- statement.bindUTF8StringParameter(2, install.hash);
- statement.bindUTF8StringParameter(3, install.os);
+ statement2.bindInt32Parameter(0, addonid);
+ statement2.bindUTF8StringParameter(1, install.url);
+ statement2.bindUTF8StringParameter(2, install.hash);
+ statement2.bindUTF8StringParameter(3, install.os);
- statement.execute();
+ statement2.execute();
}
finally
{
- statement.reset();
+ statement2.reset();
}
}
@@ -608,19 +608,19 @@ Bandwagon.Factory.FeedFactory.prototype._commitAddonComment = function(addonid,
statement.reset();
}
- statement = this.connection.createStatement("INSERT INTO addonComments VALUES (?1, ?2, ?3)");
+ var statement2 = this.connection.createStatement("INSERT INTO addonComments VALUES (?1, ?2, ?3)");
try
{
- statement.bindInt32Parameter(0, addonid);
- statement.bindUTF8StringParameter(1, comment.comment);
- statement.bindUTF8StringParameter(2, comment.author);
+ statement2.bindInt32Parameter(0, addonid);
+ statement2.bindUTF8StringParameter(1, comment.comment);
+ statement2.bindUTF8StringParameter(2, comment.author);
- statement.execute();
+ statement2.execute();
}
finally
{
- statement.reset();
+ statement2.reset();
}
}
diff --git a/bandwagon/content/ui/feedsPaneController.js b/bandwagon/content/ui/feedsPaneController.js
index 474b782..8d9de13 100644
--- a/bandwagon/content/ui/feedsPaneController.js
+++ b/bandwagon/content/ui/feedsPaneController.js
@@ -105,7 +105,8 @@ Bandwagon.Controller.FeedsPane.uninit = function()
bandwagonService.unregisterFeedListChangeObserver(Bandwagon.Controller.FeedsPane.feedListChangeObserver);
// now is a good time to save feeds to storage
- bandwagonService.commitAll();
+ if (Bandwagon.COMMIT_NOW)
+ bandwagonService.commitAll();
}
/**
@@ -466,7 +467,8 @@ Bandwagon.Controller.FeedsPane.doFeedPreviewSubscribe = function()
feed.preview = false;
feed.setAllNotified();
- bandwagonService.commit(feed);
+ if (Bandwagon.COMMIT_NOW)
+ bandwagonService.commit(feed);
Bandwagon.Controller.FeedsPane.elemBandwagonFeeds.selectedItem.preview = false;
Bandwagon.Controller.FeedsPane.doShowFeed();
diff --git a/bandwagon/content/ui/overlays/browserOverlayController.js b/bandwagon/content/ui/overlays/browserOverlayController.js
index 9dfd856..8ba39e1 100644
--- a/bandwagon/content/ui/overlays/browserOverlayController.js
+++ b/bandwagon/content/ui/overlays/browserOverlayController.js
@@ -50,7 +50,10 @@ Bandwagon.Controller.BrowserOverlay.initBandwagon = function()
// We can safely call init() for each new browser window; the service
// will only be initialized once.
+ // TODO should we observe "app-startup" instead?
+
bandwagonService.init();
+
}
catch (e)
{
diff --git a/bandwagon/content/ui/settingsController.js b/bandwagon/content/ui/settingsController.js
index e13e5b0..4957786 100644
--- a/bandwagon/content/ui/settingsController.js
+++ b/bandwagon/content/ui/settingsController.js
@@ -77,7 +77,8 @@ Bandwagon.Controller.Settings.uninit = function()
bandwagonService.unregisterFeedListChangeObserver(Bandwagon.Controller.Settings.feedListChangeObserver);
// now is a good time to save feeds to storage
- bandwagonService.commitAll();
+ if (Bandwagon.COMMIT_NOW)
+ bandwagonService.commitAll();
}
Bandwagon.Controller.Settings.feedListChangeObserver = function()