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

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

Issue 1320783002: Make SharedMemoryHandle a class on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ipc_global
Patch Set: Rebase. Created 5 years, 2 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 <windows.h> 7 #include <windows.h>
8 8
9 #include <dwrite.h> 9 #include <dwrite.h>
10 #include <limits>
10 #include <map> 11 #include <map>
11 #include <string> 12 #include <string>
12 #include <utility> 13 #include <utility>
13 #include <vector> 14 #include <vector>
14 #include <wrl/implements.h> 15 #include <wrl/implements.h>
15 #include <wrl/wrappers/corewrappers.h> 16 #include <wrl/wrappers/corewrappers.h>
16 17
17 #include "base/command_line.h" 18 #include "base/command_line.h"
18 #include "base/debug/alias.h" 19 #include "base/debug/alias.h"
19 #include "base/debug/crash_logging.h" 20 #include "base/debug/crash_logging.h"
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 return iter != cache_map_.end();; 931 return iter != cache_map_.end();;
931 } 932 }
932 933
933 bool FontCollectionLoader::LoadCacheFile() { 934 bool FontCollectionLoader::LoadCacheFile() {
934 std::string font_cache_handle_string = 935 std::string font_cache_handle_string =
935 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 936 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
936 switches::kFontCacheSharedHandle); 937 switches::kFontCacheSharedHandle);
937 if (font_cache_handle_string.empty()) 938 if (font_cache_handle_string.empty())
938 return false; 939 return false;
939 940
940 base::SharedMemoryHandle font_cache_handle = NULL; 941 unsigned int handle_uint;
941 base::StringToUint(font_cache_handle_string, 942 base::StringToUint(font_cache_handle_string, &handle_uint);
942 reinterpret_cast<unsigned int*>(&font_cache_handle)); 943 DCHECK(handle_uint);
943 DCHECK(font_cache_handle); 944 if (handle_uint > static_cast<unsigned int>(std::numeric_limits<long>::max()))
945 return false;
946 base::SharedMemoryHandle font_cache_handle(LongToHandle(handle_uint),
947 base::GetCurrentProcId());
944 948
945 base::SharedMemory* shared_mem = new base::SharedMemory( 949 base::SharedMemory* shared_mem = new base::SharedMemory(
946 font_cache_handle, true); 950 font_cache_handle, true);
947 // Map the cache file into memory. 951 // Map the cache file into memory.
948 shared_mem->Map(0); 952 shared_mem->Map(0);
949 953
950 cache_.reset(shared_mem); 954 cache_.reset(shared_mem);
951 955
952 if (base::StartsWith(base::FieldTrialList::FindFullName("LightSpeed"), 956 if (base::StartsWith(base::FieldTrialList::FindFullName("LightSpeed"),
953 "PrefetchDWriteFontCache", 957 "PrefetchDWriteFontCache",
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 g_shared_font_cache.Set(mapping); 1258 g_shared_font_cache.Set(mapping);
1255 1259
1256 return true; 1260 return true;
1257 } 1261 }
1258 1262
1259 bool BuildFontCache(const base::FilePath& file) { 1263 bool BuildFontCache(const base::FilePath& file) {
1260 return BuildFontCacheInternal(file.value().c_str()); 1264 return BuildFontCacheInternal(file.value().c_str());
1261 } 1265 }
1262 1266
1263 } // namespace content 1267 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/common/gpu/client/gpu_channel_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698