Name Description Size
AppShutdown.cpp 16232
AppShutdown.h Returns the current exit code that the process will be terminated with. 4206
AutoRestore.h functions for restoring saved values at the end of a C++ scope 1181
AvailableMemoryTracker.cpp This runnable is executed in response to a memory-pressure event; we spin the event-loop when receiving the memory-pressure event in the hope that other observers will synchronously free some memory that we'll be able to purge here. 5193
AvailableMemoryTracker.h 939
AvailableMemoryWatcher.cpp static 5516
AvailableMemoryWatcher.h 2859
AvailableMemoryWatcherLinux.cpp static 9145
AvailableMemoryWatcherMac.cpp The Mac AvailableMemoryWatcher works as follows. When the OS memory pressure level changes on macOS, nsAvailableMemoryWatcher::OnMemoryPressureChanged() is called with the new memory pressure level. The level is represented in Gecko by a MacMemoryPressureLevel instance and represents the states of normal, warning, or critical which correspond to the native levels. When the browser launches, the initial level is determined using a sysctl. Which actions are taken in the browser in response to memory pressure, and the level (warning or critical) which trigger the reponse is configurable with prefs to make it easier to perform experiments to study how the response affects the user experience. By default, the browser responds by attempting to reduce memory use when the OS transitions to the critical level and while it stays in the critical level. i.e., "critical" OS memory pressure is the default threshold for the low memory response. Setting pref "browser.lowMemoryResponseOnWarn" to true changes the memory response to occur at the "warning" level which is less severe than "critical". When entering the critical level, we begin polling the memory pressure level every 'n' milliseconds (specified via the pref "browser.lowMemoryPollingIntervalMS"). Each time the poller wakes up and finds the OS still under memory pressure, the low memory response is executed. By default, the memory pressure response is, in order, to 1) call nsITabUnloader::UnloadTabAsync(), 2) if no tabs could be unloaded, issue a Gecko MemoryPressureState::LowMemory notification. The response can be changed via the pref "browser.lowMemoryResponseMask" to limit the actions to only tab unloading or Gecko memory pressure notifications. Polling occurs on the main thread because, at each polling interval, we call into the tab unloader which requires being on the main thread. Polling only occurs while under OS memory pressure at the critical (by default) level. 22855
AvailableMemoryWatcherUtils.h The first few lines of meminfo look something like this: MemTotal: 65663448 kB MemFree: 57368112 kB MemAvailable: 61852700 kB We mostly care about the available versus the total. We calculate our memory thresholds using this, and when memory drops below 5% we consider this to be a memory pressure event. In practice these lines aren't necessarily in order, but we can simply search for MemTotal and MemAvailable. 1827
AvailableMemoryWatcherWin.cpp 13440
CFTypeRefPtr.h 5304
ClearOnShutdown.cpp 2423
ClearOnShutdown.h This header exports two public methods in the mozilla namespace: template<class SmartPtr> void ClearOnShutdown(SmartPtr *aPtr, aPhase=ShutdownPhase::XPCOMShutdownFinal) This function takes a pointer to a smart pointer and nulls the smart pointer on shutdown (and a particular phase of shutdown as needed). If a phase is specified, the ptr will be cleared at the start of that phase. Also, if a phase has already occurred when ClearOnShutdown() is called it will cause a MOZ_ASSERT. In case a phase is not explicitly cleared we will clear it on the next phase that occurs. This is useful if you have a global smart pointer object which you don't want to "leak" on shutdown. Although ClearOnShutdown will work with any smart pointer (i.e., nsCOMPtr, RefPtr, StaticRefPtr, and StaticAutoPtr), you probably want to use it only with StaticRefPtr and StaticAutoPtr. There is no way to undo a call to ClearOnShutdown, so you can call it only on smart pointers which you know will live until the program shuts down. In practice, these are likely global variables, which should be Static{Ref,Auto}Ptr. template <typename CallableT> void RunOnShutdown(CallableT&& aCallable, aPhase = ShutdownPhase::XPCOMShutdownFinal) This function takes a callable and executes it upon shutdown at the start of the specified phase. If the phase has already occurred when RunOnShutdown() is called, it will cause a MOZ_ASSERT. In case a phase is not explicitly cleared, we will clear it on the next phase that occurs. ClearOnShutdown and RunOnShutdown are both currently main-thread only because we don't want to accidentally free an object from a different thread than the one it was created on. 4775
CodeAddressService.h 8584
components.conf 1016
CountingAllocatorBase.h 5385
CycleCollectedJSContext.cpp static 34968
CycleCollectedJSContext.h 14037
CycleCollectedJSRuntime.cpp 70114
CycleCollectedJSRuntime.h 17564
CycleCollectorStats.cpp 6778
CycleCollectorStats.h 2900
DarwinObjectPtr.h Copyright (C) 2014-2021 Apple Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4148
Debug.cpp 542
Debug.h 576
DebuggerOnGCRunnable.cpp static 1262
DebuggerOnGCRunnable.h 1102
DeferredFinalize.cpp 1007
DeferredFinalize.h 1348
EnumeratedArrayCycleCollection.h 1233
ErrorList.py A nserror module. When used with a `with` statement, binds the itself to Mod.active. 64836
ErrorNames.cpp 2389
ErrorNames.h 1053
GkRustUtils.cpp static 669
GkRustUtils.h 599
HoldDropJSObjects.cpp 1909
HoldDropJSObjects.h Classes that hold strong references to JS GC things such as `JSObjects` and `JS::Values` (e.g. `JS::Heap<JSObject*> mFoo;`) must use these, generally by calling `HoldJSObjects(this)` and `DropJSObjects(this)` in the ctor and dtor respectively. For classes that are wrapper cached and hold no other strong references to JS GC things, there's no need to call these; it will be taken care of automatically by nsWrapperCache. 2924
IntentionalCrash.h 1882
JSObjectHolder.cpp 412
JSObjectHolder.h 1365
JSONStringWriteFuncs.h 1487
LogCommandLineHandler.cpp 2466
LogCommandLineHandler.h A helper function parsing provided command line arguments and handling two specific args: -MOZ_LOG=modulelist -MOZ_LOG_FILE=file/path both expecting an argument, and corresponding to the same-name environment variables we use for logging setup. When an argument is found in the proper form, the consumer callback is called with a string in a follwing form, note that we do this for every occurence, and not just at the end of the parsing: "MOZ_LOG=modulelist" or "MOZ_LOG_FILE=file/path" All the following forms of arguments of the application are possible: --MOZ_LOG modulelist -MOZ_LOG modulelist --MOZ_LOG=modulelist -MOZ_LOG=modulelist The motivation for a separte function and not implementing a command line handler interface is that we need to process this very early during the application startup. Command line handlers are proccessed way later after logging has already been set up. 1606
Logging.cpp A helper class providing reference counting for FILE*. It encapsulates the following: - the FILE handle - the order number it was created for when rotating (actual path) - number of active references 32711
Logging.h Retrieves the module with the given name. If it does not already exist it will be created. @param aName The name of the module. @return A log module for the given name. This may be shared. 11123
LogModulePrefWatcher.cpp Resets all the preferences in the logging. branch This is needed because we may crash while logging, and this would cause us to log after restarting as well. If logging after restart is desired, set the logging.config.clear_on_startup pref to false, or use the MOZ_LOG_FILE and MOZ_LOG_MODULES env vars. 7013
LogModulePrefWatcher.h Watches for changes to "logging.*" prefs and then updates the appropriate LogModule's log level. Both the integer and string versions of the LogLevel enum are supported. For example setting the pref "logging.Foo" to "Verbose" will set the LogModule for "Foo" to the LogLevel::Verbose level. Setting "logging.Bar" to 4 would set the LogModule for "Bar" to the LogLevel::Debug level. 1187
MacHelpers.h 518
MacHelpers.mm 1009
MacStringHelpers.h 698
MacStringHelpers.mm 1635
MemoryInfo.cpp static 3012
MemoryInfo.h MemoryInfo is a helper class which describes the attributes and sizes of a particular region of VM memory on Windows. It roughtly corresponds to the values in a MEMORY_BASIC_INFORMATION struct, summed over an entire region or memory. 2137
MemoryMapping.cpp 6829
MemoryMapping.h MemoryMapping is a helper class which describes an entry in the Linux /proc/<pid>/smaps file. See procfs(5) for details on the entry format. The GetMemoryMappings() function returns an array of such entries, sorted by start address, one for each entry in the current process's address space. 6253
MemoryPressureLevelMac.h 2265
MemoryReportingProcess.h 1395
MemoryTelemetry.cpp static 18487
MemoryTelemetry.h Periodically gathers memory usage metrics after cycle collection, and populates telemetry histograms with their values. 1999
moz.build 7000
nsAlgorithm.h 957
nsAutoRef.h template <class T> class nsAutoRef A class that holds a handle to a resource that must be released. No reference is added on construction. No copy constructor nor copy assignment operators are available, so the resource will be held until released on destruction or explicitly |reset()| or transferred through provided methods. The publicly available methods are the public methods on this class and its public base classes |nsAutoRefBase<T>| and |nsSimpleRef<T>|. For function return values see |nsReturnRef<T>|. For each class |T|, |nsAutoRefTraits<T>| or |nsSimpleRef<T>| must be specialized to use |nsAutoRef<T>|. @param T A class identifying the type of reference held by the |nsAutoRef<T>| and the unique set methods for managing references to the resource (defined by |nsAutoRefTraits<T>| or |nsSimpleRef<T>|). Often this is the class representing the resource. Sometimes a new possibly-incomplete class may need to be declared. Example: An Automatically closing file descriptor // References that are simple integral types (as file-descriptors are) // usually need a new class to represent the resource and how to handle its // references. class nsRawFD; // Specializing nsAutoRefTraits<nsRawFD> describes how to manage file // descriptors, so that nsAutoRef<nsRawFD> provides automatic closing of // its file descriptor on destruction. template <> class nsAutoRefTraits<nsRawFD> { public: // The file descriptor is held in an int. typedef int RawRef; // -1 means that there is no file associated with the handle. static int Void() { return -1; } // The file associated with a file descriptor is released with close(). static void Release(RawRef aFD) { close(aFD); } }; // A function returning a file descriptor that must be closed. nsReturnRef<nsRawFD> get_file(const char *filename) { // Constructing from a raw file descriptor assumes ownership. nsAutoRef<nsRawFD> fd(open(filename, O_RDONLY)); fcntl(fd, F_SETFD, FD_CLOEXEC); return fd.out(); } void f() { unsigned char buf[1024]; // Hold a file descriptor for /etc/hosts in fd1. nsAutoRef<nsRawFD> fd1(get_file("/etc/hosts")); nsAutoRef<nsRawFD> fd2; fd2.steal(fd1); // fd2 takes the file descriptor from fd1 ssize_t count = read(fd1, buf, 1024); // error fd1 has no file count = read(fd2, buf, 1024); // reads from /etc/hosts // If the file descriptor is not stored then it is closed. get_file("/etc/login.defs"); // login.defs is closed // Now use fd1 to hold a file descriptor for /etc/passwd. fd1 = get_file("/etc/passwd"); // The nsAutoRef<nsRawFD> can give up the file descriptor if explicitly // instructed, but the caller must then ensure that the file is closed. int rawfd = fd1.disown(); // Assume ownership of another file descriptor. fd1.own(open("/proc/1/maps"); // On destruction, fd1 closes /proc/1/maps and fd2 closes /etc/hosts, // but /etc/passwd is not closed. } 17223
nsClassInfoImpl.cpp 1661
nsCom.h 390
nsCOMPtr.cpp 1011
nsCOMPtr.h Having problems? See the documentation at: https://firefox-source-docs.mozilla.org/xpcom/refptr.html nsCOMPtr better than a raw pointer for owning objects -- scc 36928
nsConsoleMessage.cpp Base implementation for console messages. 1756
nsConsoleMessage.h __nsconsolemessage_h__ 860
nsConsoleService.cpp Maintains a circular buffer of recent messages, and notifies listeners when new messages are logged. 15941
nsConsoleService.h nsConsoleService class declaration. 3185
nscore.h Definitions of functions and operators that allocate memory. 8182
nsCrashOnException.cpp 1128
nsCrashOnException.h 745
nsCRTGlue.cpp 6500
nsCRTGlue.h Scan a string for the first character that is *not* in a set of delimiters. If the string is only delimiter characters, the end of the string is returned. @param aDelims The set of delimiters (null-terminated) @param aStr The string to search (null-terminated) 5291
nsCycleCollectionNoteChild.h 3099
nsCycleCollectionNoteRootCallback.h 1317
nsCycleCollectionParticipant.cpp 1260
nsCycleCollectionParticipant.h Note: the following two IIDs only differ in one bit in the last byte. This is a hack and is intentional in order to speed up the comparison inside NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED. 56695
nsCycleCollectionTraversalCallback.h 2411
nsCycleCollector.cpp 136462
nsCycleCollector.h 2798
nsCycleCollectorTraceJSHelpers.cpp 3103
nsDebug.h Warn if the given condition is true. The condition is evaluated in both release and debug builds, and the result is an expression which can be used in subsequent expressions, such as: if (NS_WARN_IF(NS_FAILED(rv)) { return rv; } This explicit warning and return is preferred to the NS_ENSURE_* macros which hide the warning and the return control flow. This macro can also be used outside of conditions just to issue a warning, like so: Unused << NS_WARN_IF(NS_FAILED(FnWithSideEffects()); (The |Unused <<| is necessary because of the [[nodiscard]] annotation.) However, note that the argument to this macro is evaluated in all builds. If you just want a warning assertion, it is better to use NS_WARNING_ASSERTION (which evaluates the condition only in debug builds) like so: NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "operation failed"); @note This is C++-only 12487
nsDebugImpl.cpp for getenv() 18388
nsDebugImpl.h If we are in multiprocess mode, return the process name. 1315
nsDumpUtils.cpp The following code supports triggering a registered callback upon receiving a specific signal. Take about:memory for example, we register 1. doGCCCDump for doMemoryReport 2. doMemoryReport for sDumpAboutMemorySignum(SIGRTMIN) and sDumpAboutMemoryAfterMMUSignum(SIGRTMIN+1). When we receive one of these signals, we write the signal number to a pipe. The IO thread then notices that the pipe has been written to, and kicks off the appropriate task on the main thread. This scheme is similar to using signalfd(), except it's portable and it doesn't require the use of sigprocmask, which is problematic because it masks signals received by child processes. In theory, we could use Chromium's MessageLoopForIO::CatchSignal() for this. But that uses libevent, which does not handle the realtime signals (bug 794074). 14323
nsDumpUtils.h Abstract base class for something which watches an fd and takes action when we can read from it without blocking. 5216
nsError.h @name Standard Error Handling Macros @return 0 or 1 (false/true with bool type for C++) 3080
nsGZFileWriter.cpp gzip encoding 3724
nsGZFileWriter.h A simple class for writing to a .gz file. Note that the file that this interface produces has a different format than what you'd get if you compressed your data as a gzip stream and dumped the result to a file. The standard gunzip tool cannot decompress a raw gzip stream, but can handle the files produced by this interface. 2259
nsIAvailableMemoryWatcherBase.idl nsITabUnloader: interface to represent TabUnloader nsIAvailableMemoryWatcherBase: interface to watch the system's memory status and invoke a registered TabUnloader when it detected a low-memory and high-memory situation. The logic to detect such a memory situation is defined per platform. 1385
nsIClassInfoImpl.h This header file provides macros which help you make your class implement nsIClassInfo. Implementing nsIClassInfo is particularly helpful if you have a C++ class which implements multiple interfaces and which you access from JavaScript. If that class implements nsIClassInfo, the JavaScript code won't have to call QueryInterface on instances of the class; all methods from all interfaces returned by GetInterfaces() will be available automagically. Here's all you need to do. Given a class class nsFooBar : public nsIFoo, public nsIBar { }; you should already have the following nsISupports implementation in its cpp file: NS_IMPL_ISUPPORTS(nsFooBar, nsIFoo, nsIBar). Change this to NS_IMPL_CLASSINFO(nsFooBar, nullptr, 0, NS_FOOBAR_CID) NS_IMPL_ISUPPORTS_CI(nsFooBar, nsIFoo, nsIBar) If nsFooBar is threadsafe, change the 0 above to nsIClassInfo::THREADSAFE. If it's a singleton, use nsIClassInfo::SINGLETON. The full list of flags is in nsIClassInfo.idl. The nullptr parameter is there so you can pass a function for converting from an XPCOM object to a scriptable helper. Unless you're doing specialized JS work, you can probably leave this as nullptr. This file also defines the NS_IMPL_QUERY_INTERFACE_CI macro, which you can use to replace NS_IMPL_QUERY_INTERFACE, if you use that instead of NS_IMPL_ISUPPORTS. That's it! The rest is gory details. Notice that nsFooBar didn't need to inherit from nsIClassInfo in order to "implement" it. However, after adding these macros to nsFooBar, you you can QueryInterface an instance of nsFooBar to nsIClassInfo. How can this be? The answer lies in the NS_IMPL_ISUPPORTS_CI macro. It modifies nsFooBar's QueryInterface implementation such that, if we ask to QI to nsIClassInfo, it returns a singleton object associated with the class. (That singleton is defined by NS_IMPL_CLASSINFO.) So all nsFooBar instances will return the same object when QI'ed to nsIClassInfo. (You can see this in NS_IMPL_QUERY_CLASSINFO below.) This hack breaks XPCOM's rules, since if you take an instance of nsFooBar, QI it to nsIClassInfo, and then try to QI to nsIFoo, that will fail. On the upside, implementing nsIClassInfo doesn't add a vtable pointer to instances of your class. In principal, you can also implement nsIClassInfo by inheriting from the interface. But some code expects that when it QI's an object to nsIClassInfo, it gets back a singleton which isn't attached to any particular object. If a class were to implement nsIClassInfo through inheritance, that code might QI to nsIClassInfo and keep the resulting object alive, thinking it was only keeping alive the classinfo singleton, but in fact keeping a whole instance of the class alive. See, e.g., bug 658632. Unless you specifically need to have a different nsIClassInfo instance for each instance of your class, you should probably just implement nsIClassInfo as a singleton. 8722
nsIConsoleListener.idl Used by the console service to notify listeners of new console messages. 592
nsIConsoleMessage.idl This is intended as a base interface; implementations may want to provide an object that can be qi'ed to provide more specific message information. 1594
nsIConsoleService.idl Convenience method for logging simple messages. 2754
nsICycleCollectorListener.idl A set of interfaces for recording the cycle collector's work. An instance of nsICycleCollectorListener can be configured to enable various options, then passed to the cycle collector when it runs. Note that additional logging options are available by setting environment variables, as described at the top of nsCycleCollector.cpp. 7022
nsID.cpp Multiplies the_int_var with 16 (0x10) and adds the value of the hexadecimal digit the_char. If it fails it returns false from the function it's used in. 7417
nsID.h A "unique identifier". This is modeled after OSF DCE UUIDs. 5034
nsIDebug2.idl interface to expose information about calls to NS_DebugBreak 2871
nsIDUtils.h Trims the brackets around the nsID string, since it wraps its ID with brackets: {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}. 1120
nsIException.idl Interfaces for representing cross-language exceptions and stack traces. 3484
nsIInterfaceRequestor.idl The nsIInterfaceRequestor interface defines a generic interface for requesting interfaces that a given object might provide access to. This is very similar to QueryInterface found in nsISupports. The main difference is that interfaces returned from GetInterface() are not required to provide a way back to the object implementing this interface. The semantics of QI() dictate that given an interface A that you QI() on to get to interface B, you must be able to QI on B to get back to A. This interface however allows you to obtain an interface C from A that may or most likely will not have the ability to get back to A. 1534
nsIInterfaceRequestorUtils.cpp 950
nsIInterfaceRequestorUtils.h 1495
nsIMacPreferencesReader.idl This interface is designed to provide scriptable access to the macOS preferences system. This interface is highly macOS specific. 955
nsIMemoryInfoDumper.idl Callback interface for |dumpGCAndCCLogsToFile|, below. Note that these method calls can occur before |dumpGCAndCCLogsToFile| returns. 6877
nsIMemoryReporter.idl Memory reporters measure Firefox's memory usage. They are primarily used to generate the about:memory page. You should read https://developer.mozilla.org/en-US/docs/Mozilla/Performance/Memory_reporting before writing a memory reporter. 25526
nsINIParser.cpp 8027
nsINIParser.h Initialize the INIParser with a nsIFile. If this method fails, no other methods should be called. This method reads and parses the file, the class does not hold a file handle open. An instance must only be initialized once. 4683
nsInterfaceRequestorAgg.cpp 2615
nsInterfaceRequestorAgg.h This function returns an instance of nsIInterfaceRequestor that aggregates two nsIInterfaceRequestor instances. Its GetInterface method queries aFirst for the requested interface and will query aSecond only if aFirst failed to supply the requested interface. Both aFirst and aSecond may be null, and will be released on the main thread when the aggregator is destroyed. 1377
nsISecurityConsoleMessage.idl Holds localization message tag and message category for security related console messages. 592
nsISizeOf.h Measures the size of the things pointed to by the object. 1257
nsISupports.idl The mother of all xpcom interfaces. 2017
nsISupportsImpl.cpp 4288
nsISupportsImpl.h needed for cargo-culting headers 70908
nsISupportsUtils.h Macro for adding a reference to an interface. @param _ptr The interface pointer. 4740
nsIUUIDGenerator.idl nsIUUIDGenerator is implemented by a service that can generate universally unique identifiers, ideally using any platform-native method for generating UUIDs. 1421
nsIVersionComparator.idl Version strings are dot-separated sequences of version-parts. A version-part consists of up to four parts, all of which are optional: <number-a><string-b><number-c><string-d (everything else)> A version-part may also consist of a single asterisk "*" which indicates "infinity". Numbers are base-10, and are zero if left out. Strings are compared bytewise. For additional backwards compatibility, if "string-b" is "+" then "number-a" is incremented by 1 and "string-b" becomes "pre". 1.0pre1 < 1.0pre2 < 1.0 == 1.0.0 == 1.0.0.0 < 1.1pre == 1.1pre0 == 1.0+ < 1.1pre1a < 1.1pre1 < 1.1pre10a < 1.1pre10 Although not required by this interface, it is recommended that numbers remain within the limits of a signed char, i.e. -127 to 128. 1541
nsIWeakReference.idl An instance of |nsIWeakReference| is a proxy object that cooperates with its referent to give clients a non-owning, non-dangling reference. Clients own the proxy, and should generally manage it with an |nsCOMPtr| (see the type |nsWeakPtr| for a |typedef| name that stands out) as they would any other XPCOM object. The |QueryReferent| member function provides a (hopefully short-lived) owning reference on demand, through which clients can get useful access to the referent, while it still exists. @version 1.0 @see nsISupportsWeakReference @see nsWeakReference @see nsWeakPtr 3705
nsIWeakReferenceUtils.h / // a type-safe shortcut for calling the |QueryReferent()| member function // T must inherit from nsIWeakReference, but the cast may be ambiguous. template <class T, class DestinationType> inline nsresult CallQueryReferent(T* aSource, DestinationType** aDestination) { MOZ_ASSERT(aSource, "null parameter"); MOZ_ASSERT(aDestination, "null parameter"); return aSource->QueryReferent(NS_GET_TEMPLATE_IID(DestinationType), reinterpret_cast<void**>(aDestination)); } inline const nsQueryReferent do_QueryReferent(nsIWeakReference* aRawPtr, nsresult* aError = 0) { return nsQueryReferent(aRawPtr, aError); } /** Deprecated, use |do_GetWeakReference| instead. 3286
nsMacPreferencesReader.h 1099
nsMacPreferencesReader.mm 3041
nsMacUtilsImpl.cpp MOZ_SANDBOX || __aarch64__ 16576
nsMacUtilsImpl.h MOZ_SANDBOX || __aarch64__ 1913
nsMaybeWeakPtr.h 4798
nsMemory.h A client that wishes to be notified of low memory situations (for example, because the client maintains a large memory cache that could be released when memory is tight) should register with the observer service (see nsIObserverService) using the topic "memory-pressure". There are specific types of notifications that can occur. These types will be passed as the |aData| parameter of the of the "memory-pressure" notification: "low-memory" This will be passed as the extra data when the pressure observer is being asked to flush for low-memory conditions. "low-memory-ongoing" This will be passed when we continue to be in a low-memory condition and we want to flush caches and do other cheap forms of memory minimization, but heavy handed approaches like a GC are unlikely to succeed. "heap-minimize" This will be passed as the extra data when the pressure observer is being asked to flush because of a heap minimize call. 2240
nsMemoryImpl.cpp 3736
nsMemoryInfoDumper.cpp The following code supports dumping about:memory upon receiving a signal. We listen for the following signals: - SIGRTMIN: Dump our memory reporters (and those of our child processes), - SIGRTMIN + 1: Dump our memory reporters (and those of our child processes) after minimizing memory usage, and - SIGRTMIN + 2: Dump the GC and CC logs in this and our child processes. When we receive one of these signals, we write the signal number to a pipe. The IO thread then notices that the pipe has been written to, and kicks off the appropriate task on the main thread. This scheme is similar to using signalfd(), except it's portable and it doesn't require the use of sigprocmask, which is problematic because it masks signals received by child processes. In theory, we could use Chromium's MessageLoopForIO::CatchSignal() for this. But that uses libevent, which does not handle the realtime signals (bug 794074). 25262
nsMemoryInfoDumper.h This class facilitates dumping information about our memory usage to disk. Its cpp file also has Linux-only code which watches various OS signals and dumps memory info upon receiving a signal. You can activate these listeners by calling Initialize(). 1578
nsMemoryReporterManager.cpp 95751
nsMemoryReporterManager.h 13364
nsObjCExceptions.h 2037
nsObjCExceptions.mm 1488
NSPRLogModulesParser.cpp 2163
NSPRLogModulesParser.h Helper function that parses the legacy NSPR_LOG_MODULES env var format for specifying log levels and logging options. @param aLogModules The log modules configuration string. @param aCallback The callback to invoke for each log module config entry. 829
nsQueryObject.h / template <class T> class MOZ_STACK_CLASS nsQueryObject final : public nsCOMPtr_helper { public: explicit nsQueryObject(T* aRawPtr) : mRawPtr(aRawPtr) {} virtual nsresult NS_FASTCALL operator()(const nsIID& aIID, void** aResult) const override { nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult) : NS_ERROR_NULL_POINTER; return status; } private: T* MOZ_NON_OWNING_REF mRawPtr; }; template <class T> class MOZ_STACK_CLASS nsQueryObjectWithError final : public nsCOMPtr_helper { public: nsQueryObjectWithError(T* aRawPtr, nsresult* aErrorPtr) : mRawPtr(aRawPtr), mErrorPtr(aErrorPtr) {} virtual nsresult NS_FASTCALL operator()(const nsIID& aIID, void** aResult) const override { nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult) : NS_ERROR_NULL_POINTER; if (mErrorPtr) { mErrorPtr = status; } return status; } private: T* MOZ_NON_OWNING_REF mRawPtr; nsresult* mErrorPtr; }; /**************************************************************************** 2956
nsrootidl.idl Root idl declarations to be used by all. 2503
nsSecurityConsoleMessage.cpp 1020
nsSecurityConsoleMessage.h 1050
nsSystemInfo.cpp 68456
nsSystemInfo.h IsExclusive 3903
nsTraceRefcnt.cpp 36856
nsTraceRefcnt.h Tell nsTraceRefcnt whether refcounting, allocation, and destruction activity is legal. This is used to trigger assertions for any such activity that occurs because of static constructors or destructors. 1284
nsUUIDGenerator.cpp 815
nsUUIDGenerator.h _NSUUIDGENERATOR_H_ 958
nsVersionComparator.cpp Parse a version part into a number and "extra text". @returns A pointer to the next versionpart, or null if none. 7899
nsVersionComparator.h In order to compare version numbers in Mozilla, you need to use the mozilla::Version class. You can construct an object of this type by passing in a string version number to the constructor. Objects of this type can be compared using the standard comparison operators. For example, let's say that you want to make sure that a given version number is not older than 15.a2. Here's how you would write a function to do that. bool IsVersionValid(const char* version) { return mozilla::Version("15.a2") <= mozilla::Version(version); } Or, since Version's constructor is implicit, you can simplify this code: bool IsVersionValid(const char* version) { return mozilla::Version("15.a2") <= version; } 3474
nsVersionComparatorImpl.cpp 798
nsVersionComparatorImpl.h 974
nsWeakReference.cpp 3698
nsWeakReference.h 2367
nsWindowsHelpers.h 8742
OwningNonNull.h A class for non-null strong pointers to reference-counted objects. 6252
PHCManager.cpp 4442
PHCManager.h 646
RLBoxSandboxPool.cpp 32-bit wasm memory 3464
RLBoxSandboxPool.h 3792
RLBoxUtils.h The RLBoxTransferBufferToSandbox class is used to copy (or directly expose in the noop-sandbox case) buffers into the sandbox that are automatically freed when the RLBoxTransferBufferToSandbox is out of scope. NOTE: The sandbox lifetime must outlive all of its RLBoxTransferBufferToSandbox. 2323
ShutdownPhase.h 885
SizeOfState.h 2446
StaticLocalPtr.h StaticLocalAutoPtr and StaticLocalRefPtr are like UniquePtr and RefPtr, except they are suitable for use as "magic static" local variables -- that is, they are able to take advantage of C++11's guarantee of thread safety during initialization by atomically constructing both the smart pointer itself as well as the object being pointed to. A static local instance of StaticLocal{Auto,Ref}Ptr does not cause the compiler to emit any atexit calls. In order to accomplish this, StaticLocal{Auto,Ref}Ptr must have a trivial destructor. As a consequence, it does not delete/release its raw pointer upon destruction. The clang plugin, run as part of our "static analysis" builds, makes it a compile-time error to use StaticLocal{Auto,Ref}Ptr as anything except a static local variable. StaticLocal{Auto,Ref}Ptr have a limited interface as compared to ns{Auto,Ref}Ptr; this is intentional, since their range of acceptable uses is smaller. 7995
StaticMonitor.h 3298
StaticMutex.h StaticMutex is a Mutex that can (and in fact, must) be used as a global/static variable. The main reason to use StaticMutex as opposed to StaticAutoPtr<OffTheBooksMutex> is that we instantiate the StaticMutex in a thread-safe manner the first time it's used. The same caveats that apply to StaticAutoPtr apply to StaticMutex. In particular, do not use StaticMutex as a stack variable or a class instance variable, because this class relies on the fact that global variablies are initialized to 0 in order to initialize mMutex. It is only safe to use StaticMutex as a global or static variable. 2798
StaticPtr.h StaticAutoPtr and StaticRefPtr are like UniquePtr and RefPtr, except they are suitable for use as global variables. In particular, a global instance of Static{Auto,Ref}Ptr doesn't cause the compiler to emit a static initializer. Since the compiler guarantees that all global variables are initialized to 0, the default constexpr constructors will result in no actual code being generated. Since we rely on this, the clang plugin, run as part of our "static analysis" builds, makes it a compile-time error to use Static{Auto,Ref}Ptr as anything except a global variable. Static{Auto,Ref}Ptr have a limited interface as compared to ns{Auto,Ref}Ptr; this is intentional, since their range of acceptable uses is smaller. 6917