summaryrefslogtreecommitdiff
blob: 78f5eeb5a437e27a91572ab23e86467cb7547bb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Index: embedding/browser/gtk/src/EmbedPrivate.cpp
===================================================================
RCS file: /cvsroot/mozilla/embedding/browser/gtk/src/EmbedPrivate.cpp,v
retrieving revision 1.30
diff -u -r1.30 EmbedPrivate.cpp
--- embedding/browser/gtk/src/EmbedPrivate.cpp	9 Nov 2002 19:38:31 -0000	1.30
+++ embedding/browser/gtk/src/EmbedPrivate.cpp	11 Feb 2003 00:11:18 -0000
@@ -78,6 +78,7 @@
 GtkWidget   *EmbedPrivate::sOffscreenWindow = 0;
 GtkWidget   *EmbedPrivate::sOffscreenFixed  = 0;
 nsIDirectoryServiceProvider *EmbedPrivate::sAppFileLocProvider = nsnull;
+nsProfileDirServiceProvider *EmbedPrivate::sProfileDirServiceProvider = nsnull;
 
 EmbedPrivate::EmbedPrivate(void)
 {
@@ -796,16 +797,14 @@
     NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(locProvider));
     if (!locProvider)
       return NS_ERROR_FAILURE;
-    
-    // Directory service holds an strong reference to any
-    // provider that is registered with it. Let it hold the
-    // only ref. locProvider won't die when we leave this scope.
     rv = locProvider->Register();
     if (NS_FAILED(rv))
       return rv;
     rv = locProvider->SetProfileDir(profileDir);
     if (NS_FAILED(rv))
       return rv;
+    // Keep a ref so we can shut it down.
+    NS_ADDREF(sProfileDirServiceProvider = locProvider);
 
     // get prefs
     nsCOMPtr<nsIPref> pref;
@@ -822,6 +821,11 @@
 void
 EmbedPrivate::ShutdownProfile(void)
 {
+  if (sProfileDirServiceProvider) {
+    sProfileDirServiceProvider->Shutdown();
+    NS_RELEASE(sProfileDirServiceProvider);
+    sProfileDirServiceProvider = 0;
+  }
   if (sPrefs) {
     NS_RELEASE(sPrefs);
     sPrefs = 0;
Index: embedding/browser/gtk/src/EmbedPrivate.h
===================================================================
RCS file: /cvsroot/mozilla/embedding/browser/gtk/src/EmbedPrivate.h,v
retrieving revision 1.16
diff -u -r1.16 EmbedPrivate.h
--- embedding/browser/gtk/src/EmbedPrivate.h	29 Jan 2002 21:39:30 -0000	1.16
+++ embedding/browser/gtk/src/EmbedPrivate.h	11 Feb 2003 00:11:18 -0000
@@ -46,6 +46,7 @@
 
 class nsPIDOMWindow;
 class nsIDirectoryServiceProvider;
+class nsProfileDirServiceProvider;
 
 class EmbedPrivate {
 
@@ -134,6 +135,7 @@
   static char                   *sProfileDir;
   static char                   *sProfileName;
   // for profiles
+  static nsProfileDirServiceProvider *sProfileDirServiceProvider;
   static nsIPref                *sPrefs;
 
   static nsIDirectoryServiceProvider * sAppFileLocProvider;
Index: profile/dirserviceprovider/public/nsProfileDirServiceProvider.h
===================================================================
RCS file: /cvsroot/mozilla/profile/dirserviceprovider/public/nsProfileDirServiceProvider.h,v
retrieving revision 1.1
diff -u -r1.1 nsProfileDirServiceProvider.h
--- profile/dirserviceprovider/public/nsProfileDirServiceProvider.h	9 Nov 2002 19:38:23 -0000	1.1
+++ profile/dirserviceprovider/public/nsProfileDirServiceProvider.h	11 Feb 2003 00:11:54 -0000
@@ -79,6 +79,16 @@
 
   virtual nsresult         Register();
 
+  /**
+   * Shutdown
+   *
+   * This method must be called before shutting down XPCOM if this object
+   * was created with aNotifyObservers == PR_TRUE. If this object was
+   * created with aNotifyObservers == PR_FALSE, this method is a no-op.
+   */
+
+  virtual nsresult         Shutdown();
+
 protected:
                            nsProfileDirServiceProvider(PRBool aNotifyObservers = PR_TRUE);
    virtual                 ~nsProfileDirServiceProvider();
Index: profile/dirserviceprovider/src/nsProfileDirServiceProvider.cpp
===================================================================
RCS file: /cvsroot/mozilla/profile/dirserviceprovider/src/nsProfileDirServiceProvider.cpp,v
retrieving revision 1.3
diff -u -r1.3 nsProfileDirServiceProvider.cpp
--- profile/dirserviceprovider/src/nsProfileDirServiceProvider.cpp	8 Jan 2003 22:41:35 -0000	1.3
+++ profile/dirserviceprovider/src/nsProfileDirServiceProvider.cpp	11 Feb 2003 00:11:54 -0000
@@ -155,6 +155,22 @@
   return directoryService->RegisterProvider(this);
 }
 
+nsresult
+nsProfileDirServiceProvider::Shutdown()
+{
+  if (!mNotifyObservers)
+    return NS_OK;
+    
+  nsCOMPtr<nsIObserverService> observerService = 
+           do_GetService("@mozilla.org/observer-service;1");
+  if (!observerService)
+    return NS_ERROR_FAILURE;
+    
+  NS_NAMED_LITERAL_STRING(context, "shutdown-persist");
+  observerService->NotifyObservers(nsnull, "profile-before-change", context.get());        
+  return NS_OK;
+}
+
 //*****************************************************************************
 // nsProfileDirServiceProvider::nsISupports
 //*****************************************************************************