Merge m-c to fx-team. a=merge
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 14 Jan 2016 11:30:40 -0500
changeset 280123 8cb84bef02030a00f25c4faace00c5ac1e525e70
parent 280122 8017627448ca6fcfe1c165a94d7e74c57eb032e3 (current diff)
parent 279991 878033e3ca98726f11dd3a30b0768961d221d22a (diff)
child 280124 436190769b9eb813437b42927db8ebe219b4b4b3
push id70334
push usercbook@mozilla.com
push dateFri, 15 Jan 2016 10:48:53 +0000
treeherdermozilla-inbound@de9a0fc7828d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone46.0a1
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
Merge m-c to fx-team. a=merge
media/webrtc/signaling/test/FakeIPC.cpp
media/webrtc/signaling/test/FakeIPC.h
deleted file mode 100644
--- a/media/webrtc/signaling/test/FakeIPC.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "FakeIPC.h"
-#include <unistd.h>
-
-// The implementations can't be in the .h file for some annoying reason
-
-/* static */ void
-PlatformThread:: YieldCurrentThread()
-{
-  sleep(1);
-}
-
-namespace base {
-
-void AtExitManager::RegisterCallback(AtExitCallbackType func, void* param)
-{
-}
-
-}
-
-// see atomicops_internals_x86_gcc.h
-// This cheats to get the unittests to build
-
-struct AtomicOps_x86CPUFeatureStruct {
-  bool field1;
-  bool field2;
-};
-
-struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = {
-  false,
-  false,
-};
deleted file mode 100644
--- a/media/webrtc/signaling/test/FakeIPC.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef FAKE_IPC_H_
-#define FAKE_IPC_H_
-#include <unistd.h>
-
-class PlatformThread {
-public:
-  static void YieldCurrentThread();
-};
-
-namespace base {
-class AtExitManager {
-public:
-  typedef void (*AtExitCallbackType)(void*);
-
-  static void RegisterCallback(AtExitCallbackType func, void* param);
-};
-}
-#endif
--- a/media/webrtc/signaling/test/jsep_session_unittest.cpp
+++ b/media/webrtc/signaling/test/jsep_session_unittest.cpp
@@ -27,19 +27,16 @@
 #include "signaling/src/jsep/JsepCodecDescription.h"
 #include "signaling/src/jsep/JsepTrack.h"
 #include "signaling/src/jsep/JsepSession.h"
 #include "signaling/src/jsep/JsepSessionImpl.h"
 #include "signaling/src/jsep/JsepTrack.h"
 
 #include "mtransport_test_utils.h"
 
