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

Unified Diff: content/child/child_shared_bitmap_manager.cc

Issue 1039043002: Add base::TerminateBecauseOutOfMemory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fri Mar 27 10:36:24 PDT 2015 Created 5 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 | « content/child/child_discardable_shared_memory_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/child_shared_bitmap_manager.cc
diff --git a/content/child/child_shared_bitmap_manager.cc b/content/child/child_shared_bitmap_manager.cc
index 73395daa8edf93985668b707304e3c45f68e7962..334a7ea8e4f705a47ed2ab30a19a94e3853f04ea 100644
--- a/content/child/child_shared_bitmap_manager.cc
+++ b/content/child/child_shared_bitmap_manager.cc
@@ -5,6 +5,7 @@
#include "content/child/child_shared_bitmap_manager.h"
#include "base/debug/alias.h"
+#include "base/process/memory.h"
#include "base/process/process_metrics.h"
#include "content/child/child_thread_impl.h"
#include "content/common/child_process_messages.h"
@@ -40,10 +41,9 @@ class ChildSharedBitmap : public SharedMemoryBitmap {
scoped_ptr<base::SharedMemory> shared_memory_holder_;
};
-#if defined(OS_WIN)
-
// Collect extra information for debugging bitmap creation failures.
-void CollectMemoryUsageAndDie(const gfx::Size& size) {
+void CollectMemoryUsageAndDie(const gfx::Size& size, size_t alloc_size) {
+#if defined(OS_WIN)
int width = size.width();
int height = size.height();
DWORD last_error = GetLastError();
@@ -61,11 +61,9 @@ void CollectMemoryUsageAndDie(const gfx::Size& size) {
base::debug::Alias(&last_error);
base::debug::Alias(&private_bytes);
base::debug::Alias(&shared_bytes);
-
- CHECK(false);
-}
-
#endif
+ base::TerminateBecauseOutOfMemory(alloc_size);
+}
} // namespace
@@ -109,21 +107,15 @@ ChildSharedBitmapManager::AllocateSharedMemoryBitmap(const gfx::Size& size) {
memory_size, id, &handle));
memory = make_scoped_ptr(new base::SharedMemory(handle, false));
if (!memory->Map(memory_size))
- CHECK(false);
+ CollectMemoryUsageAndDie(size, memory_size);
#else
memory = ChildThreadImpl::AllocateSharedMemory(memory_size, sender_.get());
-#if defined(OS_WIN)
if (!memory)
- CollectMemoryUsageAndDie(size);
-#endif
+ CollectMemoryUsageAndDie(size, memory_size);
+
+ if (!memory->Map(memory_size))
+ CollectMemoryUsageAndDie(size, memory_size);
- CHECK(memory);
- if (!memory->Map(memory_size)) {
-#if defined(OS_WIN)
- CollectMemoryUsageAndDie(size);
-#endif
- CHECK(false);
- }
base::SharedMemoryHandle handle_to_send = memory->handle();
sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap(
memory_size, handle_to_send, id));
« no previous file with comments | « content/child/child_discardable_shared_memory_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698