LCOV - code coverage report
Current view: directory - toolkit/xre - nsAppRunner.h (source / functions) Found Hit Coverage
Test: app.info Lines: 7 6 85.7 %
Date: 2012-06-02 Functions: 3 2 66.7 %

       1                 : /* -*- Mode: C++; tab-width: 2; 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 Communicator client code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      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 nsAppRunner_h__
      39                 : #define nsAppRunner_h__
      40                 : 
      41                 : #ifdef XP_WIN
      42                 : #include <windows.h>
      43                 : #else
      44                 : #include <limits.h>
      45                 : #endif
      46                 : 
      47                 : #ifndef MAXPATHLEN
      48                 : #ifdef PATH_MAX
      49                 : #define MAXPATHLEN PATH_MAX
      50                 : #elif defined(_MAX_PATH)
      51                 : #define MAXPATHLEN _MAX_PATH
      52                 : #elif defined(CCHMAXPATH)
      53                 : #define MAXPATHLEN CCHMAXPATH
      54                 : #else
      55                 : #define MAXPATHLEN 1024
      56                 : #endif
      57                 : #endif
      58                 : 
      59                 : #include "nscore.h"
      60                 : #include "nsXULAppAPI.h"
      61                 : 
      62                 : // This directory service key is a lot like NS_APP_LOCALSTORE_50_FILE,
      63                 : // but it is always the "main" localstore file, even when we're in safe mode
      64                 : // and we load localstore from somewhere else.
      65                 : #define NS_LOCALSTORE_UNSAFE_FILE "LStoreS"
      66                 : 
      67                 : /**
      68                 :  * A directory service key which provides the update directory.
      69                 :  * At present this is supported only on Windows.
      70                 :  * Windows: Documents and Settings\<User>\Local Settings\Application Data\
      71                 :  *          <Vendor>\<Application>\<relative path to app dir from Program Files>
      72                 :  * If appDir is not under the Program Files, directory service will fail.
      73                 :  * Callers should fallback to appDir.
      74                 :  */
      75                 : #define XRE_UPDATE_ROOT_DIR "UpdRootD"
      76                 : 
      77                 : class nsACString;
      78                 : struct nsStaticModuleInfo;
      79                 : 
      80                 : class nsINativeAppSupport;
      81                 : class nsICmdLineService;
      82                 : class nsXREDirProvider;
      83                 : class nsIToolkitProfileService;
      84                 : class nsILocalFile;
      85                 : class nsIProfileLock;
      86                 : class nsIProfileUnlocker;
      87                 : class nsIFactory;
      88                 : 
      89                 : extern nsXREDirProvider* gDirServiceProvider;
      90                 : 
      91                 : // NOTE: gAppData will be null in embedded contexts. The "size" parameter
      92                 : // will be the size of the original structure passed to XRE_main, but the
      93                 : // structure will have all of the members available.
      94                 : extern const nsXREAppData* gAppData;
      95                 : extern bool gSafeMode;
      96                 : 
      97                 : extern int    gArgc;
      98                 : extern char **gArgv;
      99                 : extern bool gLogConsoleErrors;
     100                 : 
     101                 : /**
     102                 :  * Create the nativeappsupport implementation.
     103                 :  *
     104                 :  * @note XPCOMInit has not happened yet.
     105                 :  */
     106                 : nsresult NS_CreateNativeAppSupport(nsINativeAppSupport* *aResult);
     107                 : 
     108                 : NS_HIDDEN_(nsresult)
     109                 : NS_NewToolkitProfileService(nsIToolkitProfileService* *aResult);
     110                 : 
     111                 : NS_HIDDEN_(nsresult)
     112                 : NS_NewToolkitProfileFactory(nsIFactory* *aResult);
     113                 : 
     114                 : /**
     115                 :  * Try to acquire exclusive access to the specified profile directory.
     116                 :  *
     117                 :  * @param aPath
     118                 :  *        The profile directory to lock.
     119                 :  * @param aTempPath
     120                 :  *        The corresponding profile temporary directory.
     121                 :  * @param aUnlocker
     122                 :  *        A callback interface used to attempt to unlock a profile that
     123                 :  *        appears to be locked.
     124                 :  * @param aResult
     125                 :  *        The resulting profile lock object (or null if the profile could
     126                 :  *        not be locked).
     127                 :  *
     128                 :  * @return NS_ERROR_FILE_ACCESS_DENIED to indicate that the profile
     129                 :  *         directory cannot be unlocked.
     130                 :  */
     131                 : NS_HIDDEN_(nsresult)
     132                 : NS_LockProfilePath(nsILocalFile* aPath, nsILocalFile* aTempPath,
     133                 :                    nsIProfileUnlocker* *aUnlocker, nsIProfileLock* *aResult);
     134                 : 
     135                 : NS_HIDDEN_(void)
     136                 : WriteConsoleLog();
     137                 : 
     138                 : #ifdef XP_WIN
     139                 : BOOL
     140                 : WinLaunchChild(const PRUnichar *exePath, int argc, 
     141                 :                char **argv, HANDLE userToken = NULL);
     142                 : #endif
     143                 : 
     144                 : #define NS_NATIVEAPPSUPPORT_CONTRACTID "@mozilla.org/toolkit/native-app-support;1"
     145                 : 
     146                 : // Like nsXREAppData, but releases all strong refs/allocated memory
     147                 : // in the destructor.
     148                 : class ScopedAppData : public nsXREAppData
     149                 : {
     150                 : public:
     151               0 :   ScopedAppData() { Zero(); this->size = sizeof(*this); }
     152                 : 
     153                 :   ScopedAppData(const nsXREAppData* aAppData);
     154                 : 
     155              23 :   void Zero() { memset(this, 0, sizeof(*this)); }
     156                 : 
     157                 :   ~ScopedAppData();
     158                 : };
     159                 : 
     160                 : /**
     161                 :  * Given "str" is holding a string allocated with NS_Alloc, or null:
     162                 :  * replace the value in "str" with a new value.
     163                 :  *
     164                 :  * @param newvalue Null is permitted. The string is cloned with
     165                 :  *                 NS_strdup
     166                 :  */
     167                 : void SetAllocatedString(const char *&str, const char *newvalue);
     168                 : 
     169                 : /**
     170                 :  * Given "str" is holding a string allocated with NS_Alloc, or null:
     171                 :  * replace the value in "str" with a new value.
     172                 :  *
     173                 :  * @param newvalue If "newvalue" is the empty string, "str" will be set
     174                 :  *                 to null.
     175                 :  */
     176                 : void SetAllocatedString(const char *&str, const nsACString &newvalue);
     177                 : 
     178                 : template<class T>
     179              69 : void SetStrongPtr(T *&ptr, T* newvalue)
     180                 : {
     181              69 :   NS_IF_RELEASE(ptr);
     182              69 :   ptr = newvalue;
     183              69 :   NS_IF_ADDREF(ptr);
     184              69 : }
     185                 : 
     186                 : namespace mozilla {
     187                 : namespace startup {
     188                 : extern GeckoProcessType sChildProcessType;
     189                 : }
     190                 : }
     191                 : 
     192                 : /**
     193                 :  * Set up platform specific error handling such as suppressing DLL load dialog
     194                 :  * and the JIT debugger on Windows, and install unix signal handlers.
     195                 :  */
     196                 : void SetupErrorHandling(const char* progname);
     197                 : 
     198                 : #endif // nsAppRunner_h__

Generated by: LCOV version 1.7