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

Side by Side Diff: samples/pdfium_test.cc

Issue 1381633008: Merge to XFA: Pass v8::Isolate to PDFium at init time. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <limits.h> 5 #include <limits.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 #include <wchar.h> 9 #include <wchar.h>
10 10
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 430
431 void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) { 431 void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) {
432 } 432 }
433 433
434 void RenderPdf(const std::string& name, const char* pBuf, size_t len, 434 void RenderPdf(const std::string& name, const char* pBuf, size_t len,
435 const Options& options) { 435 const Options& options) {
436 fprintf(stderr, "Rendering PDF file %s.\n", name.c_str()); 436 fprintf(stderr, "Rendering PDF file %s.\n", name.c_str());
437 437
438 IPDF_JSPLATFORM platform_callbacks; 438 IPDF_JSPLATFORM platform_callbacks;
439 memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); 439 memset(&platform_callbacks, '\0', sizeof(platform_callbacks));
440 platform_callbacks.version = 2; 440 platform_callbacks.version = 3;
441 platform_callbacks.app_alert = ExampleAppAlert; 441 platform_callbacks.app_alert = ExampleAppAlert;
442 platform_callbacks.Doc_gotoPage = ExampleDocGotoPage; 442 platform_callbacks.Doc_gotoPage = ExampleDocGotoPage;
443 443
444 FPDF_FORMFILLINFO form_callbacks; 444 FPDF_FORMFILLINFO form_callbacks;
445 memset(&form_callbacks, '\0', sizeof(form_callbacks)); 445 memset(&form_callbacks, '\0', sizeof(form_callbacks));
446 form_callbacks.version = 2; 446 form_callbacks.version = 2;
447 form_callbacks.m_pJsPlatform = &platform_callbacks; 447 form_callbacks.m_pJsPlatform = &platform_callbacks;
448 448
449 TestLoader loader(pBuf, len); 449 TestLoader loader(pBuf, len);
450 450
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 v8::StartupData natives; 614 v8::StartupData natives;
615 v8::StartupData snapshot; 615 v8::StartupData snapshot;
616 if (!GetExternalData(options, "natives_blob.bin", &natives) || 616 if (!GetExternalData(options, "natives_blob.bin", &natives) ||
617 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) { 617 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) {
618 return 1; 618 return 1;
619 } 619 }
620 v8::V8::SetNativesDataBlob(&natives); 620 v8::V8::SetNativesDataBlob(&natives);
621 v8::V8::SetSnapshotDataBlob(&snapshot); 621 v8::V8::SetSnapshotDataBlob(&snapshot);
622 #endif // V8_USE_EXTERNAL_STARTUP_DATA 622 #endif // V8_USE_EXTERNAL_STARTUP_DATA
623 623
624 if (options.font_directory.empty()) { 624 FPDF_LIBRARY_CONFIG config;
625 FPDF_InitLibrary(); 625 config.version = 2;
626 } else { 626 config.m_pUserFontPaths = nullptr;
627 const char* path_array[2]; 627 config.m_pIsolate = nullptr;
628 config.m_v8EmbedderSlot = 0;
629
630 const char* path_array[2];
631 if (!options.font_directory.empty()) {
628 path_array[0] = options.font_directory.c_str(); 632 path_array[0] = options.font_directory.c_str();
629 path_array[1] = nullptr; 633 path_array[1] = nullptr;
630 FPDF_LIBRARY_CONFIG config;
631 config.version = 1;
632 config.m_pUserFontPaths = path_array; 634 config.m_pUserFontPaths = path_array;
633 FPDF_InitLibraryWithConfig(&config);
634 } 635 }
636 FPDF_InitLibraryWithConfig(&config);
635 637
636 UNSUPPORT_INFO unsuppored_info; 638 UNSUPPORT_INFO unsuppored_info;
637 memset(&unsuppored_info, '\0', sizeof(unsuppored_info)); 639 memset(&unsuppored_info, '\0', sizeof(unsuppored_info));
638 unsuppored_info.version = 1; 640 unsuppored_info.version = 1;
639 unsuppored_info.FSDK_UnSupport_Handler = ExampleUnsupportedHandler; 641 unsuppored_info.FSDK_UnSupport_Handler = ExampleUnsupportedHandler;
640 642
641 FSDK_SetUnSpObjProcessHandler(&unsuppored_info); 643 FSDK_SetUnSpObjProcessHandler(&unsuppored_info);
642 644
643 while (!files.empty()) { 645 while (!files.empty()) {
644 std::string filename = files.front(); 646 std::string filename = files.front();
645 files.pop_front(); 647 files.pop_front();
646 size_t file_length = 0; 648 size_t file_length = 0;
647 char* file_contents = GetFileContents(filename.c_str(), &file_length); 649 char* file_contents = GetFileContents(filename.c_str(), &file_length);
648 if (!file_contents) 650 if (!file_contents)
649 continue; 651 continue;
650 RenderPdf(filename, file_contents, file_length, options); 652 RenderPdf(filename, file_contents, file_length, options);
651 free(file_contents); 653 free(file_contents);
652 } 654 }
653 655
654 FPDF_DestroyLibrary(); 656 FPDF_DestroyLibrary();
655 v8::V8::ShutdownPlatform(); 657 v8::V8::ShutdownPlatform();
656 delete platform; 658 delete platform;
657 659
658 return 0; 660 return 0;
659 } 661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698