| OLD | NEW |
| 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/logging.h" |
| 5 #include "base/memory/discardable_memory_emulated.h" | 6 #include "base/memory/discardable_memory_emulated.h" |
| 6 | 7 |
| 7 namespace base { | 8 namespace base { |
| 8 | 9 |
| 9 // static | 10 // static |
| 10 bool DiscardableMemory::SupportedNatively() { | 11 void DiscardableMemory::GetSupportedTypes( |
| 11 return false; | 12 std::vector<DiscardableMemoryType>* types) { |
| 13 types->push_back(DISCARDABLE_MEMORY_TYPE_EMULATED); |
| 12 } | 14 } |
| 13 | 15 |
| 14 // static | 16 // static |
| 15 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory( | 17 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory( |
| 16 size_t size) { | 18 size_t size) { |
| 17 scoped_ptr<internal::DiscardableMemoryEmulated> memory( | 19 switch (GetType()) { |
| 18 new internal::DiscardableMemoryEmulated(size)); | 20 case DISCARDABLE_MEMORY_TYPE_NONE: |
| 19 if (!memory->Initialize()) | 21 case DISCARDABLE_MEMORY_TYPE_ANDROID: |
| 20 return scoped_ptr<DiscardableMemory>(); | 22 case DISCARDABLE_MEMORY_TYPE_MAC: |
| 23 return scoped_ptr<DiscardableMemory>(); |
| 24 case DISCARDABLE_MEMORY_TYPE_EMULATED: { |
| 25 scoped_ptr<internal::DiscardableMemoryEmulated> memory( |
| 26 new internal::DiscardableMemoryEmulated(size)); |
| 27 if (!memory->Initialize()) |
| 28 return scoped_ptr<DiscardableMemory>(); |
| 21 | 29 |
| 22 return memory.PassAs<DiscardableMemory>(); | 30 return memory.PassAs<DiscardableMemory>(); |
| 31 } |
| 32 } |
| 33 |
| 34 NOTREACHED(); |
| 35 return scoped_ptr<DiscardableMemory>(); |
| 23 } | 36 } |
| 24 | 37 |
| 25 // static | 38 // static |
| 26 bool DiscardableMemory::PurgeForTestingSupported() { | 39 bool DiscardableMemory::PurgeForTestingSupported() { |
| 27 return true; | 40 return true; |
| 28 } | 41 } |
| 29 | 42 |
| 30 // static | 43 // static |
| 31 void DiscardableMemory::PurgeForTesting() { | 44 void DiscardableMemory::PurgeForTesting() { |
| 32 internal::DiscardableMemoryEmulated::PurgeForTesting(); | 45 internal::DiscardableMemoryEmulated::PurgeForTesting(); |
| 33 } | 46 } |
| 34 | 47 |
| 35 } // namespace base | 48 } // namespace base |
| OLD | NEW |