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

Side by Side Diff: base/process/memory.cc

Issue 2173463002: Make base::TerminateBecauseOutOfMemory call RaiseException on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implement in memory_stubs Created 4 years, 5 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 | « base/process/memory.h ('k') | base/process/memory_stubs.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/debug/alias.h" 5 #include "base/debug/alias.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/process/memory.h" 7 #include "base/process/memory.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 namespace base { 10 namespace base {
11 11
12 // Defined in memory_win.cc for Windows.
13 #if !defined(OS_WIN)
14
12 namespace { 15 namespace {
13 16
14 // Breakpad server classifies base::`anonymous namespace'::OnNoMemory as 17 // Breakpad server classifies base::`anonymous namespace'::OnNoMemory as
15 // out-of-memory crash. 18 // out-of-memory crash.
16 NOINLINE void OnNoMemory(size_t size) { 19 NOINLINE void OnNoMemory(size_t size) {
17 size_t tmp_size = size; 20 size_t tmp_size = size;
18 base::debug::Alias(&tmp_size); 21 base::debug::Alias(&tmp_size);
19 LOG(FATAL) << "Out of memory. size=" << tmp_size; 22 LOG(FATAL) << "Out of memory. size=" << tmp_size;
20 } 23 }
21 24
22 } // namespace 25 } // namespace
23 26
24 void TerminateBecauseOutOfMemory(size_t size) { 27 void TerminateBecauseOutOfMemory(size_t size) {
25 OnNoMemory(size); 28 OnNoMemory(size);
26 } 29 }
27 30
31 #endif
32
28 // Defined in memory_mac.mm for Mac. 33 // Defined in memory_mac.mm for Mac.
29 #if !defined(OS_MACOSX) 34 #if !defined(OS_MACOSX)
30 35
31 bool UncheckedCalloc(size_t num_items, size_t size, void** result) { 36 bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
32 const size_t alloc_size = num_items * size; 37 const size_t alloc_size = num_items * size;
33 38
34 // Overflow check 39 // Overflow check
35 if (size && ((alloc_size / size) != num_items)) { 40 if (size && ((alloc_size / size) != num_items)) {
36 *result = NULL; 41 *result = NULL;
37 return false; 42 return false;
38 } 43 }
39 44
40 if (!UncheckedMalloc(alloc_size, result)) 45 if (!UncheckedMalloc(alloc_size, result))
41 return false; 46 return false;
42 47
43 memset(*result, 0, alloc_size); 48 memset(*result, 0, alloc_size);
44 return true; 49 return true;
45 } 50 }
46 51
47 #endif 52 #endif
48 53
49 } // namespace base 54 } // namespace base
OLDNEW
« no previous file with comments | « base/process/memory.h ('k') | base/process/memory_stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698