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

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2                 :  * vim: sw=2 ts=8 et :
       3                 :  */
       4                 : /* ***** BEGIN LICENSE BLOCK *****
       5                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       6                 :  *
       7                 :  * The contents of this file are subject to the Mozilla Public License Version
       8                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       9                 :  * the License. You may obtain a copy of the License at
      10                 :  * http://www.mozilla.org/MPL/
      11                 :  *
      12                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      13                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      14                 :  * for the specific language governing rights and limitations under the
      15                 :  * License.
      16                 :  *
      17                 :  * The Original Code is Mozilla Plugin App.
      18                 :  *
      19                 :  * The Initial Developer of the Original Code is
      20                 :  *   Ben Turner <bent.mozilla@gmail.com>.
      21                 :  * Portions created by the Initial Developer are Copyright (C) 2009
      22                 :  * the Initial Developer. All Rights Reserved.
      23                 :  *
      24                 :  * Contributor(s):
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #ifndef mozilla_ipc_BrowserProcessSubThread_h
      41                 : #define mozilla_ipc_BrowserProcessSubThread_h
      42                 : 
      43                 : #include "base/thread.h"
      44                 : #include "base/lock.h"
      45                 : 
      46                 : #include "nsDebug.h"
      47                 : 
      48                 : class NotificationService;
      49                 : 
      50                 : namespace mozilla {
      51                 : namespace ipc {
      52                 : 
      53                 : // Copied from browser_process_impl.cc, modified slightly.
      54                 : class BrowserProcessSubThread : public base::Thread
      55                 : {
      56                 : public:
      57                 :   // An enumeration of the well-known threads.
      58                 :   enum ID {
      59                 :       IO,
      60                 :       //FILE,
      61                 :       //DB,
      62                 :       //HISTORY,
      63                 : #if defined(OS_LINUX)
      64                 :       // This thread has a second connection to the X server and is used
      65                 :       // to process UI requests when routing the request to the UI
      66                 :       // thread would risk deadlock.
      67                 :       BACKGROUND_X11,
      68                 : #endif
      69                 : 
      70                 :       // This identifier does not represent a thread.  Instead it counts
      71                 :       // the number of well-known threads.  Insert new well-known
      72                 :       // threads before this identifier.
      73                 :       ID_COUNT
      74                 :   };
      75                 : 
      76                 :   explicit BrowserProcessSubThread(ID aId);
      77                 :   ~BrowserProcessSubThread();
      78                 : 
      79                 :   static MessageLoop* GetMessageLoop(ID identifier);
      80                 : 
      81                 : protected:
      82                 :   virtual void Init();
      83                 :   virtual void CleanUp();
      84                 : 
      85                 : private:
      86                 :   // The identifier of this thread.  Only one thread can exist with a given
      87                 :   // identifier at a given time.
      88                 :   ID mIdentifier;
      89                 : 
      90                 :   NotificationService* mNotificationService;
      91                 : 
      92                 :   // This lock protects |browser_threads_|.  Do not read or modify that array
      93                 :   // without holding this lock.  Do not block while holding this lock.
      94                 : 
      95                 :   // FIXME/cjones: XPCOM doesn't like static vars, so can't use 
      96                 :   // mozilla::Mutex
      97                 :   static Lock sLock;
      98                 : 
      99                 :   // An array of the ChromeThread objects.  This array is protected by |lock_|.
     100                 :   // The threads are not owned by this array.  Typically, the threads are owned
     101                 :   // on the UI thread by the g_browser_process object.  ChromeThreads remove
     102                 :   // themselves from this array upon destruction.
     103                 :   static BrowserProcessSubThread* sBrowserThreads[ID_COUNT];
     104                 : };
     105                 : 
     106               0 : inline void AssertIOThread()
     107                 : {
     108               0 :   NS_ASSERTION(MessageLoop::TYPE_IO == MessageLoop::current()->type(),
     109                 :                "should be on the IO thread!");
     110               0 : }
     111                 : 
     112                 : } // namespace ipc
     113                 : } // namespace mozilla
     114                 : 
     115                 : #endif // mozilla_ipc_BrowserProcessSubThread_h

Generated by: LCOV version 1.7