profile/dirserviceprovider/public/nsProfileDirServiceProvider.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 // Interfaces Needed
     7 #include "nsIDirectoryService.h"
     8 #include "nsIFile.h"
    10 #include "nsCOMPtr.h"
    11 #include "nsDirectoryServiceUtils.h"
    12 #include "nsComponentManagerUtils.h"
    13 #include "nsServiceManagerUtils.h"
    15 #ifdef MOZILLA_INTERNAL_API
    16 #include "nsString.h"
    17 #else
    18 #include "nsEmbedString.h"
    19 #endif
    21 // Forward Declarations
    22 class nsProfileLock;
    24 // --------------------------------------------------------------------------------------
    25 // nsProfileDirServiceProvider - The nsIDirectoryServiceProvider implementation used for
    26 // profile-relative file locations.
    27 // --------------------------------------------------------------------------------------
    29 class nsProfileDirServiceProvider: public nsIDirectoryServiceProvider
    30 {  
    31   NS_DECL_ISUPPORTS
    32   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
    34   friend nsresult NS_NewProfileDirServiceProvider(bool, nsProfileDirServiceProvider**);
    36 public:
    38    /**
    39     * SetProfileDir
    40     *
    41     * @param aProfileDir   The directory containing the profile files.
    42     *                      It does not need to exist before calling this
    43     *                      method. If it does not, it will be created and
    44     *                      defaults will be copied to it. 
    45     * @param aLocalProfileDir
    46     *                      Directory for local profile data, e.g. Cache.
    47     *                      If null, aProfileDir will be used for this purpose.
    48     */
    50    virtual nsresult        SetProfileDir(nsIFile* aProfileDir,
    51                                          nsIFile* aLocalProfileDir = nullptr);
    53   /**
    54    * Register
    55    *
    56    * Convenience method to register the provider with directory service.
    57    * The service holds strong references to registered providers so consumers
    58    * don't need to hold a reference to this object after calling Register().
    59    */
    61   virtual nsresult         Register();
    63   /**
    64    * Shutdown
    65    *
    66    * This method must be called before shutting down XPCOM if this object
    67    * was created with aNotifyObservers == true. If this object was
    68    * created with aNotifyObservers == false, this method is a no-op.
    69    */
    71   virtual nsresult         Shutdown();
    73 protected:
    74                            nsProfileDirServiceProvider(bool aNotifyObservers = true);
    75    virtual                 ~nsProfileDirServiceProvider();
    77   nsresult                 Initialize();
    78   nsresult                 InitProfileDir(nsIFile* profileDir);
    79   nsresult                 InitNonSharedProfileDir();
    80   nsresult                 EnsureProfileFileExists(nsIFile *aFile, nsIFile *destDir);
    81   nsresult                 UndefineFileLocations();
    83 protected:
    85   nsCOMPtr<nsIFile>        mProfileDir;
    86   nsCOMPtr<nsIFile>        mLocalProfileDir;
    87   nsProfileLock*           mProfileDirLock;
    88   bool                     mNotifyObservers;
    90   bool                     mSharingEnabled;
    91 #ifndef MOZILLA_INTERNAL_API
    92   nsEmbedString            mNonSharedDirName;
    93 #else
    94   nsString                 mNonSharedDirName;
    95 #endif
    96   nsCOMPtr<nsIFile>        mNonSharedProfileDir;
    97 };
   100 // --------------------------------------------------------------------------------------
   102 /**
   103  * Global method to create an instance of nsProfileDirServiceProvider
   104  *
   105  * @param aNotifyObservers    If true, will send out profile startup
   106  *                            notifications when the profile directory is set.
   107  *                            See notifications.txt
   108  */
   110 nsresult NS_NewProfileDirServiceProvider(bool aNotifyObservers,
   111                                          nsProfileDirServiceProvider** aProvider);

mercurial