netwerk/protocol/http/PHttpChannelParams.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/http/PHttpChannelParams.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,173 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set sw=2 ts=8 et tw=80 : */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_net_PHttpChannelParams_h
    1.11 +#define mozilla_net_PHttpChannelParams_h
    1.12 +
    1.13 +#define ALLOW_LATE_NSHTTP_H_INCLUDE 1
    1.14 +#include "base/basictypes.h"
    1.15 +
    1.16 +#include "ipc/IPCMessageUtils.h"
    1.17 +#include "nsHttp.h"
    1.18 +#include "nsHttpHeaderArray.h"
    1.19 +#include "nsHttpResponseHead.h"
    1.20 +
    1.21 +#include "nsIClassInfo.h"
    1.22 +#include "nsNetUtil.h"
    1.23 +
    1.24 +namespace mozilla {
    1.25 +namespace net {
    1.26 +
    1.27 +struct RequestHeaderTuple {
    1.28 +  nsCString mHeader;
    1.29 +  nsCString mValue;
    1.30 +  bool      mMerge;
    1.31 +
    1.32 +  bool operator ==(const RequestHeaderTuple &other) const {
    1.33 +    return mHeader.Equals(other.mHeader) &&
    1.34 +           mValue.Equals(other.mValue) &&
    1.35 +           mMerge == other.mMerge;
    1.36 +  }
    1.37 +};
    1.38 +
    1.39 +typedef nsTArray<RequestHeaderTuple> RequestHeaderTuples;
    1.40 +
    1.41 +} // namespace net
    1.42 +} // namespace mozilla
    1.43 +
    1.44 +namespace IPC {
    1.45 +
    1.46 +template<>
    1.47 +struct ParamTraits<mozilla::net::RequestHeaderTuple>
    1.48 +{
    1.49 +  typedef mozilla::net::RequestHeaderTuple paramType;
    1.50 +
    1.51 +  static void Write(Message* aMsg, const paramType& aParam)
    1.52 +  {
    1.53 +    WriteParam(aMsg, aParam.mHeader);
    1.54 +    WriteParam(aMsg, aParam.mValue);
    1.55 +    WriteParam(aMsg, aParam.mMerge);
    1.56 +  }
    1.57 +
    1.58 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
    1.59 +  {
    1.60 +    if (!ReadParam(aMsg, aIter, &aResult->mHeader) ||
    1.61 +        !ReadParam(aMsg, aIter, &aResult->mValue)  ||
    1.62 +        !ReadParam(aMsg, aIter, &aResult->mMerge))
    1.63 +      return false;
    1.64 +
    1.65 +    return true;
    1.66 +  }
    1.67 +};
    1.68 +
    1.69 +template<>
    1.70 +struct ParamTraits<mozilla::net::nsHttpAtom>
    1.71 +{
    1.72 +  typedef mozilla::net::nsHttpAtom paramType;
    1.73 +
    1.74 +  static void Write(Message* aMsg, const paramType& aParam)
    1.75 +  {
    1.76 +    // aParam.get() cannot be null.
    1.77 +    MOZ_ASSERT(aParam.get(), "null nsHTTPAtom value");
    1.78 +    nsAutoCString value(aParam.get());
    1.79 +    WriteParam(aMsg, value);
    1.80 +  }
    1.81 +
    1.82 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
    1.83 +  {
    1.84 +    nsAutoCString value;
    1.85 +    if (!ReadParam(aMsg, aIter, &value))
    1.86 +      return false;
    1.87 +
    1.88 +    *aResult = mozilla::net::nsHttp::ResolveAtom(value.get());
    1.89 +    MOZ_ASSERT(aResult->get(), "atom table not initialized");
    1.90 +    return true;
    1.91 +  }
    1.92 +};
    1.93 +
    1.94 +template<>
    1.95 +struct ParamTraits<mozilla::net::nsHttpHeaderArray::nsEntry>
    1.96 +{
    1.97 +  typedef mozilla::net::nsHttpHeaderArray::nsEntry paramType;
    1.98 +
    1.99 +  static void Write(Message* aMsg, const paramType& aParam)
   1.100 +  {
   1.101 +    WriteParam(aMsg, aParam.header);
   1.102 +    WriteParam(aMsg, aParam.value);
   1.103 +  }
   1.104 +
   1.105 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.106 +  {
   1.107 +    if (!ReadParam(aMsg, aIter, &aResult->header) ||
   1.108 +        !ReadParam(aMsg, aIter, &aResult->value))
   1.109 +      return false;
   1.110 +
   1.111 +    return true;
   1.112 +  }
   1.113 +};
   1.114 +
   1.115 +
   1.116 +template<>
   1.117 +struct ParamTraits<mozilla::net::nsHttpHeaderArray>
   1.118 +{
   1.119 +  typedef mozilla::net::nsHttpHeaderArray paramType;
   1.120 +
   1.121 +  static void Write(Message* aMsg, const paramType& aParam)
   1.122 +  {
   1.123 +    paramType& p = const_cast<paramType&>(aParam);
   1.124 +
   1.125 +    WriteParam(aMsg, p.mHeaders);
   1.126 +  }
   1.127 +
   1.128 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.129 +  {
   1.130 +    if (!ReadParam(aMsg, aIter, &aResult->mHeaders))
   1.131 +      return false;
   1.132 +
   1.133 +    return true;
   1.134 +  }
   1.135 +};
   1.136 +
   1.137 +template<>
   1.138 +struct ParamTraits<mozilla::net::nsHttpResponseHead>
   1.139 +{
   1.140 +  typedef mozilla::net::nsHttpResponseHead paramType;
   1.141 +
   1.142 +  static void Write(Message* aMsg, const paramType& aParam)
   1.143 +  {
   1.144 +    WriteParam(aMsg, aParam.mHeaders);
   1.145 +    WriteParam(aMsg, aParam.mVersion);
   1.146 +    WriteParam(aMsg, aParam.mStatus);
   1.147 +    WriteParam(aMsg, aParam.mStatusText);
   1.148 +    WriteParam(aMsg, aParam.mContentLength);
   1.149 +    WriteParam(aMsg, aParam.mContentType);
   1.150 +    WriteParam(aMsg, aParam.mContentCharset);
   1.151 +    WriteParam(aMsg, aParam.mCacheControlNoStore);
   1.152 +    WriteParam(aMsg, aParam.mCacheControlNoCache);
   1.153 +    WriteParam(aMsg, aParam.mPragmaNoCache);
   1.154 +  }
   1.155 +
   1.156 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.157 +  {
   1.158 +    if (!ReadParam(aMsg, aIter, &aResult->mHeaders)             ||
   1.159 +        !ReadParam(aMsg, aIter, &aResult->mVersion)             ||
   1.160 +        !ReadParam(aMsg, aIter, &aResult->mStatus)              ||
   1.161 +        !ReadParam(aMsg, aIter, &aResult->mStatusText)          ||
   1.162 +        !ReadParam(aMsg, aIter, &aResult->mContentLength)       ||
   1.163 +        !ReadParam(aMsg, aIter, &aResult->mContentType)         ||
   1.164 +        !ReadParam(aMsg, aIter, &aResult->mContentCharset)      ||
   1.165 +        !ReadParam(aMsg, aIter, &aResult->mCacheControlNoStore) ||
   1.166 +        !ReadParam(aMsg, aIter, &aResult->mCacheControlNoCache) ||
   1.167 +        !ReadParam(aMsg, aIter, &aResult->mPragmaNoCache))
   1.168 +      return false;
   1.169 +
   1.170 +    return true;
   1.171 +  }
   1.172 +};
   1.173 +
   1.174 +} // namespace IPC
   1.175 +
   1.176 +#endif // mozilla_net_PHttpChannelParams_h

mercurial