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

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

Issue 17106004: Add discardable memory emulation for non-android/mac platforms (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix MemoryAfterUnlock test Created 7 years, 1 month 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 <mach/mach.h> 7 #include <mach/mach.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 private: 68 private:
69 void* const memory_; 69 void* const memory_;
70 const size_t size_; 70 const size_t size_;
71 71
72 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryMac); 72 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryMac);
73 }; 73 };
74 74
75 } // namespace 75 } // namespace
76 76
77 // static 77 // static
78 bool DiscardableMemory::Supported() { 78 bool DiscardableMemory::SupportedNatively() {
79 return true; 79 return true;
80 } 80 }
81 81
82 // static 82 // static
83 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory( 83 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory(
84 size_t size) { 84 size_t size) {
85 vm_address_t buffer = 0; 85 vm_address_t buffer = 0;
86 kern_return_t ret = vm_allocate(mach_task_self(), 86 kern_return_t ret = vm_allocate(mach_task_self(),
87 &buffer, 87 &buffer,
88 size, 88 size,
(...skipping 13 matching lines...) Expand all
102 return true; 102 return true;
103 } 103 }
104 104
105 // static 105 // static
106 void DiscardableMemory::PurgeForTesting() { 106 void DiscardableMemory::PurgeForTesting() {
107 int state = 0; 107 int state = 0;
108 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state); 108 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state);
109 } 109 }
110 110
111 } // namespace base 111 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698