-#include "FakeIPC.h"
-#include "FakeIPC.cpp"
-
 namespace mozilla {
 static std::string kAEqualsCandidate("a=candidate:");
 const static size_t kNumCandidatesPerComponent = 3;
 
 class JsepSessionTestBase : public ::testing::Test
 {
 };
 
--- a/media/webrtc/signaling/test/jsep_track_unittest.cpp
+++ b/media/webrtc/signaling/test/jsep_track_unittest.cpp
@@ -14,19 +14,16 @@
 #include "FakeLogging.h"
 
 #include "signaling/src/jsep/JsepTrack.h"
 #include "signaling/src/sdp/SipccSdp.h"
 #include "signaling/src/sdp/SdpHelper.h"
 
 #include "mtransport_test_utils.h"
 
-#include "FakeIPC.h"
-#include "FakeIPC.cpp"
-
 namespace mozilla {
 
 class JsepTrackTest : public ::testing::Test
 {
   public:
     JsepTrackTest() {}
 
     std::vector<JsepCodecDescription*>
--- a/media/webrtc/signaling/test/mediaconduit_unittests.cpp
+++ b/media/webrtc/signaling/test/mediaconduit_unittests.cpp
@@ -17,19 +17,16 @@ using namespace std;
 #include "GmpVideoCodec.h"
 #include "nsIEventTarget.h"
 #include "FakeMediaStreamsImpl.h"
 #include "FakeLogging.h"
 #include "nsThreadUtils.h"
 #include "runnable_utils.h"
 #include "signaling/src/common/EncodingConstraints.h"
 
-#include "FakeIPC.h"
-#include "FakeIPC.cpp"
-
 #define GTEST_HAS_RTTI 0
 #include "gtest/gtest.h"
 #include "gtest_utils.h"
 
 nsCOMPtr<nsIThread> gMainThread;
 nsCOMPtr<nsIThread> gGtestThread;
 bool gTestsComplete = false;
 
--- a/media/webrtc/signaling/test/mediapipeline_unittest.cpp
+++ b/media/webrtc/signaling/test/mediapipeline_unittest.cpp
@@ -31,19 +31,16 @@
 #include "mozilla/SyncRunnable.h"
 
 
 #include "mtransport_test_utils.h"
 #include "runnable_utils.h"
 
 #include "webrtc/modules/interface/module_common_types.h"
 
-#include "FakeIPC.h"
-#include "FakeIPC.cpp"
-
 #define GTEST_HAS_RTTI 0
 #include "gtest/gtest.h"
 #include "gtest_utils.h"
 
 using namespace mozilla;
 MOZ_MTLOG_MODULE("mediapipeline")
 
 MtransportTestUtils *test_utils;
--- a/media/webrtc/signaling/test/sdp_file_parser.cpp
+++ b/media/webrtc/signaling/test/sdp_file_parser.cpp
@@ -13,19 +13,16 @@
 #include "gtest_utils.h"
 
 // without this include linking fails
 #include "FakeMediaStreamsImpl.h"
 #include "FakeLogging.h"
 
 #include "signaling/src/sdp/SipccSdpParser.h"
 
-#include "FakeIPC.h"
-#include "FakeIPC.cpp"
-
 namespace mozilla {
 
 const std::string kDefaultFilename((char *)"/tmp/sdp.bin");
 std::string filename(kDefaultFilename);
 
 class SdpParseTest : public ::testing::Test
 {
   public:
--- a/media/webrtc/signaling/test/sdp_unittests.cpp
+++ b/media/webrtc/signaling/test/sdp_unittests.cpp
@@ -39,19 +39,16 @@ extern "C" {
 #include "signaling/src/sdp/sipcc/sdp_private.h"
 }
 
 #ifdef CRLF
 #undef CRLF
 #endif
 #define CRLF "\r\n"
 
-#include "FakeIPC.h"
-#include "FakeIPC.cpp"
-
 using namespace mozilla;
 
 namespace test {
 
 static bool SetupGlobalThread() {
   if (!gThread) {
     nsIThread *thread;
 
--- a/media/webrtc/signaling/test/signaling_unittests.cpp
+++ b/media/webrtc/signaling/test/signaling_unittests.cpp
@@ -40,19 +40,16 @@
 #include "mozilla/SyncRunnable.h"
 #include "logging.h"
 #include "stunserver.h"
 #include "stunserver.cpp"
 #ifdef SIGNALING_UNITTEST_STANDALONE
 #include "PeerConnectionImplEnumsBinding.cpp"
 #endif
 
-#include "FakeIPC.h"
-#include "FakeIPC.cpp"
-
 #include "ice_ctx.h"
 #include "ice_peer_ctx.h"
 
 #include "mtransport_test_utils.h"
 #include "gtest_ringbuffer_dumper.h"
 MtransportTestUtils *test_utils;
 nsCOMPtr<nsIThread> gMainThread;
 nsCOMPtr<nsIThread> gGtestThread;
--- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/ssrc_database.h
+++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/ssrc_database.h
@@ -24,20 +24,20 @@ class SSRCDatabase
 public:
     static SSRCDatabase* GetSSRCDatabase();
     static void ReturnSSRCDatabase();
 
     uint32_t CreateSSRC();
     int32_t RegisterSSRC(const uint32_t ssrc);
     int32_t ReturnSSRC(const uint32_t ssrc);
 
+protected:
     SSRCDatabase();
     virtual ~SSRCDatabase();
 
-protected:
     static SSRCDatabase* CreateInstance() { return new SSRCDatabase(); }
 
 private:
     // Friend function to allow the SSRC destructor to be accessed from the
     // template class.
     friend SSRCDatabase* GetStaticInstance<SSRCDatabase>(
         CountOperation count_operation);
     static SSRCDatabase* StaticInstance(CountOperation count_operation);
--- a/media/webrtc/trunk/webrtc/system_wrappers/interface/static_instance.h
+++ b/media/webrtc/trunk/webrtc/system_wrappers/interface/static_instance.h
@@ -8,20 +8,20 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
 #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATIC_INSTANCE_H_
 #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATIC_INSTANCE_H_
 
 #include <assert.h>
 
-#if defined(WEBRTC_ANDROID) || defined(WEBRTC_GONK)
-#define OS_LINUX
+#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
+#ifdef _WIN32
+#include "webrtc/system_wrappers/interface/fix_interlocked_exchange_pointer_win.h"
 #endif
-#include "base/singleton.h"
 
 namespace webrtc {
 
 enum CountOperation {
   kRelease,
   kAddRef,
   kAddRefNoCreate
 };
@@ -30,14 +30,124 @@ enum CreateOperation {
   kCreate,
   kDestroy
 };
 
 template <class T>
 // Construct On First Use idiom. Avoids
 // "static initialization order fiasco".
 static T* GetStaticInstance(CountOperation count_operation) {
-  // Simple solution since we don't use this for large objects anymore
-  return Singleton<T>::get();
+  // TODO (hellner): use atomic wrapper instead.
+  static volatile long instance_count = 0;
+  static T* volatile instance = NULL;
+  CreateOperation state = kInstanceExists;
+#ifndef _WIN32
+  // This memory is staticly allocated once. The application does not try to
+  // free this memory. This approach is taken to avoid issues with
+  // destruction order for statically allocated memory. The memory will be
+  // reclaimed by the OS and memory leak tools will not recognize memory
+  // reachable from statics leaked so no noise is added by doing this.
+  static CriticalSectionWrapper* crit_sect(
+    CriticalSectionWrapper::CreateCriticalSection());
+  CriticalSectionScoped lock(crit_sect);
+
+  if (count_operation ==
+      kAddRefNoCreate && instance_count == 0) {
+    return NULL;
+  }
+  if (count_operation ==
+      kAddRef ||
+      count_operation == kAddRefNoCreate) {
+    instance_count++;
+    if (instance_count == 1) {
+      state = kCreate;
+    }
+  } else {
+    instance_count--;
+    if (instance_count == 0) {
+      state = kDestroy;
+    }
+  }
+  if (state == kCreate) {
+    instance = T::CreateInstance();
+  } else if (state == kDestroy) {
+    T* old_instance = instance;
+    instance = NULL;
+    // The state will not change past this point. Release the critical
+    // section while deleting the object in case it would be blocking on
+    // access back to this object. (This is the case for the tracing class
+    // since the thread owned by the tracing class also traces).
+    // TODO(hellner): this is a bit out of place but here goes, de-couple
+    // thread implementation with trace implementation.
+    crit_sect->Leave();
+    if (old_instance) {
+      delete old_instance;
+    }
+    // Re-acquire the lock since the scoped critical section will release
+    // it.
+    crit_sect->Enter();
+    return NULL;
+  }
+#else  // _WIN32
+  if (count_operation ==
+      kAddRefNoCreate && instance_count == 0) {
+    return NULL;
+  }
+  if (count_operation == kAddRefNoCreate) {
+    if (1 == InterlockedIncrement(&instance_count)) {
+      // The instance has been destroyed by some other thread. Rollback.
+      InterlockedDecrement(&instance_count);
+      assert(false);
+      return NULL;
+    }
+    // Sanity to catch corrupt state.
+    if (instance == NULL) {
+      assert(false);
+      InterlockedDecrement(&instance_count);
+      return NULL;
+    }
+  } else if (count_operation == kAddRef) {
+    if (instance_count == 0) {
+      state = kCreate;
+    } else {
+      if (1 == InterlockedIncrement(&instance_count)) {
+        // InterlockedDecrement because reference count should not be
+        // updated just yet (that's done when the instance is created).
+        InterlockedDecrement(&instance_count);
+        state = kCreate;
+      }
+    }
+  } else {
+    int new_value = InterlockedDecrement(&instance_count);
+    if (new_value == 0) {
+      state = kDestroy;
+    }
+  }
+
+  if (state == kCreate) {
+    // Create instance and let whichever thread finishes first assign its
+    // local copy to the global instance. All other threads reclaim their
+    // local copy.
+    T* new_instance = T::CreateInstance();
+    if (1 == InterlockedIncrement(&instance_count)) {
+      InterlockedExchangePointer(reinterpret_cast<void * volatile*>(&instance),
+                                 new_instance);
+    } else {
+      InterlockedDecrement(&instance_count);
+      if (new_instance) {
+        delete static_cast<T*>(new_instance);
+      }
+    }
+  } else if (state == kDestroy) {
+    T* old_value = static_cast<T*>(InterlockedExchangePointer(
+        reinterpret_cast<void * volatile*>(&instance), NULL));
+    if (old_value) {
+      delete static_cast<T*>(old_value);
+    }
+    return NULL;
+  }
+#endif  // #ifndef _WIN32
+  return instance;
 }
+
 }  // namspace webrtc
 
 #endif  // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATIC_INSTANCE_H_
--- a/media/webrtc/trunk/webrtc/system_wrappers/source/rw_lock_win.cc
+++ b/media/webrtc/trunk/webrtc/system_wrappers/source/rw_lock_win.cc
@@ -64,21 +64,17 @@ bool RWLockWin::LoadModule() {
     return native_rw_locks_supported;
   }
   module_load_attempted = true;
   // Use native implementation if supported (i.e Vista+)
   library = LoadLibrary(TEXT("Kernel32.dll"));
   if (!library) {
     return false;
   }
-  // Don't log here, since we may be creating a FileWrapper for
-  // the TraceImpl, from within GetStaticInstance.  With singleton.h, you
-  // can't safely call GetStaticInstance on the same object from within
-  // creating that object (go figure...)
-  //WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1, "Loaded Kernel.dll");
+  WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1, "Loaded Kernel.dll");
 
   initialize_srw_lock =
     (InitializeSRWLock)GetProcAddress(library, "InitializeSRWLock");
 
   acquire_srw_lock_exclusive =
     (AcquireSRWLockExclusive)GetProcAddress(library,
                                             "AcquireSRWLockExclusive");
   release_srw_lock_exclusive =
@@ -87,15 +83,15 @@ bool RWLockWin::LoadModule() {
   acquire_srw_lock_shared =
     (AcquireSRWLockShared)GetProcAddress(library, "AcquireSRWLockShared");
   release_srw_lock_shared =
     (ReleaseSRWLockShared)GetProcAddress(library, "ReleaseSRWLockShared");
 
   if (initialize_srw_lock && acquire_srw_lock_exclusive &&
       release_srw_lock_exclusive && acquire_srw_lock_shared &&
       release_srw_lock_shared) {
-    //WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1, "Loaded Native RW Lock");
+    WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1, "Loaded Native RW Lock");
     native_rw_locks_supported = true;
   }
   return native_rw_locks_supported;
 }
 
 }  // namespace webrtc
--- a/media/webrtc/trunk/webrtc/system_wrappers/source/trace_impl.cc
+++ b/media/webrtc/trunk/webrtc/system_wrappers/source/trace_impl.cc
@@ -9,17 +9,16 @@
  */
 
 #include "webrtc/system_wrappers/source/trace_impl.h"
 
 #include <assert.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
-#include "base/singleton.h"
 
 #ifdef _WIN32
 #include "webrtc/system_wrappers/source/trace_win.h"
 #else
 #include "webrtc/system_wrappers/source/trace_posix.h"
 #endif  // _WIN32
 
 #define KEY_LEN_CHARS 31
@@ -59,22 +58,17 @@ TraceImpl* TraceImpl::StaticInstance(Cou
   // performance reasons). count_operation == kAddRefNoCreate implies that a
   // message will be written to file.
   if ((level != kTraceAll) && (count_operation == kAddRefNoCreate)) {
     if (!(level & level_filter())) {
       return NULL;
     }
   }
   TraceImpl* impl =
-#if defined(_WIN32)
-    GetStaticInstance<TraceWindows>(count_operation);
-#else
-    GetStaticInstance<TracePosix>(count_operation);
-#endif
-
+    GetStaticInstance<TraceImpl>(count_operation);
   return impl;
 }
 
 TraceImpl* TraceImpl::GetTrace(const TraceLevel level) {
   return StaticInstance(kAddRefNoCreate, level);
 }
 
 TraceImpl* TraceImpl::CreateInstance() {
--- a/testing/mozharness/mozharness/mozilla/l10n/locales.py
+++ b/testing/mozharness/mozharness/mozilla/l10n/locales.py
@@ -190,16 +190,18 @@ class LocalesMixin(ChunkingMixin):
                 dirs['abs_objdir'] = c['objdir']
             else:
                 dirs['abs_objdir'] = os.path.join(dirs['abs_mozilla_dir'],
                                                   c['objdir'])
             dirs['abs_merge_dir'] = os.path.join(dirs['abs_objdir'],
                                                  'merged')
             dirs['abs_locales_dir'] = os.path.join(dirs['abs_objdir'],
                                                    c['locales_dir'])
+        dirs['abs_compare_locales_dir'] = os.path.join(dirs['abs_work_dir'],
+                                                       'compare-locales')
         for key in dirs.keys():
             if key not in abs_dirs:
                 abs_dirs[key] = dirs[key]
         self.abs_dirs = abs_dirs
         return self.abs_dirs
 
     # This requires self to inherit a VCSMixin.
     def pull_locale_source(self, hg_l10n_base=None, parent_dir=None, vcs='hg'):