Bug 969469: use SyncRunnable to get local interface information on gonk. r=bwc
authorPatrick Wang (Chih-Kai Wang) <kk1fff@patrickz.net>
Tue, 18 Feb 2014 14:44:45 +0800
changeset 170608 25623a3aa663c02d65218e350ee78f4cae96450a
parent 170607 a55d95e28c747a66f791c8a6e10200cb995444b2
child 170609 612c8bdd4fe28a86966b8818f500f2f0bf60005d
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersbwc
bugs969469
milestone30.0a1
Bug 969469: use SyncRunnable to get local interface information on gonk. r=bwc
media/mtransport/gonk_addrs.cpp
--- a/media/mtransport/gonk_addrs.cpp
+++ b/media/mtransport/gonk_addrs.cpp
@@ -13,16 +13,17 @@ extern "C" {
 #include <vector>
 #include <string>
 #include "nsINetworkManager.h"
 #include "nsINetworkInterfaceListService.h"
 #include "runnable_utils.h"
 #include "nsCOMPtr.h"
 #include "nsThreadUtils.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/SyncRunnable.h"
 
 namespace {
 struct NetworkInterface {
   struct sockaddr_in addr;
   std::string name;
   // See NR_INTERFACE_TYPE_* in nICEr/src/net/local_addrs.h
   int type;
 };
@@ -99,22 +100,21 @@ int
 nr_stun_get_addrs(nr_local_addr aAddrs[], int aMaxAddrs,
                   int aDropLoopback, int* aCount)
 {
   nsresult rv;
   int r;
 
   // Get network interface list.
   std::vector<NetworkInterface> interfaces;
-  if (NS_FAILED(NS_DispatchToMainThread(
-                    mozilla::WrapRunnableNMRet(&GetInterfaces, &interfaces, &rv),
-                    NS_DISPATCH_SYNC))) {
-    return R_FAILED;
-  }
-
+  nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
+  mozilla::SyncRunnable::DispatchToThread(
+    mainThread.get(),
+    mozilla::WrapRunnableNMRet(&GetInterfaces, &interfaces, &rv),
+    false);
   if (NS_FAILED(rv)) {
     return R_FAILED;
   }
 
   // Translate to nr_transport_addr.
   int32_t n = 0;
   size_t num_interface = std::min(interfaces.size(), (size_t)aMaxAddrs);
   for (size_t i = 0; i < num_interface; ++i) {