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

Side by Side Diff: content/common/dwrite_font_platform_win.cc

Issue 1122163002: Ensure that the DirectWrite font cache works in Chrome canary on Windows 8+ with AppContainer prote… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased to tip Created 5 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 "content/public/common/dwrite_font_platform_win.h" 5 #include "content/public/common/dwrite_font_platform_win.h"
6 6
7 #include <dwrite.h> 7 #include <dwrite.h>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 bool FontCollectionLoader::IsFileCached(UINT32 font_key) { 914 bool FontCollectionLoader::IsFileCached(UINT32 font_key) {
915 if (!cache_.get() || cache_->memory() == NULL) { 915 if (!cache_.get() || cache_->memory() == NULL) {
916 return false; 916 return false;
917 } 917 }
918 CacheMap::iterator iter = cache_map_.find( 918 CacheMap::iterator iter = cache_map_.find(
919 GetFontNameFromKey(font_key).c_str()); 919 GetFontNameFromKey(font_key).c_str());
920 return iter != cache_map_.end();; 920 return iter != cache_map_.end();;
921 } 921 }
922 922
923 bool FontCollectionLoader::LoadCacheFile() { 923 bool FontCollectionLoader::LoadCacheFile() {
924 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 924 std::string font_cache_handle_string =
925 switches::kFontCacheSharedMemSuffix)) { 925 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
926 return false; 926 switches::kFontCacheSharedHandle);
927 } 927 if (font_cache_handle_string.empty())
928 base::SharedMemory* shared_mem = new base::SharedMemory();
929 std::string name(content::kFontCacheSharedSectionName);
930 name.append(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
931 switches::kFontCacheSharedMemSuffix));
932 if (!shared_mem->Open(name.c_str(), true))
933 return false; 928 return false;
934 929
930 base::SharedMemoryHandle font_cache_handle = NULL;
931 base::StringToUint(font_cache_handle_string,
932 reinterpret_cast<unsigned int*>(&font_cache_handle));
933 DCHECK(font_cache_handle);
934
935 base::SharedMemory* shared_mem = new base::SharedMemory(
936 font_cache_handle, true);
935 // Map while file 937 // Map while file
936 shared_mem->Map(0); 938 shared_mem->Map(0);
937 939
938 cache_.reset(shared_mem); 940 cache_.reset(shared_mem);
939 941
940 if (!ValidateAndLoadCacheMap()) { 942 if (!ValidateAndLoadCacheMap()) {
941 cache_.reset(); 943 cache_.reset();
942 return false; 944 return false;
943 } 945 }
944 946
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 g_shared_font_cache.Set(mapping); 1220 g_shared_font_cache.Set(mapping);
1219 1221
1220 return true; 1222 return true;
1221 } 1223 }
1222 1224
1223 bool BuildFontCache(const base::FilePath& file) { 1225 bool BuildFontCache(const base::FilePath& file) {
1224 return BuildFontCacheInternal(file.value().c_str()); 1226 return BuildFontCacheInternal(file.value().c_str());
1225 } 1227 }
1226 1228
1227 } // namespace content 1229 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/common/sandbox_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698