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

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

Issue 439913002: Add a cache for FillFontFamilyMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 32 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
33 #include "chrome/browser/defaults.h" 33 #include "chrome/browser/defaults.h"
34 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" 34 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
35 #include "chrome/browser/download/download_prefs.h" 35 #include "chrome/browser/download/download_prefs.h"
36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" 36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h"
37 #include "chrome/browser/extensions/extension_service.h" 37 #include "chrome/browser/extensions/extension_service.h"
38 #include "chrome/browser/extensions/extension_util.h" 38 #include "chrome/browser/extensions/extension_util.h"
39 #include "chrome/browser/extensions/extension_web_ui.h" 39 #include "chrome/browser/extensions/extension_web_ui.h"
40 #include "chrome/browser/extensions/extension_webkit_preferences.h" 40 #include "chrome/browser/extensions/extension_webkit_preferences.h"
41 #include "chrome/browser/extensions/suggest_permission_util.h" 41 #include "chrome/browser/extensions/suggest_permission_util.h"
42 #include "chrome/browser/font_family_cache.h"
42 #include "chrome/browser/geolocation/chrome_access_token_store.h" 43 #include "chrome/browser/geolocation/chrome_access_token_store.h"
43 #include "chrome/browser/geolocation/geolocation_permission_context.h" 44 #include "chrome/browser/geolocation/geolocation_permission_context.h"
44 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" 45 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
45 #include "chrome/browser/media/cast_transport_host_filter.h" 46 #include "chrome/browser/media/cast_transport_host_filter.h"
46 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 47 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
47 #include "chrome/browser/media/midi_permission_context.h" 48 #include "chrome/browser/media/midi_permission_context.h"
48 #include "chrome/browser/media/midi_permission_context_factory.h" 49 #include "chrome/browser/media/midi_permission_context_factory.h"
49 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" 50 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
50 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" 51 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
51 #include "chrome/browser/net/chrome_net_log.h" 52 #include "chrome/browser/net/chrome_net_log.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 496
496 std::string common_name; 497 std::string common_name;
497 if (filter.GetString("ISSUER.CN", &common_name) && 498 if (filter.GetString("ISSUER.CN", &common_name) &&
498 (cert.issuer().common_name == common_name)) { 499 (cert.issuer().common_name == common_name)) {
499 return true; 500 return true;
500 } 501 }
501 return false; 502 return false;
502 } 503 }
503 504
504 #if !defined(OS_ANDROID) 505 #if !defined(OS_ANDROID)
505 // Fills |map| with the per-script font prefs under path |map_name|. 506 void FillFontFamilyMap(PrefService* prefs,
506 void FillFontFamilyMap(const PrefService* prefs,
507 const char* map_name, 507 const char* map_name,
508 content::ScriptFontFamilyMap* map) { 508 content::ScriptFontFamilyMap* map) {
509 // TODO(falken): Get rid of the brute-force scan over possible 509 typedef base::ScopedPtrHashMap<const char*, PrefServiceCache>
510 // (font family / script) combinations - see http://crbug.com/308095. 510 PrefServiceCacheMap;
511 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { 511 PrefServiceCacheMap* caches = prefs->GetPrefsCaches();
512 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; 512 chrome::FontFamilyCache* cache;
513 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); 513 PrefServiceCacheMap::const_iterator it =
514 std::string font_family = prefs->GetString(pref_name.c_str()); 514 caches->find(chrome::kFontFamilyCacheKey);
515 if (!font_family.empty()) 515 if (it == caches->end()) {
516 (*map)[script] = base::UTF8ToUTF16(font_family); 516 scoped_ptr<PrefServiceCache> new_cache(new chrome::FontFamilyCache(prefs));
517 cache = static_cast<chrome::FontFamilyCache*>(new_cache.get());
518 caches->add(chrome::kFontFamilyCacheKey, new_cache.Pass());
519 } else {
520 cache = static_cast<chrome::FontFamilyCache*>(it->second);
517 } 521 }
522
523 cache->FillFontFamilyMap(map_name, map);
518 } 524 }
519 525
520 #if defined(OS_POSIX) && !defined(OS_MACOSX) 526 #if defined(OS_POSIX) && !defined(OS_MACOSX)
521 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( 527 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
522 const std::string& process_type) { 528 const std::string& process_type) {
523 base::FilePath dumps_path; 529 base::FilePath dumps_path;
524 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); 530 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path);
525 { 531 {
526 ANNOTATE_SCOPED_MEMORY_LEAK; 532 ANNOTATE_SCOPED_MEMORY_LEAK;
527 bool upload = (getenv(env_vars::kHeadless) == NULL); 533 bool upload = (getenv(env_vars::kHeadless) == NULL);
(...skipping 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2950 switches::kDisableWebRtcEncryption, 2956 switches::kDisableWebRtcEncryption,
2951 }; 2957 };
2952 to_command_line->CopySwitchesFrom(from_command_line, 2958 to_command_line->CopySwitchesFrom(from_command_line,
2953 kWebRtcDevSwitchNames, 2959 kWebRtcDevSwitchNames,
2954 arraysize(kWebRtcDevSwitchNames)); 2960 arraysize(kWebRtcDevSwitchNames));
2955 } 2961 }
2956 } 2962 }
2957 #endif // defined(ENABLE_WEBRTC) 2963 #endif // defined(ENABLE_WEBRTC)
2958 2964
2959 } // namespace chrome 2965 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698