1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
3
4/* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8include protocol PNecko;
9include protocol PStreamFilter;
10include InputStreamParams;
11include URIParams;
12include PBackgroundSharedTypes;
13include NeckoChannelParams;
14include IPCServiceWorkerDescriptor;
15
16include "mozilla/net/NeckoMessageUtils.h";
17
18using class nsHttpHeaderArray from "nsHttpHeaderArray.h";
19using mozilla::net::NetAddr from "mozilla/net/DNS.h";
20using struct mozilla::net::ResourceTimingStruct from "mozilla/net/TimingStruct.h";
21
22namespace mozilla {
23namespace net {
24
25//-------------------------------------------------------------------
26protocol PHttpChannel
27{
28  manager PNecko;
29
30parent:
31  // Note: channels are opened during construction, so no open method here:
32  // see PNecko.ipdl
33
34  async SetClassOfService(uint32_t cos);
35
36  async SetCacheTokenCachedCharset(nsCString charset);
37
38  async UpdateAssociatedContentSecurity(int32_t broken,
39                                        int32_t no);
40  async Suspend();
41  async Resume();
42
43  async Cancel(nsresult status);
44
45  // Reports approval/veto of redirect by child process redirect observers
46  async Redirect2Verify(nsresult result, RequestHeaderTuples changedHeaders,
47                        uint32_t loadFlags, uint32_t referrerPolicy,
48                        OptionalURIParams referrerUri,
49                        OptionalURIParams apiRedirectTo,
50                        OptionalCorsPreflightArgs corsPreflightArgs,
51                        bool chooseAppcache);
52
53  // For document loads we keep this protocol open after child's
54  // OnStopRequest, and send this msg (instead of __delete__) to allow
55  // partial cleanup on parent.
56  async DocumentChannelCleanup(bool clearCacheEntry);
57
58  // This might have to be sync. If this fails we must fail the document load
59  // to avoid endless loop.
60  //
61  // Explanation: the document loaded was loaded from the offline cache. But
62  // the cache group id (the manifest URL) of the cache group it was loaded
63  // from is different then the manifest the document refers to in the html
64  // tag. If we detect this during the cache selection algorithm, we must not
65  // load this document from the offline cache group it was just loaded from.
66  // Marking the cache entry as foreign in its cache group will prevent
67  // the document to load from the bad offline cache group. After it is marked,
68  // we reload the document to take the effect. If we fail to mark the entry
69  // as foreign, we will end up in the same situation and reload again and
70  // again, indefinitely.
71  async MarkOfflineCacheEntryAsForeign();
72
73  // Divert OnDataAvailable to the parent.
74  async DivertOnDataAvailable(nsCString data,
75                              uint64_t  offset,
76                              uint32_t  count);
77
78  // Divert OnStopRequest to the parent.
79  async DivertOnStopRequest(nsresult statusCode);
80
81  // Child has no more events/messages to divert to the parent.
82  async DivertComplete();
83
84  // Child has detected a CORS check failure, so needs to tell the parent
85  // to remove any matching entry from the CORS preflight cache.
86  async RemoveCorsPreflightCacheEntry(URIParams uri,
87                                      PrincipalInfo requestingPrincipal);
88
89  // After receiving this message, the parent calls SendDeleteSelf, and makes
90  // sure not to send any more messages after that.
91  async DeletingChannel();
92
93  async __delete__();
94
95child:
96  async OnStartRequest(nsresult            channelStatus,
97                       nsHttpResponseHead  responseHead,
98                       bool                useResponseHead,
99                       nsHttpHeaderArray   requestHeaders,
100                       ParentLoadInfoForwarderArgs loadInfoForwarder,
101                       bool                isFromCache,
102                       bool                cacheEntryAvailable,
103                       uint64_t            cacheEntryId,
104                       int32_t             cacheFetchCount,
105                       uint32_t            cacheExpirationTime,
106                       nsCString           cachedCharset,
107                       nsCString           securityInfoSerialization,
108                       NetAddr             selfAddr,
109                       NetAddr             peerAddr,
110                       int16_t             redirectCount,
111                       uint32_t            cacheKey,
112                       nsCString           altDataType,
113                       int64_t             altDataLength,
114                       OptionalIPCServiceWorkerDescriptor controller,
115                       bool                applyConversion);
116
117  // Used to cancel child channel if we hit errors during creating and
118  // AsyncOpen of nsHttpChannel on the parent.
119  async FailedAsyncOpen(nsresult status);
120
121  // Called to initiate content channel redirect, starts talking to sinks
122  // on the content process and reports result via Redirect2Verify above
123  async Redirect1Begin(uint32_t           registrarId,
124                       URIParams          newOriginalUri,
125                       uint32_t           redirectFlags,
126                       ParentLoadInfoForwarderArgs loadInfoForwarder,
127                       nsHttpResponseHead responseHead,
128                       nsCString          securityInfoSerialization,
129                       uint64_t           channelId,
130                       NetAddr            oldPeerAddr);
131
132  // Called if redirect successful so that child can complete setup.
133  async Redirect3Complete();
134
135  // Associate the child with an application ids
136  async AssociateApplicationCache(nsCString groupID,
137                                  nsCString clientID);
138
139  // Report a security message to the console associated with this
140  // channel.
141  async ReportSecurityMessage(nsString messageTag, nsString messageCategory);
142
143  // Tell child to delete channel (all IPDL deletes must be done from child to
144  // avoid races: see bug 591708).
145  async DeleteSelf();
146
147  // Tell the child to issue a deprecation warning.
148  async IssueDeprecationWarning(uint32_t warning, bool asError);
149
150  // When CORS blocks the request in the parent process, it doesn't have the
151  // correct window ID, so send the message to the child for logging to the web
152  // console.
153  async LogBlockedCORSRequest(nsString message);
154
155  async AttachStreamFilter(Endpoint<PStreamFilterParent> aEndpoint);
156
157  // See ADivertableParentChannel::CancelDiversion
158  async CancelDiversion();
159
160both:
161  // After receiving this message, the parent also calls
162  // SendFinishInterceptedRedirect, and makes sure not to send any more messages
163  // after that. When receiving this message, the child will call
164  // Send__delete__() and complete the steps required to finish the redirect.
165  async FinishInterceptedRedirect();
166
167  async SetPriority(int16_t priority);
168};
169
170
171} // namespace net
172} // namespace mozilla
173