Bug 563259: Fix shark/dtrace enabled combo. (r=me)
[mozilla-central.git] / profile / dirserviceprovider / public / nsProfileDirServiceProvider.h
blob03c5f460691eed27fd23b9776aa3601ed03128b9
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2002
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Conrad Carlen <ccarlen@netscape.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 // Interfaces Needed
40 #include "nsIDirectoryService.h"
41 #include "nsILocalFile.h"
43 #include "nsCOMPtr.h"
44 #include "nsDirectoryServiceUtils.h"
45 #include "nsComponentManagerUtils.h"
46 #include "nsServiceManagerUtils.h"
48 #ifdef MOZILLA_INTERNAL_API
49 #include "nsString.h"
50 #else
51 #include "nsEmbedString.h"
52 #endif
54 // Forward Declarations
55 class nsProfileLock;
57 // --------------------------------------------------------------------------------------
58 // nsProfileDirServiceProvider - The nsIDirectoryServiceProvider implementation used for
59 // profile-relative file locations.
60 // --------------------------------------------------------------------------------------
62 class nsProfileDirServiceProvider: public nsIDirectoryServiceProvider
64 NS_DECL_ISUPPORTS
65 NS_DECL_NSIDIRECTORYSERVICEPROVIDER
67 friend nsresult NS_NewProfileDirServiceProvider(PRBool, nsProfileDirServiceProvider**);
69 public:
71 /**
72 * SetProfileDir
74 * @param aProfileDir The directory containing the profile files.
75 * It does not need to exist before calling this
76 * method. If it does not, it will be created and
77 * defaults will be copied to it.
78 * @param aLocalProfileDir
79 * Directory for local profile data, e.g. Cache.
80 * If null, aProfileDir will be used for this purpose.
83 virtual nsresult SetProfileDir(nsIFile* aProfileDir,
84 nsIFile* aLocalProfileDir = nsnull);
86 /**
87 * Register
89 * Convenience method to register the provider with directory service.
90 * The service holds strong references to registered providers so consumers
91 * don't need to hold a reference to this object after calling Register().
94 virtual nsresult Register();
96 /**
97 * Shutdown
99 * This method must be called before shutting down XPCOM if this object
100 * was created with aNotifyObservers == PR_TRUE. If this object was
101 * created with aNotifyObservers == PR_FALSE, this method is a no-op.
104 virtual nsresult Shutdown();
106 protected:
107 nsProfileDirServiceProvider(PRBool aNotifyObservers = PR_TRUE);
108 virtual ~nsProfileDirServiceProvider();
110 nsresult Initialize();
111 nsresult InitProfileDir(nsIFile* profileDir);
112 nsresult InitNonSharedProfileDir();
113 nsresult EnsureProfileFileExists(nsIFile *aFile, nsIFile *destDir);
114 nsresult UndefineFileLocations();
116 protected:
118 nsCOMPtr<nsIFile> mProfileDir;
119 nsCOMPtr<nsIFile> mLocalProfileDir;
120 nsProfileLock* mProfileDirLock;
121 PRPackedBool mNotifyObservers;
123 PRPackedBool mSharingEnabled;
124 #ifndef MOZILLA_INTERNAL_API
125 nsEmbedString mNonSharedDirName;
126 #else
127 nsString mNonSharedDirName;
128 #endif
129 nsCOMPtr<nsIFile> mNonSharedProfileDir;
133 // --------------------------------------------------------------------------------------
136 * Global method to create an instance of nsProfileDirServiceProvider
138 * @param aNotifyObservers If true, will send out profile startup
139 * notifications when the profile directory is set.
140 * See nsIProfileChangeStatus.
143 nsresult NS_NewProfileDirServiceProvider(PRBool aNotifyObservers,
144 nsProfileDirServiceProvider** aProvider);