OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <objidl.h> | 9 #include <objidl.h> |
10 #include <mlang.h> | 10 #include <mlang.h> |
11 #endif | 11 #endif |
12 | 12 |
13 #include "content/renderer/render_process_impl.h" | 13 #include "content/renderer/render_process_impl.h" |
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.h" | 18 #include "base/message_loop.h" |
19 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "content/common/content_switches.h" | 21 #include "content/common/content_switches.h" |
22 #include "content/common/view_messages.h" | 22 #include "content/common/view_messages.h" |
23 #include "content/renderer/content_renderer_client.h" | 23 #include "content/renderer/content_renderer_client.h" |
24 #include "content/renderer/render_thread.h" | 24 #include "content/renderer/render_thread.h" |
25 #include "content/renderer/render_view.h" | 25 #include "content/renderer/render_view.h" |
26 #include "ipc/ipc_channel.h" | 26 #include "ipc/ipc_channel.h" |
27 #include "ipc/ipc_message_utils.h" | 27 #include "ipc/ipc_message_utils.h" |
28 #include "media/base/media.h" | |
29 #include "media/base/media_switches.h" | |
30 #include "skia/ext/platform_canvas.h" | 28 #include "skia/ext/platform_canvas.h" |
31 #include "ui/gfx/surface/transport_dib.h" | 29 #include "ui/gfx/surface/transport_dib.h" |
32 #include "webkit/plugins/npapi/plugin_instance.h" | 30 #include "webkit/plugins/npapi/plugin_instance.h" |
33 #include "webkit/plugins/npapi/plugin_lib.h" | 31 #include "webkit/plugins/npapi/plugin_lib.h" |
34 #include "webkit/glue/webkit_glue.h" | 32 #include "webkit/glue/webkit_glue.h" |
35 | 33 |
36 #if defined(OS_MACOSX) | 34 #if defined(OS_MACOSX) |
37 #include "base/mac/mac_util.h" | 35 #include "base/mac/mac_util.h" |
38 #endif | 36 #endif |
39 | 37 |
(...skipping 27 matching lines...) Expand all Loading... |
67 webkit_glue::SetJavaScriptFlags( | 65 webkit_glue::SetJavaScriptFlags( |
68 "--debugger-auto-break" | 66 "--debugger-auto-break" |
69 // Enable lazy in-memory profiling. | 67 // Enable lazy in-memory profiling. |
70 " --prof --prof-lazy --logfile=*"); | 68 " --prof --prof-lazy --logfile=*"); |
71 | 69 |
72 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 70 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
73 if (command_line.HasSwitch(switches::kJavaScriptFlags)) { | 71 if (command_line.HasSwitch(switches::kJavaScriptFlags)) { |
74 webkit_glue::SetJavaScriptFlags( | 72 webkit_glue::SetJavaScriptFlags( |
75 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); | 73 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); |
76 } | 74 } |
77 | |
78 // Note that under Linux, the media library will normally already have | |
79 // been initialized by the Zygote before this instance became a Renderer. | |
80 FilePath media_path = | |
81 content::GetContentClient()->renderer()->GetMediaLibraryPath(); | |
82 if (!media_path.empty()) | |
83 media::InitializeMediaLibrary(media_path); | |
84 | |
85 #if !defined(OS_MACOSX) | |
86 // TODO(hclam): Add more checks here. Currently this is not used. | |
87 if (media::IsMediaLibraryInitialized() && | |
88 CommandLine::ForCurrentProcess()->HasSwitch( | |
89 switches::kEnableOpenMax)) { | |
90 media::InitializeOpenMaxLibrary(media_path); | |
91 } | |
92 #endif | |
93 } | 75 } |
94 | 76 |
95 RenderProcessImpl::~RenderProcessImpl() { | 77 RenderProcessImpl::~RenderProcessImpl() { |
96 // TODO(port): Try and limit what we pull in for our non-Win unit test bundle. | 78 // TODO(port): Try and limit what we pull in for our non-Win unit test bundle. |
97 #ifndef NDEBUG | 79 #ifndef NDEBUG |
98 // log important leaked objects | 80 // log important leaked objects |
99 webkit_glue::CheckForLeaks(); | 81 webkit_glue::CheckForLeaks(); |
100 #endif | 82 #endif |
101 | 83 |
102 GetShutDownEvent()->Signal(); | 84 GetShutDownEvent()->Signal(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return; | 170 return; |
189 } | 171 } |
190 | 172 |
191 FreeTransportDIB(mem); | 173 FreeTransportDIB(mem); |
192 } | 174 } |
193 | 175 |
194 bool RenderProcessImpl::UseInProcessPlugins() const { | 176 bool RenderProcessImpl::UseInProcessPlugins() const { |
195 return in_process_plugins_; | 177 return in_process_plugins_; |
196 } | 178 } |
197 | 179 |
198 bool RenderProcessImpl::HasInitializedMediaLibrary() const { | |
199 return media::IsMediaLibraryInitialized(); | |
200 } | |
201 | |
202 bool RenderProcessImpl::GetTransportDIBFromCache(TransportDIB** mem, | 180 bool RenderProcessImpl::GetTransportDIBFromCache(TransportDIB** mem, |
203 size_t size) { | 181 size_t size) { |
204 // look for a cached object that is suitable for the requested size. | 182 // look for a cached object that is suitable for the requested size. |
205 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 183 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
206 if (shared_mem_cache_[i] && | 184 if (shared_mem_cache_[i] && |
207 size <= shared_mem_cache_[i]->size()) { | 185 size <= shared_mem_cache_[i]->size()) { |
208 *mem = shared_mem_cache_[i]; | 186 *mem = shared_mem_cache_[i]; |
209 shared_mem_cache_[i] = NULL; | 187 shared_mem_cache_[i] = NULL; |
210 return true; | 188 return true; |
211 } | 189 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 230 } |
253 | 231 |
254 void RenderProcessImpl::ClearTransportDIBCache() { | 232 void RenderProcessImpl::ClearTransportDIBCache() { |
255 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 233 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
256 if (shared_mem_cache_[i]) { | 234 if (shared_mem_cache_[i]) { |
257 FreeTransportDIB(shared_mem_cache_[i]); | 235 FreeTransportDIB(shared_mem_cache_[i]); |
258 shared_mem_cache_[i] = NULL; | 236 shared_mem_cache_[i] = NULL; |
259 } | 237 } |
260 } | 238 } |
261 } | 239 } |
OLD | NEW |