Merge mozilla-central to autoland. CLOSED TREE
[gecko.git] / netwerk / base / nsLoadGroup.h
blob055e1804d64e793e57f0f445a29a564a06e7918b
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"
12 #include "nsCOMPtr.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;
22 namespace mozilla {
23 namespace net {
25 class nsLoadGroup : public nsILoadGroup,
26 public nsILoadGroupChild,
27 public nsIObserver,
28 public nsISupportsPriority,
29 public nsSupportsWeakReference {
30 public:
31 NS_DECL_ISUPPORTS
33 ////////////////////////////////////////////////////////////////////////////
34 // nsIRequest methods:
35 NS_DECL_NSIREQUEST
37 ////////////////////////////////////////////////////////////////////////////
38 // nsILoadGroup methods:
39 NS_DECL_NSILOADGROUP
41 ////////////////////////////////////////////////////////////////////////////
42 // nsILoadGroupChild methods:
43 NS_DECL_NSILOADGROUPCHILD
45 ////////////////////////////////////////////////////////////////////////////
46 // nsISupportsPriority methods:
47 NS_DECL_NSISUPPORTSPRIORITY
49 ////////////////////////////////////////////////////////////////////////////
50 // nsIObserver methods:
51 NS_DECL_NSIOBSERVER
53 ////////////////////////////////////////////////////////////////////////////
54 // nsLoadGroup methods:
56 nsLoadGroup();
58 nsresult Init();
59 nsresult InitWithRequestContextId(const uint64_t& aRequestContextId);
61 void SetGroupObserver(nsIRequestObserver* aObserver,
62 bool aIncludeBackgroundRequests);
64 protected:
65 virtual ~nsLoadGroup();
67 nsresult MergeLoadFlags(nsIRequest* aRequest, nsLoadFlags& flags);
68 nsresult MergeDefaultLoadFlags(nsIRequest* aRequest, nsLoadFlags& flags);
70 private:
71 void TelemetryReport();
72 void TelemetryReportChannel(nsITimedChannel* timedChannel,
73 bool defaultRequest);
75 nsresult RemoveRequestFromHashtable(nsIRequest* aRequest, nsresult aStatus);
76 nsresult NotifyRemovalObservers(nsIRequest* aRequest, nsresult aStatus);
78 protected:
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;
92 nsWeakPtr mObserver;
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};
102 /* Telemetry */
103 mozilla::TimeStamp mDefaultRequestCreationTime;
104 uint32_t mTimedRequests{0};
105 uint32_t mCachedRequests{0};
108 } // namespace net
109 } // namespace mozilla
111 #endif // nsLoadGroup_h__