Remove NotificationService usage from FontFamilyCache.
FontPrefChangeNotifier automatically unregisters all registrars on
Profile destruction, so we can just delete this code.
(This was originally necessary because it used a PrefChangeRegistrar,
which isn't as smart.)
Bug: 268984
Change-Id: I332c6ac6d2033783b88dca8d369770c336a3c236
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832684
Commit-Queue: Evan Stade <[email protected]>
Reviewed-by: Colin Blundell <[email protected]>
Cr-Commit-Position: refs/heads/master@{#702418}
diff --git a/chrome/browser/font_family_cache.h b/chrome/browser/font_family_cache.h
index 36577f32..a99372e 100644
--- a/chrome/browser/font_family_cache.h
+++ b/chrome/browser/font_family_cache.h
@@ -12,8 +12,6 @@
#include "base/strings/string16.h"
#include "base/supports_user_data.h"
#include "chrome/browser/font_pref_change_notifier.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "content/public/common/web_preferences.h"
class PrefService;
@@ -29,8 +27,7 @@
// "content::ScriptFontFamilyMap". This is necessary since Chrome attempts to
// update content::ScriptFontFamilyMap 20000 times at startup. See
// https://crbug.com/308095.
-class FontFamilyCache : public base::SupportsUserData::Data,
- public content::NotificationObserver {
+class FontFamilyCache : public base::SupportsUserData::Data {
public:
explicit FontFamilyCache(Profile* profile);
~FontFamilyCache() override;
@@ -76,12 +73,6 @@
// Note: It is safe to remove the observer from the pref change callback.
void OnPrefsChanged(const std::string& pref_name);
- // content::NotificationObserver override.
- // Called when the profile is being destructed.
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
-
// Cache of font family preferences.
FontFamilyMap font_family_map_;
@@ -90,12 +81,13 @@
// PrefService, so there is no worry about an invalid pointer.
const PrefService* prefs_;
- // Reacts to profile font changes.
+ // Reacts to profile font changes. |font_change_registrar_| will be
+ // automatically unregistered when the FontPrefChangeNotifier is destroyed as
+ // part of Profile destruction, thus ensuring safe unregistration even though
+ // |this| is destroyed after the Profile destructor completes as part of
+ // Profile's super class destructor ~base::SupportsUserData.
FontPrefChangeNotifier::Registrar font_change_registrar_;
- // Listens for profile destruction.
- content::NotificationRegistrar notification_registrar_;
-
DISALLOW_COPY_AND_ASSIGN(FontFamilyCache);
};