// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/renderer/render_process_impl.h" #include "build/build_config.h" #if defined(OS_WIN) #include #include #include #endif #include "base/basictypes.h" #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/sys_info.h" #include "content/child/site_isolation_stats_gatherer.h" #include "content/public/common/content_switches.h" #include "content/public/renderer/content_renderer_client.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "v8/include/v8.h" namespace content { RenderProcessImpl::RenderProcessImpl() : enabled_bindings_(0) { #if defined(OS_WIN) // HACK: See http://b/issue?id=1024307 for rationale. if (GetModuleHandle(L"LPK.DLL") == NULL) { // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works // when buffering into a EMF buffer for printing. typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs); GdiInitializeLanguagePack gdi_init_lpk = reinterpret_cast(GetProcAddress( GetModuleHandle(L"GDI32.DLL"), "GdiInitializeLanguagePack")); DCHECK(gdi_init_lpk); if (gdi_init_lpk) { gdi_init_lpk(0); } } #endif std::string scavenge_reclaim_unmodified_flag( "--scavenge_reclaim_unmodified_objects"); v8::V8::SetFlagsFromString( scavenge_reclaim_unmodified_flag.c_str(), static_cast(scavenge_reclaim_unmodified_flag.size())); if (base::SysInfo::IsLowEndDevice()) { std::string optimize_flag("--optimize-for-size"); v8::V8::SetFlagsFromString(optimize_flag.c_str(), static_cast(optimize_flag.size())); } const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); if (command_line.HasSwitch(switches::kJavaScriptFlags)) { std::string flags( command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); v8::V8::SetFlagsFromString(flags.c_str(), static_cast(flags.size())); } if (command_line.HasSwitch( switches::kEnableExperimentalWebPlatformFeatures)) { std::string extras_flag("--experimental_extras"); v8::V8::SetFlagsFromString(extras_flag.c_str(), static_cast(extras_flag.size())); } SiteIsolationStatsGatherer::SetEnabled( GetContentClient()->renderer()->ShouldGatherSiteIsolationStats()); } RenderProcessImpl::~RenderProcessImpl() { #ifndef NDEBUG int count = blink::WebFrame::instanceCount(); if (count) DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES"; #endif GetShutDownEvent()->Signal(); } void RenderProcessImpl::AddBindings(int bindings) { enabled_bindings_ |= bindings; } int RenderProcessImpl::GetEnabledBindings() const { return enabled_bindings_; } } // namespace content