Hook up the event loop changes and fix the build
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 30 Jun 2009 12:02:37 -0400
changeset 35737 df1133412587e158f5965b9f423b27f51896f240
parent 35736 db2c3e1c7d2882299a83ba307ef4596216b1646d
child 35738 b44e0c08c4cf52b7a5a87049ef5e1565cb439f54
push idunknown
push userunknown
push dateunknown
milestone1.9.2a1pre
Hook up the event loop changes and fix the build
ipc/chromium/Makefile.in
ipc/chromium/base/file_version_info_linux.h
ipc/glue/Makefile.in
toolkit/library/libxul-config.mk
widget/src/xpwidgets/Makefile.in
widget/src/xpwidgets/nsBaseAppShell.cpp
widget/src/xpwidgets/nsBaseAppShell.h
--- a/ipc/chromium/Makefile.in
+++ b/ipc/chromium/Makefile.in
@@ -36,18 +36,22 @@
 
 DEPTH = ../..
 topsrcdir = @top_srcdir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
+OS_CXXFLAGS := $(filter-out -fshort-wchar,$(OS_CXXFLAGS))
+
 LIBRARY_NAME = chromium_s
 FORCE_STATIC_LIB = 1
+LIBXUL_LIBRARY = 1
+EXPORT_LIBRARY = 1
 
 ENABLE_CXX_EXCEPTIONS = 1
 ACDEFINES =
 
 vpath %.c \
   $(srcdir)/src/third_party/libevent \
   $(NULL)
 
@@ -59,16 +63,19 @@ vpath %.cc \
   $(srcdir)/src/chrome/common \
   $(NULL)
 
 vpath %.mm \
   $(srcdir)/src/base \
   $(srcdir)/src/chrome/common \
   $(NULL)
 
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
+
 CPPSRCS += \
   dtoa.cc \
   g_fmt.cc \
   prtime.cc \
   at_exit.cc \
   base_paths.cc \
   base_switches.cc \
   command_line.cc \
@@ -249,17 +256,17 @@ CPPSRCS += \
   $(NULL)
 
 endif # } OS_LINUX
 
 # libevent
 
 ifdef OS_POSIX # {
 
-LOCAL_INCLUDES += $(srcdir)/src/third_party/libevent
+LOCAL_INCLUDES += -I$(srcdir)/src/third_party/libevent
 DEFINES += -DHAVE_CONFIG_H
 
 CSRCS += \
   buffer.c \
   evbuffer.c \
   evdns.c \
   event.c \
   event_tagging.c \
@@ -269,25 +276,23 @@ CSRCS += \
   log.c \
   poll.c \
   select.c \
   signal.c \
   strlcpy.c \
   $(NULL)
 
 ifdef OS_MACOSX # {
-LOCAL_INCLUDES += $(srcdir)/src/third_party/libevent/mac
+LOCAL_INCLUDES += -I$(srcdir)/src/third_party/libevent/mac
 CSRCS += kqueue.c
 endif # }
 
 ifdef OS_LINUX # {
-LOCAL_INCLUDES += $(srcdir)/src/third_party/libevent/linux
+LOCAL_INCLUDES += -I$(srcdir)/src/third_party/libevent/linux
 CSRCS += \
   epoll.c \
   epoll_sub.c \
   $(NULL)
 endif # }
 
 endif # }
 
-include $(topsrcdir)/config/config.mk
-include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
copy from ipc/chromium/src/base/file_version_info_linux.h.version
copy to ipc/chromium/base/file_version_info_linux.h
--- a/ipc/chromium/src/base/file_version_info_linux.h.version
+++ b/ipc/chromium/base/file_version_info_linux.h
@@ -9,17 +9,17 @@
 #define FILE_DESCRIPTION L"@PRODUCT_FULLNAME@"
 #define FILE_VERSION L"@MAJOR@.@MINOR@.@BUILD@.@PATCH@"
 #define LEGAL_COPYRIGHT L"@COPYRIGHT@"
 #define PRODUCT_NAME L"@PRODUCT_FULLNAME@"
 #define PRODUCT_VERSION L"@MAJOR@.@MINOR@.@BUILD@.@PATCH@"
 #define COMPANY_SHORT_NAME L"@COMPANY_SHORTNAME@"
 #define PRODUCT_SHORT_NAME L"@PRODUCT_SHORTNAME@"
 #define LAST_CHANGE L"@LASTCHANGE@"
