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

Side by Side Diff: content/child/child_shared_bitmap_manager.cc

Issue 2010563004: content: Not all memory creation failures are out of memory errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « content/child/blob_storage/webblobregistry_impl.cc ('k') | content/child/child_thread_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/child/child_shared_bitmap_manager.h" 5 #include "content/child/child_shared_bitmap_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 TRACE_EVENT2("renderer", 101 TRACE_EVENT2("renderer",
102 "ChildSharedBitmapManager::AllocateSharedMemoryBitmap", "width", 102 "ChildSharedBitmapManager::AllocateSharedMemoryBitmap", "width",
103 size.width(), "height", size.height()); 103 size.width(), "height", size.height());
104 size_t memory_size; 104 size_t memory_size;
105 if (!cc::SharedBitmap::SizeInBytes(size, &memory_size)) 105 if (!cc::SharedBitmap::SizeInBytes(size, &memory_size))
106 return std::unique_ptr<SharedMemoryBitmap>(); 106 return std::unique_ptr<SharedMemoryBitmap>();
107 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); 107 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
108 std::unique_ptr<base::SharedMemory> memory; 108 std::unique_ptr<base::SharedMemory> memory;
109 #if defined(OS_POSIX) 109 #if defined(OS_POSIX)
110 base::SharedMemoryHandle handle; 110 base::SharedMemoryHandle handle;
111 sender_->Send(new ChildProcessHostMsg_SyncAllocateSharedBitmap( 111 bool send_success =
112 memory_size, id, &handle)); 112 sender_->Send(new ChildProcessHostMsg_SyncAllocateSharedBitmap(
113 memory_size, id, &handle));
114 if (!send_success)
115 return nullptr;
113 memory = base::WrapUnique(new base::SharedMemory(handle, false)); 116 memory = base::WrapUnique(new base::SharedMemory(handle, false));
114 if (!memory->Map(memory_size)) 117 if (!memory->Map(memory_size))
115 CollectMemoryUsageAndDie(size, memory_size); 118 CollectMemoryUsageAndDie(size, memory_size);
116 #else 119 #else
117 memory = ChildThreadImpl::AllocateSharedMemory(memory_size, sender_.get()); 120 bool out_of_memory;
118 if (!memory) 121 memory = ChildThreadImpl::AllocateSharedMemory(memory_size, sender_.get(),
119 CollectMemoryUsageAndDie(size, memory_size); 122 &out_of_memory);
123 if (!memory) {
124 if (out_of_memory)
125 CollectMemoryUsageAndDie(size, memory_size);
126 else
127 return nullptr;
128 }
120 129
121 if (!memory->Map(memory_size)) 130 if (!memory->Map(memory_size))
122 CollectMemoryUsageAndDie(size, memory_size); 131 CollectMemoryUsageAndDie(size, memory_size);
123 132
124 base::SharedMemoryHandle handle_to_send = memory->handle(); 133 base::SharedMemoryHandle handle_to_send = memory->handle();
125 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( 134 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap(
126 memory_size, handle_to_send, id)); 135 memory_size, handle_to_send, id));
127 #endif 136 #endif
128 return base::WrapUnique( 137 return base::WrapUnique(
129 new ChildSharedBitmap(sender_, std::move(memory), id)); 138 new ChildSharedBitmap(sender_, std::move(memory), id));
(...skipping 14 matching lines...) Expand all
144 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send)) 153 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send))
145 return std::unique_ptr<cc::SharedBitmap>(); 154 return std::unique_ptr<cc::SharedBitmap>();
146 #endif 155 #endif
147 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( 156 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap(
148 mem->mapped_size(), handle_to_send, id)); 157 mem->mapped_size(), handle_to_send, id));
149 158
150 return base::WrapUnique(new ChildSharedBitmap(sender_, mem, id)); 159 return base::WrapUnique(new ChildSharedBitmap(sender_, mem, id));
151 } 160 }
152 161
153 } // namespace content 162 } // namespace content
OLDNEW
« no previous file with comments | « content/child/blob_storage/webblobregistry_impl.cc ('k') | content/child/child_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698