Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <dwrite.h> | 9 #include <dwrite.h> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 return iter != cache_map_.end();; | 930 return iter != cache_map_.end();; |
| 931 } | 931 } |
| 932 | 932 |
| 933 bool FontCollectionLoader::LoadCacheFile() { | 933 bool FontCollectionLoader::LoadCacheFile() { |
| 934 std::string font_cache_handle_string = | 934 std::string font_cache_handle_string = |
| 935 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 935 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 936 switches::kFontCacheSharedHandle); | 936 switches::kFontCacheSharedHandle); |
| 937 if (font_cache_handle_string.empty()) | 937 if (font_cache_handle_string.empty()) |
| 938 return false; | 938 return false; |
| 939 | 939 |
| 940 base::SharedMemoryHandle font_cache_handle = NULL; | 940 unsigned int handle_int; |
| 941 base::StringToUint(font_cache_handle_string, | 941 base::StringToUint(font_cache_handle_string, |
| 942 reinterpret_cast<unsigned int*>(&font_cache_handle)); | 942 reinterpret_cast<unsigned int*>(&handle_int)); |
|
Tom Sepez
2015/09/23 22:06:13
note: technically wrong, this needs to be the addr
erikchen
2015/09/24 00:44:18
handle_int was a poorly named variable - it was ac
| |
| 943 DCHECK(font_cache_handle); | 943 DCHECK(handle_int); |
| 944 base::SharedMemoryHandle font_cache_handle(LongToHandle(handle_int), | |
| 945 base::GetCurrentProcId()); | |
| 944 | 946 |
| 945 base::SharedMemory* shared_mem = new base::SharedMemory( | 947 base::SharedMemory* shared_mem = new base::SharedMemory( |
| 946 font_cache_handle, true); | 948 font_cache_handle, true); |
| 947 // Map the cache file into memory. | 949 // Map the cache file into memory. |
| 948 shared_mem->Map(0); | 950 shared_mem->Map(0); |
| 949 | 951 |
| 950 cache_.reset(shared_mem); | 952 cache_.reset(shared_mem); |
| 951 | 953 |
| 952 if (base::StartsWith(base::FieldTrialList::FindFullName("LightSpeed"), | 954 if (base::StartsWith(base::FieldTrialList::FindFullName("LightSpeed"), |
| 953 "PrefetchDWriteFontCache", | 955 "PrefetchDWriteFontCache", |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1254 g_shared_font_cache.Set(mapping); | 1256 g_shared_font_cache.Set(mapping); |
| 1255 | 1257 |
| 1256 return true; | 1258 return true; |
| 1257 } | 1259 } |
| 1258 | 1260 |
| 1259 bool BuildFontCache(const base::FilePath& file) { | 1261 bool BuildFontCache(const base::FilePath& file) { |
| 1260 return BuildFontCacheInternal(file.value().c_str()); | 1262 return BuildFontCacheInternal(file.value().c_str()); |
| 1261 } | 1263 } |
| 1262 | 1264 |
| 1263 } // namespace content | 1265 } // namespace content |
| OLD | NEW |