Bug 715162: Move LazyIdleThread to xpcom/. r=bent
authorKyle Huey <khuey@kylehuey.com>
Thu, 05 Jan 2012 08:42:47 -0500
changeset 85028 2c8e6bd39c55fa2c549e7385aa330f647b491f08
parent 85027 8d341b0d890400c803281415dc0bccd0c687c52e
child 85029 f3e1f687b8f727ee9125e161a6076504a45dff63
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs715162
milestone12.0a1
Bug 715162: Move LazyIdleThread to xpcom/. r=bent
dom/indexedDB/IDBDatabase.cpp
dom/indexedDB/IDBFactory.cpp
dom/indexedDB/IndexedDatabaseManager.cpp
dom/indexedDB/LazyIdleThread.cpp
dom/indexedDB/LazyIdleThread.h
dom/indexedDB/Makefile.in
xpcom/threads/LazyIdleThread.cpp
xpcom/threads/LazyIdleThread.h
xpcom/threads/Makefile.in
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -52,17 +52,16 @@
 #include "CheckQuotaHelper.h"
 #include "DatabaseInfo.h"
 #include "IDBEvents.h"
 #include "IDBIndex.h"
 #include "IDBObjectStore.h"
 #include "IDBTransaction.h"
 #include "IDBFactory.h"
 #include "IndexedDatabaseManager.h"
