| OLD | NEW |
| 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/memory/discardable_memory.h" | 5 #include "base/memory/discardable_memory.h" |
| 6 | 6 |
| 7 #include <sys/mman.h> | 7 #include <sys/mman.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 // Upper limit on the number of discardable memory to avoid hitting file | 24 // Upper limit on the number of discardable memory to avoid hitting file |
| 25 // descriptor limit. | 25 // descriptor limit. |
| 26 const int kDiscardableMemoryNumLimit = 128; | 26 const int kDiscardableMemoryNumLimit = 128; |
| 27 | 27 |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace base { | 30 namespace base { |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 bool DiscardableMemory::Supported() { | 33 bool DiscardableMemory::SupportedNatively() { |
| 34 return true; | 34 return true; |
| 35 } | 35 } |
| 36 | 36 |
| 37 DiscardableMemory::~DiscardableMemory() { | 37 DiscardableMemory::~DiscardableMemory() { |
| 38 if (is_locked_) | 38 if (is_locked_) |
| 39 Unlock(); | 39 Unlock(); |
| 40 // If fd_ is smaller than 0, initialization must have failed and | 40 // If fd_ is smaller than 0, initialization must have failed and |
| 41 // g_num_discardable_memory is not incremented by the caller. | 41 // g_num_discardable_memory is not incremented by the caller. |
| 42 if (fd_ < 0) | 42 if (fd_ < 0) |
| 43 return; | 43 return; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 bool DiscardableMemory::PurgeForTestingSupported() { | 155 bool DiscardableMemory::PurgeForTestingSupported() { |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| 158 | 158 |
| 159 // static | 159 // static |
| 160 void DiscardableMemory::PurgeForTesting() { | 160 void DiscardableMemory::PurgeForTesting() { |
| 161 NOTIMPLEMENTED(); | 161 NOTIMPLEMENTED(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace base | 164 } // namespace base |
| OLD | NEW |