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

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

Issue 654593002: base: Add NOTREACHED() for when using a non-supported discardable memory type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/memory/discardable_memory_android.cc ('k') | base/memory/discardable_memory_mac.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/memory/discardable_memory.h" 5 #include "base/memory/discardable_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/discardable_memory_emulated.h" 8 #include "base/memory/discardable_memory_emulated.h"
9 #include "base/memory/discardable_memory_malloc.h" 9 #include "base/memory/discardable_memory_malloc.h"
10 10
(...skipping 11 matching lines...) Expand all
22 DISCARDABLE_MEMORY_TYPE_EMULATED, 22 DISCARDABLE_MEMORY_TYPE_EMULATED,
23 DISCARDABLE_MEMORY_TYPE_MALLOC 23 DISCARDABLE_MEMORY_TYPE_MALLOC
24 }; 24 };
25 types->assign(supported_types, supported_types + arraysize(supported_types)); 25 types->assign(supported_types, supported_types + arraysize(supported_types));
26 } 26 }
27 27
28 // static 28 // static
29 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType( 29 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
30 DiscardableMemoryType type, size_t size) { 30 DiscardableMemoryType type, size_t size) {
31 switch (type) { 31 switch (type) {
32 case DISCARDABLE_MEMORY_TYPE_NONE:
33 case DISCARDABLE_MEMORY_TYPE_ASHMEM:
34 case DISCARDABLE_MEMORY_TYPE_MAC:
35 return scoped_ptr<DiscardableMemory>();
36 case DISCARDABLE_MEMORY_TYPE_EMULATED: { 32 case DISCARDABLE_MEMORY_TYPE_EMULATED: {
37 scoped_ptr<internal::DiscardableMemoryEmulated> memory( 33 scoped_ptr<internal::DiscardableMemoryEmulated> memory(
38 new internal::DiscardableMemoryEmulated(size)); 34 new internal::DiscardableMemoryEmulated(size));
39 if (!memory->Initialize()) 35 if (!memory->Initialize())
40 return scoped_ptr<DiscardableMemory>(); 36 return scoped_ptr<DiscardableMemory>();
41 37
42 return memory.PassAs<DiscardableMemory>(); 38 return memory.PassAs<DiscardableMemory>();
43 } 39 }
44 case DISCARDABLE_MEMORY_TYPE_MALLOC: { 40 case DISCARDABLE_MEMORY_TYPE_MALLOC: {
45 scoped_ptr<internal::DiscardableMemoryMalloc> memory( 41 scoped_ptr<internal::DiscardableMemoryMalloc> memory(
46 new internal::DiscardableMemoryMalloc(size)); 42 new internal::DiscardableMemoryMalloc(size));
47 if (!memory->Initialize()) 43 if (!memory->Initialize())
48 return scoped_ptr<DiscardableMemory>(); 44 return scoped_ptr<DiscardableMemory>();
49 45
50 return memory.PassAs<DiscardableMemory>(); 46 return memory.PassAs<DiscardableMemory>();
51 } 47 }
48 case DISCARDABLE_MEMORY_TYPE_NONE:
49 case DISCARDABLE_MEMORY_TYPE_ASHMEM:
50 case DISCARDABLE_MEMORY_TYPE_MAC:
51 NOTREACHED();
52 return scoped_ptr<DiscardableMemory>();
52 } 53 }
53 54
54 NOTREACHED(); 55 NOTREACHED();
55 return scoped_ptr<DiscardableMemory>(); 56 return scoped_ptr<DiscardableMemory>();
56 } 57 }
57 58
58 // static 59 // static
59 void DiscardableMemory::PurgeForTesting() { 60 void DiscardableMemory::PurgeForTesting() {
60 internal::DiscardableMemoryEmulated::PurgeForTesting(); 61 internal::DiscardableMemoryEmulated::PurgeForTesting();
61 } 62 }
62 63
63 } // namespace base 64 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_android.cc ('k') | base/memory/discardable_memory_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698