netwerk/protocol/http/PHttpChannelParams.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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set sw=2 ts=8 et tw=80 : */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_net_PHttpChannelParams_h
michael@0 8 #define mozilla_net_PHttpChannelParams_h
michael@0 9
michael@0 10 #define ALLOW_LATE_NSHTTP_H_INCLUDE 1
michael@0 11 #include "base/basictypes.h"
michael@0 12
michael@0 13 #include "ipc/IPCMessageUtils.h"
michael@0 14 #include "nsHttp.h"
michael@0 15 #include "nsHttpHeaderArray.h"
michael@0 16 #include "nsHttpResponseHead.h"
michael@0 17
michael@0 18 #include "nsIClassInfo.h"
michael@0 19 #include "nsNetUtil.h"
michael@0 20
michael@0 21 namespace mozilla {
michael@0 22 namespace net {
michael@0 23
michael@0 24 struct RequestHeaderTuple {
michael@0 25 nsCString mHeader;
michael@0 26 nsCString mValue;
michael@0 27 bool mMerge;
michael@0 28
michael@0 29 bool operator ==(const RequestHeaderTuple &other) const {
michael@0 30 return mHeader.Equals(other.mHeader) &&
michael@0 31 mValue.Equals(other.mValue) &&
michael@0 32 mMerge == other.mMerge;
michael@0 33 }
michael@0 34 };
michael@0 35
michael@0 36 typedef nsTArray<RequestHeaderTuple> RequestHeaderTuples;
michael@0 37
michael@0 38 } // namespace net
michael@0 39 } // namespace mozilla
michael@0 40
michael@0 41 namespace IPC {
michael@0 42
michael@0 43 template<>
michael@0 44 struct ParamTraits<mozilla::net::RequestHeaderTuple>
michael@0 45 {
michael@0 46 typedef mozilla::net::RequestHeaderTuple paramType;
michael@0 47
michael@0 48 static void Write(Message* aMsg, const paramType& aParam)
michael@0 49 {
michael@0 50 WriteParam(aMsg, aParam.mHeader);
michael@0 51 WriteParam(aMsg, aParam.mValue);
michael@0 52 WriteParam(aMsg, aParam.mMerge);
michael@0 53 }
michael@0 54
michael@0 55 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 56 {
michael@0 57 if (!ReadParam(aMsg, aIter, &aResult->mHeader) ||
michael@0 58 !ReadParam(aMsg, aIter, &aResult->mValue) ||
michael@0 59 !ReadParam(aMsg, aIter, &aResult->mMerge))
michael@0 60 return false;
michael@0 61
michael@0 62 return true;
michael@0 63 }
michael@0 64 };
michael@0 65
michael@0 66 template<>
michael@0 67 struct ParamTraits<mozilla::net::nsHttpAtom>
michael@0 68 {
michael@0 69 typedef mozilla::net::nsHttpAtom paramType;
michael@0 70
michael@0 71 static void Write(Message* aMsg, const paramType& aParam)
michael@0 72 {
michael@0 73 // aParam.get() cannot be null.
michael@0 74 MOZ_ASSERT(aParam.get(), "null nsHTTPAtom value");
michael@0 75 nsAutoCString value(aParam.get());
michael@0 76 WriteParam(aMsg, value);
michael@0 77 }
michael@0 78
michael@0 79 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 80 {
michael@0 81 nsAutoCString value;
michael@0 82 if (!ReadParam(aMsg, aIter, &value))
michael@0 83 return false;
michael@0 84
michael@0 85 *aResult = mozilla::net::nsHttp::ResolveAtom(value.get());
michael@0 86 MOZ_ASSERT(aResult->get(), "atom table not initialized");
michael@0 87 return true;
michael@0 88 }
michael@0 89 };
michael@0 90
michael@0 91 template<>
michael@0 92 struct ParamTraits<mozilla::net::nsHttpHeaderArray::nsEntry>
michael@0 93 {
michael@0 94 typedef mozilla::net::nsHttpHeaderArray::nsEntry paramType;
michael@0 95
michael@0 96 static void Write(Message* aMsg, const paramType& aParam)
michael@0 97 {
michael@0 98 WriteParam(aMsg, aParam.header);
michael@0 99 WriteParam(aMsg, aParam.value);
michael@0 100 }
michael@0 101
michael@0 102 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 103 {
michael@0 104 if (!ReadParam(aMsg, aIter, &aResult->header) ||
michael@0 105 !ReadParam(aMsg, aIter, &aResult->value))
michael@0 106 return false;
michael@0 107
michael@0 108 return true;
michael@0 109 }
michael@0 110 };
michael@0 111
michael@0 112
michael@0 113 template<>
michael@0 114 struct ParamTraits<mozilla::net::nsHttpHeaderArray>
michael@0 115 {
michael@0 116 typedef mozilla::net::nsHttpHeaderArray paramType;
michael@0 117
michael@0 118 static void Write(Message* aMsg, const paramType& aParam)
michael@0 119 {
michael@0 120 paramType& p = const_cast<paramType&>(aParam);
michael@0 121
michael@0 122 WriteParam(aMsg, p.mHeaders);
michael@0 123 }
michael@0 124
michael@0 125 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 126 {
michael@0 127 if (!ReadParam(aMsg, aIter, &aResult->mHeaders))
michael@0 128 return false;
michael@0 129
michael@0 130 return true;
michael@0 131 }
michael@0 132 };
michael@0 133
michael@0 134 template<>
michael@0 135 struct ParamTraits<mozilla::net::nsHttpResponseHead>
michael@0 136 {
michael@0 137 typedef mozilla::net::nsHttpResponseHead paramType;
michael@0 138
michael@0 139 static void Write(Message* aMsg, const paramType& aParam)
michael@0 140 {
michael@0 141 WriteParam(aMsg, aParam.mHeaders);
michael@0 142 WriteParam(aMsg, aParam.mVersion);
michael@0 143 WriteParam(aMsg, aParam.mStatus);
michael@0 144 WriteParam(aMsg, aParam.mStatusText);
michael@0 145 WriteParam(aMsg, aParam.mContentLength);
michael@0 146 WriteParam(aMsg, aParam.mContentType);
michael@0 147 WriteParam(aMsg, aParam.mContentCharset);
michael@0 148 WriteParam(aMsg, aParam.mCacheControlNoStore);
michael@0 149 WriteParam(aMsg, aParam.mCacheControlNoCache);
michael@0 150 WriteParam(aMsg, aParam.mPragmaNoCache);
michael@0 151 }
michael@0 152
michael@0 153 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 154 {
michael@0 155 if (!ReadParam(aMsg, aIter, &aResult->mHeaders) ||
michael@0 156 !ReadParam(aMsg, aIter, &aResult->mVersion) ||
michael@0 157 !ReadParam(aMsg, aIter, &aResult->mStatus) ||
michael@0 158 !ReadParam(aMsg, aIter, &aResult->mStatusText) ||
michael@0 159 !ReadParam(aMsg, aIter, &aResult->mContentLength) ||
michael@0 160 !ReadParam(aMsg, aIter, &aResult->mContentType) ||
michael@0 161 !ReadParam(aMsg, aIter, &aResult->mContentCharset) ||
michael@0 162 !ReadParam(aMsg, aIter, &aResult->mCacheControlNoStore) ||
michael@0 163 !ReadParam(aMsg, aIter, &aResult->mCacheControlNoCache) ||
michael@0 164 !ReadParam(aMsg, aIter, &aResult->mPragmaNoCache))
michael@0 165 return false;
michael@0 166
michael@0 167 return true;
michael@0 168 }
michael@0 169 };
michael@0 170
michael@0 171 } // namespace IPC
michael@0 172
michael@0 173 #endif // mozilla_net_PHttpChannelParams_h

mercurial