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

Side by Side Diff: testing/test_support.cpp

Issue 2068563002: Fix memory leaks with V8 startup data. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix non-V8 builds Created 4 years, 6 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
« no previous file with comments | « testing/embedder_test.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 PDFium Authors. All rights reserved. 1 // Copyright 2015 PDFium 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 "testing/test_support.h" 5 #include "testing/test_support.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 #ifdef PDF_ENABLE_V8 152 #ifdef PDF_ENABLE_V8
153 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 153 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
154 bool InitializeV8ForPDFium(const std::string& exe_path, 154 bool InitializeV8ForPDFium(const std::string& exe_path,
155 const std::string& bin_dir, 155 const std::string& bin_dir,
156 v8::StartupData* natives_blob, 156 v8::StartupData* natives_blob,
157 v8::StartupData* snapshot_blob, 157 v8::StartupData* snapshot_blob,
158 v8::Platform** platform) { 158 v8::Platform** platform) {
159 InitializeV8Common(exe_path.c_str(), platform); 159 InitializeV8Common(exe_path.c_str(), platform);
160 if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob)) 160 if (natives_blob && snapshot_blob) {
161 return false; 161 if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob))
162 if (!GetExternalData(exe_path, bin_dir, "snapshot_blob.bin", snapshot_blob)) 162 return false;
163 return false; 163 if (!GetExternalData(exe_path, bin_dir, "snapshot_blob.bin", snapshot_blob))
164 v8::V8::SetNativesDataBlob(natives_blob); 164 return false;
165 v8::V8::SetSnapshotDataBlob(snapshot_blob); 165 v8::V8::SetNativesDataBlob(natives_blob);
166 v8::V8::SetSnapshotDataBlob(snapshot_blob);
167 }
166 return true; 168 return true;
167 } 169 }
168 #else // V8_USE_EXTERNAL_STARTUP_DATA 170 #else // V8_USE_EXTERNAL_STARTUP_DATA
169 bool InitializeV8ForPDFium(const std::string& exe_path, 171 bool InitializeV8ForPDFium(const std::string& exe_path,
170 v8::Platform** platform) { 172 v8::Platform** platform) {
171 InitializeV8Common(exe_path.c_str(), platform); 173 InitializeV8Common(exe_path.c_str(), platform);
172 return true; 174 return true;
173 } 175 }
174 #endif // V8_USE_EXTERNAL_STARTUP_DATA 176 #endif // V8_USE_EXTERNAL_STARTUP_DATA
175 #endif // PDF_ENABLE_V8 177 #endif // PDF_ENABLE_V8
(...skipping 25 matching lines...) Expand all
201 } 203 }
202 204
203 // static 205 // static
204 int TestSaver::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, 206 int TestSaver::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite,
205 const void* data, 207 const void* data,
206 unsigned long size) { 208 unsigned long size) {
207 TestSaver* pThis = static_cast<TestSaver*>(pFileWrite); 209 TestSaver* pThis = static_cast<TestSaver*>(pFileWrite);
208 pThis->m_String.append(static_cast<const char*>(data), size); 210 pThis->m_String.append(static_cast<const char*>(data), size);
209 return 1; 211 return 1;
210 } 212 }
OLDNEW
« no previous file with comments | « testing/embedder_test.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698