blob: 2a320a3ac0f730a436304d275a89404fd9a1d7f2 [file] [log] [blame]
[email protected]fd911dd2012-01-27 01:57:101// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]d353541f2012-05-03 22:45:415#include "content/renderer/render_process_impl.h"
6
[email protected]037fce02009-01-22 01:42:157#include "build/build_config.h"
8
9#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:2910#include <windows.h>
11#include <objidl.h>
12#include <mlang.h>
[email protected]037fce02009-01-22 01:42:1513#endif
initial.commit09911bf2008-07-26 23:55:2914
initial.commit09911bf2008-07-26 23:55:2915#include "base/basictypes.h"
16#include "base/command_line.h"
[email protected]037fce02009-01-22 01:42:1517#include "base/compiler_specific.h"
[email protected]35b4f0c2014-06-26 16:55:2718#include "base/sys_info.h"
nicke7cd12a2015-06-17 06:48:3819#include "content/child/site_isolation_stats_gatherer.h"
[email protected]c08950d22011-10-13 22:20:2920#include "content/public/common/content_switches.h"
[email protected]d344114c2011-10-01 01:24:3421#include "content/public/renderer/content_renderer_client.h"
[email protected]6bd867b2013-07-24 22:10:2022#include "third_party/WebKit/public/web/WebFrame.h"
[email protected]067f5192014-01-29 05:22:0923#include "v8/include/v8.h"
initial.commit09911bf2008-07-26 23:55:2924
[email protected]eb398192012-10-22 20:16:1925namespace content {
26
[email protected]396c3a462010-03-03 05:03:2227RenderProcessImpl::RenderProcessImpl()
[email protected]1cf03f7f2014-04-24 03:09:4928 : enabled_bindings_(0) {
[email protected]396c3a462010-03-03 05:03:2229#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);
[email protected]00c39612010-03-06 02:53:2840 if (gdi_init_lpk) {
[email protected]396c3a462010-03-03 05:03:2241 gdi_init_lpk(0);
[email protected]00c39612010-03-06 02:53:2842 }
[email protected]396c3a462010-03-03 05:03:2243 }
[email protected]e68e62fa2009-02-20 02:00:0444#endif
45
[email protected]35b4f0c2014-06-26 16:55:2746 if (base::SysInfo::IsLowEndDevice()) {
[email protected]067f5192014-01-29 05:22:0947 std::string optimize_flag("--optimize-for-size");
48 v8::V8::SetFlagsFromString(optimize_flag.c_str(),
49 static_cast<int>(optimize_flag.size()));
50 }
[email protected]987422f2013-10-01 10:33:3151
avi83883c82014-12-23 00:08:4952 const base::CommandLine& command_line =
53 *base::CommandLine::ForCurrentProcess();
[email protected]396c3a462010-03-03 05:03:2254 if (command_line.HasSwitch(switches::kJavaScriptFlags)) {
[email protected]067f5192014-01-29 05:22:0955 std::string flags(
[email protected]95edc392010-07-30 22:00:3856 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags));
[email protected]067f5192014-01-29 05:22:0957 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
[email protected]396c3a462010-03-03 05:03:2258 }
[email protected]55dd9332013-09-04 17:17:5059
nick88299ba2015-06-16 23:57:4160 SiteIsolationStatsGatherer::SetEnabled(
61 GetContentClient()->renderer()->ShouldGatherSiteIsolationStats());
[email protected]e68e62fa2009-02-20 02:00:0462}
63
[email protected]396c3a462010-03-03 05:03:2264RenderProcessImpl::~RenderProcessImpl() {
[email protected]396c3a462010-03-03 05:03:2265#ifndef NDEBUG
[email protected]180ef242013-11-07 06:50:4666 int count = blink::WebFrame::instanceCount();
[email protected]6bd867b2013-07-24 22:10:2067 if (count)
68 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES";
[email protected]396c3a462010-03-03 05:03:2269#endif
[email protected]e68e62fa2009-02-20 02:00:0470
[email protected]396c3a462010-03-03 05:03:2271 GetShutDownEvent()->Signal();
[email protected]396c3a462010-03-03 05:03:2272}
[email protected]e68e62fa2009-02-20 02:00:0473
[email protected]744c2a22012-03-15 18:42:0474void RenderProcessImpl::AddBindings(int bindings) {
75 enabled_bindings_ |= bindings;
76}
77
78int RenderProcessImpl::GetEnabledBindings() const {
79 return enabled_bindings_;
80}
81
[email protected]eb398192012-10-22 20:16:1982} // namespace content