Bug 648338 - Remove Firefox 3.5/3.6 compat code in the form engine. r=rnewman
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Thu, 07 Apr 2011 15:30:54 -0700
changeset 67775 7249a475841963025662109455c1ba4cbda88a48
parent 67774 20ab4d32a215b9112ebe239946942eefdaea2ee7
child 67776 7a31e654594358df05f20849c63fcd6f6b26ef02
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs648338
milestone2.2a1pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 648338 - Remove Firefox 3.5/3.6 compat code in the form engine. r=rnewman
services/sync/modules/engines/forms.js
--- a/services/sync/modules/engines/forms.js
+++ b/services/sync/modules/engines/forms.js
@@ -61,35 +61,35 @@ FormRec.prototype = {
 Utils.deferGetSet(FormRec, "cleartext", ["name", "value"]);
 
 
 let FormWrapper = {
   _log: Log4Moz.repository.getLogger('Engine.Forms'),
     
   getAllEntries: function getAllEntries() {
     // Sort by (lastUsed - minLast) / (maxLast - minLast) * timesUsed / maxTimes
-    let query = this.createStatement(
+    let query = Svc.Form.DBConnection.createAsyncStatement(
       "SELECT fieldname name, value FROM moz_formhistory " +
       "ORDER BY 1.0 * (lastUsed - (SELECT lastUsed FROM moz_formhistory ORDER BY lastUsed ASC LIMIT 1)) / " +
         "((SELECT lastUsed FROM moz_formhistory ORDER BY lastUsed DESC LIMIT 1) - (SELECT lastUsed FROM moz_formhistory ORDER BY lastUsed ASC LIMIT 1)) * " +
         "timesUsed / (SELECT timesUsed FROM moz_formhistory ORDER BY timesUsed DESC LIMIT 1) DESC " +
       "LIMIT 500");
     return Utils.queryAsync(query, ["name", "value"]);
   },
 
   getEntry: function getEntry(guid) {
-    let query = this.createStatement(
+    let query = Svc.Form.DBConnection.createAsyncStatement(
       "SELECT fieldname name, value FROM moz_formhistory WHERE guid = :guid");
     query.params.guid = guid;
     return Utils.queryAsync(query, ["name", "value"])[0];
   },
 
   getGUID: function getGUID(name, value) {
     // Query for the provided entry
-    let getQuery = this.createStatement(
+    let getQuery = Svc.Form.DBConnection.createAsyncStatement(
       "SELECT guid FROM moz_formhistory " +
       "WHERE fieldname = :name AND value = :value");
     getQuery.params.name = name;
     getQuery.params.value = value;
 
     // Give the guid if we found one
     let item = Utils.queryAsync(getQuery, ["guid"])[0];
     
@@ -101,60 +101,43 @@ let FormWrapper = {
                       JSON.stringify(value) + ") => " + item);
       return null;
     }
     
     if (item.guid != null)
       return item.guid;
 
     // We need to create a guid for this entry
-    let setQuery = this.createStatement(
+    let setQuery = Svc.Form.DBConnection.createAsyncStatement(
       "UPDATE moz_formhistory SET guid = :guid " +
       "WHERE fieldname = :name AND value = :value");
     let guid = Utils.makeGUID();
     setQuery.params.guid = guid;
     setQuery.params.name = name;
     setQuery.params.value = value;
     Utils.queryAsync(setQuery);
 
     return guid;
   },
 
   hasGUID: function hasGUID(guid) {
-    let query = this.createStatement(
+    let query = Svc.Form.DBConnection.createAsyncStatement(
       "SELECT guid FROM moz_formhistory WHERE guid = :guid LIMIT 1");
     query.params.guid = guid;
     return Utils.queryAsync(query, ["guid"]).length == 1;
   },
 
   replaceGUID: function replaceGUID(oldGUID, newGUID) {
-    let query = this.createStatement(
+    let query = Svc.Form.DBConnection.createAsyncStatement(
       "UPDATE moz_formhistory SET guid = :newGUID WHERE guid = :oldGUID");
     query.params.oldGUID = oldGUID;
     query.params.newGUID = newGUID;
     Utils.queryAsync(query);
-  },
+  }
 
-  createStatement: function createStatement(query) {
-    try {
-      // Just return the statement right away if it's okay
-      return Utils.createStatement(Svc.Form.DBConnection, query);
-    }
-    catch(ex) {
-      // Assume guid column must not exist yet, so add it with an index
-      Svc.Form.DBConnection.executeSimpleSQL(
-        "ALTER TABLE moz_formhistory ADD COLUMN guid TEXT");
-      Svc.Form.DBConnection.executeSimpleSQL(
-        "CREATE INDEX IF NOT EXISTS moz_formhistory_guid_index " +
-        "ON moz_formhistory (guid)");
-
-      // Try creating the query now that the column exists
-      return Utils.createStatement(Svc.Form.DBConnection, query);
-    }
-  }
 };
 
 function FormEngine() {
   SyncEngine.call(this, "Forms");
 }
 FormEngine.prototype = {
   __proto__: SyncEngine.prototype,
   _storeObj: FormStore,
@@ -278,53 +261,29 @@ FormTracker.prototype = {
           Svc.Obs.remove("form-notifier", this);
           Svc.Obs.remove("satchel-storage-changed", this);
           Cc["@mozilla.org/observer-service;1"]
             .getService(Ci.nsIObserverService)
             .removeObserver(this, "earlyformsubmit");
           this._enabled = false;
         }
         break;
-      // Firefox 4.0
       case "satchel-storage-changed":
         if (data == "addEntry" || data == "before-removeEntry") {
           subject = subject.QueryInterface(Ci.nsIArray);
           let name = subject.queryElementAt(0, Ci.nsISupportsString)
                             .toString();
           let value = subject.queryElementAt(1, Ci.nsISupportsString)
                              .toString();
           this.trackEntry(name, value);
         }
         break;
-      // Firefox 3.5/3.6
-      case "form-notifier":
-        this.onFormNotifier(data);
-        break;
     }
   },
 
-  // Firefox 3.5/3.6
-  onFormNotifier: function onFormNotifier(data) {
-    let name, value;
-
-    // Figure out if it's a function that we care about tracking
-    let formCall = JSON.parse(data);
-    let func = formCall.func;
-    if ((func == "addEntry" && formCall.type == "after") ||
-        (func == "removeEntry" && formCall.type == "before"))
-      [name, value] = formCall.args;
-
-    // Skip if there's nothing of interest
-    if (name == null || value == null)
-      return;
-
-    this._log.trace("Logging form action: " + [func, name, value]);
-    this.trackEntry(name, value);
-  },
-
   notify: function FormTracker_notify(formElement, aWindow, actionURI) {
     if (this.ignoreAll)
       return;
 
     this._log.trace("Form submission notification for " + actionURI.spec);
 
     // XXX Bug 487541 Copy the logic from nsFormHistory::Notify to avoid
     // divergent logic, which can lead to security issues, until there's a