-#define OFFICIAL_BUILD @OFFICIAL_BUILD@
+#define OFFICIAL_BUILD 1
 // TODO(mmoss) Do these have values for Linux?
 #define INTERNAL_NAME L""
 #define ORIGINAL_FILENAME L""
 #define PRIVATE_BUILD L""
 #define SPECIAL_BUILD L""
 #define COMMENTS L""
 #define LEGAL_TRADEMARKS L""
 
--- a/ipc/glue/Makefile.in
+++ b/ipc/glue/Makefile.in
@@ -40,16 +40,17 @@ srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = ipc
 LIBRARY_NAME = mozipc_s
 FORCE_STATIC_LIB = 1
 LIBXUL_LIBRARY = 1
+EXPORT_LIBRARY = 1
 
 EXPORTS_NAMESPACES = IPC mozilla/ipc
 
 EXPORTS_IPC =					\
   IPCMessageUtils.h 				\
   $(NULL)
 
 # FIXME/cjones: "ChromeThread" is a misnomer
--- a/toolkit/library/libxul-config.mk
+++ b/toolkit/library/libxul-config.mk
@@ -86,16 +86,23 @@ ifdef MOZ_ENABLE_LIBXUL
 RESFILE = xulrunos2.res
 RCFLAGS += -i $(topsrcdir)/widget/src/os2
 endif
 
 LOCAL_INCLUDES += -I$(topsrcdir)/widget/src/os2
 endif
 
 # dependent libraries
+ifdef MOZ_IPC
+STATIC_LIBS += \
+  mozipc_s \
+  chromium_s \
+  $(NULL)
+endif
+
 STATIC_LIBS += \
 	xpcom_core \
 	ucvutil_s \
 	gkgfx \
 	gfxshared_s \
 	$(NULL)
 
 #ifndef MOZ_EMBEDDING_LEVEL_DEFAULT
--- a/widget/src/xpwidgets/Makefile.in
+++ b/widget/src/xpwidgets/Makefile.in
@@ -60,17 +60,21 @@ REQUIRES	= xpcom \
 		  uconv \
 		  unicharutil \
 		  view \
 		  windowwatcher \
 		  qcms \
 		  thebes \
 		  $(NULL)
 
-DEFINES		+= -D_IMPL_NS_WIDGET -DUSE_TLS_FOR_TOOLKIT
+DEFINES += \
+  -D_IMPL_NS_WIDGET \
+  -DUSE_TLS_FOR_TOOLKIT \
+  -DNO_NSPR_10_SUPPORT=1 \
+  $(NULL)
 
 CPPSRCS		= \
 		nsBaseAppShell.cpp \
 		nsBaseWidget.cpp \
 		nsTransferable.cpp \
 		nsHTMLFormatConverter.cpp \
 		nsBaseDragService.cpp \
 		nsPrimitiveHelpers.cpp \
