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

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

Issue 15650016: [Not for review] Discardable memory emulation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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 (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 11 matching lines...) Expand all
22 int g_num_discardable_memory = 0; 22 int g_num_discardable_memory = 0;
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
33 bool DiscardableMemory::Supported() {
34 return true;
35 }
36
37 DiscardableMemory::~DiscardableMemory() { 32 DiscardableMemory::~DiscardableMemory() {
38 if (is_locked_) 33 if (is_locked_)
39 Unlock(); 34 Unlock();
40 // If fd_ is smaller than 0, initialization must have failed and 35 // If fd_ is smaller than 0, initialization must have failed and
41 // g_num_discardable_memory is not incremented by the caller. 36 // g_num_discardable_memory is not incremented by the caller.
42 if (fd_ < 0) 37 if (fd_ < 0)
43 return; 38 return;
44 HANDLE_EINTR(close(fd_)); 39 HANDLE_EINTR(close(fd_));
45 fd_ = -1; 40 fd_ = -1;
46 ReleaseFileDescriptor(); 41 ReleaseFileDescriptor();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 bool DiscardableMemory::PurgeForTestingSupported() { 150 bool DiscardableMemory::PurgeForTestingSupported() {
156 return false; 151 return false;
157 } 152 }
158 153
159 // static 154 // static
160 void DiscardableMemory::PurgeForTesting() { 155 void DiscardableMemory::PurgeForTesting() {
161 NOTIMPLEMENTED(); 156 NOTIMPLEMENTED();
162 } 157 }
163 158
164 } // namespace base 159 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698