| 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/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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 #include <wrl/implements.h> | 12 #include <wrl/implements.h> |
| 13 #include <wrl/wrappers/corewrappers.h> | 13 #include <wrl/wrappers/corewrappers.h> |
| 14 | 14 |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 26 #include "base/path_service.h" | 26 #include "base/path_service.h" |
| 27 #include "base/process/process_handle.h" | 27 #include "base/process/process_handle.h" |
| 28 #include "base/stl_util.h" | 28 #include "base/stl_util.h" |
| 29 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
| 30 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
| 31 #include "base/synchronization/lock.h" | 31 #include "base/synchronization/lock.h" |
| 32 #include "base/time/time.h" | 32 #include "base/time/time.h" |
| 33 #include "base/win/registry.h" | 33 #include "base/win/registry.h" |
| 34 #include "base/win/scoped_comptr.h" | 34 #include "base/win/scoped_comptr.h" |
| 35 #include "content/public/common/content_switches.h" | 35 #include "content/public/common/content_switches.h" |
| 36 #include "content/public/common/dwrite_font_cache_win.h" |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| 39 // Font Cache implementation short story: | 40 // Font Cache implementation short story: |
| 40 // Due to our sandboxing restrictions, we cannot connect to Windows font cache | 41 // Due to our sandboxing restrictions, we cannot connect to Windows font cache |
| 41 // service from Renderer and need to use DirectWrite isolated font loading | 42 // service from Renderer and need to use DirectWrite isolated font loading |
| 42 // mechanism. | 43 // mechanism. |
| 43 // DirectWrite needs to be initialized before any of the API could be used. | 44 // DirectWrite needs to be initialized before any of the API could be used. |
| 44 // During initialization DirectWrite loads all font files and populates | 45 // During initialization DirectWrite loads all font files and populates |
| 45 // internal cache, we refer this phase as enumeration and we are trying | 46 // internal cache, we refer this phase as enumeration and we are trying |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 CHECK(false); | 1166 CHECK(false); |
| 1166 return false; | 1167 return false; |
| 1167 } | 1168 } |
| 1168 | 1169 |
| 1169 DCHECK(!g_shared_font_cache.IsValid()); | 1170 DCHECK(!g_shared_font_cache.IsValid()); |
| 1170 g_shared_font_cache.Set(mapping); | 1171 g_shared_font_cache.Set(mapping); |
| 1171 | 1172 |
| 1172 return true; | 1173 return true; |
| 1173 } | 1174 } |
| 1174 | 1175 |
| 1175 bool BuildFontCache(const base::FilePath& file) { | 1176 // Assumption for this function is that it will get called through a posted task |
| 1176 return BuildFontCacheInternal(file.value().c_str()); | 1177 // on FILE thread. |
| 1178 bool BuildAndLoadFontCache(const base::FilePath& file) { |
| 1179 if (BuildFontCacheInternal(file.value().c_str())) |
| 1180 return LoadFontCache(file); |
| 1181 return false; |
| 1177 } | 1182 } |
| 1178 | 1183 |
| 1179 } // namespace content | 1184 } // namespace content |
| OLD | NEW |