Bug 1157323 - Part 5: Remove some unnecessary members. r=froydnj
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 05 Aug 2016 13:39:34 -0500
changeset 315363 f33fe0269dea6849b6543a2f14df841739b3f9ba
parent 315362 344fdfed174a97aef02c99b9738a0b38c5c6fe43
child 315364 40bb8f061490845dca8c73c40bd927a0dc483500
push id30748
push usercbook@mozilla.com
push dateWed, 28 Sep 2016 13:53:19 +0000
treeherdermozilla-central@8c84b7618840 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1157323
milestone52.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 1157323 - Part 5: Remove some unnecessary members. r=froydnj MozReview-Commit-ID: Fhkq0CZoqQP
xpcom/threads/TimerThread.cpp
xpcom/threads/nsTimerImpl.cpp
xpcom/threads/nsTimerImpl.h
--- a/xpcom/threads/TimerThread.cpp
+++ b/xpcom/threads/TimerThread.cpp
@@ -616,17 +616,16 @@ TimerThread::AddTimerInternal(nsTimerImp
 
   TimerAdditionComparator c(now, aTimer);
   nsTimerImpl** insertSlot = mTimers.InsertElementSorted(aTimer, c);
 
   if (!insertSlot) {
     return -1;
   }
 
-  aTimer->mArmed = true;
   NS_ADDREF(aTimer);
 
 #ifdef MOZ_TASK_TRACER
   // Caller of AddTimer is the parent task of its timer event, so we store the
   // TraceInfo here for later used.
   aTimer->GetTLSTraceInfo();
 #endif
 
@@ -647,18 +646,16 @@ TimerThread::RemoveTimerInternal(nsTimer
 
 void
 TimerThread::ReleaseTimerInternal(nsTimerImpl* aTimer)
 {
   if (!mShutdown) {
     // copied to a local array before releasing in shutdown
     mMonitor.AssertCurrentThreadOwns();
   }
-  // Order is crucial here -- see nsTimerImpl::Release.
-  aTimer->mArmed = false;
   NS_RELEASE(aTimer);
 }
 
 already_AddRefed<nsTimerImpl>
 TimerThread::PostTimerEvent(already_AddRefed<nsTimerImpl> aTimerRef)
 {
   mMonitor.AssertCurrentThreadOwns();
 
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -134,19 +134,16 @@ nsTimer::Release(void)
 
   return count;
 }
 
 nsTimerImpl::nsTimerImpl(nsITimer* aTimer) :
   mClosure(nullptr),
   mName(nsTimerImpl::Nothing),
   mCallbackType(CallbackType::Unknown),
-  mFiring(false),
-  mArmed(false),
-  mCanceled(false),
   mGeneration(0),
   mDelay(0),
   mITimer(aTimer)
 {
   MOZ_COUNT_CTOR(nsTimerImpl);
   // XXXbsmedberg: shouldn't this be in Init()?
   mEventTarget = static_cast<nsIEventTarget*>(NS_GetCurrentThread());
 
@@ -214,17 +211,16 @@ nsTimerImpl::InitCommon(uint32_t aDelay,
   }
 
   rv = gThread->Init();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   gThread->RemoveTimer(this);
-  mCanceled = false;
   mTimeout = TimeStamp();
   mGeneration = gGenerator++;
 
   mType = (uint8_t)aType;
   SetDelayInternal(aDelay);
 
   return gThread->AddTimer(this);
 }
@@ -311,17 +307,16 @@ nsTimerImpl::Init(nsIObserver* aObserver
   NS_ADDREF(mCallback.o);
 
   return InitCommon(aDelay, aType);
 }
 
 NS_IMETHODIMP
 nsTimerImpl::Cancel()
 {
-  mCanceled = true;
 
   if (gThread) {
     gThread->RemoveTimer(this);
   }
 
   ReleaseCallback();
 
   return NS_OK;
@@ -437,17 +432,17 @@ nsTimerImpl::SetTarget(nsIEventTarget* a
   }
   return NS_OK;
 }
 
 
 void
 nsTimerImpl::Fire()
 {
-  if (mCanceled) {
+  if (mCallbackType == CallbackType::Unknown) {
     return;
   }
 
   PROFILER_LABEL("Timer", "Fire",
                  js::ProfileEntry::Category::OTHER);
 
   TimeStamp now = TimeStamp::Now();
   if (MOZ_LOG_TEST(GetTimerLog(), LogLevel::Debug)) {
--- a/xpcom/threads/nsTimerImpl.h
+++ b/xpcom/threads/nsTimerImpl.h
@@ -52,20 +52,16 @@ public:
 
   void Fire();
 
 #ifdef MOZ_TASK_TRACER
   void GetTLSTraceInfo();
   mozilla::tasktracer::TracedTaskCommon GetTracedTask();
 #endif
 
-  // If a failure is encountered, the reference is returned to the caller
-  static already_AddRefed<nsTimerImpl> PostTimerEvent(
-    already_AddRefed<nsTimerImpl> aTimerRef);
-
   int32_t GetGeneration()
   {
     return mGeneration;
   }
 
   enum class CallbackType : uint8_t {
     Unknown = 0,
     Interface = 1,
@@ -144,35 +140,22 @@ public:
                                       uint32_t aDelay,
                                       uint32_t aType,
                                       Name aName);
 
   // This is set by Init. It records the name (if there is one) for the timer,
   // for use when logging timer firings.
   Name mName;
 
-  // Some callers expect to be able to access the callback while the
-  // timer is firing.
-  nsCOMPtr<nsITimerCallback> mTimerCallbackWhileFiring;
-
   // These members are set by Init and never reset.
   CallbackType          mCallbackType;
 
   // These members are set by the initiating thread, when the timer's type is
   // changed and during the period where it fires on that thread.
   uint8_t               mType;
-  bool                  mFiring;
-
-
-  // Use a bool (int) here to isolate loads and stores of these two members
-  // done on various threads under the protection of TimerThread::mLock, from
-  // loads and stores done on the initiating/type-changing/timer-firing thread
-  // to the above uint8_t/bool members.
-  bool                  mArmed;
-  bool                  mCanceled;
 
   // The generation number of this timer, re-generated each time the timer is
   // initialized so one-shot timers can be canceled and re-initialized by the
   // arming thread without any bad race conditions.
   int32_t               mGeneration;
 
   uint32_t              mDelay;
   TimeStamp             mTimeout;