Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / render_process_impl.cc
blob4213cb1322fd307329f4c4829cafee564a5842da
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
3 // found in the LICENSE file.
5 #include "content/renderer/render_process_impl.h"
7 #include "build/build_config.h"
9 #if defined(OS_WIN)
10 #include <windows.h>
11 #include <objidl.h>
12 #include <mlang.h>
13 #endif
15 #include "base/basictypes.h"
16 #include "base/command_line.h"
17 #include "base/compiler_specific.h"
18 #include "base/sys_info.h"
19 #include "content/child/site_isolation_stats_gatherer.h"
20 #include "content/public/common/content_switches.h"
21 #include "content/public/renderer/content_renderer_client.h"
22 #include "third_party/WebKit/public/web/WebFrame.h"
23 #include "v8/include/v8.h"
25 namespace content {
27 RenderProcessImpl::RenderProcessImpl()
28 : enabled_bindings_(0) {
29 #if defined(OS_WIN)
30 // HACK: See http://b/issue?id=1024307 for rationale.
31 if (GetModuleHandle(L"LPK.DLL") == NULL) {
32 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works
33 // when buffering into a EMF buffer for printing.
34 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs);
35 GdiInitializeLanguagePack gdi_init_lpk =
36 reinterpret_cast<GdiInitializeLanguagePack>(GetProcAddress(
37 GetModuleHandle(L"GDI32.DLL"),
38 "GdiInitializeLanguagePack"));
39 DCHECK(gdi_init_lpk);
40 if (gdi_init_lpk) {
41 gdi_init_lpk(0);
44 #endif
46 if (base::SysInfo::IsLowEndDevice()) {
47 std::string optimize_flag("--optimize-for-size");
48 v8::V8::SetFlagsFromString(optimize_flag.c_str(),
49 static_cast<int>(optimize_flag.size()));
52 const base::CommandLine& command_line =
53 *base::CommandLine::ForCurrentProcess();
54 if (command_line.HasSwitch(switches::kJavaScriptFlags)) {
55 std::string flags(
56 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags));
57 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
60 if (command_line.HasSwitch(
61 switches::kEnableExperimentalWebPlatformFeatures)) {
62 std::string extras_flag("--experimental_extras");
63 v8::V8::SetFlagsFromString(extras_flag.c_str(),
64 static_cast<int>(extras_flag.size()));
67 SiteIsolationStatsGatherer::SetEnabled(
68 GetContentClient()->renderer()->ShouldGatherSiteIsolationStats());
71 RenderProcessImpl::~RenderProcessImpl() {
72 #ifndef NDEBUG
73 int count = blink::WebFrame::instanceCount();
74 if (count)
75 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES";
76 #endif
78 GetShutDownEvent()->Signal();
81 void RenderProcessImpl::AddBindings(int bindings) {
82 enabled_bindings_ |= bindings;
85 int RenderProcessImpl::GetEnabledBindings() const {
86 return enabled_bindings_;
89 } // namespace content