Files
palemoon27/xpcom/threads/TimerThread.h
roytam1 0bd640ce7b import changes from `dev' branch of rmottola/Arctic-Fox:
- fix missing import (64d6ffefa5)
- reorder imports and some var-let (22f3f6178e)
- Cleanup PopupNotifications.jsm (d3800a3735)
- fix init order (b500029e0c)
- Bug 1093101 - Use user-set browser.newtab.url pref for new tabs in private windows. r=dao (49d751dc01)
- missing bit of Bug 666804 - [e10s] Support NetworkPrioritizer (r=felipe) (3245252fe8)
- shuffle init (005db95181)
- Bug 1193527 - Fix common PB warning (r=Gijs) (b675bc1d8e)
- bits of Bug 940669 (31301db972)
- Bug 1106075 - Fix for double click to try again for offline errors. r=Dao (c680d109cc)
- Bug 1180189 - Fix crash in mozilla::a11y::HTMLTableRowAccessible::GroupPosition, r=MarcoZ (a2ee5f2df8)
- Bug 1194859 - crash in mozilla::a11y::ARIAGridCellAccessible::GroupPosition, r=marcoz (879bad005f)
- Bug 1194859 - crash in mozilla::a11y::ARIAGridCellAccessible::GroupPosition(), part2, r=marcoz (38193050c0)
- put back moz-action scheme test (55a939e3e3)
- Bug 1062631 - Handle null ownerDoc in browser.js and content.js for the benefit of browser_newtab_drag_drop_ext.js. r=ttaubert (760dda22b9)
- Bug 946450 - [e10s] Make all the different link destinations work on about:newtab. r=jimm (d02dde60ac)
- import some telemetry to unbreak context menu (0ac5475de9)
- add missing ignoreWarningButton (740c0c6360)
- missing parts of Bug 577892 - allow icons to change when href attribute is set directly, with automated test, r=dolske,bz (2fab05a4d2)
- comment and style (a3ae06e5e6)
- Bug 1140859 - Pass the outerWindowID into nsContextMenu.saveHelper() and use that to get the window, rather than unsafely accessing doc.defaultView. r=gabor (1e7278d905)
- Bug 1160339 - Make nsContextMenu.linkText a function again for addon-compat. r=mconley (45623a2501)
- Bug 1210381 - Remove view-source: when copying links. r=mconley (30d7c6dedb)
- Bug 1194764. Fix the way we pass the outer window id to various things in context menu code to work in non-e10s mode too. r=jryans (dec053b2dd)
- missing of  Bug 1005601 - "gContextMenu is null" thrown for first textarea context menu in a window. r=Gijs (4ad385ab34)
- missing bit of Bug 1071771, disable dictionary list when it cannot be accessed from another process. This makes the context menu work again after using it on a misspelled word, r=mconley (5384454af5)
- Bug 1134391 - Make "View Image/Video" command use messages to avoid unsafe CPOW warnings. r=mconley (42a1ea3745)
- Bug 1134424 - Use a message to safely get the dataURL of the canvas for saving media with e10s. r=gabor (81e51d6a88)
- Bug 991427 - Check if the last character of the string is part of a surrogate pair when truncating text for display in the context menu, to avoid splitting surrogate pairs, r=gavin (3ec991dff3)
- Bug 1135916 - Make "Copy Email Address" use gContextMenuContentData to avoid unsafe CPOW warning. r=mconley (74778b860c)
- Bug 773988 - Allow saving a snapshot from a media stream without a known filename, r=dolske. (725937a046)
- missing bit of Bug 1135619 - Make "Bookmark This Frame" fetch the document title and description via message so it is safe in e10s. r=gabor (78ac660eea)
- var/let (7b3552e2ba)
- Bug 1203395 - Repair view selection source in window mode. r=mconley (1963513715)
- var-let and some misspatch fixes (a6d3b0c9cb)
- Bug 1160450 - Places Maintenance never runs. r=ttaubert (ce7915c8ad)
- Bug 1129529 - Bookmark backup may not be restorable. r=mak (01b1f1c75a)
- Bug 1156592 - Add a time elapsed helper to TelemetryStopwatch. r=felipe (b0609708ff)
- Bug 1207882 - Add an initial partial implementation of a new, faster, build backend. r=gps Bug 1209401 - Don't use preprocessor forced includes for API keys in nsURLFormatter.js. r=gps (d146620b87)
- Bug 1207490 - Part 10: Remove use of expression closure from browser/modules/ContentLinkHandler.jsm. r=Gijs (511b3fb54b)
- Bug 1053467 - Add telemetry to measure the usage and values of the sizes attribute of <link rel=icon>. r=MattN (bea8604223)
- Bug 970276 - Don't respect <link rel=""> elements from subframes (r=felipe) (3c62065450)
- missing bit of Bug 1048048 - add preload content policy types for images (995411c95d)
- missing bit of Bug 944147 - [Australis] Collect UITelemetry on bookmark star usage. (781b242c9e)
- Bug 1141978 - Support rowgroup and colgroup HTML scope, r=marcoz (11eedb88f0)
- Bug 1146257 - spanned headers don't work well in our table code, r=marcoz (d9b11584c2)
- remove unused MultiCompartmentMatcher (480d895553)
- Bug 1168170 - Mark reference counted members of nsTimerImpl::mCallback as MOZ_OWNING_REF. r=froydnj (b84c55460a)
- Bug 1178363 - make nsTimerImpl::SetDelayInternal a private method; r=poiru (5f70ed869e)
- Bug 1178363 - make nsTimerImpl::Fire a private method; r=poiru (4b6007c376)
- Bug 1178363 - make MOZ_TASK_TRACER-dependent bits of nsTimerImpl private; r=poiru (e1f54cde97)
- Bug 1178363 - make nsTimerImpl::PostTimerEvent a private method; r=poiru (0a0b71eae3)
- Bug 1178363 - make nsTimerImpl::GetGeneration a private method; r=poiru (593d3a3f2d)
- Bug 1059572 - Part 0: Fuzz test for timers. r=nfroyd (7b03728aa4)
- Bug 1059572 - Part 0.5: Fixes for pre-existing problems in TestTimers. r=nfroyd (e463afc995)
- Bug 1059572 - Part 1: Move PostTimerEvent to TimerThread to allow TimerThread's monitor to protect it. r=nfroyd (5e56ce272a)
- Bug 1059572 - Part 2: Make absolutely sure a timer is removed before reinitting it. r=nfroyd (7d916a9aa9)
- Bug 1190735 - Remove nsITimer.TYPE_REPEATING_PRECISE. r=froydnj. (34f7e4c02e)
- Bug 1203427 (part 5) - Add logging of timer firings. r=froydnj. (664954eef7)
2022-09-15 12:15:57 +08:00

117 lines
2.7 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 TimerThread_h___
#define TimerThread_h___
#include "nsIObserver.h"
#include "nsIRunnable.h"
#include "nsIThread.h"
#include "nsTimerImpl.h"
#include "nsThreadUtils.h"
#include "nsTArray.h"
#include "mozilla/Atomics.h"
#include "mozilla/Attributes.h"
#include "mozilla/Monitor.h"
namespace mozilla {
class TimeStamp;
} // namespace mozilla
class TimerThread final
: public nsIRunnable
, public nsIObserver
{
public:
typedef mozilla::Monitor Monitor;
typedef mozilla::TimeStamp TimeStamp;
typedef mozilla::TimeDuration TimeDuration;
TimerThread();
nsresult InitLocks();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIRUNNABLE
NS_DECL_NSIOBSERVER
nsresult Init();
nsresult Shutdown();
nsresult AddTimer(nsTimerImpl* aTimer);
nsresult TimerDelayChanged(nsTimerImpl* aTimer);
nsresult RemoveTimer(nsTimerImpl* aTimer);
void DoBeforeSleep();
void DoAfterSleep();
bool IsOnTimerThread() const
{
return mThread == NS_GetCurrentThread();
}
private:
~TimerThread();
mozilla::Atomic<bool> mInitInProgress;
bool mInitialized;
// These two internal helper methods must be called while mMonitor is held.
// AddTimerInternal returns the position where the timer was added in the
// list, or -1 if it failed.
int32_t AddTimerInternal(nsTimerImpl* aTimer);
bool RemoveTimerInternal(nsTimerImpl* aTimer);
void ReleaseTimerInternal(nsTimerImpl* aTimer);
already_AddRefed<nsTimerImpl> PostTimerEvent(already_AddRefed<nsTimerImpl> aTimerRef);
nsCOMPtr<nsIThread> mThread;
Monitor mMonitor;
bool mShutdown;
bool mWaiting;
bool mNotified;
bool mSleeping;
nsTArray<nsTimerImpl*> mTimers;
};
struct TimerAdditionComparator
{
TimerAdditionComparator(const mozilla::TimeStamp& aNow,
nsTimerImpl* aTimerToInsert) :
now(aNow)
#ifdef DEBUG
, timerToInsert(aTimerToInsert)
#endif
{
}
bool LessThan(nsTimerImpl* aFromArray, nsTimerImpl* aNewTimer) const
{
MOZ_ASSERT(aNewTimer == timerToInsert, "Unexpected timer ordering");
// Skip any overdue timers.
return aFromArray->mTimeout <= now ||
aFromArray->mTimeout <= aNewTimer->mTimeout;
}
bool Equals(nsTimerImpl* aFromArray, nsTimerImpl* aNewTimer) const
{
return false;
}
private:
const mozilla::TimeStamp& now;
#ifdef DEBUG
const nsTimerImpl* const timerToInsert;
#endif
};
#endif /* TimerThread_h___ */