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

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

Issue 114923005: base: Discardable memory types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 "base/lazy_instance.h"
6 #include "base/logging.h"
5 #include "base/memory/discardable_memory_emulated.h" 7 #include "base/memory/discardable_memory_emulated.h"
6 8
7 namespace base { 9 namespace base {
10 namespace {
11
12 struct SupportedTypeVector {
13 SupportedTypeVector() {
14 v.push_back(DISCARDABLE_MEMORY_EMULATED);
15 }
16 std::vector<DiscardableMemoryType> v;
17 };
18 LazyInstance<SupportedTypeVector>::Leaky g_supported_types =
19 LAZY_INSTANCE_INITIALIZER;
20
21 } // namespace
8 22
9 // static 23 // static
10 bool DiscardableMemory::SupportedNatively() { 24 const std::vector<DiscardableMemoryType>&
11 return false; 25 DiscardableMemory::GetSupportedTypes() {
26 return g_supported_types.Get().v;
12 } 27 }
13 28
14 // static 29 // static
15 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory( 30 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory(
16 size_t size) { 31 size_t size) {
17 scoped_ptr<internal::DiscardableMemoryEmulated> memory( 32 switch (GetType()) {
18 new internal::DiscardableMemoryEmulated(size)); 33 case DISCARDABLE_MEMORY_NONE:
19 if (!memory->Initialize()) 34 case DISCARDABLE_MEMORY_ANDROID:
20 return scoped_ptr<DiscardableMemory>(); 35 case DISCARDABLE_MEMORY_MAC:
36 return scoped_ptr<DiscardableMemory>();
37 case DISCARDABLE_MEMORY_EMULATED: {
38 scoped_ptr<internal::DiscardableMemoryEmulated> memory(
39 new internal::DiscardableMemoryEmulated(size));
40 if (!memory->Initialize())
41 return scoped_ptr<DiscardableMemory>();
21 42
22 return memory.PassAs<DiscardableMemory>(); 43 return memory.PassAs<DiscardableMemory>();
44 }
45 }
46
47 NOTREACHED();
48 return scoped_ptr<DiscardableMemory>();
23 } 49 }
24 50
25 // static 51 // static
26 bool DiscardableMemory::PurgeForTestingSupported() { 52 bool DiscardableMemory::PurgeForTestingSupported() {
27 return true; 53 return true;
28 } 54 }
29 55
30 // static 56 // static
31 void DiscardableMemory::PurgeForTesting() { 57 void DiscardableMemory::PurgeForTesting() {
32 internal::DiscardableMemoryEmulated::PurgeForTesting(); 58 internal::DiscardableMemoryEmulated::PurgeForTesting();
33 } 59 }
34 60
35 } // namespace base 61 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698