Bug 575514: Make DROP_DEAD not die for releases, and allow override by NECKO_ERRORS_ARE_FATAL env var. r=jdm
authorJason Duell <jduell.mcbugs@gmail.com>
Mon, 21 Jun 2010 00:11:50 -0700
changeset 46927 6ebee222742d37044c81d825c1836aa92480c0cb
parent 46926 f3e0fcbb5eb6f2e0d7aa7ec0495a3dbb50b63408
child 46928 a8fa5480651a66565de40f2006621f1ae803fe11
push idunknown
push userunknown
push dateunknown
reviewersjdm
bugs575514
milestone2.0b2pre
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 575514: Make DROP_DEAD not die for releases, and allow override by NECKO_ERRORS_ARE_FATAL env var. r=jdm
netwerk/ipc/NeckoCommon.h
netwerk/protocol/http/HttpChannelParent.cpp
--- a/netwerk/ipc/NeckoCommon.h
+++ b/netwerk/ipc/NeckoCommon.h
@@ -38,27 +38,48 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_net_NeckoCommon_h
 #define mozilla_net_NeckoCommon_h
 
 #include "nsXULAppAPI.h"
 
-// Temporary: use while we figure out which XPCOM interfaces (from list
-// copied from nsHttpChannel) HttpChannel{Child|Parent}, etc., actually need to
-// implement.  I.e., implement interfaces as we need them, and if we never hit a
-// given interface, figure out if we can stop advertising it.
+#if defined(DEBUG) || defined(ENABLE_TESTS)
+# define NECKO_ERRORS_ARE_FATAL_DEFAULT true
+#else
+# define NECKO_ERRORS_ARE_FATAL_DEFAULT false
+#endif 
+
+// TODO: Eventually remove NECKO_MAYBE_ABORT and DROP_DEAD (bug 575494).
+// Still useful for catching listener interfaces we don't yet support across
+// processes, etc.
+
+#define NECKO_MAYBE_ABORT(msg)                                                 \
+  do {                                                                         \
+    bool abort = NECKO_ERRORS_ARE_FATAL_DEFAULT;                               \
+    const char *e = PR_GetEnv("NECKO_ERRORS_ARE_FATAL");                       \
+    if (e)                                                                     \
+      abort = (*e == '0') ? false : true;                                      \
+    if (abort) {                                                               \
+      msg.Append(" (set NECKO_ERRORS_ARE_FATAL=0 in your environment to "      \
+                      "convert this error into a warning.)");                  \
+      NS_RUNTIMEABORT(msg.get());                                              \
+    } else {                                                                   \
+      msg.Append(" (set NECKO_ERRORS_ARE_FATAL=1 in your environment to "      \
+                      "convert this warning into a fatal error.)");            \
+      NS_WARNING(msg.get());                                                   \
+    }                                                                          \
+  } while (0)
 
 #define DROP_DEAD()                                                            \
   do {                                                                         \
-    fprintf(stderr,                                                            \
-            "*&*&*&*&*&*&*&**&*&&*& FATAL ERROR: '%s' UNIMPLEMENTED: %s +%d",  \
-            __FUNCTION__, __FILE__, __LINE__);                                 \
-    NS_ABORT();                                                                \
+    nsPrintfCString msg(1000,"FATAL NECKO ERROR: '%s' UNIMPLEMENTED",          \
+                        __FUNCTION__);                                         \
+    NECKO_MAYBE_ABORT(msg);                                                    \
     return NS_ERROR_NOT_IMPLEMENTED;                                           \
   } while (0)
 
 
 namespace mozilla {
 namespace net {
 
 inline bool 
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -276,16 +276,24 @@ HttpChannelParent::OnDataAvailable(nsIRe
 
 //-----------------------------------------------------------------------------
 // HttpChannelParent::nsIInterfaceRequestor
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP 
 HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
 {
+  if (aIID.Equals(NS_GET_IID(nsIAuthPromptProvider))) {
+    if (!mTabParent)
+      return NS_NOINTERFACE;
+    return mTabParent->QueryInterface(aIID, result);
+  }
+
+  // TODO: 575494: once we're confident we're handling all needed interfaces,
+  // remove all code below and simply "return QueryInterface(aIID, result)"
   if (// Known interface calls:
 
       // FIXME: HTTP Authorization (bug 537782):
       // nsHttpChannel first tries to get this as an nsIAuthPromptProvider; if that
       // fails, it tries as an nsIAuthPrompt2, and if that fails, an nsIAuthPrompt.
       // See nsHttpChannel::GetAuthPrompt().  So if we can return any one of these,
       // HTTP auth should be all set.  The other two if checks can be eventually
       // deleted.
@@ -302,32 +310,26 @@ HttpChannelParent::GetInterface(const ns
       aIID.Equals(NS_GET_IID(nsIApplicationCacheContainer)) ||
       aIID.Equals(NS_GET_IID(nsIProgressEventSink)) ||
       // FIXME:  bug 561830: when fixed, we shouldn't be asked for this interface
       aIID.Equals(NS_GET_IID(nsIDocShellTreeItem)) ||
       // Let this return NS_ERROR_NO_INTERFACE: it's OK to not provide it.
       aIID.Equals(NS_GET_IID(nsIBadCertListener2))) 
   {
     return QueryInterface(aIID, result);
-  } 
-
-  if (aIID.Equals(NS_GET_IID(nsIAuthPromptProvider))) {
-    if (!mTabParent)
-      return NS_NOINTERFACE;
-    return mTabParent->QueryInterface(aIID, result);
+  } else {
+    nsPrintfCString msg(2000, 
+       "HttpChannelParent::GetInterface: interface UUID=%s not yet supported! "
+       "Use 'grep -ri UUID <mozilla_src>' to find the name of the interface, "
+       "check http://tinyurl.com/255ojvu to see if a bug has already been "
+       "filed, and if not, add one and make it block bug 516730. Thanks!",
+       aIID.ToString());
+    NECKO_MAYBE_ABORT(msg);
+    return NS_NOINTERFACE;
   }
-
-  // Interface we haven't dealt with yet. Make sure we know by dying.
-  // - use "grep -ri [uuid] ROOT_SRC_DIR" with the uuid from the printf to
-  //   find the offending interface.
-  // - FIXME: make non-fatal before we ship
-  printf("*&*&*& HttpChannelParent::GetInterface: uuid=%s not impl'd yet! "
-         "File a bug!\n", 
-         aIID.ToString());
-  DROP_DEAD();
 }
 
 //-----------------------------------------------------------------------------
 // HttpChannelParent::nsIProgressEventSink
 //-----------------------------------------------------------------------------
  
 NS_IMETHODIMP
 HttpChannelParent::OnProgress(nsIRequest *aRequest,