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

Side by Side Diff: fpdfsdk/src/fpdfview.cpp

Issue 1367033002: Pass v8::Isolate to PDFium at init time. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix leak, clear globals while we're at it. 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 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../core/include/fxcodec/fx_codec.h" 7 #include "../../core/include/fxcodec/fx_codec.h"
8 #include "../../core/include/fxcrt/fx_safe_types.h" 8 #include "../../core/include/fxcrt/fx_safe_types.h"
9 #include "../../public/fpdf_ext.h" 9 #include "../../public/fpdf_ext.h"
10 #include "../../public/fpdf_progressive.h" 10 #include "../../public/fpdf_progressive.h"
11 #include "../../public/fpdfview.h" 11 #include "../../public/fpdfview.h"
12 #include "../../third_party/base/nonstd_unique_ptr.h" 12 #include "../../third_party/base/nonstd_unique_ptr.h"
13 #include "../../third_party/base/numerics/safe_conversions_impl.h" 13 #include "../../third_party/base/numerics/safe_conversions_impl.h"
14 #include "../include/fsdk_define.h" 14 #include "../include/fsdk_define.h"
15 #include "../include/fsdk_mgr.h" 15 #include "../include/fsdk_mgr.h"
16 #include "../include/fsdk_rendercontext.h" 16 #include "../include/fsdk_rendercontext.h"
17 #include "../include/jsapi/fxjs_v8.h"
17 18
18 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) { 19 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) {
19 if (pFileAccess) 20 if (pFileAccess)
20 m_FileAccess = *pFileAccess; 21 m_FileAccess = *pFileAccess;
21 } 22 }
22 23
23 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, 24 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer,
24 FX_FILESIZE offset, 25 FX_FILESIZE offset,
25 size_t size) { 26 size_t size) {
26 if (offset < 0) { 27 if (offset < 0) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 CPDF_ModuleMgr::Get()->SetCodecModule(g_pCodecModule); 103 CPDF_ModuleMgr::Get()->SetCodecModule(g_pCodecModule);
103 CPDF_ModuleMgr::Get()->InitPageModule(); 104 CPDF_ModuleMgr::Get()->InitPageModule();
104 CPDF_ModuleMgr::Get()->InitRenderModule(); 105 CPDF_ModuleMgr::Get()->InitRenderModule();
105 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get(); 106 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get();
106 if (pModuleMgr) { 107 if (pModuleMgr) {
107 pModuleMgr->LoadEmbeddedGB1CMaps(); 108 pModuleMgr->LoadEmbeddedGB1CMaps();
108 pModuleMgr->LoadEmbeddedJapan1CMaps(); 109 pModuleMgr->LoadEmbeddedJapan1CMaps();
109 pModuleMgr->LoadEmbeddedCNS1CMaps(); 110 pModuleMgr->LoadEmbeddedCNS1CMaps();
110 pModuleMgr->LoadEmbeddedKorea1CMaps(); 111 pModuleMgr->LoadEmbeddedKorea1CMaps();
111 } 112 }
113 if (cfg && cfg->version >= 2) {
Lei Zhang 2015/10/02 22:02:15 Do we want to nag callers using API version 1, or
Tom Sepez 2015/10/02 22:46:50 I want to continue to seamlessly support those emb
114 FXJS_Initialize(cfg->m_v8EmbedderSlot,
115 reinterpret_cast<v8::Isolate*>(cfg->m_pIsolate));
116 }
112 } 117 }
113 118
114 DLLEXPORT void STDCALL FPDF_DestroyLibrary() { 119 DLLEXPORT void STDCALL FPDF_DestroyLibrary() {
115 #if _FX_OS_ == _FX_LINUX_EMBEDDED_ 120 #if _FX_OS_ == _FX_LINUX_EMBEDDED_
116 delete g_pFontMapper; 121 delete g_pFontMapper;
117 g_pFontMapper = nullptr; 122 g_pFontMapper = nullptr;
118 #endif 123 #endif
119 CPDF_ModuleMgr::Destroy(); 124 CPDF_ModuleMgr::Destroy();
120 CFX_GEModule::Destroy(); 125 CFX_GEModule::Destroy();
121 delete g_pCodecModule; 126 delete g_pCodecModule;
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 if (!buffer) { 914 if (!buffer) {
910 *buflen = len; 915 *buflen = len;
911 } else if (*buflen >= len) { 916 } else if (*buflen >= len) {
912 memcpy(buffer, utf16Name.c_str(), len); 917 memcpy(buffer, utf16Name.c_str(), len);
913 *buflen = len; 918 *buflen = len;
914 } else { 919 } else {
915 *buflen = -1; 920 *buflen = -1;
916 } 921 }
917 return (FPDF_DEST)pDestObj; 922 return (FPDF_DEST)pDestObj;
918 } 923 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698