-#include "LazyIdleThread.h"
 #include "TransactionThreadPool.h"
 #include "DictionaryHelpers.h"
 
 USING_INDEXEDDB_NAMESPACE
 
 namespace {
 
 class CreateObjectStoreHelper : public AsyncConnectionHelper
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -64,17 +64,16 @@
 #include "AsyncConnectionHelper.h"
 #include "CheckPermissionsHelper.h"
 #include "DatabaseInfo.h"
 #include "IDBDatabase.h"
 #include "IDBEvents.h"
 #include "IDBKeyRange.h"
 #include "IndexedDatabaseManager.h"
 #include "Key.h"
-#include "LazyIdleThread.h"
 #include "nsIScriptSecurityManager.h"
 
 using namespace mozilla;
 
 USING_INDEXEDDB_NAMESPACE
 
 namespace {
 
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -44,33 +44,33 @@
 #include "nsIFile.h"
 #include "nsIObserverService.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsISHEntry.h"
 #include "nsISimpleEnumerator.h"
 #include "nsITimer.h"
 
+#include "mozilla/LazyIdleThread.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/storage.h"
 #include "nsContentUtils.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOM.h"
 #include "nsXPCOMPrivate.h"
 #include "test_quota.h"
 #include "xpcpublic.h"
 
 #include "AsyncConnectionHelper.h"
 #include "CheckQuotaHelper.h"
 #include "IDBDatabase.h"
 #include "IDBEvents.h"
 #include "IDBFactory.h"
 #include "IDBKeyRange.h"
-#include "LazyIdleThread.h"
 #include "OpenDatabaseHelper.h"
 #include "TransactionThreadPool.h"
 
 // The amount of time, in milliseconds, that our IO thread will stay alive
 // after the last event it processes.
 #define DEFAULT_THREAD_TIMEOUT_MS 30000
 
 // The amount of time, in milliseconds, that we will wait for active database
--- a/dom/indexedDB/Makefile.in
+++ b/dom/indexedDB/Makefile.in
@@ -63,17 +63,16 @@ CPPSRCS = \
   IDBEvents.cpp \
   IDBIndex.cpp \
   IDBKeyRange.cpp \
   IDBObjectStore.cpp \
   IDBRequest.cpp \
   IDBTransaction.cpp \
   IDBFactory.cpp \
   IndexedDatabaseManager.cpp \
-  LazyIdleThread.cpp \
   OpenDatabaseHelper.cpp \
   TransactionThreadPool.cpp \
   Key.cpp \
   $(NULL)
 
 EXPORTS_mozilla/dom/indexedDB = \
   IDBCursor.h \
   IDBDatabase.h \
@@ -82,17 +81,16 @@ EXPORTS_mozilla/dom/indexedDB = \
   IDBKeyRange.h \
   IDBObjectStore.h \
   IDBRequest.h \
   IDBTransaction.h \
   IndexedDatabase.h \
   IndexedDatabaseManager.h \
   IDBFactory.h \
   Key.h \
-  LazyIdleThread.h \
   FileManager.h \
   FileInfo.h \
   $(NULL)
 
 LOCAL_INCLUDES = \
   -I$(topsrcdir)/db/sqlite3/src \
   -I$(topsrcdir)/xpcom/build \
   -I$(topsrcdir)/dom/base \
rename from dom/indexedDB/LazyIdleThread.cpp
rename to xpcom/threads/LazyIdleThread.cpp
--- a/dom/indexedDB/LazyIdleThread.cpp
+++ b/xpcom/threads/LazyIdleThread.cpp
@@ -55,19 +55,17 @@
       nsCOMPtr<nsISupports> test(do_QueryInterface(mOwningThread));            \
       NS_ASSERTION(current == test, "Wrong thread!");                          \
     }                                                                          \
   PR_END_MACRO
 #else
 #define ASSERT_OWNING_THREAD() /* nothing */
 #endif
 
-USING_INDEXEDDB_NAMESPACE
-
-using mozilla::MutexAutoLock;
+namespace mozilla {
 
 LazyIdleThread::LazyIdleThread(PRUint32 aIdleTimeoutMS,
                                ShutdownMethod aShutdownMethod,
                                nsIObserver* aIdleObserver)
 : mMutex("LazyIdleThread::mMutex"),
   mOwningThread(NS_GetCurrentThread()),
   mIdleObserver(aIdleObserver),
   mQueuedRunnables(nsnull),
@@ -553,8 +551,10 @@ LazyIdleThread::Observe(nsISupports* /* 
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   NS_ASSERTION(mShutdownMethod == AutomaticShutdown,
                "Should not receive notifications if not AutomaticShutdown!");
   NS_ASSERTION(!strcmp("xpcom-shutdown-threads", aTopic), "Bad topic!");
 
   Shutdown();
   return NS_OK;
 }
+
+} // namespace mozilla
rename from dom/indexedDB/LazyIdleThread.h
rename to xpcom/threads/LazyIdleThread.h
--- a/dom/indexedDB/LazyIdleThread.h
+++ b/xpcom/threads/LazyIdleThread.h
@@ -32,30 +32,33 @@
  * 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 ***** */
 
-#ifndef mozilla_dom_indexeddb_lazyidlethread_h__
-#define mozilla_dom_indexeddb_lazyidlethread_h__
+#ifndef mozilla_lazyidlethread_h__
+#define mozilla_lazyidlethread_h__
 
-#include "mozilla/dom/indexedDB/IndexedDatabase.h"
+#ifndef MOZILLA_INTERNAL_API
+#error "This header is only usable from within libxul (MOZILLA_INTERNAL_API)."
+#endif
 
 #include "nsIObserver.h"
 #include "nsIThreadInternal.h"
 #include "nsITimer.h"
 
 #include "mozilla/Mutex.h"
+#include "nsCOMPtr.h"
 
 #define IDLE_THREAD_TOPIC "thread-shutting-down"
 
-BEGIN_INDEXEDDB_NAMESPACE
+namespace mozilla {
 
 /**
  * This class provides a basic event target that creates its thread lazily and
  * destroys its thread after a period of inactivity. It may be created on any
  * thread but it may only be used from the thread on which it is created. If it
  * is created on the main thread then it will automatically join its thread on
  * XPCOM shutdown using the Observer Service.
  */
@@ -231,11 +234,11 @@ private:
   bool mThreadIsShuttingDown;
 
   /**
    * Whether or not the idle timeout is enabled.
    */
   bool mIdleTimeoutEnabled;
 };
 
-END_INDEXEDDB_NAMESPACE
+} // namespace mozilla
 
-#endif // mozilla_dom_indexeddb_lazyidlethread_h__
+#endif // mozilla_lazyidlethread_h__
--- a/xpcom/threads/Makefile.in
+++ b/xpcom/threads/Makefile.in
@@ -56,27 +56,29 @@ CPPSRCS		= \
 		nsEnvironment.cpp \
 		nsThread.cpp \
 		nsThreadManager.cpp \
 		nsThreadPool.cpp \
 		nsProcessCommon.cpp \
 		nsTimerImpl.cpp \
 		TimerThread.cpp \
 		HangMonitor.cpp \
+		LazyIdleThread.cpp \
 		$(NULL)
 
 EXPORTS		= \
 		nsThread.h \
 		nsProcess.h \
 		nsEventQueue.h \
 		nsThreadUtilsInternal.h \
 		$(NULL)
 
 EXPORTS_mozilla = \
   HangMonitor.h \
+  LazyIdleThread.h \
   $(NULL)
 
 XPIDLSRCS	= \
 		nsIEventTarget.idl \
 		nsIThread.idl \
 		nsIThreadInternal.idl \
 		nsIThreadManager.idl \
 		nsIThreadPool.idl \