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

Unified Diff: content/child/child_shared_bitmap_manager.cc

Issue 822433003: Collect more information when failing to allocate a SharedBitmap on win (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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: 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 aa9f1f37ba6dd854418aab8be314b2ece5d091c4..66982328c70b1d5d23359aa07411b5d19b7bd75a 100644
--- a/content/child/child_shared_bitmap_manager.cc
+++ b/content/child/child_shared_bitmap_manager.cc
@@ -4,6 +4,8 @@
#include "content/child/child_shared_bitmap_manager.h"
+#include "base/debug/alias.h"
+#include "base/process/process_metrics.h"
#include "content/child/child_thread.h"
#include "content/common/child_process_messages.h"
#include "ui/gfx/size.h"
@@ -38,6 +40,33 @@ 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) {
+ int width = size.width();
+ int height = size.height();
+ DWORD last_error = GetLastError();
+
+ scoped_ptr<base::ProcessMetrics> metrics(
+ base::ProcessMetrics::CreateProcessMetrics(
+ base::GetCurrentProcessHandle()));
+
+ size_t private_bytes = 0;
+ size_t shared_bytes = 0;
+ metrics->GetMemoryBytes(&private_bytes, &shared_bytes);
+
+ base::debug::Alias(&width);
+ base::debug::Alias(&height);
+ base::debug::Alias(&last_error);
+ base::debug::Alias(&private_bytes);
+ base::debug::Alias(&shared_bytes);
+
+ CHECK(false);
+}
+
+#endif
+
} // namespace
SharedMemoryBitmap::SharedMemoryBitmap(uint8* pixels,
@@ -83,9 +112,18 @@ ChildSharedBitmapManager::AllocateSharedMemoryBitmap(const gfx::Size& size) {
CHECK(false);
#else
memory = ChildThread::AllocateSharedMemory(memory_size, sender_.get());
+#if defined(OS_WIN)
+ if (!memory)
+ CollectMemoryUsageAndDie(size);
+#endif
+
CHECK(memory);
- if (!memory->Map(memory_size))
+ 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 | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698