Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / content / renderer / render_process_impl.cc
blob8e754b5824749e8941b302c9084ae8ef6de40fb5
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/message_loop/message_loop.h"
19 #include "base/strings/utf_string_conversions.h"
20 #include "base/sys_info.h"
21 #include "content/child/child_thread.h"
22 #include "content/child/npapi/plugin_instance.h"
23 #include "content/child/npapi/plugin_lib.h"
24 #include "content/child/site_isolation_policy.h"
25 #include "content/common/view_messages.h"
26 #include "content/public/common/content_switches.h"
27 #include "content/public/renderer/content_renderer_client.h"
28 #include "ipc/ipc_channel.h"
29 #include "ipc/ipc_message_utils.h"
30 #include "skia/ext/platform_canvas.h"
31 #include "third_party/WebKit/public/web/WebFrame.h"
32 #include "ui/surface/transport_dib.h"
33 #include "v8/include/v8.h"
35 #if defined(OS_MACOSX)
36 #include "base/mac/mac_util.h"
37 #endif
39 #if defined(OS_ANDROID)
40 #include "base/android/sys_utils.h"
41 #endif
43 namespace content {
45 RenderProcessImpl::RenderProcessImpl()
46 : enabled_bindings_(0) {
47 #if defined(OS_WIN)
48 // HACK: See http://b/issue?id=1024307 for rationale.
49 if (GetModuleHandle(L"LPK.DLL") == NULL) {
50 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works
51 // when buffering into a EMF buffer for printing.
52 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs);
53 GdiInitializeLanguagePack gdi_init_lpk =
54 reinterpret_cast<GdiInitializeLanguagePack>(GetProcAddress(
55 GetModuleHandle(L"GDI32.DLL"),
56 "GdiInitializeLanguagePack"));
57 DCHECK(gdi_init_lpk);
58 if (gdi_init_lpk) {
59 gdi_init_lpk(0);
62 #endif
64 #if defined(OS_ANDROID)
65 if (base::android::SysUtils::IsLowEndDevice()) {
66 std::string optimize_flag("--optimize-for-size");
67 v8::V8::SetFlagsFromString(optimize_flag.c_str(),
68 static_cast<int>(optimize_flag.size()));
70 #endif
72 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
73 if (command_line.HasSwitch(switches::kJavaScriptFlags)) {
74 std::string flags(
75 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags));
76 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
79 // Turn on cross-site document blocking for renderer processes.
80 SiteIsolationPolicy::SetPolicyEnabled(
81 GetContentClient()->renderer()->ShouldEnableSiteIsolationPolicy());
84 RenderProcessImpl::~RenderProcessImpl() {
85 #ifndef NDEBUG
86 int count = blink::WebFrame::instanceCount();
87 if (count)
88 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES";
89 #endif
91 GetShutDownEvent()->Signal();
94 void RenderProcessImpl::AddBindings(int bindings) {
95 enabled_bindings_ |= bindings;
98 int RenderProcessImpl::GetEnabledBindings() const {
99 return enabled_bindings_;
102 } // namespace content