In order to ensure thread safety it is important that all of the objects and interfaces of URI objects are immutable. If you are implementing a new URI type, please make sure that none of the type’s public methods change the URL.
URI - Uniform Resource Identifier
URL - Uniform Resource Locator
These two terms are used interchangeably throughout the codebase and essentially represent the same thing - a string of characters that represents a specific resource.
While we could simply pass strings around and leave it to the final consumer to deal with it, that creates a burden for the consumer and would probably be inefficient. Instead we parse the string into a nsIURI object as soon as possible and pass that object through function calls. This allows the consumer to easily extract only the part of the string they are interested in (eg. the hostname or the path).
This is the most important interface for URI parsing. It contains a series of readonly attributes that consumers can use to extract information from the URI.
Defines a structure for the URI’s path (directory, fileName, fileBaseName, fileExtension)
Has a file attribute of type
Used for local protocols to access the file represented by the
Used to represent an icon. Contains additional attributes such as the size and contentType or state of the URL.
Used to represent a resource inside of a JAR (zip archive) file.
/ocean.htmlresource located inside the
blue.jararchive that can be fetched via HTTP from example.com.
Defines a few constant flags used to determine the type of the URL. No other attributes.
innermostURIis just a helper - one could also get it by going through
innerURIrepeatedly until the attribute no longer QIs to nsINestedURI.
Objects that implement this interface will have a
getSensitiveInfoHiddenSpec()method that returns the spec of the URI with sensitive info (such as the password) replaced by the
Diagram of interfaces¶
To ensure thread safety all implementations of nsIURI must be immutable.
To change a URI the consumer must call
nsIURI.mutate() which returns a
nsIMutator has several setter methods that can be used change attributes on the concrete object. Once done changing the object, the consumer will call
nsIMutator.finalize() to obtain an immutable
This interface contains a series of setters that can be used to mutate and/or construct a
overrides nsStandardURL::GetFile to provide nsIFile resolution.
This allows us to map URLs such as
resource://gre/actors/RemotePageChild.jsmto the actual file on the disk.
Used to represent icon URLs
Used for simple URIs that normally don’t have an authority (username, password, host, port)
Normally only the extra scheme of the nestedURI is relevant (eg.
Most of the getter/setters are delegated to the innerURI
Similar to nsSimpleNestedURI, but has an extra
mBaseURImember that allows us to propagate the base URI to about:blank correctly`
Similar to nsSimpleURI, but also has a revoked field.
This class wraps an object parsed by the
While not yet enabled by default, due to small bugs in that parser, the plan is to eventually use this implementation for all unknown protocols that don’t have their own URL parser.
Used to represent resources inside of JAR files.