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

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

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

Powered by Google App Engine
This is Rietveld 408576698