| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/render_process_impl.h" | 5 #include "content/renderer/render_process_impl.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #include <objidl.h> | 11 #include <objidl.h> |
| 12 #include <mlang.h> | 12 #include <mlang.h> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
| 21 #include "base/sys_utils.h" |
| 21 #include "content/child/child_thread.h" | 22 #include "content/child/child_thread.h" |
| 22 #include "content/child/npapi/plugin_instance.h" | 23 #include "content/child/npapi/plugin_instance.h" |
| 23 #include "content/child/npapi/plugin_lib.h" | 24 #include "content/child/npapi/plugin_lib.h" |
| 24 #include "content/child/site_isolation_policy.h" | 25 #include "content/child/site_isolation_policy.h" |
| 25 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
| 26 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
| 27 #include "content/public/renderer/content_renderer_client.h" | 28 #include "content/public/renderer/content_renderer_client.h" |
| 28 #include "ipc/ipc_channel.h" | 29 #include "ipc/ipc_channel.h" |
| 29 #include "ipc/ipc_message_utils.h" | 30 #include "ipc/ipc_message_utils.h" |
| 30 #include "skia/ext/platform_canvas.h" | 31 #include "skia/ext/platform_canvas.h" |
| 31 #include "third_party/WebKit/public/web/WebFrame.h" | 32 #include "third_party/WebKit/public/web/WebFrame.h" |
| 32 #include "ui/surface/transport_dib.h" | 33 #include "ui/surface/transport_dib.h" |
| 33 #include "v8/include/v8.h" | 34 #include "v8/include/v8.h" |
| 34 | 35 |
| 35 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
| 36 #include "base/mac/mac_util.h" | 37 #include "base/mac/mac_util.h" |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 #if defined(OS_ANDROID) | |
| 40 #include "base/android/sys_utils.h" | |
| 41 #endif | |
| 42 | |
| 43 namespace content { | 40 namespace content { |
| 44 | 41 |
| 45 RenderProcessImpl::RenderProcessImpl() | 42 RenderProcessImpl::RenderProcessImpl() |
| 46 : shared_mem_cache_cleaner_( | 43 : shared_mem_cache_cleaner_( |
| 47 FROM_HERE, base::TimeDelta::FromSeconds(5), | 44 FROM_HERE, base::TimeDelta::FromSeconds(5), |
| 48 this, &RenderProcessImpl::ClearTransportDIBCache), | 45 this, &RenderProcessImpl::ClearTransportDIBCache), |
| 49 transport_dib_next_sequence_number_(0), | 46 transport_dib_next_sequence_number_(0), |
| 50 enabled_bindings_(0) { | 47 enabled_bindings_(0) { |
| 51 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) | 48 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) |
| 52 shared_mem_cache_[i] = NULL; | 49 shared_mem_cache_[i] = NULL; |
| 53 | 50 |
| 54 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
| 55 // HACK: See http://b/issue?id=1024307 for rationale. | 52 // HACK: See http://b/issue?id=1024307 for rationale. |
| 56 if (GetModuleHandle(L"LPK.DLL") == NULL) { | 53 if (GetModuleHandle(L"LPK.DLL") == NULL) { |
| 57 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works | 54 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works |
| 58 // when buffering into a EMF buffer for printing. | 55 // when buffering into a EMF buffer for printing. |
| 59 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs); | 56 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs); |
| 60 GdiInitializeLanguagePack gdi_init_lpk = | 57 GdiInitializeLanguagePack gdi_init_lpk = |
| 61 reinterpret_cast<GdiInitializeLanguagePack>(GetProcAddress( | 58 reinterpret_cast<GdiInitializeLanguagePack>(GetProcAddress( |
| 62 GetModuleHandle(L"GDI32.DLL"), | 59 GetModuleHandle(L"GDI32.DLL"), |
| 63 "GdiInitializeLanguagePack")); | 60 "GdiInitializeLanguagePack")); |
| 64 DCHECK(gdi_init_lpk); | 61 DCHECK(gdi_init_lpk); |
| 65 if (gdi_init_lpk) { | 62 if (gdi_init_lpk) { |
| 66 gdi_init_lpk(0); | 63 gdi_init_lpk(0); |
| 67 } | 64 } |
| 68 } | 65 } |
| 69 #endif | 66 #endif |
| 70 | 67 |
| 71 #if defined(OS_ANDROID) | 68 if (base::SysUtils::IsLowEndDevice()) { |
| 72 if (base::android::SysUtils::IsLowEndDevice()) { | |
| 73 std::string optimize_flag("--optimize-for-size"); | 69 std::string optimize_flag("--optimize-for-size"); |
| 74 v8::V8::SetFlagsFromString(optimize_flag.c_str(), | 70 v8::V8::SetFlagsFromString(optimize_flag.c_str(), |
| 75 static_cast<int>(optimize_flag.size())); | 71 static_cast<int>(optimize_flag.size())); |
| 76 } | 72 } |
| 77 #endif | |
| 78 | 73 |
| 79 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 74 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 80 if (command_line.HasSwitch(switches::kJavaScriptFlags)) { | 75 if (command_line.HasSwitch(switches::kJavaScriptFlags)) { |
| 81 std::string flags( | 76 std::string flags( |
| 82 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); | 77 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); |
| 83 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | 78 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); |
| 84 } | 79 } |
| 85 | 80 |
| 86 // Turn on cross-site document blocking for renderer processes. | 81 // Turn on cross-site document blocking for renderer processes. |
| 87 SiteIsolationPolicy::SetPolicyEnabled( | 82 SiteIsolationPolicy::SetPolicyEnabled( |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 void RenderProcessImpl::ClearTransportDIBCache() { | 231 void RenderProcessImpl::ClearTransportDIBCache() { |
| 237 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 232 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
| 238 if (shared_mem_cache_[i]) { | 233 if (shared_mem_cache_[i]) { |
| 239 FreeTransportDIB(shared_mem_cache_[i]); | 234 FreeTransportDIB(shared_mem_cache_[i]); |
| 240 shared_mem_cache_[i] = NULL; | 235 shared_mem_cache_[i] = NULL; |
| 241 } | 236 } |
| 242 } | 237 } |
| 243 } | 238 } |
| 244 | 239 |
| 245 } // namespace content | 240 } // namespace content |
| OLD | NEW |