/* vim:set ts=4 sw=2 sts=2 et cin: */ /* 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/. */
class PendingTransactionInfo; class ConnectionEntry;
class DnsAndConnectSocket final : public nsIOutputStreamCallback, public nsITransportEventSink, public nsIInterfaceRequestor, public nsITimerCallback, public nsINamed, public nsSupportsWeakReference, public nsIDNSListener {
~DnsAndConnectSocket();
// Checks whether the transaction can be dispatched using this // half-open's connection. If this half-open is marked as urgent-start, // it only accepts urgent start transactions. Call only before Claim(). bool AcceptsTransaction(nsHttpTransaction* trans); bool Claim(); void Unclaim();
private: // This performs checks that the DnsAndConnectSocket has been properly cleand // up. void CheckIsDone();
/** * State: * INIT: initial state. From this state: * 1) change the state to RESOLVING and start the primary DNS lookup * if mSkipDnsResolution is false, * 2) or the lookup is skip and the state changes to CONNECTING and * start the backup timer. * 3) or changes to DONE in case of an error. * RESOLVING: the primary DNS resolution is in progress. From this state * we transition into CONNECTING or DONE. * CONNECTING: We change to this state when the primary connection has * started. At that point the backup timer is started. * ONE_CONNECTED: We change into this state when one of the connections * is connected and the second is in progres. * DONE * * Events: * INIT_EVENT: Start the primary dns resolution (if mSkipDnsResolution is * false), otherwise start the primary connection. * RESOLVED_PRIMARY_EVENT: the primary DNS resolution is done. This event * may be resent due to DNS retries * CONNECTED_EVENT: A connecion (primary or backup) is done
*/ enum DnsAndSocketState {
INIT,
RESOLVING,
CONNECTING,
ONE_CONNECTED,
DONE
} mState = INIT;
// To find out whether |mTransaction| is still in the connection entry's // pending queue. If the transaction is found and |removeWhenFound| is // true, the transaction will be removed from the pending queue.
already_AddRefed<PendingTransactionInfo> FindTransactionHelper( bool removeWhenFound);
// mSpeculative is set if the socket was created from // SpeculativeConnect(). It is cleared when a transaction would normally // start a new connection from scratch but instead finds this one in // the half open list and claims it for its own use. (which due to // the vagaries of scheduling from the pending queue might not actually // match up - but it prevents a speculative connection from opening // more connections that are needed.) bool mSpeculative;
// If created with a non-null urgent transaction, remember it, so we can // mark the connection as urgent rightaway it's created. bool mUrgentStart;
// mIsFromPredictor is set if the socket originated from the network // Predictor. It is used to gather telemetry data on used speculative // connections from the predictor. bool mIsFromPredictor;
bool mAllow1918 = true;
// mHasConnected tracks whether one of the sockets has completed the // connection process. It may have completed unsuccessfully. bool mHasConnected = false;
bool mBackupConnStatsSet = false;
// A DnsAndConnectSocket can be made for a concrete non-null transaction, // but the transaction can be dispatch to another connection. In that // case we can free this transaction to be claimed by other // transactions. bool mFreeToUse = true;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.