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

Side by Side Diff: pdf/instance.cc

Issue 705623002: Initialize V8 in PDFium from external files (in-renderer process only). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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) 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 #include "pdf/instance.h" 5 #include "pdf/instance.h"
6 6
7 #include <algorithm> // for min() 7 #include <algorithm> // for min()
8 #define _USE_MATH_DEFINES // for M_PI 8 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 9 #include <cmath> // for log() and pow()
10 #include <math.h> 10 #include <math.h>
(...skipping 28 matching lines...) Expand all
39 #include "ppapi/cpp/private/pdf.h" 39 #include "ppapi/cpp/private/pdf.h"
40 #include "ppapi/cpp/rect.h" 40 #include "ppapi/cpp/rect.h"
41 #include "ppapi/cpp/resource.h" 41 #include "ppapi/cpp/resource.h"
42 #include "ppapi/cpp/url_request_info.h" 42 #include "ppapi/cpp/url_request_info.h"
43 #include "ui/events/keycodes/keyboard_codes.h" 43 #include "ui/events/keycodes/keyboard_codes.h"
44 44
45 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
46 #include "base/mac/mac_util.h" 46 #include "base/mac/mac_util.h"
47 #endif 47 #endif
48 48
49 #if !defined(OS_ANDROID) && defined(V8_USE_EXTERNAL_STARTUP_DATA)
raymes 2014/11/04 22:18:13 *You should be able to get rid of all the OS_ANDRO
baixo1 2014/11/07 21:35:34 Done.
50 #include "v8/include/v8.h"
raymes 2014/11/04 22:18:13 I just want to make sure - does pdfium use this sa
baixo1 2014/11/07 21:35:34 According to Lei, this file is part of pdf.dll, wh
raymes 2014/11/10 03:29:05 That sounds right to me. Thanks!
51 #endif
52
49 namespace chrome_pdf { 53 namespace chrome_pdf {
50 54
51 struct ToolbarButtonInfo { 55 struct ToolbarButtonInfo {
52 uint32 id; 56 uint32 id;
53 Button::ButtonStyle style; 57 Button::ButtonStyle style;
54 PP_ResourceImage normal; 58 PP_ResourceImage normal;
55 PP_ResourceImage highlighted; 59 PP_ResourceImage highlighted;
56 PP_ResourceImage pressed; 60 PP_ResourceImage pressed;
57 }; 61 };
58 62
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 timer_factory_.CancelAll(); 316 timer_factory_.CancelAll();
313 timer_pending_ = false; 317 timer_pending_ = false;
314 } 318 }
315 // The engine may try to access this instance during its destruction. 319 // The engine may try to access this instance during its destruction.
316 // Make sure this happens early while the instance is still intact. 320 // Make sure this happens early while the instance is still intact.
317 engine_.reset(); 321 engine_.reset();
318 RemovePerInstanceObject(kPPPPdfInterface, this); 322 RemovePerInstanceObject(kPPPPdfInterface, this);
319 } 323 }
320 324
321 bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) { 325 bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) {
326 #if !defined(OS_ANDROID) && defined(V8_USE_EXTERNAL_STARTUP_DATA)
327 v8::StartupData natives;
328 natives.data = pp::PDF::GetV8NativesData(this);
329 natives.raw_size = pp::PDF::GetV8NativesSize(this);
330 natives.compressed_size = pp::PDF::GetV8NativesSize(this);
331 v8::V8::SetNativesDataBlob(&natives);
332
333 v8::StartupData snapshot;
334 snapshot.data = pp::PDF::GetV8SnapshotData(this);
335 snapshot.raw_size = pp::PDF::GetV8SnapshotSize(this);
336 snapshot.compressed_size = pp::PDF::GetV8SnapshotSize(this);
337 v8::V8::SetSnapshotDataBlob(&snapshot);
338 #endif // !defined(OS_ANDROID) && defined(V8_USE_EXTERNAL_STARTUP_DATA)
339
322 // For now, we hide HiDPI support behind a flag. 340 // For now, we hide HiDPI support behind a flag.
323 if (pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_HIDPI)) 341 if (pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_HIDPI))
324 hidpi_enabled_ = true; 342 hidpi_enabled_ = true;
325 343
326 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING); 344 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING);
327 if (printing_enabled_) { 345 if (printing_enabled_) {
328 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons)); 346 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons));
329 } else { 347 } else {
330 CreateToolbar(kPDFNoPrintToolbarButtons, 348 CreateToolbar(kPDFNoPrintToolbarButtons,
331 arraysize(kPDFNoPrintToolbarButtons)); 349 arraysize(kPDFNoPrintToolbarButtons));
(...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 return instance_->HasScriptableMethod(name, exception); 2789 return instance_->HasScriptableMethod(name, exception);
2772 } 2790 }
2773 2791
2774 pp::Var PDFScriptableObject::Call(const pp::Var& method, 2792 pp::Var PDFScriptableObject::Call(const pp::Var& method,
2775 const std::vector<pp::Var>& args, 2793 const std::vector<pp::Var>& args,
2776 pp::Var* exception) { 2794 pp::Var* exception) {
2777 return instance_->CallScriptableMethod(method, args, exception); 2795 return instance_->CallScriptableMethod(method, args, exception);
2778 } 2796 }
2779 2797
2780 } // namespace chrome_pdf 2798 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698