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

Side by Side Diff: pdf/pdf.cc

Issue 819473002: Load V8 external data prior to initializng PDFium SDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 "pdf/pdf.h" 5 #include "pdf/pdf.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "pdf/instance.h" 13 #include "pdf/instance.h"
14 #include "pdf/out_of_process_instance.h" 14 #include "pdf/out_of_process_instance.h"
15 #include "ppapi/c/ppp.h" 15 #include "ppapi/c/ppp.h"
16 #include "ppapi/cpp/private/pdf.h" 16 #include "ppapi/cpp/private/pdf.h"
17 #include "v8/include/v8.h"
17 18
18 bool g_sdk_initialized_via_pepper = false; 19 bool g_sdk_initialized_via_pepper = false;
19 20
20 // The Mac release builds discard CreateModule and the entire PDFModule 21 // The Mac release builds discard CreateModule and the entire PDFModule
21 // definition because they are not referenced here. This causes the Pepper 22 // definition because they are not referenced here. This causes the Pepper
22 // exports (PPP_GetInterface etc) to not be exported. So we force the linker 23 // exports (PPP_GetInterface etc) to not be exported. So we force the linker
23 // to include this code by using __attribute__((used)). 24 // to include this code by using __attribute__((used)).
24 #if __GNUC__ >= 4 25 #if __GNUC__ >= 4
25 #define PDF_USED __attribute__((used)) 26 #define PDF_USED __attribute__((used))
26 #else 27 #else
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 g_sdk_initialized_via_pepper = false; 91 g_sdk_initialized_via_pepper = false;
91 } 92 }
92 } 93 }
93 94
94 bool PDFModule::Init() { 95 bool PDFModule::Init() {
95 return true; 96 return true;
96 } 97 }
97 98
98 pp::Instance* PDFModule::CreateInstance(PP_Instance instance) { 99 pp::Instance* PDFModule::CreateInstance(PP_Instance instance) {
99 if (!g_sdk_initialized_via_pepper) { 100 if (!g_sdk_initialized_via_pepper) {
101 v8::StartupData natives;
102 v8::StartupData snapshot;
103 pp::PDF::GetV8ExternalSnapshotData(pp::InstanceHandle(instance),
104 &natives.data, &natives.raw_size,
105 &snapshot.data, &snapshot.raw_size);
106 if (natives.data) {
107 v8::V8::SetNativesDataBlob(&natives);
108 v8::V8::SetSnapshotDataBlob(&snapshot);
109 }
100 if (!chrome_pdf::InitializeSDK()) 110 if (!chrome_pdf::InitializeSDK())
101 return NULL; 111 return NULL;
102 g_sdk_initialized_via_pepper = true; 112 g_sdk_initialized_via_pepper = true;
103 } 113 }
104 114
105 if (pp::PDF::IsOutOfProcess(pp::InstanceHandle(instance))) 115 if (pp::PDF::IsOutOfProcess(pp::InstanceHandle(instance)))
106 return new OutOfProcessInstance(instance); 116 return new OutOfProcessInstance(instance);
107 return new Instance(instance); 117 return new Instance(instance);
108 } 118 }
109 119
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 autorotate); 269 autorotate);
260 bool ret = engine_exports->RenderPDFPageToBitmap( 270 bool ret = engine_exports->RenderPDFPageToBitmap(
261 pdf_buffer, pdf_buffer_size, page_number, settings, bitmap_buffer); 271 pdf_buffer, pdf_buffer_size, page_number, settings, bitmap_buffer);
262 if (!g_sdk_initialized_via_pepper) { 272 if (!g_sdk_initialized_via_pepper) {
263 chrome_pdf::ShutdownSDK(); 273 chrome_pdf::ShutdownSDK();
264 } 274 }
265 return ret; 275 return ret;
266 } 276 }
267 277
268 } // extern "C" 278 } // extern "C"
OLDNEW
« pdf/out_of_process_instance.cc ('K') | « pdf/out_of_process_instance.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698