OLD | NEW |
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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 #include <stddef.h> | 6 #include <stddef.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 memcpy(font_shmem_->memory(), font_data.c_str(), font_data_length_); | 60 memcpy(font_shmem_->memory(), font_data.c_str(), font_data_length_); |
61 if (!font_shmem_->Unmap()) { | 61 if (!font_shmem_->Unmap()) { |
62 LOG(ERROR) << "SharedMemory::Unmap failed"; | 62 LOG(ERROR) << "SharedMemory::Unmap failed"; |
63 return false; | 63 return false; |
64 } | 64 } |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 bool FontLoadingTestCase::SandboxedTest() { | 68 bool FontLoadingTestCase::SandboxedTest() { |
69 base::SharedMemoryHandle shmem_handle; | 69 base::SharedMemoryHandle shmem_handle = font_shmem_->handle().Duplicate(); |
70 if (!font_shmem_->ShareToProcess(base::kNullProcessHandle, &shmem_handle)) { | 70 if (!shmem_handle.IsValid()) { |
71 LOG(ERROR) << "SharedMemory::ShareToProcess failed"; | 71 LOG(ERROR) << "SharedMemory handle duplication failed"; |
72 return false; | 72 return false; |
73 } | 73 } |
74 | 74 |
75 CGFontRef cg_font_ref; | 75 CGFontRef cg_font_ref; |
76 if (!FontLoader::CGFontRefFromBuffer(shmem_handle, font_data_length_, | 76 if (!FontLoader::CGFontRefFromBuffer(shmem_handle, font_data_length_, |
77 &cg_font_ref)) { | 77 &cg_font_ref)) { |
78 LOG(ERROR) << "Call to CreateCGFontFromBuffer() failed"; | 78 LOG(ERROR) << "Call to CreateCGFontFromBuffer() failed"; |
79 return false; | 79 return false; |
80 } | 80 } |
81 | 81 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 static_cast<const char *>(result.font_data.memory()), | 122 static_cast<const char *>(result.font_data.memory()), |
123 result.font_data_size); | 123 result.font_data_size); |
124 | 124 |
125 ASSERT_TRUE(RunTestInSandbox(SANDBOX_TYPE_RENDERER, | 125 ASSERT_TRUE(RunTestInSandbox(SANDBOX_TYPE_RENDERER, |
126 "FontLoadingTestCase", temp_file_path.value().c_str())); | 126 "FontLoadingTestCase", temp_file_path.value().c_str())); |
127 temp_file_closer.reset(); | 127 temp_file_closer.reset(); |
128 ASSERT_TRUE(base::DeleteFile(temp_file_path, false)); | 128 ASSERT_TRUE(base::DeleteFile(temp_file_path, false)); |
129 } | 129 } |
130 | 130 |
131 } // namespace content | 131 } // namespace content |
OLD | NEW |