void MediaDevices::OnDeviceChange() { MOZ_ASSERT(NS_IsMainThread()); nsresult rv = CheckInnerWindowCorrectness(); if (NS_FAILED(rv)) { MOZ_ASSERT(false); return; } if (!(MediaManager::Get()->IsActivelyCapturingOrHasAPermission( GetOwner()->WindowID()) || Preferences::GetBool("media.navigator.permission.disabled", false))) { return; } // Do not fire event to content script when // privacy.resistFingerprinting is true. if (nsContentUtils::ShouldResistFingerprinting()) { return; } if (!mFuzzTimer) { mFuzzTimer = NS_NewTimer(); } if (!mFuzzTimer) { MOZ_ASSERT(false); return; } mFuzzTimer->Cancel(); RefPtr<FuzzTimerCallBack> cb = new FuzzTimerCallBack(this); mFuzzTimer->InitWithCallback(cb, DEVICECHANGE_HOLD_TIME_IN_MS, nsITimer::TYPE_ONE_SHOT); }
void ChannelMediaDecoder::ResourceCallback::Connect(ChannelMediaDecoder* aDecoder) { MOZ_ASSERT(NS_IsMainThread()); mDecoder = aDecoder; DecoderDoctorLogger::LinkParentAndChild( "ChannelMediaDecoder::ResourceCallback", this, "decoder", mDecoder); mTimer = NS_NewTimer(mAbstractMainThread->AsEventTarget()); }
void ScrollbarActivity::StartFadeBeginTimer() { if (GetForceAlwaysVisiblePref()) { return; } if (!mFadeBeginTimer) { mFadeBeginTimer = NS_NewTimer(); } mFadeBeginTimer->InitWithNamedFuncCallback( FadeBeginTimerFired, this, mScrollbarFadeBeginDelay, nsITimer::TYPE_ONE_SHOT, "ScrollbarActivity::FadeBeginTimerFired"); }
void FileReader::StartProgressEventTimer() { if (!mProgressNotifier) { mProgressNotifier = NS_NewTimer(); } if (mProgressNotifier) { mProgressEventWasDelayed = false; mTimerIsActive = true; mProgressNotifier->Cancel(); mProgressNotifier->SetTarget(mTarget); mProgressNotifier->InitWithCallback(this, NS_PROGRESS_EVENT_INTERVAL, nsITimer::TYPE_ONE_SHOT); } }
void IdleTaskRunner::Schedule(bool aAllowIdleDispatch) { if (!mCallback) { return; } if (mMayStopProcessing && mMayStopProcessing()) { Cancel(); return; } mDeadline = TimeStamp(); TimeStamp now = TimeStamp::Now(); TimeStamp hint = nsRefreshDriver::GetIdleDeadlineHint(now); if (hint != now) { // RefreshDriver is ticking, let it schedule the idle dispatch. nsRefreshDriver::DispatchIdleRunnableAfterTick(this, mDelay); // Ensure we get called at some point, even if RefreshDriver is stopped. SetTimerInternal(mDelay); } else { // RefreshDriver doesn't seem to be running. if (aAllowIdleDispatch) { nsCOMPtr<nsIRunnable> runnable = this; SetTimerInternal(mDelay); NS_IdleDispatchToCurrentThread(runnable.forget()); } else { if (!mScheduleTimer) { mScheduleTimer = NS_NewTimer(); if (!mScheduleTimer) { return; } } else { mScheduleTimer->Cancel(); } if (TaskCategory::Count != mTaskCategory) { mScheduleTimer->SetTarget(SystemGroup::EventTargetFor(mTaskCategory)); } // We weren't allowed to do idle dispatch immediately, do it after a // short timeout. mScheduleTimer->InitWithNamedFuncCallback(ScheduleTimedOut, this, 16, nsITimer::TYPE_ONE_SHOT_LOW_PRIORITY, "IdleTaskRunner"); } } }
void IdleTaskRunner::SetTimerInternal(uint32_t aDelay) { if (mTimerActive) { return; } if (!mTimer) { mTimer = NS_NewTimer(); } else { mTimer->Cancel(); } if (mTimer) { if (TaskCategory::Count != mTaskCategory) { mTimer->SetTarget(SystemGroup::EventTargetFor(mTaskCategory)); } mTimer->InitWithNamedFuncCallback(TimedOut, this, aDelay, nsITimer::TYPE_ONE_SHOT, "IdleTaskRunner"); mTimerActive = true; } }