Bug 459493 - remove placesBackground, r+a=mconnor
authorMarco Bonardo <mak77@bonardo.net>
Thu, 06 Nov 2008 23:22:10 +0100
changeset 21400 35826c8d31984e997c2251816e0abd65793045bf
parent 21399 4b525208d2e39f0285e393d87e2ab0749efed029
child 21401 4f773b27f03312e043a9d12dbd444f001fd9b713
child 21518 8c4eb359350eae4a379525a3b94205bb9793feb9
push id3533
push usermak77@bonardo.net
push dateThu, 06 Nov 2008 22:23:12 +0000
treeherdermozilla-central@35826c8d3198 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs459493
milestone1.9.1b2pre
Bug 459493 - remove placesBackground, r+a=mconnor
toolkit/components/places/src/Makefile.in
toolkit/components/places/src/PlacesBackground.jsm
toolkit/components/places/tests/Makefile.in
toolkit/components/places/tests/background/head_background.js
toolkit/components/places/tests/background/test_background.js
--- a/toolkit/components/places/src/Makefile.in
+++ b/toolkit/components/places/src/Makefile.in
@@ -105,14 +105,13 @@ LOCAL_INCLUDES += -I$(srcdir)/../../buil
 
 EXTRA_PP_COMPONENTS = nsLivemarkService.js \
                       nsTaggingService.js \
                       nsPlacesDBFlush.js \
                       $(NULL)
 
 EXTRA_JS_MODULES = \
   utils.js \
-  PlacesBackground.jsm \
   $(NULL)
 
 EXTRA_PP_JS_MODULES = utils.js
 
 include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/toolkit/components/places/src/PlacesBackground.jsm
+++ /dev/null
@@ -1,112 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=2 sts=2 expandtab filetype=javascript
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2008
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Shawn Wilsher <me@shawnwilsher.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-var EXPORTED_SYMBOLS = [ "PlacesBackground" ];
-
-////////////////////////////////////////////////////////////////////////////////
-//// Constants
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
-const kQuitApplication = "quit-application";
-const kPlacesBackgroundShutdown = "places-background-shutdown";
-
-////////////////////////////////////////////////////////////////////////////////
-//// nsPlacesBackgound class
-
-function nsPlacesBackground()
-{
-  let tm = Cc["@mozilla.org/thread-manager;1"].
-           getService(Ci.nsIThreadManager);
-  this._thread = tm.newThread(0);
-
-  let os = Cc["@mozilla.org/observer-service;1"].
-           getService(Ci.nsIObserverService);
-  os.addObserver(this, kQuitApplication, false);
-}
-
-nsPlacesBackground.prototype = {
-  //////////////////////////////////////////////////////////////////////////////
-  //// nsIEventTarget
-
-  dispatch: function PlacesBackground_dispatch(aEvent, aFlags)
-  {
-    this._thread.dispatch(aEvent, aFlags);
-  },
-
-  isOnCurrentThread: function PlacesBackground_isOnCurrentThread()
-  {
-    return this._thread.isOnCurrentThread();
-  },
-
-  //////////////////////////////////////////////////////////////////////////////
-  //// nsIObserver
-
-  observe: function PlacesBackground_observe(aSubject, aTopic, aData)
-  {
-    if (aTopic == kQuitApplication) {
-      // Notify consumers that we are shutting down.
-      let os = Cc["@mozilla.org/observer-service;1"].
-               getService(Ci.nsIObserverService);
-      os.notifyObservers(null, kPlacesBackgroundShutdown, null);
-
-      // Now shut the thread down.
-      this._thread.shutdown();
-      this._thread = null;
-    }
-  },
-
-  //////////////////////////////////////////////////////////////////////////////
-  //// nsISupports
-
-  QueryInterface: XPCOMUtils.generateQI([
-    Ci.nsIEventTarget,
-    Ci.nsIObserver,
-  ])
-};
-
-
-__defineGetter__("PlacesBackground", function() {
-  delete this.PlacesBackground;
-  return this.PlacesBackground = new nsPlacesBackground;
-});
--- a/toolkit/components/places/tests/Makefile.in
+++ b/toolkit/components/places/tests/Makefile.in
@@ -43,17 +43,16 @@ VPATH		= @srcdir@
 relativesrcdir	= toolkit/components/places/tests
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= test_places
 
 XPCSHELL_TESTS = \
                  autocomplete \
-                 background \
                  sync \
                  bookmarks \
                  queries \
                  unit \
                  $(NULL)
 
 # Simple MochiTests
 MOCHI_TESTS = mochitest/test_bug_405924.html \
