Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: webkit/plugins/npapi/webplugin_delegate_impl_win.cc

Issue 9688022: Switch the plugin cap back to a reporting mode (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/npapi/webplugin_delegate_impl_win.cc
===================================================================
--- webkit/plugins/npapi/webplugin_delegate_impl_win.cc (revision 126095)
+++ webkit/plugins/npapi/webplugin_delegate_impl_win.cc (working copy)
@@ -145,67 +145,17 @@
static volatile intptr_t g_max_exec_mem_size;
static scoped_ptr<base::Lock> g_exec_mem_lock;
-bool UpdateExecMemSize(intptr_t size) {
+void UpdateExecMemSize(intptr_t size) {
base::AutoLock locked(*g_exec_mem_lock);
- const intptr_t kMaxPluginExecMemSizeSpike = 80 * 1024 * 1024; // 80mb.
- const DWORD kTimeLimit = 6; // 6 minute timeout.
-
static intptr_t s_exec_mem_size = 0;
- static intptr_t s_exec_mem_size_old = 0;
- static struct {
- intptr_t size;
- DWORD minutes;
- } s_exec_mem_log[kTimeLimit];
- static size_t s_old_idx;
- static size_t s_now_idx;
- DWORD now = ::GetTickCount() / (60 * 1000);
-
- // Keep the size change history. This is done using a ring of entries with
- // with the size and tick count
- if (s_exec_mem_log[s_now_idx].minutes == now) {
- s_exec_mem_log[s_now_idx].size += size;
- } else {
- // Move the index forward and clear the old entry if needed.
- s_now_idx = (s_now_idx + 1) % kTimeLimit;
- if (s_now_idx == s_old_idx) {
- s_exec_mem_size_old = std::max(0, s_exec_mem_log[s_old_idx].size +
- s_exec_mem_size_old);
- ++s_old_idx;
- }
- s_exec_mem_log[s_now_idx].minutes = now;
- s_exec_mem_log[s_now_idx].size = size;
-
- // Expire any waiting old entries.
- for (; s_old_idx != s_now_idx; s_old_idx = (s_old_idx + 1) % kTimeLimit) {
- DWORD minutes = s_exec_mem_log[s_old_idx].minutes;
- if (now - minutes < kTimeLimit)
- break;
- s_exec_mem_size_old = std::max(0, s_exec_mem_log[s_old_idx].size +
- s_exec_mem_size_old);
- }
- }
-
// Floor to zero since shutdown may unmap pages created before our hooks.
s_exec_mem_size = std::max(0, s_exec_mem_size + size);
if (s_exec_mem_size > g_max_exec_mem_size)
g_max_exec_mem_size = s_exec_mem_size;
-
-
- if ((s_exec_mem_size - s_exec_mem_size_old) > kMaxPluginExecMemSizeSpike)
- return false;
-
- return true;
}
-// Throw a unique exception when the JIT limit is hit.
-inline void RaiseJITException() {
- static const ULONG parameters[] = {1, 0xabad1dea /* 2880249322 */ };
- ::RaiseException(EXCEPTION_ACCESS_VIOLATION, EXCEPTION_NONCONTINUABLE,
- arraysize(parameters), parameters);
-}
-
// http://crbug.com/16114
// Enforces providing a valid device context in NPWindow, so that NPP_SetWindow
// is never called with NPNWindoTypeDrawable and NPWindow set to NULL.
@@ -396,8 +346,7 @@
bool is_exec = new_protect == kExecPageMask;
bool was_exec = *old_protect == kExecPageMask;
if (is_exec && !was_exec) {
- if (!UpdateExecMemSize(static_cast<intptr_t>(size)))
- RaiseJITException();
+ UpdateExecMemSize(static_cast<intptr_t>(size));
} else if (!is_exec && was_exec) {
UpdateExecMemSize(-(static_cast<intptr_t>(size)));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698