Thu, 15 Jan 2015 21:03:48 +0100
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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ |
michael@0 | 3 | |
michael@0 | 4 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | include protocol PNecko; |
michael@0 | 9 | include InputStreamParams; |
michael@0 | 10 | include URIParams; |
michael@0 | 11 | |
michael@0 | 12 | include protocol PBlob; //FIXME: bug #792908 |
michael@0 | 13 | |
michael@0 | 14 | include "mozilla/net/NeckoMessageUtils.h"; |
michael@0 | 15 | |
michael@0 | 16 | using RequestHeaderTuples from "mozilla/net/PHttpChannelParams.h"; |
michael@0 | 17 | using class nsHttpHeaderArray from "nsHttpHeaderArray.h"; |
michael@0 | 18 | using class nsHttpResponseHead from "nsHttpResponseHead.h"; |
michael@0 | 19 | using struct nsHttpAtom from "nsHttp.h"; |
michael@0 | 20 | using mozilla::net::NetAddr from "mozilla/net/DNS.h"; |
michael@0 | 21 | |
michael@0 | 22 | namespace mozilla { |
michael@0 | 23 | namespace net { |
michael@0 | 24 | |
michael@0 | 25 | //------------------------------------------------------------------- |
michael@0 | 26 | protocol PHttpChannel |
michael@0 | 27 | { |
michael@0 | 28 | manager PNecko; |
michael@0 | 29 | |
michael@0 | 30 | parent: |
michael@0 | 31 | // Note: channels are opened during construction, so no open method here: |
michael@0 | 32 | // see PNecko.ipdl |
michael@0 | 33 | |
michael@0 | 34 | SetPriority(uint16_t priority); |
michael@0 | 35 | |
michael@0 | 36 | SetCacheTokenCachedCharset(nsCString charset); |
michael@0 | 37 | |
michael@0 | 38 | UpdateAssociatedContentSecurity(int32_t broken, |
michael@0 | 39 | int32_t no); |
michael@0 | 40 | Suspend(); |
michael@0 | 41 | Resume(); |
michael@0 | 42 | |
michael@0 | 43 | Cancel(nsresult status); |
michael@0 | 44 | |
michael@0 | 45 | // Reports approval/veto of redirect by child process redirect observers |
michael@0 | 46 | Redirect2Verify(nsresult result, RequestHeaderTuples changedHeaders, |
michael@0 | 47 | OptionalURIParams apiRedirectTo); |
michael@0 | 48 | |
michael@0 | 49 | // For document loads we keep this protocol open after child's |
michael@0 | 50 | // OnStopRequest, and send this msg (instead of __delete__) to allow |
michael@0 | 51 | // partial cleanup on parent. |
michael@0 | 52 | DocumentChannelCleanup(); |
michael@0 | 53 | |
michael@0 | 54 | // This might have to be sync. If this fails we must fail the document load |
michael@0 | 55 | // to avoid endless loop. |
michael@0 | 56 | // |
michael@0 | 57 | // Explanation: the document loaded was loaded from the offline cache. But |
michael@0 | 58 | // the cache group id (the manifest URL) of the cache group it was loaded |
michael@0 | 59 | // from is different then the manifest the document refers to in the html |
michael@0 | 60 | // tag. If we detect this during the cache selection algorithm, we must not |
michael@0 | 61 | // load this document from the offline cache group it was just loaded from. |
michael@0 | 62 | // Marking the cache entry as foreign in its cache group will prevent |
michael@0 | 63 | // the document to load from the bad offline cache group. After it is marked, |
michael@0 | 64 | // we reload the document to take the effect. If we fail to mark the entry |
michael@0 | 65 | // as foreign, we will end up in the same situation and reload again and |
michael@0 | 66 | // again, indefinitely. |
michael@0 | 67 | MarkOfflineCacheEntryAsForeign(); |
michael@0 | 68 | |
michael@0 | 69 | // Divert OnDataAvailable to the parent. |
michael@0 | 70 | DivertOnDataAvailable(nsCString data, |
michael@0 | 71 | uint64_t offset, |
michael@0 | 72 | uint32_t count); |
michael@0 | 73 | |
michael@0 | 74 | // Divert OnStopRequest to the parent. |
michael@0 | 75 | DivertOnStopRequest(nsresult statusCode); |
michael@0 | 76 | |
michael@0 | 77 | // Child has no more events/messages to divert to the parent. |
michael@0 | 78 | DivertComplete(); |
michael@0 | 79 | |
michael@0 | 80 | __delete__(); |
michael@0 | 81 | |
michael@0 | 82 | child: |
michael@0 | 83 | OnStartRequest(nsresult channelStatus, |
michael@0 | 84 | nsHttpResponseHead responseHead, |
michael@0 | 85 | bool useResponseHead, |
michael@0 | 86 | nsHttpHeaderArray requestHeaders, |
michael@0 | 87 | bool isFromCache, |
michael@0 | 88 | bool cacheEntryAvailable, |
michael@0 | 89 | uint32_t cacheExpirationTime, |
michael@0 | 90 | nsCString cachedCharset, |
michael@0 | 91 | nsCString securityInfoSerialization, |
michael@0 | 92 | NetAddr selfAddr, |
michael@0 | 93 | NetAddr peerAddr, |
michael@0 | 94 | int16_t redirectCount); |
michael@0 | 95 | |
michael@0 | 96 | // Combines a single OnDataAvailable and its associated OnProgress & |
michael@0 | 97 | // OnStatus calls into one IPDL message |
michael@0 | 98 | OnTransportAndData(nsresult channelStatus, |
michael@0 | 99 | nsresult transportStatus, |
michael@0 | 100 | uint64_t progress, |
michael@0 | 101 | uint64_t progressMax, |
michael@0 | 102 | nsCString data, |
michael@0 | 103 | uint64_t offset, |
michael@0 | 104 | uint32_t count); |
michael@0 | 105 | |
michael@0 | 106 | OnStopRequest(nsresult channelStatus); |
michael@0 | 107 | |
michael@0 | 108 | OnProgress(uint64_t progress, uint64_t progressMax); |
michael@0 | 109 | |
michael@0 | 110 | OnStatus(nsresult status); |
michael@0 | 111 | |
michael@0 | 112 | // Used to cancel child channel if we hit errors during creating and |
michael@0 | 113 | // AsyncOpen of nsHttpChannel on the parent. |
michael@0 | 114 | FailedAsyncOpen(nsresult status); |
michael@0 | 115 | |
michael@0 | 116 | // Called to initiate content channel redirect, starts talking to sinks |
michael@0 | 117 | // on the content process and reports result via Redirect2Verify above |
michael@0 | 118 | Redirect1Begin(uint32_t newChannelId, |
michael@0 | 119 | URIParams newUri, |
michael@0 | 120 | uint32_t redirectFlags, |
michael@0 | 121 | nsHttpResponseHead responseHead); |
michael@0 | 122 | |
michael@0 | 123 | // Called if redirect successful so that child can complete setup. |
michael@0 | 124 | Redirect3Complete(); |
michael@0 | 125 | |
michael@0 | 126 | // Associte the child with an application ids |
michael@0 | 127 | AssociateApplicationCache(nsCString groupID, |
michael@0 | 128 | nsCString clientID); |
michael@0 | 129 | |
michael@0 | 130 | // Parent has been suspended for diversion; no more events to be enqueued. |
michael@0 | 131 | FlushedForDiversion(); |
michael@0 | 132 | |
michael@0 | 133 | // Child should resume processing the ChannelEventQueue, i.e. diverting any |
michael@0 | 134 | // OnDataAvailable and OnStopRequest messages in the queue back to the parent. |
michael@0 | 135 | DivertMessages(); |
michael@0 | 136 | |
michael@0 | 137 | // Tell child to delete channel (all IPDL deletes must be done from child to |
michael@0 | 138 | // avoid races: see bug 591708). |
michael@0 | 139 | DeleteSelf(); |
michael@0 | 140 | }; |
michael@0 | 141 | |
michael@0 | 142 | |
michael@0 | 143 | } // namespace net |
michael@0 | 144 | } // namespace mozilla |
michael@0 | 145 |