Chromium Code Reviews| 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..7e7caed21edcb01de2d3dd176e0f0557272f6c10 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,19 @@ 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) |
| + if (!memory) |
|
piman
2014/12/20 02:40:45
nit: memory is !null here, so you can remove the i
|
| + CollectMemoryUsageAndDie(size); |
| +#endif |
| CHECK(false); |
| + } |
| base::SharedMemoryHandle handle_to_send = memory->handle(); |
| sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( |
| memory_size, handle_to_send, id)); |