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

Side by Side Diff: chrome/browser/font_family_cache.cc

Issue 2842833003: Update SupportsUserData uses with unique_ptr. (Closed)
Patch Set: rebase Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/font_family_cache.h" 5 #include "chrome/browser/font_family_cache.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/memory/ptr_util.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/pref_font_webkit_names.h" 16 #include "chrome/common/pref_font_webkit_names.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
18 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
19 20
20 // Identifies the user data on the profile. 21 // Identifies the user data on the profile.
(...skipping 10 matching lines...) Expand all
31 FontFamilyCache::~FontFamilyCache() { 32 FontFamilyCache::~FontFamilyCache() {
32 } 33 }
33 34
34 void FontFamilyCache::FillFontFamilyMap(Profile* profile, 35 void FontFamilyCache::FillFontFamilyMap(Profile* profile,
35 const char* map_name, 36 const char* map_name,
36 content::ScriptFontFamilyMap* map) { 37 content::ScriptFontFamilyMap* map) {
37 FontFamilyCache* cache = 38 FontFamilyCache* cache =
38 static_cast<FontFamilyCache*>(profile->GetUserData(&kFontFamilyCacheKey)); 39 static_cast<FontFamilyCache*>(profile->GetUserData(&kFontFamilyCacheKey));
39 if (!cache) { 40 if (!cache) {
40 cache = new FontFamilyCache(profile); 41 cache = new FontFamilyCache(profile);
41 // The profile takes ownership of |cache|. 42 profile->SetUserData(&kFontFamilyCacheKey, base::WrapUnique(cache));
42 profile->SetUserData(&kFontFamilyCacheKey, cache);
43 } 43 }
44 44
45 cache->FillFontFamilyMap(map_name, map); 45 cache->FillFontFamilyMap(map_name, map);
46 } 46 }
47 47
48 void FontFamilyCache::FillFontFamilyMap(const char* map_name, 48 void FontFamilyCache::FillFontFamilyMap(const char* map_name,
49 content::ScriptFontFamilyMap* map) { 49 content::ScriptFontFamilyMap* map) {
50 // TODO(falken): Get rid of the brute-force scan over possible 50 // TODO(falken): Get rid of the brute-force scan over possible
51 // (font family / script) combinations - see http://crbug.com/308095. 51 // (font family / script) combinations - see http://crbug.com/308095.
52 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { 52 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 } 128 }
129 } 129 }
130 130
131 void FontFamilyCache::Observe(int type, 131 void FontFamilyCache::Observe(int type,
132 const content::NotificationSource& source, 132 const content::NotificationSource& source,
133 const content::NotificationDetails& details) { 133 const content::NotificationDetails& details) {
134 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 134 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
135 profile_pref_registrar_.RemoveAll(); 135 profile_pref_registrar_.RemoveAll();
136 } 136 }
OLDNEW
« no previous file with comments | « chrome/browser/data_use_measurement/data_use_web_contents_observer.cc ('k') | chrome/browser/infobars/infobar_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698