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

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: Add switches::kUseDiscardableMemory to kForwardSwitches Created 6 years, 11 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 | Annotate | Revision Log
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"
6
7 #include "base/logging.h"
5 #include "base/memory/discardable_memory_emulated.h" 8 #include "base/memory/discardable_memory_emulated.h"
6 9
7 namespace base { 10 namespace base {
8 11
9 // static 12 // static
10 bool DiscardableMemory::SupportedNatively() { 13 void DiscardableMemory::GetSupportedTypes(
11 return false; 14 std::vector<DiscardableMemoryType>* types) {
15 const DiscardableMemoryType supported_types[] = {
16 DISCARDABLE_MEMORY_TYPE_EMULATED
17 };
18 types->assign(supported_types, supported_types + arraysize(supported_types));
12 } 19 }
13 20
14 // static 21 // static
15 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory( 22 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
16 size_t size) { 23 DiscardableMemoryType type, size_t size) {
17 scoped_ptr<internal::DiscardableMemoryEmulated> memory( 24 switch (type) {
18 new internal::DiscardableMemoryEmulated(size)); 25 case DISCARDABLE_MEMORY_TYPE_NONE:
19 if (!memory->Initialize()) 26 case DISCARDABLE_MEMORY_TYPE_ANDROID:
20 return scoped_ptr<DiscardableMemory>(); 27 case DISCARDABLE_MEMORY_TYPE_MAC:
28 return scoped_ptr<DiscardableMemory>();
29 case DISCARDABLE_MEMORY_TYPE_EMULATED: {
30 scoped_ptr<internal::DiscardableMemoryEmulated> memory(
31 new internal::DiscardableMemoryEmulated(size));
32 if (!memory->Initialize())
33 return scoped_ptr<DiscardableMemory>();
21 34
22 return memory.PassAs<DiscardableMemory>(); 35 return memory.PassAs<DiscardableMemory>();
36 }
37 }
38
39 NOTREACHED();
40 return scoped_ptr<DiscardableMemory>();
23 } 41 }
24 42
25 // static 43 // static
26 bool DiscardableMemory::PurgeForTestingSupported() { 44 bool DiscardableMemory::PurgeForTestingSupported() {
27 return true; 45 return true;
28 } 46 }
29 47
30 // static 48 // static
31 void DiscardableMemory::PurgeForTesting() { 49 void DiscardableMemory::PurgeForTesting() {
32 internal::DiscardableMemoryEmulated::PurgeForTesting(); 50 internal::DiscardableMemoryEmulated::PurgeForTesting();
33 } 51 }
34 52
35 } // namespace base 53 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_unittest.cc ('k') | chrome/browser/chromeos/login/chrome_restart_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698