Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / render_process_impl.cc
blob2a320a3ac0f730a436304d275a89404fd9a1d7f2
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 SiteIsolationStatsGatherer::SetEnabled(
61 GetContentClient()->renderer()->ShouldGatherSiteIsolationStats());
64 RenderProcessImpl::~RenderProcessImpl() {
65 #ifndef NDEBUG
66 int count = blink::WebFrame::instanceCount();
67 if (count)
68 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES";
69 #endif
71 GetShutDownEvent()->Signal();
74 void RenderProcessImpl::AddBindings(int bindings) {
75 enabled_bindings_ |= bindings;
78 int RenderProcessImpl::GetEnabledBindings() const {
79 return enabled_bindings_;
82 } // namespace content