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 "webkit/plugins/npapi/webplugin_delegate_impl.h" | 5 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 SIZE_T size, | 141 SIZE_T size, |
142 DWORD free_type); | 142 DWORD free_type); |
143 | 143 |
144 const DWORD kExecPageMask = PAGE_EXECUTE_READ; | 144 const DWORD kExecPageMask = PAGE_EXECUTE_READ; |
145 static volatile intptr_t g_max_exec_mem_size; | 145 static volatile intptr_t g_max_exec_mem_size; |
146 static scoped_ptr<base::Lock> g_exec_mem_lock; | 146 static scoped_ptr<base::Lock> g_exec_mem_lock; |
147 | 147 |
148 bool UpdateExecMemSize(intptr_t size) { | 148 bool UpdateExecMemSize(intptr_t size) { |
149 base::AutoLock locked(*g_exec_mem_lock); | 149 base::AutoLock locked(*g_exec_mem_lock); |
150 | 150 |
151 const intptr_t kMaxPluginExecMemSize = 192 * 1024 * 1024; // 192mb. | 151 const intptr_t kMaxPluginExecMemSizeSpike = 80 * 1024 * 1024; // 80mb. |
152 const intptr_t kMaxPluginExecMemSizeSpike = 64 * 1024 * 1024; // 64mb. | |
153 const DWORD kTimeLimit = 6; // 6 minute timeout. | 152 const DWORD kTimeLimit = 6; // 6 minute timeout. |
154 | 153 |
155 static intptr_t s_exec_mem_size = 0; | 154 static intptr_t s_exec_mem_size = 0; |
156 static intptr_t s_exec_mem_size_old = 0; | 155 static intptr_t s_exec_mem_size_old = 0; |
157 static struct { | 156 static struct { |
158 intptr_t size; | 157 intptr_t size; |
159 DWORD minutes; | 158 DWORD minutes; |
160 } s_exec_mem_log[kTimeLimit]; | 159 } s_exec_mem_log[kTimeLimit]; |
161 static size_t s_old_idx; | 160 static size_t s_old_idx; |
162 static size_t s_now_idx; | 161 static size_t s_now_idx; |
(...skipping 24 matching lines...) Expand all Loading... |
187 s_exec_mem_size_old); | 186 s_exec_mem_size_old); |
188 } | 187 } |
189 } | 188 } |
190 | 189 |
191 // Floor to zero since shutdown may unmap pages created before our hooks. | 190 // Floor to zero since shutdown may unmap pages created before our hooks. |
192 s_exec_mem_size = std::max(0, s_exec_mem_size + size); | 191 s_exec_mem_size = std::max(0, s_exec_mem_size + size); |
193 if (s_exec_mem_size > g_max_exec_mem_size) | 192 if (s_exec_mem_size > g_max_exec_mem_size) |
194 g_max_exec_mem_size = s_exec_mem_size; | 193 g_max_exec_mem_size = s_exec_mem_size; |
195 | 194 |
196 | 195 |
197 if (s_exec_mem_size > kMaxPluginExecMemSize) | |
198 return false; | |
199 if ((s_exec_mem_size - s_exec_mem_size_old) > kMaxPluginExecMemSizeSpike) | 196 if ((s_exec_mem_size - s_exec_mem_size_old) > kMaxPluginExecMemSizeSpike) |
200 return false; | 197 return false; |
201 | 198 |
202 return true; | 199 return true; |
203 } | 200 } |
204 | 201 |
205 // Throw a unique exception when the JIT limit is hit. | 202 // Throw a unique exception when the JIT limit is hit. |
206 inline void RaiseJITException() { | 203 inline void RaiseJITException() { |
207 static const ULONG parameters[] = {1, 0xabad1dea /* 2880249322 */ }; | 204 static const ULONG parameters[] = {1, 0xabad1dea /* 2880249322 */ }; |
208 ::RaiseException(EXCEPTION_ACCESS_VIOLATION, EXCEPTION_NONCONTINUABLE, | 205 ::RaiseException(EXCEPTION_ACCESS_VIOLATION, EXCEPTION_NONCONTINUABLE, |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 ::ReleaseCapture(); | 1715 ::ReleaseCapture(); |
1719 break; | 1716 break; |
1720 | 1717 |
1721 default: | 1718 default: |
1722 break; | 1719 break; |
1723 } | 1720 } |
1724 } | 1721 } |
1725 | 1722 |
1726 } // namespace npapi | 1723 } // namespace npapi |
1727 } // namespace webkit | 1724 } // namespace webkit |
OLD | NEW |