LCOV - code coverage report
Current view: directory - toolkit/components/url-classifier - nsUrlClassifierProxies.h (source / functions) Found Hit Coverage
Test: app.info Lines: 68 68 100.0 %
Date: 2012-04-21 Functions: 47 47 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                 : #include "LookupCache.h"
      44                 : 
      45                 : using namespace mozilla::safebrowsing;
      46                 : 
      47                 : /**
      48                 :  * Thread proxy from the main thread to the worker thread.
      49                 :  */
      50                 : class UrlClassifierDBServiceWorkerProxy :
      51                 :   public nsIUrlClassifierDBServiceWorker
      52               7 : {
      53                 : public:
      54               7 :   UrlClassifierDBServiceWorkerProxy(nsIUrlClassifierDBServiceWorker* aTarget)
      55               7 :     : mTarget(aTarget)
      56               7 :   { }
      57                 : 
      58                 :   NS_DECL_ISUPPORTS
      59                 :   NS_DECL_NSIURLCLASSIFIERDBSERVICE
      60                 :   NS_DECL_NSIURLCLASSIFIERDBSERVICEWORKER
      61                 : 
      62                 :   class LookupRunnable : public nsRunnable
      63             560 :   {
      64                 :   public:
      65             140 :     LookupRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
      66                 :                    const nsACString& aSpec,
      67                 :                    nsIUrlClassifierCallback* aCB)
      68                 :       : mTarget(aTarget)
      69                 :       , mSpec(aSpec)
      70             140 :       , mCB(aCB)
      71             140 :     { }
      72                 : 
      73                 :     NS_DECL_NSIRUNNABLE
      74                 : 
      75                 :   private:
      76                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
      77                 :     nsCString mSpec;
      78                 :     nsCOMPtr<nsIUrlClassifierCallback> mCB;
      79                 :   };
      80                 : 
      81                 :   class GetTablesRunnable : public nsRunnable
      82             192 :   {
      83                 :   public:
      84              48 :     GetTablesRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
      85                 :                       nsIUrlClassifierCallback* aCB)
      86                 :       : mTarget(aTarget)
      87              48 :       , mCB(aCB)
      88              48 :     { }
      89                 : 
      90                 :     NS_DECL_NSIRUNNABLE
      91                 : 
      92                 :   private:
      93                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
      94                 :     nsCOMPtr<nsIUrlClassifierCallback> mCB;
      95                 :   };
      96                 : 
      97                 :   class BeginUpdateRunnable : public nsRunnable
      98             308 :   {
      99                 :   public:
     100              77 :     BeginUpdateRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
     101                 :                         nsIUrlClassifierUpdateObserver* aUpdater,
     102                 :                         const nsACString& aTables,
     103                 :                         const nsACString& aClientKey)
     104                 :       : mTarget(aTarget)
     105                 :       , mUpdater(aUpdater)
     106                 :       , mTables(aTables)
     107              77 :       , mClientKey(aClientKey)
     108              77 :     { }
     109                 : 
     110                 :     NS_DECL_NSIRUNNABLE
     111                 : 
     112                 :   private:
     113                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     114                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mUpdater;
     115                 :     nsCString mTables, mClientKey;
     116                 :   };
     117                 : 
     118                 :   class BeginStreamRunnable : public nsRunnable
     119             356 :   {
     120                 :   public:
     121              89 :     BeginStreamRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
     122                 :                         const nsACString& aTable,
     123                 :                         const nsACString& aServerMAC)
     124                 :       : mTarget(aTarget)
     125                 :       , mTable(aTable)
     126              89 :       , mServerMAC(aServerMAC)
     127              89 :     { }
     128                 : 
     129                 :     NS_DECL_NSIRUNNABLE
     130                 : 
     131                 :   private:
     132                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     133                 :     nsCString mTable, mServerMAC;
     134                 :   };
     135                 : 
     136                 :   class UpdateStreamRunnable : public nsRunnable
     137             348 :   {
     138                 :   public:
     139              87 :     UpdateStreamRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
     140                 :                          const nsACString& aUpdateChunk)
     141                 :       : mTarget(aTarget)
     142              87 :       , mUpdateChunk(aUpdateChunk)
     143              87 :     { }
     144                 : 
     145                 :     NS_DECL_NSIRUNNABLE
     146                 : 
     147                 :   private:
     148                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     149                 :     nsCString mUpdateChunk;
     150                 :   };
     151                 : 
     152                 :   class CacheCompletionsRunnable : public nsRunnable
     153             116 :   {
     154                 :   public:
     155              29 :     CacheCompletionsRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
     156                 :                              CacheResultArray *aEntries)
     157                 :       : mTarget(aTarget)
     158              29 :       , mEntries(aEntries)
     159              29 :     { }
     160                 : 
     161                 :     NS_DECL_NSIRUNNABLE
     162                 : 
     163                 :   private:
     164                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     165                 :      CacheResultArray *mEntries;
     166                 :   };
     167                 : 
     168                 :   class CacheMissesRunnable : public nsRunnable
     169             560 :   {
     170                 :   public:
     171             140 :     CacheMissesRunnable(nsIUrlClassifierDBServiceWorker* aTarget,
     172                 :                         PrefixArray *aEntries)
     173                 :       : mTarget(aTarget)
     174             140 :       , mEntries(aEntries)
     175             140 :     { }
     176                 : 
     177                 :     NS_DECL_NSIRUNNABLE
     178                 : 
     179                 :   private:
     180                 :     nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     181                 :     PrefixArray *mEntries;
     182                 :   };
     183                 : 
     184                 : private:
     185                 :   nsCOMPtr<nsIUrlClassifierDBServiceWorker> mTarget;
     186                 : };
     187                 : 
     188                 : // The remaining classes here are all proxies to the main thread
     189                 : 
     190                 : class UrlClassifierLookupCallbackProxy : public nsIUrlClassifierLookupCallback
     191             140 : {
     192                 : public:
     193             140 :   UrlClassifierLookupCallbackProxy(nsIUrlClassifierLookupCallback* aTarget)
     194             140 :     : mTarget(aTarget)
     195             140 :   { }
     196                 : 
     197                 :   NS_DECL_ISUPPORTS
     198                 :   NS_DECL_NSIURLCLASSIFIERLOOKUPCALLBACK
     199                 : 
     200                 :   class LookupCompleteRunnable : public nsRunnable
     201             560 :   {
     202                 :   public:
     203             140 :     LookupCompleteRunnable(nsIUrlClassifierLookupCallback* aTarget,
     204                 :                            LookupResultArray *aResults)
     205                 :       : mTarget(aTarget)
     206             140 :       , mResults(aResults)
     207             140 :     { }
     208                 : 
     209                 :     NS_DECL_NSIRUNNABLE
     210                 : 
     211                 :   private:
     212                 :     nsCOMPtr<nsIUrlClassifierLookupCallback> mTarget;
     213                 :     LookupResultArray * mResults;
     214                 :   };
     215                 : 
     216                 : private:
     217                 :   nsCOMPtr<nsIUrlClassifierLookupCallback> mTarget;
     218                 : };
     219                 : 
     220                 : class UrlClassifierCallbackProxy : public nsIUrlClassifierCallback
     221              48 : {
     222                 : public:
     223              48 :   UrlClassifierCallbackProxy(nsIUrlClassifierCallback* aTarget)
     224              48 :     : mTarget(aTarget)
     225              48 :   { }
     226                 : 
     227                 :   NS_DECL_ISUPPORTS
     228                 :   NS_DECL_NSIURLCLASSIFIERCALLBACK
     229                 : 
     230                 :   class HandleEventRunnable : public nsRunnable
     231             192 :   {
     232                 :   public:
     233              48 :     HandleEventRunnable(nsIUrlClassifierCallback* aTarget,
     234                 :                         const nsACString& aValue)
     235                 :       : mTarget(aTarget)
     236              48 :       , mValue(aValue)
     237              48 :     { }
     238                 : 
     239                 :     NS_DECL_NSIRUNNABLE
     240                 : 
     241                 :   private:
     242                 :     nsCOMPtr<nsIUrlClassifierCallback> mTarget;
     243                 :     nsCString mValue;
     244                 :   };
     245                 : 
     246                 : private:
     247                 :   nsCOMPtr<nsIUrlClassifierCallback> mTarget;
     248                 : };
     249                 : 
     250                 : class UrlClassifierUpdateObserverProxy : public nsIUrlClassifierUpdateObserver
     251              77 : {
     252                 : public:
     253              77 :   UrlClassifierUpdateObserverProxy(nsIUrlClassifierUpdateObserver* aTarget)
     254              77 :     : mTarget(aTarget)
     255              77 :   { }
     256                 : 
     257                 :   NS_DECL_ISUPPORTS
     258                 :   NS_DECL_NSIURLCLASSIFIERUPDATEOBSERVER
     259                 : 
     260                 :   class UpdateUrlRequestedRunnable : public nsRunnable
     261              64 :   {
     262                 :   public:
     263              16 :     UpdateUrlRequestedRunnable(nsIUrlClassifierUpdateObserver* aTarget,
     264                 :                                const nsACString& aURL,
     265                 :                                const nsACString& aTable,
     266                 :                                const nsACString& aServerMAC)
     267                 :       : mTarget(aTarget)
     268                 :       , mURL(aURL)
     269                 :       , mTable(aTable)
     270              16 :       , mServerMAC(aServerMAC)
     271              16 :     { }
     272                 : 
     273                 :     NS_DECL_NSIRUNNABLE
     274                 : 
     275                 :   private:
     276                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     277                 :     nsCString mURL, mTable, mServerMAC;
     278                 :   };
     279                 : 
     280                 :   class StreamFinishedRunnable : public nsRunnable
     281             348 :   {
     282                 :   public:
     283              87 :     StreamFinishedRunnable(nsIUrlClassifierUpdateObserver* aTarget,
     284                 :                            nsresult aStatus, PRUint32 aDelay)
     285                 :       : mTarget(aTarget)
     286                 :       , mStatus(aStatus)
     287              87 :       , mDelay(aDelay)
     288              87 :     { }
     289                 : 
     290                 :     NS_DECL_NSIRUNNABLE
     291                 : 
     292                 :   private:
     293                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     294                 :     nsresult mStatus;
     295                 :     PRUint32 mDelay;
     296                 :   };
     297                 : 
     298                 :   class UpdateErrorRunnable : public nsRunnable
     299              36 :   {
     300                 :   public:
     301               9 :     UpdateErrorRunnable(nsIUrlClassifierUpdateObserver* aTarget,
     302                 :                         nsresult aError)
     303                 :       : mTarget(aTarget)
     304               9 :       , mError(aError)
     305               9 :     { }
     306                 : 
     307                 :     NS_DECL_NSIRUNNABLE
     308                 : 
     309                 :   private:
     310                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     311                 :     nsresult mError;
     312                 :   };
     313                 : 
     314                 :   class UpdateSuccessRunnable : public nsRunnable
     315             272 :   {
     316                 :   public:
     317              68 :     UpdateSuccessRunnable(nsIUrlClassifierUpdateObserver* aTarget,
     318                 :                           PRUint32 aRequestedTimeout)
     319                 :       : mTarget(aTarget)
     320              68 :       , mRequestedTimeout(aRequestedTimeout)
     321              68 :     { }
     322                 : 
     323                 :     NS_DECL_NSIRUNNABLE
     324                 : 
     325                 :   private:
     326                 :     nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     327                 :     PRUint32 mRequestedTimeout;
     328                 :   };
     329                 : 
     330                 : private:
     331                 :   nsCOMPtr<nsIUrlClassifierUpdateObserver> mTarget;
     332                 : };
     333                 : 
     334                 : #endif // nsUrlClassifierProxies_h

Generated by: LCOV version 1.7