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

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

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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_unittest.cc ('k') | base/memory/memory_pressure_listener.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 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"
9 #include "base/memory/discardable_memory_shmem.h" 8 #include "base/memory/discardable_memory_shmem.h"
10 9
11 namespace base { 10 namespace base {
12 11
13 // static 12 // static
14 bool DiscardableMemory::ReduceMemoryUsage() {
15 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
16 }
17
18 // static
19 void DiscardableMemory::GetSupportedTypes( 13 void DiscardableMemory::GetSupportedTypes(
20 std::vector<DiscardableMemoryType>* types) { 14 std::vector<DiscardableMemoryType>* types) {
21 const DiscardableMemoryType supported_types[] = { 15 const DiscardableMemoryType supported_types[] = {
22 DISCARDABLE_MEMORY_TYPE_SHMEM, 16 DISCARDABLE_MEMORY_TYPE_SHMEM
23 DISCARDABLE_MEMORY_TYPE_EMULATED
24 }; 17 };
25 types->assign(supported_types, supported_types + arraysize(supported_types)); 18 types->assign(supported_types, supported_types + arraysize(supported_types));
26 } 19 }
27 20
28 // static 21 // static
29 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType( 22 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
30 DiscardableMemoryType type, size_t size) { 23 DiscardableMemoryType type, size_t size) {
31 switch (type) { 24 switch (type) {
32 case DISCARDABLE_MEMORY_TYPE_EMULATED: { 25 case DISCARDABLE_MEMORY_TYPE_SHMEM:
33 scoped_ptr<internal::DiscardableMemoryEmulated> memory( 26 return make_scoped_ptr(new internal::DiscardableMemoryShmem(size));
34 new internal::DiscardableMemoryEmulated(size));
35 if (!memory->Initialize())
36 return nullptr;
37
38 return memory.Pass();
39 }
40 case DISCARDABLE_MEMORY_TYPE_SHMEM: {
41 scoped_ptr<internal::DiscardableMemoryShmem> memory(
42 new internal::DiscardableMemoryShmem(size));
43 if (!memory->Initialize())
44 return nullptr;
45
46 return memory.Pass();
47 }
48 case DISCARDABLE_MEMORY_TYPE_NONE: 27 case DISCARDABLE_MEMORY_TYPE_NONE:
49 case DISCARDABLE_MEMORY_TYPE_ASHMEM:
50 case DISCARDABLE_MEMORY_TYPE_MACH:
51 NOTREACHED(); 28 NOTREACHED();
52 return nullptr; 29 return nullptr;
53 } 30 }
54 31
55 NOTREACHED(); 32 NOTREACHED();
56 return nullptr; 33 return nullptr;
57 } 34 }
58 35
59 } // namespace base 36 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_unittest.cc ('k') | base/memory/memory_pressure_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698