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

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

Issue 2045713002: [Merge to 2743] Exit immediately on failure to allocate SharedMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
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. This is expected behavior during the Fast
117 // Shutdown path, so use EXIT_SUCCESS. https://crbug.com/615121.
118 exit(EXIT_SUCCESS);
119 }
116 memory = base::WrapUnique(new base::SharedMemory(handle, false)); 120 memory = base::WrapUnique(new base::SharedMemory(handle, false));
117 if (!memory->Map(memory_size)) 121 if (!memory->Map(memory_size))
118 CollectMemoryUsageAndDie(size, memory_size); 122 CollectMemoryUsageAndDie(size, memory_size);
119 #else 123 #else
120 bool out_of_memory; 124 bool out_of_memory;
121 memory = ChildThreadImpl::AllocateSharedMemory(memory_size, sender_.get(), 125 memory = ChildThreadImpl::AllocateSharedMemory(memory_size, sender_.get(),
122 &out_of_memory); 126 &out_of_memory);
123 if (!memory) { 127 if (!memory) {
124 if (out_of_memory) 128 if (out_of_memory) {
125 CollectMemoryUsageAndDie(size, memory_size); 129 CollectMemoryUsageAndDie(size, memory_size);
126 else 130 } else {
127 return nullptr; 131 // Callers of this method are not prepared to handle failures during
132 // shutdown. Exit immediately. This is expected behavior during the Fast
133 // Shutdown path, so use EXIT_SUCCESS. https://crbug.com/615121.
134 exit(EXIT_SUCCESS);
135 }
128 } 136 }
129 137
130 if (!memory->Map(memory_size)) 138 if (!memory->Map(memory_size))
131 CollectMemoryUsageAndDie(size, memory_size); 139 CollectMemoryUsageAndDie(size, memory_size);
132 140
133 base::SharedMemoryHandle handle_to_send = memory->handle(); 141 base::SharedMemoryHandle handle_to_send = memory->handle();
134 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( 142 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap(
135 memory_size, handle_to_send, id)); 143 memory_size, handle_to_send, id));
136 #endif 144 #endif
137 return base::WrapUnique( 145 return base::WrapUnique(
(...skipping 15 matching lines...) Expand all
153 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send)) 161 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send))
154 return std::unique_ptr<cc::SharedBitmap>(); 162 return std::unique_ptr<cc::SharedBitmap>();
155 #endif 163 #endif
156 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( 164 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap(
157 mem->mapped_size(), handle_to_send, id)); 165 mem->mapped_size(), handle_to_send, id));
158 166
159 return base::WrapUnique(new ChildSharedBitmap(sender_, mem, id)); 167 return base::WrapUnique(new ChildSharedBitmap(sender_, mem, id));
160 } 168 }
161 169
162 } // namespace content 170 } // 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