@@ -92,20 +96,21 @@ ifneq (,$(filter beos qt gtk2 os2 cocoa 
 CPPSRCS += nsBaseFilePicker.cpp
 REQUIRES += docshell view intl
 endif
 
 ifneq (,$(filter qt gtk2 windows cocoa,$(MOZ_WIDGET_TOOLKIT)))
 CPPSRCS += nsNativeTheme.cpp
 endif
 
-LOCAL_INCLUDES	= \
+LOCAL_INCLUDES	+= \
 		-I$(srcdir)/../$(MOZ_WIDGET_TOOLKIT) \
 		-I$(srcdir) \
 		$(NULL)
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS	+= $(TK_CFLAGS)
-
--- a/widget/src/xpwidgets/nsBaseAppShell.cpp
+++ b/widget/src/xpwidgets/nsBaseAppShell.cpp
@@ -36,16 +36,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsBaseAppShell.h"
 #include "nsThreadUtils.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
 
+#include "base/message_loop.h"
+
 // When processing the next thread event, the appshell may process native
 // events (if not in performance mode), which can result in suppressing the
 // next thread event for at most this many ticks:
 #define THREAD_EVENT_STARVATION_LIMIT PR_MillisecondsToInterval(20)
 
 NS_IMPL_THREADSAFE_ISUPPORTS3(nsBaseAppShell, nsIAppShell, nsIThreadObserver,
                               nsIObserver)
 
@@ -54,17 +56,17 @@ nsBaseAppShell::nsBaseAppShell()
   , mBlockedWait(nsnull)
   , mFavorPerf(0)
   , mNativeEventPending(0)
   , mEventloopNestingLevel(0)
   , mStarvationDelay(0)
   , mSwitchTime(0)
   , mLastNativeEventTime(0)
   , mEventloopNestingState(eEventloopNone)
-  , mRunWasCalled(PR_FALSE)
+  , mRunning(PR_FALSE)
   , mExiting(PR_FALSE)
   , mBlockNativeEvent(PR_FALSE)
 {
 }
 
 nsresult
 nsBaseAppShell::Init()
 {
@@ -156,31 +158,33 @@ nsBaseAppShell::DoProcessNextNativeEvent
 }
 
 //-------------------------------------------------------------------------
 // nsIAppShell methods:
 
 NS_IMETHODIMP
 nsBaseAppShell::Run(void)
 {
-  nsIThread *thread = NS_GetCurrentThread();
-
-  NS_ENSURE_STATE(!mRunWasCalled);  // should not call Run twice
-  mRunWasCalled = PR_TRUE;
+  NS_ENSURE_STATE(!mRunning);  // should not call Run twice
+  mRunning = PR_TRUE;
 
-  while (!mExiting)
-    NS_ProcessNextEvent(thread);
+  MessageLoop::current()->Run();
 
-  NS_ProcessPendingEvents(thread);
+  NS_ProcessPendingEvents(NS_GetCurrentThread());
+
+  mRunning = PR_FALSE;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBaseAppShell::Exit(void)
 {
+  if (mRunning && !mExiting) {
+    MessageLoop::current()->Quit();
+  }
   mExiting = PR_TRUE;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBaseAppShell::FavorPerformanceHint(PRBool favorPerfOverStarvation,
                                      PRUint32 starvationDelay)
 {
--- a/widget/src/xpwidgets/nsBaseAppShell.h
+++ b/widget/src/xpwidgets/nsBaseAppShell.h
@@ -114,17 +114,17 @@ private:
   PRIntervalTime mSwitchTime;
   PRIntervalTime mLastNativeEventTime;
   enum EventloopNestingState {
     eEventloopNone,  // top level thread execution
     eEventloopXPCOM, // innermost native event loop is ProcessNextNativeEvent
     eEventloopOther  // innermost native event loop is a native library/plugin etc
   };
   EventloopNestingState mEventloopNestingState;
-  PRPackedBool mRunWasCalled;
+  PRPackedBool mRunning;
   PRPackedBool mExiting;
   /**
    * mBlockNativeEvent blocks the appshell from processing native events.
    * It is set to PR_TRUE while a nested native event loop (eEventloopOther)
    * is processing gecko events in NativeEventCallback(), thus queuing up
    * native events until we return to that loop (bug 420148).
    * We force mBlockNativeEvent to PR_FALSE in case handling one of the gecko
    * events spins up a nested XPCOM event loop (eg. modal window) which would