Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map.h

Issue 7218073: Explicitly ShutdownOnUIThread the HostContentSettingsMap when destroying the Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Maps hostnames to custom content settings. Written on the UI thread and read 5 // Maps hostnames to custom content settings. Written on the UI thread and read
6 // on any thread. One instance per profile. 6 // on any thread. One instance per profile.
7 7
8 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ 8 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_
9 #define CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ 9 #define CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_
10 #pragma once 10 #pragma once
(...skipping 14 matching lines...) Expand all
25 #include "content/common/notification_observer.h" 25 #include "content/common/notification_observer.h"
26 #include "content/common/notification_registrar.h" 26 #include "content/common/notification_registrar.h"
27 27
28 namespace content_settings { 28 namespace content_settings {
29 class DefaultProviderInterface; 29 class DefaultProviderInterface;
30 class ProviderInterface; 30 class ProviderInterface;
31 } // namespace content_settings 31 } // namespace content_settings
32 32
33 class ContentSettingsDetails; 33 class ContentSettingsDetails;
34 class DictionaryValue; 34 class DictionaryValue;
35 class ExtensionService;
35 class GURL; 36 class GURL;
36 class PrefService; 37 class PrefService;
37 class Profile; 38 class Profile;
38 39
39 class HostContentSettingsMap 40 class HostContentSettingsMap
40 : public NotificationObserver, 41 : public NotificationObserver,
41 public base::RefCountedThreadSafe<HostContentSettingsMap, 42 public base::RefCountedThreadSafe<HostContentSettingsMap> {
42 BrowserThread::DeleteOnUIThread> {
43 public: 43 public:
44 typedef Tuple3<ContentSettingsPattern, ContentSetting, std::string> 44 typedef Tuple3<ContentSettingsPattern, ContentSetting, std::string>
45 PatternSettingSourceTriple; 45 PatternSettingSourceTriple;
46 typedef std::vector<PatternSettingSourceTriple> SettingsForOneType; 46 typedef std::vector<PatternSettingSourceTriple> SettingsForOneType;
47 47
48 explicit HostContentSettingsMap(Profile* profile); 48 HostContentSettingsMap(PrefService* prefs,
49 ExtensionService* extension_service,
50 bool incognito);
49 51
50 static void RegisterUserPrefs(PrefService* prefs); 52 static void RegisterUserPrefs(PrefService* prefs);
51 53
52 // Returns the default setting for a particular content type. 54 // Returns the default setting for a particular content type.
53 // 55 //
54 // This may be called on any thread. 56 // This may be called on any thread.
55 ContentSetting GetDefaultContentSetting( 57 ContentSetting GetDefaultContentSetting(
56 ContentSettingsType content_type) const; 58 ContentSettingsType content_type) const;
57 59
58 // Returns the default settings for all content types. 60 // Returns the default settings for all content types.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Afterwards, none of the methods above that should only be called on the UI 189 // Afterwards, none of the methods above that should only be called on the UI
188 // thread should be called anymore. 190 // thread should be called anymore.
189 void ShutdownOnUIThread(); 191 void ShutdownOnUIThread();
190 192
191 // NotificationObserver implementation. 193 // NotificationObserver implementation.
192 virtual void Observe(NotificationType type, 194 virtual void Observe(NotificationType type,
193 const NotificationSource& source, 195 const NotificationSource& source,
194 const NotificationDetails& details); 196 const NotificationDetails& details);
195 197
196 private: 198 private:
197 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 199 friend class base::RefCountedThreadSafe<HostContentSettingsMap>;
198 friend class DeleteTask<HostContentSettingsMap>;
199 200
200 virtual ~HostContentSettingsMap(); 201 virtual ~HostContentSettingsMap();
201 202
202 ContentSetting GetContentSettingInternal( 203 ContentSetting GetContentSettingInternal(
203 const GURL& primary_url, 204 const GURL& primary_url,
204 const GURL& secondary_url, 205 const GURL& secondary_url,
205 ContentSettingsType content_type, 206 ContentSettingsType content_type,
206 const std::string& resource_identifier) const; 207 const std::string& resource_identifier) const;
207 208
208 void UnregisterObservers();
209
210 // Various migration methods (old cookie, popup and per-host data gets 209 // Various migration methods (old cookie, popup and per-host data gets
211 // migrated to the new format). 210 // migrated to the new format).
212 void MigrateObsoleteCookiePref(PrefService* prefs); 211 void MigrateObsoleteCookiePref();
213 212
214 // The profile we're associated with. 213 // Weak; owned by the Profile.
215 Profile* profile_; 214 PrefService* prefs_;
216 215
217 NotificationRegistrar notification_registrar_;
218 PrefChangeRegistrar pref_change_registrar_; 216 PrefChangeRegistrar pref_change_registrar_;
219 217
220 // Whether this settings map is for an OTR session. 218 // Whether this settings map is for an OTR session.
221 bool is_off_the_record_; 219 bool is_off_the_record_;
222 220
223 // Whether we are currently updating preferences, this is used to ignore 221 // Whether we are currently updating preferences, this is used to ignore
224 // notifications from the preferences service that we triggered ourself. 222 // notifications from the preferences service that we triggered ourself.
225 bool updating_preferences_; 223 bool updating_preferences_;
226 224
227 // Default content setting providers. 225 // Default content setting providers.
228 std::vector<linked_ptr<content_settings::DefaultProviderInterface> > 226 std::vector<linked_ptr<content_settings::DefaultProviderInterface> >
229 default_content_settings_providers_; 227 default_content_settings_providers_;
230 228
231 // Content setting providers. 229 // Content setting providers.
232 std::vector<linked_ptr<content_settings::ProviderInterface> > 230 std::vector<linked_ptr<content_settings::ProviderInterface> >
233 content_settings_providers_; 231 content_settings_providers_;
234 232
235 // Used around accesses to the following objects to guarantee thread safety. 233 // Used around accesses to the following objects to guarantee thread safety.
236 mutable base::Lock lock_; 234 mutable base::Lock lock_;
237 235
238 // Misc global settings. 236 // Misc global settings.
239 bool block_third_party_cookies_; 237 bool block_third_party_cookies_;
240 bool is_block_third_party_cookies_managed_; 238 bool is_block_third_party_cookies_managed_;
241 239
242 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); 240 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap);
243 }; 241 };
244 242
245 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ 243 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698