LCOV - code coverage report
Current view: directory - toolkit/components/url-classifier - nsUrlClassifierProxies.h (source / functions) Found Hit Coverage
Test: app.info Lines: 64 64 100.0 %
Date: 2012-06-02 Functions: 44 44 100.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 Firefox.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * the Mozilla Foundation <http://www.mozilla.org>.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef nsUrlClassifierProxies_h
      39                 : #define nsUrlClassifierProxies_h
      40                 : 
      41                 : #include "nsIUrlClassifierDBService.h"
      42                 : #include "nsThreadUtils.h"
      43                 : 
      44                 : /**
      45                 :  * Thread proxy from the main thread to the worker thread.
      46                 :  */
      47                 : class UrlClassifierDBServiceWorkerProxy :
      48                 :   public nsIUrlClassifierDBServiceWorker
      49               8 : {
      50                 : public:
      51               8 :   UrlClassifierDBServiceWorkerProxy(nsIUrlClassifierDBServiceWorker* aTarget)
      52               8 :     : mTarget(aTarget)
      53               8 :   { }
      54                 : 
      55                 :   NS_DECL_ISUPPORTS
      56                 :   NS_DECL_NSIURLCLASSIFIERDBSERVICE
      57                 :   NS_DECL_NSIURLCLASSIFIERDBSERVICEWORKER
      58                 : 
      59                 :   class LookupRunnable : public nsRunnable
      60             564 :   {
      61                 :   public:
      62             141 :     LookupRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
      63                 :                    const nsACString& aSpec,
      64                 :                    nsIUrlClassifierCallback* aCB)
      65                 :       : mTarget(aTarget)
      66                 :       , mSpec(aSpec)
      67             141 :       , mCB(aCB)
      68             141 :     { }
      69                 : 
      70                 :     NS_DECL_NSIRUNNABLE
      71                 : 
      72                 :   private:
      73                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
      74                 :     nsCString mSpec;
      75                 :     nsCOMPtr<nsIUrlClassifierCallback> mCB;
      76                 :   };
      77                 : 
      78                 :   class GetTablesRunnable : public nsRunnable
      79             212 :   {
      80                 :   public:
      81              53 :     GetTablesRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
      82                 :                       nsIUrlClassifierCallback* aCB)
      83                 :       : mTarget(aTarget)
      84              53 :       , mCB(aCB)
      85              53 :     { }
      86                 : 
      87                 :     NS_DECL_NSIRUNNABLE
      88                 : 
      89                 :   private:
      90                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
      91                 :     nsCOMPtr<nsIUrlClassifierCallback> mCB;
      92                 :   };
      93                 : 
      94                 :   class BeginUpdateRunnable : public nsRunnable
      95             348 :   {
      96                 :   public:
      97              87 :     BeginUpdateRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
      98                 :                         nsIUrlClassifierUpdateObserver* aUpdater,
      99                 :                         const nsACString& aTables,
     100                 :                         const nsACString& aClientKey)
     101                 :       : mTarget(aTarget)
     102                 :       , mUpdater(aUpdater)
     103                 :       , mTables(aTables)
     104              87 :       , mClientKey(aClientKey)
     105              87 :     { }
     106                 : 
     107                 :     NS_DECL_NSIRUNNABLE
     108                 : 
     109                 :   private:
     110                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     111                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mUpdater;
     112                 :     nsCString mTables, mClientKey;
     113                 :   };
     114                 : 
     115                 :   class BeginStreamRunnable : public nsRunnable
     116             408 :   {
     117                 :   public:
     118             102 :     BeginStreamRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
     119                 :                         const nsACString& aTable,
     120                 :                         const nsACString& aServerMAC)
     121                 :       : mTarget(aTarget)
     122                 :       , mTable(aTable)
     123             102 :       , mServerMAC(aServerMAC)
     124             102 :     { }
     125                 : 
     126                 :     NS_DECL_NSIRUNNABLE
     127                 : 
     128                 :   private:
     129                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     130                 :     nsCString mTable, mServerMAC;
     131                 :   };
     132                 : 
     133                 :   class UpdateStreamRunnable : public nsRunnable
     134             400 :   {
     135                 :   public:
     136             100 :     UpdateStreamRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
     137                 :                          const nsACString& aUpdateChunk)
     138                 :       : mTarget(aTarget)
     139             100 :       , mUpdateChunk(aUpdateChunk)
     140             100 :     { }
     141                 : 
     142                 :     NS_DECL_NSIRUNNABLE
     143                 : 
     144                 :   private:
     145                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     146                 :     nsCString mUpdateChunk;
     147                 :   };
     148                 : 
     149                 :   class CacheCompletionsRunnable : public nsRunnable
     150              80 :   {
     151                 :   public:
     152              20 :     CacheCompletionsRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
     153                 :                              nsTArray<nsUrlClassifierLookupResult>* aEntries)
     154                 :       : mTarget(aTarget)
     155              20 :       , mEntries(aEntries)
     156              20 :     { }
     157                 : 
     158                 :     NS_DECL_NSIRUNNABLE
     159                 : 
     160                 :   private:
     161                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     162                 :     nsTArray<nsUrlClassifierLookupResult>* mEntries;
     163                 :   };
     164                 : 
     165                 : private:
     166                 :   nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     167                 : };
     168                 : 
     169                 : // The remaining classes here are all proxies to the main thread
     170                 : 
     171                 : class UrlClassifierLookupCallbackProxy : public nsIUrlClassifierLookupCallback
     172             141 : {
     173                 : public:
     174             141 :   UrlClassifierLookupCallbackProxy(nsIUrlClassifierLookupCallback* aTarget)
     175             141 :     : mTarget(aTarget)
     176             141 :   { }
     177                 : 
     178                 :   NS_DECL_ISUPPORTS
     179                 :   NS_DECL_NSIURLCLASSIFIERLOOKUPCALLBACK
     180                 : 
     181                 :   class LookupCompleteRunnable : public nsRunnable
     182             564 :   {
     183                 :   public:
     184             141 :     LookupCompleteRunnable(nsIUrlClassifierLookupCallback* aTarget,
     185                 :                            nsTArray<nsUrlClassifierLookupResult>* aResults)
     186                 :       : mTarget(aTarget)
     187             141 :       , mResults(aResults)
     188             141 :     { }
     189                 : 
     190                 :     NS_DECL_NSIRUNNABLE
     191                 : 
     192                 :   private:
     193                 :     nsCOMPtr<nsIUrlClassifierLookupCallback> mTarget;
     194                 :     nsTArray<nsUrlClassifierLookupResult>* mResults;
     195                 :   };
     196                 : 
     197                 : private:
     198                 :   nsCOMPtr<nsIUrlClassifierLookupCallback> mTarget;
     199                 : };
     200                 : 
     201                 : class UrlClassifierCallbackProxy : public nsIUrlClassifierCallback
     202              53 : {
     203                 : public:
     204              53 :   UrlClassifierCallbackProxy(nsIUrlClassifierCallback* aTarget)
     205              53 :     : mTarget(aTarget)
     206              53 :   { }
     207                 : 
     208                 :   NS_DECL_ISUPPORTS
     209                 :   NS_DECL_NSIURLCLASSIFIERCALLBACK
     210                 : 
     211                 :   class HandleEventRunnable : public nsRunnable
     212             212 :   {
     213                 :   public:
     214              53 :     HandleEventRunnable(nsIUrlClassifierCallback* aTarget,
     215                 :                         const nsACString& aValue)
     216                 :       : mTarget(aTarget)
     217              53 :       , mValue(aValue)
     218              53 :     { }
     219                 : 
     220                 :     NS_DECL_NSIRUNNABLE
     221                 : 
     222                 :   private:
     223                 :     nsCOMPtr<nsIUrlClassifierCallback> mTarget;
     224                 :     nsCString mValue;
     225                 :   };
     226                 : 
     227                 : private:
     228                 :   nsCOMPtr<nsIUrlClassifierCallback> mTarget;
     229                 : };
     230                 : 
     231                 : class UrlClassifierUpdateObserverProxy : public nsIUrlClassifierUpdateObserver
     232              87 : {
     233                 : public:
     234              87 :   UrlClassifierUpdateObserverProxy(nsIUrlClassifierUpdateObserver* aTarget)
     235              87 :     : mTarget(aTarget)
     236              87 :   { }
     237                 : 
     238                 :   NS_DECL_ISUPPORTS
     239                 :   NS_DECL_NSIURLCLASSIFIERUPDATEOBSERVER
     240                 : 
     241                 :   class UpdateUrlRequestedRunnable : public nsRunnable
     242              68 :   {
     243                 :   public:
     244              17 :     UpdateUrlRequestedRunnable(nsIUrlClassifierUpdateObserver* aTarget,
     245                 :                                const nsACString& aURL,
     246                 :                                const nsACString& aTable,
     247                 :                                const nsACString& aServerMAC)
     248                 :       : mTarget(aTarget)
     249                 :       , mURL(aURL)
     250                 :       , mTable(aTable)
     251              17 :       , mServerMAC(aServerMAC)
     252              17 :     { }
     253                 : 
     254                 :     NS_DECL_NSIRUNNABLE
     255                 : 
     256                 :   private:
     257                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     258                 :     nsCString mURL, mTable, mServerMAC;
     259                 :   };
     260                 : 
     261                 :   class StreamFinishedRunnable : public nsRunnable
     262             400 :   {
     263                 :   public:
     264             100 :     StreamFinishedRunnable(nsIUrlClassifierUpdateObserver* aTarget,
     265                 :                            nsresult aStatus, PRUint32 aDelay)
     266                 :       : mTarget(aTarget)
     267                 :       , mStatus(aStatus)
     268             100 :       , mDelay(aDelay)
     269             100 :     { }
     270                 : 
     271                 :     NS_DECL_NSIRUNNABLE
     272                 : 
     273                 :   private:
     274                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     275                 :     nsresult mStatus;
     276                 :     PRUint32 mDelay;
     277                 :   };
     278                 : 
     279                 :   class UpdateErrorRunnable : public nsRunnable
     280              12 :   {
     281                 :   public:
     282               3 :     UpdateErrorRunnable(nsIUrlClassifierUpdateObserver* aTarget,
     283                 :                         nsresult aError)
     284                 :       : mTarget(aTarget)
     285               3 :       , mError(aError)
     286               3 :     { }
     287                 : 
     288                 :     NS_DECL_NSIRUNNABLE
     289                 : 
     290                 :   private:
     291                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     292                 :     nsresult mError;
     293                 :   };
     294                 : 
     295                 :   class UpdateSuccessRunnable : public nsRunnable
     296             336 :   {
     297                 :   public:
     298              84 :     UpdateSuccessRunnable(nsIUrlClassifierUpdateObserver* aTarget,
     299                 :                           PRUint32 aRequestedTimeout)
     300                 :       : mTarget(aTarget)
     301              84 :       , mRequestedTimeout(aRequestedTimeout)
     302              84 :     { }
     303                 : 
     304                 :     NS_DECL_NSIRUNNABLE
     305                 : 
     306                 :   private:
     307                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     308                 :     PRUint32 mRequestedTimeout;
     309                 :   };
     310                 : 
     311                 : private:
     312                 :   nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     313                 : };
     314                 : 
     315                 : #endif // nsUrlClassifierProxies_h

Generated by: LCOV version 1.7