1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsLoadGroup_h__
7 #define nsLoadGroup_h__
9 #include "nsILoadGroup.h"
10 #include "nsILoadGroupChild.h"
11 #include "nsIObserver.h"
13 #include "nsWeakReference.h"
14 #include "nsISupportsPriority.h"
15 #include "PLDHashTable.h"
16 #include "mozilla/TimeStamp.h"
18 class nsIRequestContext
;
19 class nsIRequestContextService
;
20 class nsITimedChannel
;
25 class nsLoadGroup
: public nsILoadGroup
,
26 public nsILoadGroupChild
,
28 public nsISupportsPriority
,
29 public nsSupportsWeakReference
{
33 ////////////////////////////////////////////////////////////////////////////
34 // nsIRequest methods:
37 ////////////////////////////////////////////////////////////////////////////
38 // nsILoadGroup methods:
41 ////////////////////////////////////////////////////////////////////////////
42 // nsILoadGroupChild methods:
43 NS_DECL_NSILOADGROUPCHILD
45 ////////////////////////////////////////////////////////////////////////////
46 // nsISupportsPriority methods:
47 NS_DECL_NSISUPPORTSPRIORITY
49 ////////////////////////////////////////////////////////////////////////////
50 // nsIObserver methods:
53 ////////////////////////////////////////////////////////////////////////////
54 // nsLoadGroup methods:
59 nsresult
InitWithRequestContextId(const uint64_t& aRequestContextId
);
61 void SetGroupObserver(nsIRequestObserver
* aObserver
,
62 bool aIncludeBackgroundRequests
);
65 virtual ~nsLoadGroup();
67 nsresult
MergeLoadFlags(nsIRequest
* aRequest
, nsLoadFlags
& flags
);
68 nsresult
MergeDefaultLoadFlags(nsIRequest
* aRequest
, nsLoadFlags
& flags
);
71 void TelemetryReport();
72 void TelemetryReportChannel(nsITimedChannel
* timedChannel
,
75 nsresult
RemoveRequestFromHashtable(nsIRequest
* aRequest
, nsresult aStatus
);
76 nsresult
NotifyRemovalObservers(nsIRequest
* aRequest
, nsresult aStatus
);
79 uint32_t mForegroundCount
{0};
80 uint32_t mLoadFlags
{LOAD_NORMAL
};
81 uint32_t mDefaultLoadFlags
{0};
82 int32_t mPriority
{PRIORITY_NORMAL
};
84 nsCOMPtr
<nsILoadGroup
> mLoadGroup
; // load groups can contain load groups
85 nsCOMPtr
<nsIInterfaceRequestor
> mCallbacks
;
86 nsCOMPtr
<nsIRequestContext
> mRequestContext
;
87 nsCOMPtr
<nsIRequestContextService
> mRequestContextService
;
89 nsCOMPtr
<nsIRequest
> mDefaultLoadRequest
;
90 PLDHashTable mRequests
;
93 nsWeakPtr mParentLoadGroup
;
95 nsresult mStatus
{NS_OK
};
96 bool mIsCanceling
{false};
97 bool mDefaultLoadIsTimed
{false};
98 bool mBrowsingContextDiscarded
{false};
99 bool mExternalRequestContext
{false};
100 bool mNotifyObserverAboutBackgroundRequests
{false};
103 mozilla::TimeStamp mDefaultRequestCreationTime
;
104 uint32_t mTimedRequests
{0};
105 uint32_t mCachedRequests
{0};
109 } // namespace mozilla
111 #endif // nsLoadGroup_h__