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

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

Issue 2028833003: Exit immediately on failure to allocate SharedMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | no next file » | 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool send_success = 111 bool send_success =
112 sender_->Send(new ChildProcessHostMsg_SyncAllocateSharedBitmap( 112 sender_->Send(new ChildProcessHostMsg_SyncAllocateSharedBitmap(
113 memory_size, id, &handle)); 113 memory_size, id, &handle));
114 if (!send_success) 114 if (!send_success) {
115 return nullptr; 115 // Callers of this method are not prepared to handle failures during
116 // shutdown. Exit immediately. https://crbug.com/615121.
117 exit(EXIT_SUCCESS);
Avi (use Gerrit) 2016/06/01 21:07:38 /base/process/memory.h's TerminateBecauseOutOfMemo
erikchen 2016/06/01 21:10:46 That is both inaccurate, as this is not an OOM, an
118 }
116 memory = base::WrapUnique(new base::SharedMemory(handle, false)); 119 memory = base::WrapUnique(new base::SharedMemory(handle, false));
117 if (!memory->Map(memory_size)) 120 if (!memory->Map(memory_size))
118 CollectMemoryUsageAndDie(size, memory_size); 121 CollectMemoryUsageAndDie(size, memory_size);
119 #else 122 #else
120 bool out_of_memory; 123 bool out_of_memory;
121 memory = ChildThreadImpl::AllocateSharedMemory(memory_size, sender_.get(), 124 memory = ChildThreadImpl::AllocateSharedMemory(memory_size, sender_.get(),
122 &out_of_memory); 125 &out_of_memory);
123 if (!memory) { 126 if (!memory) {
124 if (out_of_memory) 127 if (out_of_memory) {
125 CollectMemoryUsageAndDie(size, memory_size); 128 CollectMemoryUsageAndDie(size, memory_size);
126 else 129 } else {
127 return nullptr; 130 // Callers of this method are not prepared to handle failures during
131 // shutdown. Exit immediately. https://crbug.com/615121.
132 exit(EXIT_SUCCESS);
133 }
128 } 134 }
129 135
130 if (!memory->Map(memory_size)) 136 if (!memory->Map(memory_size))
131 CollectMemoryUsageAndDie(size, memory_size); 137 CollectMemoryUsageAndDie(size, memory_size);
132 138
133 base::SharedMemoryHandle handle_to_send = memory->handle(); 139 base::SharedMemoryHandle handle_to_send = memory->handle();
134 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( 140 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap(
135 memory_size, handle_to_send, id)); 141 memory_size, handle_to_send, id));
136 #endif 142 #endif
137 return base::WrapUnique( 143 return base::WrapUnique(
(...skipping 15 matching lines...) Expand all
153 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send)) 159 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send))
154 return std::unique_ptr<cc::SharedBitmap>(); 160 return std::unique_ptr<cc::SharedBitmap>();
155 #endif 161 #endif
156 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( 162 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap(
157 mem->mapped_size(), handle_to_send, id)); 163 mem->mapped_size(), handle_to_send, id));
158 164
159 return base::WrapUnique(new ChildSharedBitmap(sender_, mem, id)); 165 return base::WrapUnique(new ChildSharedBitmap(sender_, mem, id));
160 } 166 }
161 167
162 } // namespace content 168 } // namespace content
OLDNEW
« 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