deleted file mode 100644
--- a/toolkit/components/places/tests/background/head_background.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Places.
- *
- * The Initial Developer of the Original Code is
- * Google Inc.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Brian Ryner <bryner@brianryner.com>
- *  Dietrich Ayala <dietrich@mozilla.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-const NS_APP_USER_PROFILE_50_DIR = "ProfD";
-const NS_APP_HISTORY_50_FILE = "UHist";
-
-const Ci = Components.interfaces;
-const Cc = Components.classes;
-const Cr = Components.results;
-
-function LOG(aMsg) {
-  aMsg = ("*** PLACES TESTS: " + aMsg);
-  Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).
-                                      logStringMessage(aMsg);
-  print(aMsg);
-}
-
-// If there's no location registered for the profile direcotry, register one now.
-var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
-var profileDir = null;
-try {
-  profileDir = dirSvc.get(NS_APP_USER_PROFILE_50_DIR, Ci.nsIFile);
-} catch (e) {}
-if (!profileDir) {
-  // Register our own provider for the profile directory.
-  // It will simply return the current directory.
-  var provider = {
-    getFile: function(prop, persistent) {
-      persistent.value = true;
-      if (prop == NS_APP_USER_PROFILE_50_DIR) {
-        return dirSvc.get("CurProcD", Ci.nsIFile);
-      }
-      if (prop == NS_APP_HISTORY_50_FILE) {
-        var histFile = dirSvc.get("CurProcD", Ci.nsIFile);
-        histFile.append("history.dat");
-        return histFile;
-      }
-      throw Cr.NS_ERROR_FAILURE;
-    },
-    QueryInterface: function(iid) {
-      if (iid.equals(Ci.nsIDirectoryServiceProvider) ||
-          iid.equals(Ci.nsISupports)) {
-        return this;
-      }
-      throw Cr.NS_ERROR_NO_INTERFACE;
-    }
-  };
-  dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
-}
-
-var iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-
-function uri(spec) {
-  return iosvc.newURI(spec, null, null);
-}
-
-// Delete a previously created sqlite file
-function clearDB() {
-  try {
-    var file = dirSvc.get('ProfD', Ci.nsIFile);
-    file.append("places.sqlite");
-    if (file.exists())
-      file.remove(false);
-  } catch(ex) { dump("Exception: " + ex); }
-}
-clearDB();
deleted file mode 100644
--- a/toolkit/components/places/tests/background/test_background.js
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=2 sts=2 expandtab
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2008
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Shawn Wilsher <me@shawnwilsher.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-Components.utils.import("resource://gre/modules/PlacesBackground.jsm");
-
-function test_service_exists()
-{
-  do_check_neq(PlacesBackground, null);
-}
-
-function test_isOnCurrentThread()
-{
-  do_check_false(PlacesBackground.isOnCurrentThread());
-
-  let event = {
-    run: function()
-    {
-      do_check_true(PlacesBackground.isOnCurrentThread());
-    }
-  };
-  PlacesBackground.dispatch(event, Ci.nsIEventTarget.DISPATCH_SYNC);
-}
-
-function test_two_events_same_thread()
-{
-  // This test imports PlacesBackground.jsm onto two different objects to
-  // ensure that the thread is the same for both.
-  let event = {
-    run: function()
-    {
-      let tm = Cc["@mozilla.org/thread-manager;1"].
-               getService(Ci.nsIThreadManager);
-
-      if (!this.thread1)
-        this.thread1 = tm.currentThread;
-      else
-        this.thread2 = tm.currentThread;
-    }
-  };
-
-  let obj1 = { };
-  Components.utils.import("resource://gre/modules/PlacesBackground.jsm", obj1);
-  obj1.PlacesBackground.dispatch(event, Ci.nsIEventTarget.DISPATCH_SYNC);
-  let obj2 = { };
-  Components.utils.import("resource://gre/modules/PlacesBackground.jsm", obj2);
-  obj2.PlacesBackground.dispatch(event, Ci.nsIEventTarget.DISPATCH_SYNC);
-  do_check_eq(event.thread1, event.thread2);
-}
-
-function test_places_background_shutdown_topic()
-{
-  // Ensures that the places shutdown topic is dispatched before the thread is
-  // shutdown.
-  let os = Cc["@mozilla.org/observer-service;1"].
-           getService(Ci.nsIObserverService);
-  os.addObserver({
-    observe: function(aSubject, aTopic, aData)
-    {
-      // We should still be able to dispatch an event without throwing now!
-      PlacesBackground.dispatch({
-        run: function()
-        {
-          do_test_finished();
-        }
-      }, Ci.nsIEventTarget.DISPATCH_NORMAL);
-    }
-  }, "places-background-shutdown", false);
-  do_test_pending();
-}
-
-let tests = [
-  test_service_exists,
-  test_isOnCurrentThread,
-  test_two_events_same_thread,
-  test_places_background_shutdown_topic,
-];
-
-function run_test()
-{
-  for (let i = 0; i < tests.length; i++)
-    tests[i]();
-
-  // xpcshell doesn't dispatch shutdown-application
-  let os = Cc["@mozilla.org/observer-service;1"].
-           getService(Ci.nsIObserverService);
-  os.notifyObservers(null, "quit-application", null);
-}