1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/protocol/http/nsHttpHandler.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,571 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsHttpHandler_h__ 1.10 +#define nsHttpHandler_h__ 1.11 + 1.12 +#include "nsHttp.h" 1.13 +#include "nsHttpAuthCache.h" 1.14 +#include "nsHttpConnectionMgr.h" 1.15 +#include "ASpdySession.h" 1.16 + 1.17 +#include "nsString.h" 1.18 +#include "nsCOMPtr.h" 1.19 +#include "nsWeakReference.h" 1.20 + 1.21 +#include "nsIHttpProtocolHandler.h" 1.22 +#include "nsIObserver.h" 1.23 +#include "nsISpeculativeConnect.h" 1.24 +#include "nsICache.h" 1.25 + 1.26 +class nsIHttpChannel; 1.27 +class nsIPrefBranch; 1.28 +class nsICancelable; 1.29 +class nsICookieService; 1.30 +class nsIIOService; 1.31 +class nsIObserverService; 1.32 +class nsISiteSecurityService; 1.33 +class nsIStreamConverterService; 1.34 +class nsITimer; 1.35 + 1.36 +namespace mozilla { 1.37 +namespace net { 1.38 +class ATokenBucketEvent; 1.39 +class EventTokenBucket; 1.40 +class Tickler; 1.41 +class nsHttpConnection; 1.42 +class nsHttpConnectionInfo; 1.43 +class nsHttpTransaction; 1.44 + 1.45 +//----------------------------------------------------------------------------- 1.46 +// nsHttpHandler - protocol handler for HTTP and HTTPS 1.47 +//----------------------------------------------------------------------------- 1.48 + 1.49 +class nsHttpHandler : public nsIHttpProtocolHandler 1.50 + , public nsIObserver 1.51 + , public nsSupportsWeakReference 1.52 + , public nsISpeculativeConnect 1.53 +{ 1.54 +public: 1.55 + NS_DECL_THREADSAFE_ISUPPORTS 1.56 + NS_DECL_NSIPROTOCOLHANDLER 1.57 + NS_DECL_NSIPROXIEDPROTOCOLHANDLER 1.58 + NS_DECL_NSIHTTPPROTOCOLHANDLER 1.59 + NS_DECL_NSIOBSERVER 1.60 + NS_DECL_NSISPECULATIVECONNECT 1.61 + 1.62 + nsHttpHandler(); 1.63 + virtual ~nsHttpHandler(); 1.64 + 1.65 + nsresult Init(); 1.66 + nsresult AddStandardRequestHeaders(nsHttpHeaderArray *); 1.67 + nsresult AddConnectionHeader(nsHttpHeaderArray *, 1.68 + uint32_t capabilities); 1.69 + bool IsAcceptableEncoding(const char *encoding); 1.70 + 1.71 + const nsAFlatCString &UserAgent(); 1.72 + 1.73 + nsHttpVersion HttpVersion() { return mHttpVersion; } 1.74 + nsHttpVersion ProxyHttpVersion() { return mProxyHttpVersion; } 1.75 + uint8_t ReferrerLevel() { return mReferrerLevel; } 1.76 + bool SpoofReferrerSource() { return mSpoofReferrerSource; } 1.77 + uint8_t ReferrerTrimmingPolicy() { return mReferrerTrimmingPolicy; } 1.78 + uint8_t ReferrerXOriginPolicy() { return mReferrerXOriginPolicy; } 1.79 + bool SendSecureXSiteReferrer() { return mSendSecureXSiteReferrer; } 1.80 + uint8_t RedirectionLimit() { return mRedirectionLimit; } 1.81 + PRIntervalTime IdleTimeout() { return mIdleTimeout; } 1.82 + PRIntervalTime SpdyTimeout() { return mSpdyTimeout; } 1.83 + PRIntervalTime ResponseTimeout() { 1.84 + return mResponseTimeoutEnabled ? mResponseTimeout : 0; 1.85 + } 1.86 + PRIntervalTime ResponseTimeoutEnabled() { return mResponseTimeoutEnabled; } 1.87 + uint16_t MaxRequestAttempts() { return mMaxRequestAttempts; } 1.88 + const char *DefaultSocketType() { return mDefaultSocketType.get(); /* ok to return null */ } 1.89 + uint32_t PhishyUserPassLength() { return mPhishyUserPassLength; } 1.90 + uint8_t GetQoSBits() { return mQoSBits; } 1.91 + uint16_t GetIdleSynTimeout() { return mIdleSynTimeout; } 1.92 + bool FastFallbackToIPv4() { return mFastFallbackToIPv4; } 1.93 + bool ProxyPipelining() { return mProxyPipelining; } 1.94 + uint32_t MaxSocketCount(); 1.95 + bool EnforceAssocReq() { return mEnforceAssocReq; } 1.96 + 1.97 + bool IsPersistentHttpsCachingEnabled() { return mEnablePersistentHttpsCaching; } 1.98 + bool IsTelemetryEnabled() { return mTelemetryEnabled; } 1.99 + bool AllowExperiments() { return mTelemetryEnabled && mAllowExperiments; } 1.100 + 1.101 + bool IsSpdyEnabled() { return mEnableSpdy; } 1.102 + bool IsSpdyV3Enabled() { return mSpdyV3; } 1.103 + bool IsSpdyV31Enabled() { return mSpdyV31; } 1.104 + bool IsHttp2DraftEnabled() { return mHttp2DraftEnabled; } 1.105 + bool EnforceHttp2TlsProfile() { return mEnforceHttp2TlsProfile; } 1.106 + bool CoalesceSpdy() { return mCoalesceSpdy; } 1.107 + bool UseSpdyPersistentSettings() { return mSpdyPersistentSettings; } 1.108 + uint32_t SpdySendingChunkSize() { return mSpdySendingChunkSize; } 1.109 + uint32_t SpdySendBufferSize() { return mSpdySendBufferSize; } 1.110 + uint32_t SpdyPushAllowance() { return mSpdyPushAllowance; } 1.111 + PRIntervalTime SpdyPingThreshold() { return mSpdyPingThreshold; } 1.112 + PRIntervalTime SpdyPingTimeout() { return mSpdyPingTimeout; } 1.113 + bool AllowPush() { return mAllowPush; } 1.114 + uint32_t ConnectTimeout() { return mConnectTimeout; } 1.115 + uint32_t ParallelSpeculativeConnectLimit() { return mParallelSpeculativeConnectLimit; } 1.116 + bool CriticalRequestPrioritization() { return mCriticalRequestPrioritization; } 1.117 + double BypassCacheLockThreshold() { return mBypassCacheLockThreshold; } 1.118 + 1.119 + bool UseRequestTokenBucket() { return mRequestTokenBucketEnabled; } 1.120 + uint16_t RequestTokenBucketMinParallelism() { return mRequestTokenBucketMinParallelism; } 1.121 + uint32_t RequestTokenBucketHz() { return mRequestTokenBucketHz; } 1.122 + uint32_t RequestTokenBucketBurst() {return mRequestTokenBucketBurst; } 1.123 + 1.124 + bool PromptTempRedirect() { return mPromptTempRedirect; } 1.125 + 1.126 + // TCP Keepalive configuration values. 1.127 + 1.128 + // Returns true if TCP keepalive should be enabled for short-lived conns. 1.129 + bool TCPKeepaliveEnabledForShortLivedConns() { 1.130 + return mTCPKeepaliveShortLivedEnabled; 1.131 + } 1.132 + // Return time (secs) that a connection is consider short lived (for TCP 1.133 + // keepalive purposes). After this time, the connection is long-lived. 1.134 + int32_t GetTCPKeepaliveShortLivedTime() { 1.135 + return mTCPKeepaliveShortLivedTimeS; 1.136 + } 1.137 + // Returns time (secs) before first TCP keepalive probes should be sent; 1.138 + // same time used between successful keepalive probes. 1.139 + int32_t GetTCPKeepaliveShortLivedIdleTime() { 1.140 + return mTCPKeepaliveShortLivedIdleTimeS; 1.141 + } 1.142 + 1.143 + // Returns true if TCP keepalive should be enabled for long-lived conns. 1.144 + bool TCPKeepaliveEnabledForLongLivedConns() { 1.145 + return mTCPKeepaliveLongLivedEnabled; 1.146 + } 1.147 + // Returns time (secs) before first TCP keepalive probes should be sent; 1.148 + // same time used between successful keepalive probes. 1.149 + int32_t GetTCPKeepaliveLongLivedIdleTime() { 1.150 + return mTCPKeepaliveLongLivedIdleTimeS; 1.151 + } 1.152 + 1.153 + nsHttpAuthCache *AuthCache(bool aPrivate) { 1.154 + return aPrivate ? &mPrivateAuthCache : &mAuthCache; 1.155 + } 1.156 + nsHttpConnectionMgr *ConnMgr() { return mConnMgr; } 1.157 + 1.158 + // cache support 1.159 + bool UseCache() const { return mUseCache; } 1.160 + uint32_t GenerateUniqueID() { return ++mLastUniqueID; } 1.161 + uint32_t SessionStartTime() { return mSessionStartTime; } 1.162 + 1.163 + // 1.164 + // Connection management methods: 1.165 + // 1.166 + // - the handler only owns idle connections; it does not own active 1.167 + // connections. 1.168 + // 1.169 + // - the handler keeps a count of active connections to enforce the 1.170 + // steady-state max-connections pref. 1.171 + // 1.172 + 1.173 + // Called to kick-off a new transaction, by default the transaction 1.174 + // will be put on the pending transaction queue if it cannot be 1.175 + // initiated at this time. Callable from any thread. 1.176 + nsresult InitiateTransaction(nsHttpTransaction *trans, int32_t priority) 1.177 + { 1.178 + return mConnMgr->AddTransaction(trans, priority); 1.179 + } 1.180 + 1.181 + // Called to change the priority of an existing transaction that has 1.182 + // already been initiated. 1.183 + nsresult RescheduleTransaction(nsHttpTransaction *trans, int32_t priority) 1.184 + { 1.185 + return mConnMgr->RescheduleTransaction(trans, priority); 1.186 + } 1.187 + 1.188 + // Called to cancel a transaction, which may or may not be assigned to 1.189 + // a connection. Callable from any thread. 1.190 + nsresult CancelTransaction(nsHttpTransaction *trans, nsresult reason) 1.191 + { 1.192 + return mConnMgr->CancelTransaction(trans, reason); 1.193 + } 1.194 + 1.195 + // Called when a connection is done processing a transaction. Callable 1.196 + // from any thread. 1.197 + nsresult ReclaimConnection(nsHttpConnection *conn) 1.198 + { 1.199 + return mConnMgr->ReclaimConnection(conn); 1.200 + } 1.201 + 1.202 + nsresult ProcessPendingQ(nsHttpConnectionInfo *cinfo) 1.203 + { 1.204 + return mConnMgr->ProcessPendingQ(cinfo); 1.205 + } 1.206 + 1.207 + nsresult ProcessPendingQ() 1.208 + { 1.209 + return mConnMgr->ProcessPendingQ(); 1.210 + } 1.211 + 1.212 + nsresult GetSocketThreadTarget(nsIEventTarget **target) 1.213 + { 1.214 + return mConnMgr->GetSocketThreadTarget(target); 1.215 + } 1.216 + 1.217 + nsresult SpeculativeConnect(nsHttpConnectionInfo *ci, 1.218 + nsIInterfaceRequestor *callbacks, 1.219 + uint32_t caps = 0) 1.220 + { 1.221 + TickleWifi(callbacks); 1.222 + return mConnMgr->SpeculativeConnect(ci, callbacks, caps); 1.223 + } 1.224 + 1.225 + // 1.226 + // The HTTP handler caches pointers to specific XPCOM services, and 1.227 + // provides the following helper routines for accessing those services: 1.228 + // 1.229 + nsresult GetStreamConverterService(nsIStreamConverterService **); 1.230 + nsresult GetIOService(nsIIOService** service); 1.231 + nsICookieService * GetCookieService(); // not addrefed 1.232 + nsISiteSecurityService * GetSSService(); 1.233 + 1.234 + // callable from socket thread only 1.235 + uint32_t Get32BitsOfPseudoRandom(); 1.236 + 1.237 + // Called by the channel synchronously during asyncOpen 1.238 + void OnOpeningRequest(nsIHttpChannel *chan) 1.239 + { 1.240 + NotifyObservers(chan, NS_HTTP_ON_OPENING_REQUEST_TOPIC); 1.241 + } 1.242 + 1.243 + // Called by the channel before writing a request 1.244 + void OnModifyRequest(nsIHttpChannel *chan) 1.245 + { 1.246 + NotifyObservers(chan, NS_HTTP_ON_MODIFY_REQUEST_TOPIC); 1.247 + } 1.248 + 1.249 + // Called by the channel once headers are available 1.250 + void OnExamineResponse(nsIHttpChannel *chan) 1.251 + { 1.252 + NotifyObservers(chan, NS_HTTP_ON_EXAMINE_RESPONSE_TOPIC); 1.253 + } 1.254 + 1.255 + // Called by the channel once headers have been merged with cached headers 1.256 + void OnExamineMergedResponse(nsIHttpChannel *chan) 1.257 + { 1.258 + NotifyObservers(chan, NS_HTTP_ON_EXAMINE_MERGED_RESPONSE_TOPIC); 1.259 + } 1.260 + 1.261 + // Called by channels before a redirect happens. This notifies both the 1.262 + // channel's and the global redirect observers. 1.263 + nsresult AsyncOnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan, 1.264 + uint32_t flags); 1.265 + 1.266 + // Called by the channel when the response is read from the cache without 1.267 + // communicating with the server. 1.268 + void OnExamineCachedResponse(nsIHttpChannel *chan) 1.269 + { 1.270 + NotifyObservers(chan, NS_HTTP_ON_EXAMINE_CACHED_RESPONSE_TOPIC); 1.271 + } 1.272 + 1.273 + // Generates the host:port string for use in the Host: header as well as the 1.274 + // CONNECT line for proxies. This handles IPv6 literals correctly. 1.275 + static nsresult GenerateHostPort(const nsCString& host, int32_t port, 1.276 + nsCString& hostLine); 1.277 + 1.278 + bool GetPipelineAggressive() { return mPipelineAggressive; } 1.279 + uint32_t GetMaxPipelinedRequests() { return mMaxPipelinedRequests; } 1.280 + uint32_t GetMaxOptimisticPipelinedRequests() { return mMaxOptimisticPipelinedRequests; } 1.281 + void GetMaxPipelineObjectSize(int64_t *outVal) 1.282 + { 1.283 + *outVal = mMaxPipelineObjectSize; 1.284 + } 1.285 + 1.286 + bool GetPipelineEnabled() 1.287 + { 1.288 + return mCapabilities & NS_HTTP_ALLOW_PIPELINING; 1.289 + } 1.290 + 1.291 + bool GetPipelineRescheduleOnTimeout() 1.292 + { 1.293 + return mPipelineRescheduleOnTimeout; 1.294 + } 1.295 + 1.296 + PRIntervalTime GetPipelineRescheduleTimeout() 1.297 + { 1.298 + return mPipelineRescheduleTimeout; 1.299 + } 1.300 + 1.301 + PRIntervalTime GetPipelineTimeout() { return mPipelineReadTimeout; } 1.302 + 1.303 + SpdyInformation *SpdyInfo() { return &mSpdyInfo; } 1.304 + 1.305 + // returns true in between Init and Shutdown states 1.306 + bool Active() { return mHandlerActive; } 1.307 + 1.308 + static void GetCacheSessionNameForStoragePolicy( 1.309 + nsCacheStoragePolicy storagePolicy, 1.310 + bool isPrivate, 1.311 + uint32_t appId, 1.312 + bool inBrowser, 1.313 + nsACString& sessionName); 1.314 + 1.315 + // When the disk cache is responding slowly its use is suppressed 1.316 + // for 1 minute for most requests. Callable from main thread only. 1.317 + TimeStamp GetCacheSkippedUntil() { return mCacheSkippedUntil; } 1.318 + void SetCacheSkippedUntil(TimeStamp arg) { mCacheSkippedUntil = arg; } 1.319 + void ClearCacheSkippedUntil() { mCacheSkippedUntil = TimeStamp(); } 1.320 + 1.321 +private: 1.322 + 1.323 + // 1.324 + // Useragent/prefs helper methods 1.325 + // 1.326 + void BuildUserAgent(); 1.327 + void InitUserAgentComponents(); 1.328 + void PrefsChanged(nsIPrefBranch *prefs, const char *pref); 1.329 + 1.330 + nsresult SetAccept(const char *); 1.331 + nsresult SetAcceptLanguages(const char *); 1.332 + nsresult SetAcceptEncodings(const char *); 1.333 + 1.334 + nsresult InitConnectionMgr(); 1.335 + 1.336 + void NotifyObservers(nsIHttpChannel *chan, const char *event); 1.337 + 1.338 + static void TimerCallback(nsITimer * aTimer, void * aClosure); 1.339 +private: 1.340 + 1.341 + // cached services 1.342 + nsMainThreadPtrHandle<nsIIOService> mIOService; 1.343 + nsMainThreadPtrHandle<nsIStreamConverterService> mStreamConvSvc; 1.344 + nsMainThreadPtrHandle<nsIObserverService> mObserverService; 1.345 + nsMainThreadPtrHandle<nsICookieService> mCookieService; 1.346 + nsMainThreadPtrHandle<nsISiteSecurityService> mSSService; 1.347 + 1.348 + // the authentication credentials cache 1.349 + nsHttpAuthCache mAuthCache; 1.350 + nsHttpAuthCache mPrivateAuthCache; 1.351 + 1.352 + // the connection manager 1.353 + nsHttpConnectionMgr *mConnMgr; 1.354 + 1.355 + // 1.356 + // prefs 1.357 + // 1.358 + 1.359 + uint8_t mHttpVersion; 1.360 + uint8_t mProxyHttpVersion; 1.361 + uint32_t mCapabilities; 1.362 + uint8_t mReferrerLevel; 1.363 + uint8_t mSpoofReferrerSource; 1.364 + uint8_t mReferrerTrimmingPolicy; 1.365 + uint8_t mReferrerXOriginPolicy; 1.366 + 1.367 + bool mFastFallbackToIPv4; 1.368 + bool mProxyPipelining; 1.369 + PRIntervalTime mIdleTimeout; 1.370 + PRIntervalTime mSpdyTimeout; 1.371 + PRIntervalTime mResponseTimeout; 1.372 + bool mResponseTimeoutEnabled; 1.373 + 1.374 + uint16_t mMaxRequestAttempts; 1.375 + uint16_t mMaxRequestDelay; 1.376 + uint16_t mIdleSynTimeout; 1.377 + 1.378 + bool mPipeliningEnabled; 1.379 + uint16_t mMaxConnections; 1.380 + uint8_t mMaxPersistentConnectionsPerServer; 1.381 + uint8_t mMaxPersistentConnectionsPerProxy; 1.382 + uint16_t mMaxPipelinedRequests; 1.383 + uint16_t mMaxOptimisticPipelinedRequests; 1.384 + bool mPipelineAggressive; 1.385 + int64_t mMaxPipelineObjectSize; 1.386 + bool mPipelineRescheduleOnTimeout; 1.387 + PRIntervalTime mPipelineRescheduleTimeout; 1.388 + PRIntervalTime mPipelineReadTimeout; 1.389 + nsCOMPtr<nsITimer> mPipelineTestTimer; 1.390 + 1.391 + uint8_t mRedirectionLimit; 1.392 + 1.393 + // we'll warn the user if we load an URL containing a userpass field 1.394 + // unless its length is less than this threshold. this warning is 1.395 + // intended to protect the user against spoofing attempts that use 1.396 + // the userpass field of the URL to obscure the actual origin server. 1.397 + uint8_t mPhishyUserPassLength; 1.398 + 1.399 + uint8_t mQoSBits; 1.400 + 1.401 + bool mPipeliningOverSSL; 1.402 + bool mEnforceAssocReq; 1.403 + 1.404 + nsCString mAccept; 1.405 + nsCString mAcceptLanguages; 1.406 + nsCString mAcceptEncodings; 1.407 + 1.408 + nsXPIDLCString mDefaultSocketType; 1.409 + 1.410 + // cache support 1.411 + uint32_t mLastUniqueID; 1.412 + uint32_t mSessionStartTime; 1.413 + 1.414 + // useragent components 1.415 + nsCString mLegacyAppName; 1.416 + nsCString mLegacyAppVersion; 1.417 + nsCString mPlatform; 1.418 + nsCString mOscpu; 1.419 + nsCString mMisc; 1.420 + nsCString mProduct; 1.421 + nsXPIDLCString mProductSub; 1.422 + nsXPIDLCString mAppName; 1.423 + nsXPIDLCString mAppVersion; 1.424 + nsCString mCompatFirefox; 1.425 + bool mCompatFirefoxEnabled; 1.426 + nsXPIDLCString mCompatDevice; 1.427 + 1.428 + nsCString mUserAgent; 1.429 + nsXPIDLCString mUserAgentOverride; 1.430 + bool mUserAgentIsDirty; // true if mUserAgent should be rebuilt 1.431 + 1.432 + bool mUseCache; 1.433 + 1.434 + bool mPromptTempRedirect; 1.435 + // mSendSecureXSiteReferrer: default is false, 1.436 + // if true allow referrer headers between secure non-matching hosts 1.437 + bool mSendSecureXSiteReferrer; 1.438 + 1.439 + // Persistent HTTPS caching flag 1.440 + bool mEnablePersistentHttpsCaching; 1.441 + 1.442 + // For broadcasting tracking preference 1.443 + bool mDoNotTrackEnabled; 1.444 + uint8_t mDoNotTrackValue; 1.445 + 1.446 + // for broadcasting safe hint; 1.447 + bool mSafeHintEnabled; 1.448 + bool mParentalControlEnabled; 1.449 + 1.450 + // Whether telemetry is reported or not 1.451 + uint32_t mTelemetryEnabled : 1; 1.452 + 1.453 + // The value of network.allow-experiments 1.454 + uint32_t mAllowExperiments : 1; 1.455 + 1.456 + // true in between init and shutdown states 1.457 + uint32_t mHandlerActive : 1; 1.458 + 1.459 + uint32_t mEnableSpdy : 1; 1.460 + uint32_t mSpdyV3 : 1; 1.461 + uint32_t mSpdyV31 : 1; 1.462 + uint32_t mHttp2DraftEnabled : 1; 1.463 + uint32_t mEnforceHttp2TlsProfile : 1; 1.464 + uint32_t mCoalesceSpdy : 1; 1.465 + uint32_t mSpdyPersistentSettings : 1; 1.466 + uint32_t mAllowPush : 1; 1.467 + 1.468 + // Try to use SPDY features instead of HTTP/1.1 over SSL 1.469 + SpdyInformation mSpdyInfo; 1.470 + 1.471 + uint32_t mSpdySendingChunkSize; 1.472 + uint32_t mSpdySendBufferSize; 1.473 + uint32_t mSpdyPushAllowance; 1.474 + PRIntervalTime mSpdyPingThreshold; 1.475 + PRIntervalTime mSpdyPingTimeout; 1.476 + 1.477 + // The maximum amount of time to wait for socket transport to be 1.478 + // established. In milliseconds. 1.479 + uint32_t mConnectTimeout; 1.480 + 1.481 + // The maximum amount of time the nsICacheSession lock can be held 1.482 + // before a new transaction bypasses the cache. In milliseconds. 1.483 + double mBypassCacheLockThreshold; 1.484 + 1.485 + // The maximum number of current global half open sockets allowable 1.486 + // when starting a new speculative connection. 1.487 + uint32_t mParallelSpeculativeConnectLimit; 1.488 + 1.489 + // For Rate Pacing of HTTP/1 requests through a netwerk/base/src/EventTokenBucket 1.490 + // Active requests <= *MinParallelism are not subject to the rate pacing 1.491 + bool mRequestTokenBucketEnabled; 1.492 + uint16_t mRequestTokenBucketMinParallelism; 1.493 + uint32_t mRequestTokenBucketHz; // EventTokenBucket HZ 1.494 + uint32_t mRequestTokenBucketBurst; // EventTokenBucket Burst 1.495 + 1.496 + // Whether or not to block requests for non head js/css items (e.g. media) 1.497 + // while those elements load. 1.498 + bool mCriticalRequestPrioritization; 1.499 + 1.500 + // When the disk cache is responding slowly its use is suppressed 1.501 + // for 1 minute for most requests. 1.502 + TimeStamp mCacheSkippedUntil; 1.503 + 1.504 + // TCP Keepalive configuration values. 1.505 + 1.506 + // True if TCP keepalive is enabled for short-lived conns. 1.507 + bool mTCPKeepaliveShortLivedEnabled; 1.508 + // Time (secs) indicating how long a conn is considered short-lived. 1.509 + int32_t mTCPKeepaliveShortLivedTimeS; 1.510 + // Time (secs) before first keepalive probe; between successful probes. 1.511 + int32_t mTCPKeepaliveShortLivedIdleTimeS; 1.512 + 1.513 + // True if TCP keepalive is enabled for long-lived conns. 1.514 + bool mTCPKeepaliveLongLivedEnabled; 1.515 + // Time (secs) before first keepalive probe; between successful probes. 1.516 + int32_t mTCPKeepaliveLongLivedIdleTimeS; 1.517 + 1.518 +private: 1.519 + // For Rate Pacing Certain Network Events. Only assign this pointer on 1.520 + // socket thread. 1.521 + void MakeNewRequestTokenBucket(); 1.522 + nsRefPtr<EventTokenBucket> mRequestTokenBucket; 1.523 + 1.524 +public: 1.525 + // Socket thread only 1.526 + nsresult SubmitPacedRequest(ATokenBucketEvent *event, 1.527 + nsICancelable **cancel) 1.528 + { 1.529 + if (!mRequestTokenBucket) 1.530 + return NS_ERROR_UNEXPECTED; 1.531 + return mRequestTokenBucket->SubmitEvent(event, cancel); 1.532 + } 1.533 + 1.534 + // Socket thread only 1.535 + void SetRequestTokenBucket(EventTokenBucket *aTokenBucket) 1.536 + { 1.537 + mRequestTokenBucket = aTokenBucket; 1.538 + } 1.539 + 1.540 +private: 1.541 + nsRefPtr<Tickler> mWifiTickler; 1.542 + void TickleWifi(nsIInterfaceRequestor *cb); 1.543 +}; 1.544 + 1.545 +extern nsHttpHandler *gHttpHandler; 1.546 + 1.547 +//----------------------------------------------------------------------------- 1.548 +// nsHttpsHandler - thin wrapper to distinguish the HTTP handler from the 1.549 +// HTTPS handler (even though they share the same impl). 1.550 +//----------------------------------------------------------------------------- 1.551 + 1.552 +class nsHttpsHandler : public nsIHttpProtocolHandler 1.553 + , public nsSupportsWeakReference 1.554 + , public nsISpeculativeConnect 1.555 +{ 1.556 +public: 1.557 + // we basically just want to override GetScheme and GetDefaultPort... 1.558 + // all other methods should be forwarded to the nsHttpHandler instance. 1.559 + 1.560 + NS_DECL_THREADSAFE_ISUPPORTS 1.561 + NS_DECL_NSIPROTOCOLHANDLER 1.562 + NS_FORWARD_NSIPROXIEDPROTOCOLHANDLER (gHttpHandler->) 1.563 + NS_FORWARD_NSIHTTPPROTOCOLHANDLER (gHttpHandler->) 1.564 + NS_FORWARD_NSISPECULATIVECONNECT (gHttpHandler->) 1.565 + 1.566 + nsHttpsHandler() { } 1.567 + virtual ~nsHttpsHandler() { } 1.568 + 1.569 + nsresult Init(); 1.570 +}; 1.571 + 1.572 +}} // namespace mozilla::net 1.573 + 1.574 +#endif // nsHttpHandler_h__