netwerk/protocol/http/nsHttpHandler.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsHttpHandler_h__
michael@0 7 #define nsHttpHandler_h__
michael@0 8
michael@0 9 #include "nsHttp.h"
michael@0 10 #include "nsHttpAuthCache.h"
michael@0 11 #include "nsHttpConnectionMgr.h"
michael@0 12 #include "ASpdySession.h"
michael@0 13
michael@0 14 #include "nsString.h"
michael@0 15 #include "nsCOMPtr.h"
michael@0 16 #include "nsWeakReference.h"
michael@0 17
michael@0 18 #include "nsIHttpProtocolHandler.h"
michael@0 19 #include "nsIObserver.h"
michael@0 20 #include "nsISpeculativeConnect.h"
michael@0 21 #include "nsICache.h"
michael@0 22
michael@0 23 class nsIHttpChannel;
michael@0 24 class nsIPrefBranch;
michael@0 25 class nsICancelable;
michael@0 26 class nsICookieService;
michael@0 27 class nsIIOService;
michael@0 28 class nsIObserverService;
michael@0 29 class nsISiteSecurityService;
michael@0 30 class nsIStreamConverterService;
michael@0 31 class nsITimer;
michael@0 32
michael@0 33 namespace mozilla {
michael@0 34 namespace net {
michael@0 35 class ATokenBucketEvent;
michael@0 36 class EventTokenBucket;
michael@0 37 class Tickler;
michael@0 38 class nsHttpConnection;
michael@0 39 class nsHttpConnectionInfo;
michael@0 40 class nsHttpTransaction;
michael@0 41
michael@0 42 //-----------------------------------------------------------------------------
michael@0 43 // nsHttpHandler - protocol handler for HTTP and HTTPS
michael@0 44 //-----------------------------------------------------------------------------
michael@0 45
michael@0 46 class nsHttpHandler : public nsIHttpProtocolHandler
michael@0 47 , public nsIObserver
michael@0 48 , public nsSupportsWeakReference
michael@0 49 , public nsISpeculativeConnect
michael@0 50 {
michael@0 51 public:
michael@0 52 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 53 NS_DECL_NSIPROTOCOLHANDLER
michael@0 54 NS_DECL_NSIPROXIEDPROTOCOLHANDLER
michael@0 55 NS_DECL_NSIHTTPPROTOCOLHANDLER
michael@0 56 NS_DECL_NSIOBSERVER
michael@0 57 NS_DECL_NSISPECULATIVECONNECT
michael@0 58
michael@0 59 nsHttpHandler();
michael@0 60 virtual ~nsHttpHandler();
michael@0 61
michael@0 62 nsresult Init();
michael@0 63 nsresult AddStandardRequestHeaders(nsHttpHeaderArray *);
michael@0 64 nsresult AddConnectionHeader(nsHttpHeaderArray *,
michael@0 65 uint32_t capabilities);
michael@0 66 bool IsAcceptableEncoding(const char *encoding);
michael@0 67
michael@0 68 const nsAFlatCString &UserAgent();
michael@0 69
michael@0 70 nsHttpVersion HttpVersion() { return mHttpVersion; }
michael@0 71 nsHttpVersion ProxyHttpVersion() { return mProxyHttpVersion; }
michael@0 72 uint8_t ReferrerLevel() { return mReferrerLevel; }
michael@0 73 bool SpoofReferrerSource() { return mSpoofReferrerSource; }
michael@0 74 uint8_t ReferrerTrimmingPolicy() { return mReferrerTrimmingPolicy; }
michael@0 75 uint8_t ReferrerXOriginPolicy() { return mReferrerXOriginPolicy; }
michael@0 76 bool SendSecureXSiteReferrer() { return mSendSecureXSiteReferrer; }
michael@0 77 uint8_t RedirectionLimit() { return mRedirectionLimit; }
michael@0 78 PRIntervalTime IdleTimeout() { return mIdleTimeout; }
michael@0 79 PRIntervalTime SpdyTimeout() { return mSpdyTimeout; }
michael@0 80 PRIntervalTime ResponseTimeout() {
michael@0 81 return mResponseTimeoutEnabled ? mResponseTimeout : 0;
michael@0 82 }
michael@0 83 PRIntervalTime ResponseTimeoutEnabled() { return mResponseTimeoutEnabled; }
michael@0 84 uint16_t MaxRequestAttempts() { return mMaxRequestAttempts; }
michael@0 85 const char *DefaultSocketType() { return mDefaultSocketType.get(); /* ok to return null */ }
michael@0 86 uint32_t PhishyUserPassLength() { return mPhishyUserPassLength; }
michael@0 87 uint8_t GetQoSBits() { return mQoSBits; }
michael@0 88 uint16_t GetIdleSynTimeout() { return mIdleSynTimeout; }
michael@0 89 bool FastFallbackToIPv4() { return mFastFallbackToIPv4; }
michael@0 90 bool ProxyPipelining() { return mProxyPipelining; }
michael@0 91 uint32_t MaxSocketCount();
michael@0 92 bool EnforceAssocReq() { return mEnforceAssocReq; }
michael@0 93
michael@0 94 bool IsPersistentHttpsCachingEnabled() { return mEnablePersistentHttpsCaching; }
michael@0 95 bool IsTelemetryEnabled() { return mTelemetryEnabled; }
michael@0 96 bool AllowExperiments() { return mTelemetryEnabled && mAllowExperiments; }
michael@0 97
michael@0 98 bool IsSpdyEnabled() { return mEnableSpdy; }
michael@0 99 bool IsSpdyV3Enabled() { return mSpdyV3; }
michael@0 100 bool IsSpdyV31Enabled() { return mSpdyV31; }
michael@0 101 bool IsHttp2DraftEnabled() { return mHttp2DraftEnabled; }
michael@0 102 bool EnforceHttp2TlsProfile() { return mEnforceHttp2TlsProfile; }
michael@0 103 bool CoalesceSpdy() { return mCoalesceSpdy; }
michael@0 104 bool UseSpdyPersistentSettings() { return mSpdyPersistentSettings; }
michael@0 105 uint32_t SpdySendingChunkSize() { return mSpdySendingChunkSize; }
michael@0 106 uint32_t SpdySendBufferSize() { return mSpdySendBufferSize; }
michael@0 107 uint32_t SpdyPushAllowance() { return mSpdyPushAllowance; }
michael@0 108 PRIntervalTime SpdyPingThreshold() { return mSpdyPingThreshold; }
michael@0 109 PRIntervalTime SpdyPingTimeout() { return mSpdyPingTimeout; }
michael@0 110 bool AllowPush() { return mAllowPush; }
michael@0 111 uint32_t ConnectTimeout() { return mConnectTimeout; }
michael@0 112 uint32_t ParallelSpeculativeConnectLimit() { return mParallelSpeculativeConnectLimit; }
michael@0 113 bool CriticalRequestPrioritization() { return mCriticalRequestPrioritization; }
michael@0 114 double BypassCacheLockThreshold() { return mBypassCacheLockThreshold; }
michael@0 115
michael@0 116 bool UseRequestTokenBucket() { return mRequestTokenBucketEnabled; }
michael@0 117 uint16_t RequestTokenBucketMinParallelism() { return mRequestTokenBucketMinParallelism; }
michael@0 118 uint32_t RequestTokenBucketHz() { return mRequestTokenBucketHz; }
michael@0 119 uint32_t RequestTokenBucketBurst() {return mRequestTokenBucketBurst; }
michael@0 120
michael@0 121 bool PromptTempRedirect() { return mPromptTempRedirect; }
michael@0 122
michael@0 123 // TCP Keepalive configuration values.
michael@0 124
michael@0 125 // Returns true if TCP keepalive should be enabled for short-lived conns.
michael@0 126 bool TCPKeepaliveEnabledForShortLivedConns() {
michael@0 127 return mTCPKeepaliveShortLivedEnabled;
michael@0 128 }
michael@0 129 // Return time (secs) that a connection is consider short lived (for TCP
michael@0 130 // keepalive purposes). After this time, the connection is long-lived.
michael@0 131 int32_t GetTCPKeepaliveShortLivedTime() {
michael@0 132 return mTCPKeepaliveShortLivedTimeS;
michael@0 133 }
michael@0 134 // Returns time (secs) before first TCP keepalive probes should be sent;
michael@0 135 // same time used between successful keepalive probes.
michael@0 136 int32_t GetTCPKeepaliveShortLivedIdleTime() {
michael@0 137 return mTCPKeepaliveShortLivedIdleTimeS;
michael@0 138 }
michael@0 139
michael@0 140 // Returns true if TCP keepalive should be enabled for long-lived conns.
michael@0 141 bool TCPKeepaliveEnabledForLongLivedConns() {
michael@0 142 return mTCPKeepaliveLongLivedEnabled;
michael@0 143 }
michael@0 144 // Returns time (secs) before first TCP keepalive probes should be sent;
michael@0 145 // same time used between successful keepalive probes.
michael@0 146 int32_t GetTCPKeepaliveLongLivedIdleTime() {
michael@0 147 return mTCPKeepaliveLongLivedIdleTimeS;
michael@0 148 }
michael@0 149
michael@0 150 nsHttpAuthCache *AuthCache(bool aPrivate) {
michael@0 151 return aPrivate ? &mPrivateAuthCache : &mAuthCache;
michael@0 152 }
michael@0 153 nsHttpConnectionMgr *ConnMgr() { return mConnMgr; }
michael@0 154
michael@0 155 // cache support
michael@0 156 bool UseCache() const { return mUseCache; }
michael@0 157 uint32_t GenerateUniqueID() { return ++mLastUniqueID; }
michael@0 158 uint32_t SessionStartTime() { return mSessionStartTime; }
michael@0 159
michael@0 160 //
michael@0 161 // Connection management methods:
michael@0 162 //
michael@0 163 // - the handler only owns idle connections; it does not own active
michael@0 164 // connections.
michael@0 165 //
michael@0 166 // - the handler keeps a count of active connections to enforce the
michael@0 167 // steady-state max-connections pref.
michael@0 168 //
michael@0 169
michael@0 170 // Called to kick-off a new transaction, by default the transaction
michael@0 171 // will be put on the pending transaction queue if it cannot be
michael@0 172 // initiated at this time. Callable from any thread.
michael@0 173 nsresult InitiateTransaction(nsHttpTransaction *trans, int32_t priority)
michael@0 174 {
michael@0 175 return mConnMgr->AddTransaction(trans, priority);
michael@0 176 }
michael@0 177
michael@0 178 // Called to change the priority of an existing transaction that has
michael@0 179 // already been initiated.
michael@0 180 nsresult RescheduleTransaction(nsHttpTransaction *trans, int32_t priority)
michael@0 181 {
michael@0 182 return mConnMgr->RescheduleTransaction(trans, priority);
michael@0 183 }
michael@0 184
michael@0 185 // Called to cancel a transaction, which may or may not be assigned to
michael@0 186 // a connection. Callable from any thread.
michael@0 187 nsresult CancelTransaction(nsHttpTransaction *trans, nsresult reason)
michael@0 188 {
michael@0 189 return mConnMgr->CancelTransaction(trans, reason);
michael@0 190 }
michael@0 191
michael@0 192 // Called when a connection is done processing a transaction. Callable
michael@0 193 // from any thread.
michael@0 194 nsresult ReclaimConnection(nsHttpConnection *conn)
michael@0 195 {
michael@0 196 return mConnMgr->ReclaimConnection(conn);
michael@0 197 }
michael@0 198
michael@0 199 nsresult ProcessPendingQ(nsHttpConnectionInfo *cinfo)
michael@0 200 {
michael@0 201 return mConnMgr->ProcessPendingQ(cinfo);
michael@0 202 }
michael@0 203
michael@0 204 nsresult ProcessPendingQ()
michael@0 205 {
michael@0 206 return mConnMgr->ProcessPendingQ();
michael@0 207 }
michael@0 208
michael@0 209 nsresult GetSocketThreadTarget(nsIEventTarget **target)
michael@0 210 {
michael@0 211 return mConnMgr->GetSocketThreadTarget(target);
michael@0 212 }
michael@0 213
michael@0 214 nsresult SpeculativeConnect(nsHttpConnectionInfo *ci,
michael@0 215 nsIInterfaceRequestor *callbacks,
michael@0 216 uint32_t caps = 0)
michael@0 217 {
michael@0 218 TickleWifi(callbacks);
michael@0 219 return mConnMgr->SpeculativeConnect(ci, callbacks, caps);
michael@0 220 }
michael@0 221
michael@0 222 //
michael@0 223 // The HTTP handler caches pointers to specific XPCOM services, and
michael@0 224 // provides the following helper routines for accessing those services:
michael@0 225 //
michael@0 226 nsresult GetStreamConverterService(nsIStreamConverterService **);
michael@0 227 nsresult GetIOService(nsIIOService** service);
michael@0 228 nsICookieService * GetCookieService(); // not addrefed
michael@0 229 nsISiteSecurityService * GetSSService();
michael@0 230
michael@0 231 // callable from socket thread only
michael@0 232 uint32_t Get32BitsOfPseudoRandom();
michael@0 233
michael@0 234 // Called by the channel synchronously during asyncOpen
michael@0 235 void OnOpeningRequest(nsIHttpChannel *chan)
michael@0 236 {
michael@0 237 NotifyObservers(chan, NS_HTTP_ON_OPENING_REQUEST_TOPIC);
michael@0 238 }
michael@0 239
michael@0 240 // Called by the channel before writing a request
michael@0 241 void OnModifyRequest(nsIHttpChannel *chan)
michael@0 242 {
michael@0 243 NotifyObservers(chan, NS_HTTP_ON_MODIFY_REQUEST_TOPIC);
michael@0 244 }
michael@0 245
michael@0 246 // Called by the channel once headers are available
michael@0 247 void OnExamineResponse(nsIHttpChannel *chan)
michael@0 248 {
michael@0 249 NotifyObservers(chan, NS_HTTP_ON_EXAMINE_RESPONSE_TOPIC);
michael@0 250 }
michael@0 251
michael@0 252 // Called by the channel once headers have been merged with cached headers
michael@0 253 void OnExamineMergedResponse(nsIHttpChannel *chan)
michael@0 254 {
michael@0 255 NotifyObservers(chan, NS_HTTP_ON_EXAMINE_MERGED_RESPONSE_TOPIC);
michael@0 256 }
michael@0 257
michael@0 258 // Called by channels before a redirect happens. This notifies both the
michael@0 259 // channel's and the global redirect observers.
michael@0 260 nsresult AsyncOnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan,
michael@0 261 uint32_t flags);
michael@0 262
michael@0 263 // Called by the channel when the response is read from the cache without
michael@0 264 // communicating with the server.
michael@0 265 void OnExamineCachedResponse(nsIHttpChannel *chan)
michael@0 266 {
michael@0 267 NotifyObservers(chan, NS_HTTP_ON_EXAMINE_CACHED_RESPONSE_TOPIC);
michael@0 268 }
michael@0 269
michael@0 270 // Generates the host:port string for use in the Host: header as well as the
michael@0 271 // CONNECT line for proxies. This handles IPv6 literals correctly.
michael@0 272 static nsresult GenerateHostPort(const nsCString& host, int32_t port,
michael@0 273 nsCString& hostLine);
michael@0 274
michael@0 275 bool GetPipelineAggressive() { return mPipelineAggressive; }
michael@0 276 uint32_t GetMaxPipelinedRequests() { return mMaxPipelinedRequests; }
michael@0 277 uint32_t GetMaxOptimisticPipelinedRequests() { return mMaxOptimisticPipelinedRequests; }
michael@0 278 void GetMaxPipelineObjectSize(int64_t *outVal)
michael@0 279 {
michael@0 280 *outVal = mMaxPipelineObjectSize;
michael@0 281 }
michael@0 282
michael@0 283 bool GetPipelineEnabled()
michael@0 284 {
michael@0 285 return mCapabilities & NS_HTTP_ALLOW_PIPELINING;
michael@0 286 }
michael@0 287
michael@0 288 bool GetPipelineRescheduleOnTimeout()
michael@0 289 {
michael@0 290 return mPipelineRescheduleOnTimeout;
michael@0 291 }
michael@0 292
michael@0 293 PRIntervalTime GetPipelineRescheduleTimeout()
michael@0 294 {
michael@0 295 return mPipelineRescheduleTimeout;
michael@0 296 }
michael@0 297
michael@0 298 PRIntervalTime GetPipelineTimeout() { return mPipelineReadTimeout; }
michael@0 299
michael@0 300 SpdyInformation *SpdyInfo() { return &mSpdyInfo; }
michael@0 301
michael@0 302 // returns true in between Init and Shutdown states
michael@0 303 bool Active() { return mHandlerActive; }
michael@0 304
michael@0 305 static void GetCacheSessionNameForStoragePolicy(
michael@0 306 nsCacheStoragePolicy storagePolicy,
michael@0 307 bool isPrivate,
michael@0 308 uint32_t appId,
michael@0 309 bool inBrowser,
michael@0 310 nsACString& sessionName);
michael@0 311
michael@0 312 // When the disk cache is responding slowly its use is suppressed
michael@0 313 // for 1 minute for most requests. Callable from main thread only.
michael@0 314 TimeStamp GetCacheSkippedUntil() { return mCacheSkippedUntil; }
michael@0 315 void SetCacheSkippedUntil(TimeStamp arg) { mCacheSkippedUntil = arg; }
michael@0 316 void ClearCacheSkippedUntil() { mCacheSkippedUntil = TimeStamp(); }
michael@0 317
michael@0 318 private:
michael@0 319
michael@0 320 //
michael@0 321 // Useragent/prefs helper methods
michael@0 322 //
michael@0 323 void BuildUserAgent();
michael@0 324 void InitUserAgentComponents();
michael@0 325 void PrefsChanged(nsIPrefBranch *prefs, const char *pref);
michael@0 326
michael@0 327 nsresult SetAccept(const char *);
michael@0 328 nsresult SetAcceptLanguages(const char *);
michael@0 329 nsresult SetAcceptEncodings(const char *);
michael@0 330
michael@0 331 nsresult InitConnectionMgr();
michael@0 332
michael@0 333 void NotifyObservers(nsIHttpChannel *chan, const char *event);
michael@0 334
michael@0 335 static void TimerCallback(nsITimer * aTimer, void * aClosure);
michael@0 336 private:
michael@0 337
michael@0 338 // cached services
michael@0 339 nsMainThreadPtrHandle<nsIIOService> mIOService;
michael@0 340 nsMainThreadPtrHandle<nsIStreamConverterService> mStreamConvSvc;
michael@0 341 nsMainThreadPtrHandle<nsIObserverService> mObserverService;
michael@0 342 nsMainThreadPtrHandle<nsICookieService> mCookieService;
michael@0 343 nsMainThreadPtrHandle<nsISiteSecurityService> mSSService;
michael@0 344
michael@0 345 // the authentication credentials cache
michael@0 346 nsHttpAuthCache mAuthCache;
michael@0 347 nsHttpAuthCache mPrivateAuthCache;
michael@0 348
michael@0 349 // the connection manager
michael@0 350 nsHttpConnectionMgr *mConnMgr;
michael@0 351
michael@0 352 //
michael@0 353 // prefs
michael@0 354 //
michael@0 355
michael@0 356 uint8_t mHttpVersion;
michael@0 357 uint8_t mProxyHttpVersion;
michael@0 358 uint32_t mCapabilities;
michael@0 359 uint8_t mReferrerLevel;
michael@0 360 uint8_t mSpoofReferrerSource;
michael@0 361 uint8_t mReferrerTrimmingPolicy;
michael@0 362 uint8_t mReferrerXOriginPolicy;
michael@0 363
michael@0 364 bool mFastFallbackToIPv4;
michael@0 365 bool mProxyPipelining;
michael@0 366 PRIntervalTime mIdleTimeout;
michael@0 367 PRIntervalTime mSpdyTimeout;
michael@0 368 PRIntervalTime mResponseTimeout;
michael@0 369 bool mResponseTimeoutEnabled;
michael@0 370
michael@0 371 uint16_t mMaxRequestAttempts;
michael@0 372 uint16_t mMaxRequestDelay;
michael@0 373 uint16_t mIdleSynTimeout;
michael@0 374
michael@0 375 bool mPipeliningEnabled;
michael@0 376 uint16_t mMaxConnections;
michael@0 377 uint8_t mMaxPersistentConnectionsPerServer;
michael@0 378 uint8_t mMaxPersistentConnectionsPerProxy;
michael@0 379 uint16_t mMaxPipelinedRequests;
michael@0 380 uint16_t mMaxOptimisticPipelinedRequests;
michael@0 381 bool mPipelineAggressive;
michael@0 382 int64_t mMaxPipelineObjectSize;
michael@0 383 bool mPipelineRescheduleOnTimeout;
michael@0 384 PRIntervalTime mPipelineRescheduleTimeout;
michael@0 385 PRIntervalTime mPipelineReadTimeout;
michael@0 386 nsCOMPtr<nsITimer> mPipelineTestTimer;
michael@0 387
michael@0 388 uint8_t mRedirectionLimit;
michael@0 389
michael@0 390 // we'll warn the user if we load an URL containing a userpass field
michael@0 391 // unless its length is less than this threshold. this warning is
michael@0 392 // intended to protect the user against spoofing attempts that use
michael@0 393 // the userpass field of the URL to obscure the actual origin server.
michael@0 394 uint8_t mPhishyUserPassLength;
michael@0 395
michael@0 396 uint8_t mQoSBits;
michael@0 397
michael@0 398 bool mPipeliningOverSSL;
michael@0 399 bool mEnforceAssocReq;
michael@0 400
michael@0 401 nsCString mAccept;
michael@0 402 nsCString mAcceptLanguages;
michael@0 403 nsCString mAcceptEncodings;
michael@0 404
michael@0 405 nsXPIDLCString mDefaultSocketType;
michael@0 406
michael@0 407 // cache support
michael@0 408 uint32_t mLastUniqueID;
michael@0 409 uint32_t mSessionStartTime;
michael@0 410
michael@0 411 // useragent components
michael@0 412 nsCString mLegacyAppName;
michael@0 413 nsCString mLegacyAppVersion;
michael@0 414 nsCString mPlatform;
michael@0 415 nsCString mOscpu;
michael@0 416 nsCString mMisc;
michael@0 417 nsCString mProduct;
michael@0 418 nsXPIDLCString mProductSub;
michael@0 419 nsXPIDLCString mAppName;
michael@0 420 nsXPIDLCString mAppVersion;
michael@0 421 nsCString mCompatFirefox;
michael@0 422 bool mCompatFirefoxEnabled;
michael@0 423 nsXPIDLCString mCompatDevice;
michael@0 424
michael@0 425 nsCString mUserAgent;
michael@0 426 nsXPIDLCString mUserAgentOverride;
michael@0 427 bool mUserAgentIsDirty; // true if mUserAgent should be rebuilt
michael@0 428
michael@0 429 bool mUseCache;
michael@0 430
michael@0 431 bool mPromptTempRedirect;
michael@0 432 // mSendSecureXSiteReferrer: default is false,
michael@0 433 // if true allow referrer headers between secure non-matching hosts
michael@0 434 bool mSendSecureXSiteReferrer;
michael@0 435
michael@0 436 // Persistent HTTPS caching flag
michael@0 437 bool mEnablePersistentHttpsCaching;
michael@0 438
michael@0 439 // For broadcasting tracking preference
michael@0 440 bool mDoNotTrackEnabled;
michael@0 441 uint8_t mDoNotTrackValue;
michael@0 442
michael@0 443 // for broadcasting safe hint;
michael@0 444 bool mSafeHintEnabled;
michael@0 445 bool mParentalControlEnabled;
michael@0 446
michael@0 447 // Whether telemetry is reported or not
michael@0 448 uint32_t mTelemetryEnabled : 1;
michael@0 449
michael@0 450 // The value of network.allow-experiments
michael@0 451 uint32_t mAllowExperiments : 1;
michael@0 452
michael@0 453 // true in between init and shutdown states
michael@0 454 uint32_t mHandlerActive : 1;
michael@0 455
michael@0 456 uint32_t mEnableSpdy : 1;
michael@0 457 uint32_t mSpdyV3 : 1;
michael@0 458 uint32_t mSpdyV31 : 1;
michael@0 459 uint32_t mHttp2DraftEnabled : 1;
michael@0 460 uint32_t mEnforceHttp2TlsProfile : 1;
michael@0 461 uint32_t mCoalesceSpdy : 1;
michael@0 462 uint32_t mSpdyPersistentSettings : 1;
michael@0 463 uint32_t mAllowPush : 1;
michael@0 464
michael@0 465 // Try to use SPDY features instead of HTTP/1.1 over SSL
michael@0 466 SpdyInformation mSpdyInfo;
michael@0 467
michael@0 468 uint32_t mSpdySendingChunkSize;
michael@0 469 uint32_t mSpdySendBufferSize;
michael@0 470 uint32_t mSpdyPushAllowance;
michael@0 471 PRIntervalTime mSpdyPingThreshold;
michael@0 472 PRIntervalTime mSpdyPingTimeout;
michael@0 473
michael@0 474 // The maximum amount of time to wait for socket transport to be
michael@0 475 // established. In milliseconds.
michael@0 476 uint32_t mConnectTimeout;
michael@0 477
michael@0 478 // The maximum amount of time the nsICacheSession lock can be held
michael@0 479 // before a new transaction bypasses the cache. In milliseconds.
michael@0 480 double mBypassCacheLockThreshold;
michael@0 481
michael@0 482 // The maximum number of current global half open sockets allowable
michael@0 483 // when starting a new speculative connection.
michael@0 484 uint32_t mParallelSpeculativeConnectLimit;
michael@0 485
michael@0 486 // For Rate Pacing of HTTP/1 requests through a netwerk/base/src/EventTokenBucket
michael@0 487 // Active requests <= *MinParallelism are not subject to the rate pacing
michael@0 488 bool mRequestTokenBucketEnabled;
michael@0 489 uint16_t mRequestTokenBucketMinParallelism;
michael@0 490 uint32_t mRequestTokenBucketHz; // EventTokenBucket HZ
michael@0 491 uint32_t mRequestTokenBucketBurst; // EventTokenBucket Burst
michael@0 492
michael@0 493 // Whether or not to block requests for non head js/css items (e.g. media)
michael@0 494 // while those elements load.
michael@0 495 bool mCriticalRequestPrioritization;
michael@0 496
michael@0 497 // When the disk cache is responding slowly its use is suppressed
michael@0 498 // for 1 minute for most requests.
michael@0 499 TimeStamp mCacheSkippedUntil;
michael@0 500
michael@0 501 // TCP Keepalive configuration values.
michael@0 502
michael@0 503 // True if TCP keepalive is enabled for short-lived conns.
michael@0 504 bool mTCPKeepaliveShortLivedEnabled;
michael@0 505 // Time (secs) indicating how long a conn is considered short-lived.
michael@0 506 int32_t mTCPKeepaliveShortLivedTimeS;
michael@0 507 // Time (secs) before first keepalive probe; between successful probes.
michael@0 508 int32_t mTCPKeepaliveShortLivedIdleTimeS;
michael@0 509
michael@0 510 // True if TCP keepalive is enabled for long-lived conns.
michael@0 511 bool mTCPKeepaliveLongLivedEnabled;
michael@0 512 // Time (secs) before first keepalive probe; between successful probes.
michael@0 513 int32_t mTCPKeepaliveLongLivedIdleTimeS;
michael@0 514
michael@0 515 private:
michael@0 516 // For Rate Pacing Certain Network Events. Only assign this pointer on
michael@0 517 // socket thread.
michael@0 518 void MakeNewRequestTokenBucket();
michael@0 519 nsRefPtr<EventTokenBucket> mRequestTokenBucket;
michael@0 520
michael@0 521 public:
michael@0 522 // Socket thread only
michael@0 523 nsresult SubmitPacedRequest(ATokenBucketEvent *event,
michael@0 524 nsICancelable **cancel)
michael@0 525 {
michael@0 526 if (!mRequestTokenBucket)
michael@0 527 return NS_ERROR_UNEXPECTED;
michael@0 528 return mRequestTokenBucket->SubmitEvent(event, cancel);
michael@0 529 }
michael@0 530
michael@0 531 // Socket thread only
michael@0 532 void SetRequestTokenBucket(EventTokenBucket *aTokenBucket)
michael@0 533 {
michael@0 534 mRequestTokenBucket = aTokenBucket;
michael@0 535 }
michael@0 536
michael@0 537 private:
michael@0 538 nsRefPtr<Tickler> mWifiTickler;
michael@0 539 void TickleWifi(nsIInterfaceRequestor *cb);
michael@0 540 };
michael@0 541
michael@0 542 extern nsHttpHandler *gHttpHandler;
michael@0 543
michael@0 544 //-----------------------------------------------------------------------------
michael@0 545 // nsHttpsHandler - thin wrapper to distinguish the HTTP handler from the
michael@0 546 // HTTPS handler (even though they share the same impl).
michael@0 547 //-----------------------------------------------------------------------------
michael@0 548
michael@0 549 class nsHttpsHandler : public nsIHttpProtocolHandler
michael@0 550 , public nsSupportsWeakReference
michael@0 551 , public nsISpeculativeConnect
michael@0 552 {
michael@0 553 public:
michael@0 554 // we basically just want to override GetScheme and GetDefaultPort...
michael@0 555 // all other methods should be forwarded to the nsHttpHandler instance.
michael@0 556
michael@0 557 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 558 NS_DECL_NSIPROTOCOLHANDLER
michael@0 559 NS_FORWARD_NSIPROXIEDPROTOCOLHANDLER (gHttpHandler->)
michael@0 560 NS_FORWARD_NSIHTTPPROTOCOLHANDLER (gHttpHandler->)
michael@0 561 NS_FORWARD_NSISPECULATIVECONNECT (gHttpHandler->)
michael@0 562
michael@0 563 nsHttpsHandler() { }
michael@0 564 virtual ~nsHttpsHandler() { }
michael@0 565
michael@0 566 nsresult Init();
michael@0 567 };
michael@0 568
michael@0 569 }} // namespace mozilla::net
michael@0 570
michael@0 571 #endif // nsHttpHandler_h__

mercurial