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"
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"
27 RenderProcessImpl::RenderProcessImpl()
28 : enabled_bindings_(0) {
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"));
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
)) {
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() {
66 int count
= blink::WebFrame::instanceCount();
68 DLOG(ERROR
) << "WebFrame LEAKED " << count
<< " TIMES";
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