Bug 1062533 - part 1 - convert easy cases of chromium IPC locks to mozilla mutexes; r=mccr8
authorNathan Froyd <froydnj@mozilla.com>
Wed, 09 Jan 2019 11:09:25 -0400
changeset 510188 51cd91552f13befa2d4948e9305fdd73dbf5c226
parent 510187 50d18f1d0ab6102582e367964493d50ec4b994cb
child 510189 3ec91f0aa186e1477adfa160b604638c9ca1be32
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1062533
milestone66.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
Bug 1062533 - part 1 - convert easy cases of chromium IPC locks to mozilla mutexes; r=mccr8 Other cases will require some special handling.
ipc/chromium/src/base/at_exit.cc
ipc/chromium/src/base/at_exit.h
ipc/chromium/src/base/histogram.cc
ipc/chromium/src/base/histogram.h
ipc/chromium/src/base/message_loop.cc
ipc/chromium/src/base/message_loop.h
ipc/chromium/src/base/message_pump_win.h
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
--- a/ipc/chromium/src/base/at_exit.cc
+++ b/ipc/chromium/src/base/at_exit.cc
@@ -10,22 +10,25 @@
 namespace base {
 
 // Keep a stack of registered AtExitManagers.  We always operate on the most
 // recent, and we should never have more than one outside of testing, when we
 // use the shadow version of the constructor.  We don't protect this for
 // thread-safe access, since it will only be modified in testing.
 static AtExitManager* g_top_manager = NULL;
 
-AtExitManager::AtExitManager() : next_manager_(NULL) {
+AtExitManager::AtExitManager() : lock_("AtExitManager"),
+                                 next_manager_(NULL) {
   DCHECK(!g_top_manager);
   g_top_manager = this;
 }
 
-AtExitManager::AtExitManager(bool shadow) : next_manager_(g_top_manager) {
+AtExitManager::AtExitManager(bool shadow) : lock_("AtExitManager"),
+                                            next_manager_(g_top_manager)
+ {
   DCHECK(shadow || !g_top_manager);
   g_top_manager = this;
 }
 
 AtExitManager::~AtExitManager() {
   if (!g_top_manager) {
     NOTREACHED() << "Tried to ~AtExitManager without an AtExitManager";
     return;
@@ -40,28 +43,28 @@ AtExitManager::~AtExitManager() {
 void AtExitManager::RegisterCallback(AtExitCallbackType func, void* param) {
   if (!g_top_manager) {
     NOTREACHED() << "Tried to RegisterCallback without an AtExitManager";
     return;
   }
 
   DCHECK(func);
 
-  AutoLock lock(g_top_manager->lock_);
+  mozilla::MutexAutoLock lock(g_top_manager->lock_);
   g_top_manager->stack_.push(CallbackAndParam(func, param));
 }
 
 // static
 void AtExitManager::ProcessCallbacksNow() {
   if (!g_top_manager) {
     NOTREACHED() << "Tried to ProcessCallbacksNow without an AtExitManager";
     return;
   }
 
-  AutoLock lock(g_top_manager->lock_);
+  mozilla::MutexAutoLock lock(g_top_manager->lock_);
 
   while (!g_top_manager->stack_.empty()) {
     CallbackAndParam callback_and_param = g_top_manager->stack_.top();
     g_top_manager->stack_.pop();
 
     callback_and_param.func_(callback_and_param.param_);
   }
 }
--- a/ipc/chromium/src/base/at_exit.h
+++ b/ipc/chromium/src/base/at_exit.h
@@ -5,17 +5,18 @@
 // found in the LICENSE file.
 
 #ifndef BASE_AT_EXIT_H_
 #define BASE_AT_EXIT_H_
 
 #include <stack>
 
 #include "base/basictypes.h"
-#include "base/lock.h"
+
+#include "mozilla/Mutex.h"
 
 namespace base {
 
 // This class provides a facility similar to the CRT atexit(), except that
 // we control when the callbacks are executed. Under Windows for a DLL they
 // happen at a really bad time and under the loader lock. This facility is
 // mostly used by base::Singleton.
 //
@@ -58,17 +59,17 @@ class AtExitManager {
  private:
   struct CallbackAndParam {
     CallbackAndParam(AtExitCallbackType func, void* param)
         : func_(func), param_(param) {}
     AtExitCallbackType func_;
     void* param_;
   };
 
-  Lock lock_;
+  mozilla::Mutex lock_;
   std::stack<CallbackAndParam> stack_;
   AtExitManager* next_manager_;  // Stack of managers to allow shadowing.
 
   DISALLOW_COPY_AND_ASSIGN(AtExitManager);
 };
 
 }  // namespace base
 
--- a/ipc/chromium/src/base/histogram.cc
+++ b/ipc/chromium/src/base/histogram.cc
@@ -21,18 +21,16 @@
 #include "base/string_util.h"
 #include "base/logging.h"
 
 namespace base {
 
 #define DVLOG(x) CHROMIUM_LOG(ERROR)
 #define CHECK_GT DCHECK_GT
 #define CHECK_LT DCHECK_LT
-typedef ::Lock Lock;
-typedef ::AutoLock AutoLock;
 
 // Static table of checksums for all possible 8 bit bytes.
 const uint32_t Histogram::kCrcTable[256] = {
     0x0,         0x77073096L, 0xee0e612cL, 0x990951baL, 0x76dc419L,
     0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0xedb8832L,  0x79dcb8a4L,
     0xe0d5e91eL, 0x97d2d988L, 0x9b64c2bL,  0x7eb17cbdL, 0xe7b82d07L,
     0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
     0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
--- a/ipc/chromium/src/base/histogram.h
+++ b/ipc/chromium/src/base/histogram.h
@@ -45,17 +45,16 @@
 
 #include "mozilla/Atomics.h"
 #include "mozilla/MemoryReporting.h"
 
 #include <map>
 #include <string>
 
 #include "base/time.h"
-#include "base/lock.h"
 
 #include "nsTArray.h"
 
 namespace base {
 
 //------------------------------------------------------------------------------
 
 class BooleanHistogram;
--- a/ipc/chromium/src/base/message_loop.cc
+++ b/ipc/chromium/src/base/message_loop.cc
@@ -166,16 +166,17 @@ void MessageLoop::set_current(MessageLoo
 
 static mozilla::Atomic<int32_t> message_loop_id_seq(0);
 
 MessageLoop::MessageLoop(Type type, nsIEventTarget* aEventTarget)
     : type_(type),
       id_(++message_loop_id_seq),
       nestable_tasks_allowed_(true),
       exception_restoration_(false),
+      incoming_queue_lock_("MessageLoop Incoming Queue Lock"),
       state_(NULL),
       run_depth_base_(1),
       shutting_down_(false),
 #ifdef OS_WIN
       os_modal_loop_(false),
 #endif  // OS_WIN
       transient_hang_timeout_(0),
       permanent_hang_timeout_(0),
@@ -395,17 +396,17 @@ void MessageLoop::PostTask_Helper(alread
   }
 
   // Warning: Don't try to short-circuit, and handle this thread's tasks more
   // directly, as it could starve handling of foreign threads.  Put every task
   // into this queue.
 
   RefPtr<base::MessagePump> pump;
   {
-    AutoLock locked(incoming_queue_lock_);
+    mozilla::MutexAutoLock locked(incoming_queue_lock_);
     incoming_queue_.push(std::move(pending_task));
     pump = pump_;
   }
   // Since the incoming_queue_ may contain a task that destroys this message
   // loop, we cannot exit incoming_queue_lock_ until we are done with |this|.
   // We use a stack-based reference to the message pump so that we can call
   // ScheduleWork outside of incoming_queue_lock_.
 
@@ -473,17 +474,17 @@ void MessageLoop::ReloadWorkQueue() {
   // work_queue_ by waiting until the last minute (work_queue_ is empty) to
   // load.  That reduces the number of locks-per-task significantly when our
   // queues get large.
   if (!work_queue_.empty())
     return;  // Wait till we *really* need to lock and load.
 
   // Acquire all we can from the inter-thread queue with one lock acquisition.
   {
-    AutoLock lock(incoming_queue_lock_);
+    mozilla::MutexAutoLock lock(incoming_queue_lock_);
     if (incoming_queue_.empty()) return;
     std::swap(incoming_queue_, work_queue_);
     DCHECK(incoming_queue_.empty());
   }
 }
 
 bool MessageLoop::DeletePendingTasks() {
   MOZ_ASSERT(work_queue_.empty());
--- a/ipc/chromium/src/base/message_loop.h
+++ b/ipc/chromium/src/base/message_loop.h
@@ -8,20 +8,21 @@
 #define BASE_MESSAGE_LOOP_H_
 
 #include <deque>
 #include <queue>
 #include <string>
 #include <vector>
 #include <map>
 
-#include "base/lock.h"
 #include "base/message_pump.h"
 #include "base/observer_list.h"
 
+#include "mozilla/Mutex.h"
+
 #if defined(OS_WIN)
 // We need this to declare base::MessagePumpWin::Dispatcher, which we should
 // really just eliminate.
 #include "base/message_pump_win.h"
 #elif defined(OS_POSIX)
 #include "base/message_pump_libevent.h"
 #endif
 
@@ -418,17 +419,17 @@ class MessageLoop : public base::Message
   std::string thread_name_;
 
   // A null terminated list which creates an incoming_queue of tasks that are
   // aquired under a mutex for processing on this instance's thread. These tasks
   // have not yet been sorted out into items for our work_queue_ vs items that
   // will be handled by the TimerManager.
   TaskQueue incoming_queue_;
   // Protect access to incoming_queue_.
-  Lock incoming_queue_lock_;
+  mozilla::Mutex incoming_queue_lock_;
 
   RunState* state_;
   int run_depth_base_;
   bool shutting_down_;
 
 #if defined(OS_WIN)
   // Should be set to true before calling Windows APIs like TrackPopupMenu, etc
   // which enter a modal message loop.
--- a/ipc/chromium/src/base/message_pump_win.h
+++ b/ipc/chromium/src/base/message_pump_win.h
@@ -6,17 +6,16 @@
 
 #ifndef BASE_MESSAGE_PUMP_WIN_H_
 #define BASE_MESSAGE_PUMP_WIN_H_
 
 #include <windows.h>
 
 #include <list>
 
-#include "base/lock.h"
 #include "base/message_pump.h"
 #include "base/observer_list.h"
 #include "base/scoped_handle.h"
 #include "base/time.h"
 
 namespace base {
 
 // MessagePumpWin serves as the base for specialized versions of the MessagePump
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -6,16 +6,17 @@
 #include <cstdlib>
 #include <cerrno>
 #include <deque>
 #include <set>
 #include <sstream>
 #include <vector>
 
 #include "CSFLog.h"
+#include "base/histogram.h"
 #include "timecard.h"
 
 #include "jsapi.h"
 #include "nspr.h"
 #include "nss.h"
 #include "pk11pub.h"
 
 #include "nsNetCID.h"