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> |
(...skipping 30 matching lines...) Expand all Loading... |
41 #endif | 41 #endif |
42 | 42 |
43 namespace content { | 43 namespace content { |
44 | 44 |
45 RenderProcessImpl::RenderProcessImpl() | 45 RenderProcessImpl::RenderProcessImpl() |
46 : shared_mem_cache_cleaner_( | 46 : shared_mem_cache_cleaner_( |
47 FROM_HERE, base::TimeDelta::FromSeconds(5), | 47 FROM_HERE, base::TimeDelta::FromSeconds(5), |
48 this, &RenderProcessImpl::ClearTransportDIBCache), | 48 this, &RenderProcessImpl::ClearTransportDIBCache), |
49 transport_dib_next_sequence_number_(0), | 49 transport_dib_next_sequence_number_(0), |
50 enabled_bindings_(0) { | 50 enabled_bindings_(0) { |
51 in_process_plugins_ = InProcessPlugins(); | |
52 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) | 51 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) |
53 shared_mem_cache_[i] = NULL; | 52 shared_mem_cache_[i] = NULL; |
54 | 53 |
55 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
56 // HACK: See http://b/issue?id=1024307 for rationale. | 55 // HACK: See http://b/issue?id=1024307 for rationale. |
57 if (GetModuleHandle(L"LPK.DLL") == NULL) { | 56 if (GetModuleHandle(L"LPK.DLL") == NULL) { |
58 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works | 57 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works |
59 // when buffering into a EMF buffer for printing. | 58 // when buffering into a EMF buffer for printing. |
60 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs); | 59 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs); |
61 GdiInitializeLanguagePack gdi_init_lpk = | 60 GdiInitializeLanguagePack gdi_init_lpk = |
(...skipping 30 matching lines...) Expand all Loading... |
92 #ifndef NDEBUG | 91 #ifndef NDEBUG |
93 int count = blink::WebFrame::instanceCount(); | 92 int count = blink::WebFrame::instanceCount(); |
94 if (count) | 93 if (count) |
95 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES"; | 94 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES"; |
96 #endif | 95 #endif |
97 | 96 |
98 GetShutDownEvent()->Signal(); | 97 GetShutDownEvent()->Signal(); |
99 ClearTransportDIBCache(); | 98 ClearTransportDIBCache(); |
100 } | 99 } |
101 | 100 |
102 bool RenderProcessImpl::InProcessPlugins() { | |
103 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
104 #if defined(OS_LINUX) || defined(OS_OPENBSD) | |
105 // Plugin processes require a UI message loop, and the Linux message loop | |
106 // implementation only allows one UI loop per process. | |
107 if (command_line.HasSwitch(switches::kInProcessPlugins)) | |
108 NOTIMPLEMENTED() << ": in process plugins not supported on Linux"; | |
109 return command_line.HasSwitch(switches::kInProcessPlugins); | |
110 #else | |
111 return command_line.HasSwitch(switches::kInProcessPlugins) || | |
112 command_line.HasSwitch(switches::kSingleProcess); | |
113 #endif | |
114 } | |
115 | |
116 void RenderProcessImpl::AddBindings(int bindings) { | 101 void RenderProcessImpl::AddBindings(int bindings) { |
117 enabled_bindings_ |= bindings; | 102 enabled_bindings_ |= bindings; |
118 } | 103 } |
119 | 104 |
120 int RenderProcessImpl::GetEnabledBindings() const { | 105 int RenderProcessImpl::GetEnabledBindings() const { |
121 return enabled_bindings_; | 106 return enabled_bindings_; |
122 } | 107 } |
123 | 108 |
124 // ----------------------------------------------------------------------------- | 109 // ----------------------------------------------------------------------------- |
125 // Platform specific code for dealing with bitmap transport... | 110 // Platform specific code for dealing with bitmap transport... |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 174 |
190 void RenderProcessImpl::ReleaseTransportDIB(TransportDIB* mem) { | 175 void RenderProcessImpl::ReleaseTransportDIB(TransportDIB* mem) { |
191 if (PutSharedMemInCache(mem)) { | 176 if (PutSharedMemInCache(mem)) { |
192 shared_mem_cache_cleaner_.Reset(); | 177 shared_mem_cache_cleaner_.Reset(); |
193 return; | 178 return; |
194 } | 179 } |
195 | 180 |
196 FreeTransportDIB(mem); | 181 FreeTransportDIB(mem); |
197 } | 182 } |
198 | 183 |
199 bool RenderProcessImpl::UseInProcessPlugins() const { | |
200 return in_process_plugins_; | |
201 } | |
202 | |
203 bool RenderProcessImpl::GetTransportDIBFromCache(TransportDIB** mem, | 184 bool RenderProcessImpl::GetTransportDIBFromCache(TransportDIB** mem, |
204 size_t size) { | 185 size_t size) { |
205 // look for a cached object that is suitable for the requested size. | 186 // look for a cached object that is suitable for the requested size. |
206 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 187 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
207 if (shared_mem_cache_[i] && | 188 if (shared_mem_cache_[i] && |
208 size <= shared_mem_cache_[i]->size()) { | 189 size <= shared_mem_cache_[i]->size()) { |
209 *mem = shared_mem_cache_[i]; | 190 *mem = shared_mem_cache_[i]; |
210 shared_mem_cache_[i] = NULL; | 191 shared_mem_cache_[i] = NULL; |
211 return true; | 192 return true; |
212 } | 193 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 void RenderProcessImpl::ClearTransportDIBCache() { | 236 void RenderProcessImpl::ClearTransportDIBCache() { |
256 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 237 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
257 if (shared_mem_cache_[i]) { | 238 if (shared_mem_cache_[i]) { |
258 FreeTransportDIB(shared_mem_cache_[i]); | 239 FreeTransportDIB(shared_mem_cache_[i]); |
259 shared_mem_cache_[i] = NULL; | 240 shared_mem_cache_[i] = NULL; |
260 } | 241 } |
261 } | 242 } |
262 } | 243 } |
263 | 244 |
264 } // namespace content | 245 } // namespace content |
OLD | NEW |