LCOV - code coverage report
Current view: directory - objdir/dist/include/mozilla/chrome - RegistryMessageUtils.h (source / functions) Found Hit Coverage
Test: app.info Lines: 64 0 0.0 %
Date: 2012-06-02 Functions: 21 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * the Mozilla Foundation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Josh Matthews <josh@joshmatthews.net> (Initial Developer)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef mozilla_RegistryMessageUtils_h
      40                 : #define mozilla_RegistryMessageUtils_h
      41                 : 
      42                 : #include "IPC/IPCMessageUtils.h"
      43                 : #include "nsStringGlue.h"
      44                 : 
      45                 : struct SerializedURI
      46               0 : {
      47                 :   nsCString spec;
      48                 :   nsCString charset;
      49                 : };
      50                 : 
      51                 : struct ChromePackage
      52               0 : {
      53                 :   nsCString package;
      54                 :   SerializedURI contentBaseURI;
      55                 :   SerializedURI localeBaseURI;
      56                 :   SerializedURI skinBaseURI;
      57                 :   PRUint32 flags;
      58                 : };
      59                 : 
      60                 : struct ResourceMapping
      61               0 : {
      62                 :   nsCString resource;
      63                 :   SerializedURI resolvedURI;
      64                 : };
      65                 : 
      66                 : struct OverrideMapping
      67               0 : {
      68                 :   SerializedURI originalURI;
      69                 :   SerializedURI overrideURI;
      70                 : };
      71                 : 
      72                 : namespace IPC {
      73                 : 
      74                 : template<>
      75                 : struct ParamTraits<SerializedURI>
      76                 : {
      77                 :   typedef SerializedURI paramType;
      78                 : 
      79               0 :   static void Write(Message* aMsg, const paramType& aParam)
      80                 :   {
      81               0 :     WriteParam(aMsg, aParam.spec);
      82               0 :     WriteParam(aMsg, aParam.charset);
      83               0 :   }
      84                 : 
      85               0 :   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
      86                 :   {
      87               0 :     nsCString spec, charset;
      88               0 :     if (ReadParam(aMsg, aIter, &spec) &&
      89               0 :         ReadParam(aMsg, aIter, &charset)) {
      90               0 :       aResult->spec = spec;
      91               0 :       aResult->charset = charset;
      92               0 :       return true;
      93                 :     }
      94               0 :     return false;
      95                 :   }
      96                 : };
      97                 :   
      98                 : template <>
      99                 : struct ParamTraits<ChromePackage>
     100                 : {
     101                 :   typedef ChromePackage paramType;
     102                 :   
     103               0 :   static void Write(Message* aMsg, const paramType& aParam)
     104                 :   {
     105               0 :     WriteParam(aMsg, aParam.package);
     106               0 :     WriteParam(aMsg, aParam.contentBaseURI);
     107               0 :     WriteParam(aMsg, aParam.localeBaseURI);
     108               0 :     WriteParam(aMsg, aParam.skinBaseURI);
     109               0 :     WriteParam(aMsg, aParam.flags);
     110               0 :   }
     111                 :   
     112               0 :   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
     113                 :   {
     114               0 :     nsCString package;
     115               0 :     SerializedURI contentBaseURI, localeBaseURI, skinBaseURI;
     116                 :     PRUint32 flags;
     117                 :     
     118               0 :     if (ReadParam(aMsg, aIter, &package) &&
     119               0 :         ReadParam(aMsg, aIter, &contentBaseURI) &&
     120               0 :         ReadParam(aMsg, aIter, &localeBaseURI) &&
     121               0 :         ReadParam(aMsg, aIter, &skinBaseURI) &&
     122               0 :         ReadParam(aMsg, aIter, &flags)) {
     123               0 :       aResult->package = package;
     124               0 :       aResult->contentBaseURI = contentBaseURI;
     125               0 :       aResult->localeBaseURI = localeBaseURI;
     126               0 :       aResult->skinBaseURI = skinBaseURI;
     127               0 :       aResult->flags = flags;
     128               0 :       return true;
     129                 :     }
     130               0 :     return false;
     131                 :   }
     132                 : 
     133                 :   static void Log(const paramType& aParam, std::wstring* aLog)
     134                 :   {
     135                 :     aLog->append(StringPrintf(L"[%s, %s, %s, %s, %u]", aParam.package.get(),
     136                 :                              aParam.contentBaseURI.spec.get(),
     137                 :                              aParam.localeBaseURI.spec.get(),
     138                 :                              aParam.skinBaseURI.spec.get(), aParam.flags));
     139                 :   }
     140                 : };
     141                 : 
     142                 : template <>
     143                 : struct ParamTraits<ResourceMapping>
     144                 : {
     145                 :   typedef ResourceMapping paramType;
     146                 :   
     147               0 :   static void Write(Message* aMsg, const paramType& aParam)
     148                 :   {
     149               0 :     WriteParam(aMsg, aParam.resource);
     150               0 :     WriteParam(aMsg, aParam.resolvedURI);
     151               0 :   }
     152                 :   
     153               0 :   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
     154                 :   {
     155               0 :     nsCString resource;
     156               0 :     SerializedURI resolvedURI;
     157                 :     
     158               0 :     if (ReadParam(aMsg, aIter, &resource) &&
     159               0 :         ReadParam(aMsg, aIter, &resolvedURI)) {
     160               0 :       aResult->resource = resource;
     161               0 :       aResult->resolvedURI = resolvedURI;
     162               0 :       return true;
     163                 :     }
     164               0 :     return false;
     165                 :   }
     166                 : 
     167                 :   static void Log(const paramType& aParam, std::wstring* aLog)
     168                 :   {
     169                 :     aLog->append(StringPrintf(L"[%s, %s, %u]", aParam.resource.get(),
     170                 :                              aParam.resolvedURI.spec.get()));
     171                 :   }
     172                 : };
     173                 : 
     174                 : template <>
     175                 : struct ParamTraits<OverrideMapping>
     176                 : {
     177                 :   typedef OverrideMapping paramType;
     178                 :   
     179               0 :   static void Write(Message* aMsg, const paramType& aParam)
     180                 :   {
     181               0 :     WriteParam(aMsg, aParam.originalURI);
     182               0 :     WriteParam(aMsg, aParam.overrideURI);
     183               0 :   }
     184                 :   
     185               0 :   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
     186                 :   {
     187               0 :     SerializedURI originalURI;
     188               0 :     SerializedURI overrideURI;
     189                 :     
     190               0 :     if (ReadParam(aMsg, aIter, &originalURI) &&
     191               0 :         ReadParam(aMsg, aIter, &overrideURI)) {
     192               0 :       aResult->originalURI = originalURI;
     193               0 :       aResult->overrideURI = overrideURI;
     194               0 :       return true;
     195                 :     }
     196               0 :     return false;
     197                 :   }
     198                 : 
     199                 :   static void Log(const paramType& aParam, std::wstring* aLog)
     200                 :   {
     201                 :     aLog->append(StringPrintf(L"[%s, %s, %u]", aParam.originalURI.spec.get(),
     202                 :                              aParam.overrideURI.spec.get()));
     203                 :   }
     204                 : };
     205                 : 
     206                 : }
     207                 : 
     208                 : #endif // RegistryMessageUtils_h

Generated by: LCOV version 1.7