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

Side by Side Diff: content/common/host_discardable_shared_memory_manager.h

Issue 1004043002: Re-land: base: Implement browser process support for discardable memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set allocator instance for blink tests Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ 5 #ifndef CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_
6 #define CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ 6 #define CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/discardable_memory_shmem_allocator.h" 10 #include "base/memory/discardable_memory_shmem_allocator.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 linked_ptr<base::DiscardableSharedMemory> memory; 64 linked_ptr<base::DiscardableSharedMemory> memory;
65 base::ProcessHandle process_handle; 65 base::ProcessHandle process_handle;
66 }; 66 };
67 67
68 static bool CompareMemoryUsageTime(const MemorySegment& a, 68 static bool CompareMemoryUsageTime(const MemorySegment& a,
69 const MemorySegment& b) { 69 const MemorySegment& b) {
70 // In this system, LRU memory segment is evicted first. 70 // In this system, LRU memory segment is evicted first.
71 return a.memory->last_known_usage() > b.memory->last_known_usage(); 71 return a.memory->last_known_usage() > b.memory->last_known_usage();
72 } 72 }
73 73
74 void AllocateLockedDiscardableSharedMemory(
75 base::ProcessHandle process_handle,
76 size_t size,
77 base::SharedMemoryHandle* shared_memory_handle);
74 void OnMemoryPressure( 78 void OnMemoryPressure(
75 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); 79 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
76 void ReduceMemoryUsageUntilWithinMemoryLimit(); 80 void ReduceMemoryUsageUntilWithinMemoryLimit();
77 void ReduceMemoryUsageUntilWithinLimit(size_t limit); 81 void ReduceMemoryUsageUntilWithinLimit(size_t limit);
78 void BytesAllocatedChanged(size_t new_bytes_allocated) const; 82 void BytesAllocatedChanged(size_t new_bytes_allocated) const;
79 83
80 // Virtual for tests. 84 // Virtual for tests.
81 virtual base::Time Now() const; 85 virtual base::Time Now() const;
82 virtual void ScheduleEnforceMemoryPolicy(); 86 virtual void ScheduleEnforceMemoryPolicy();
83 87
84 base::Lock lock_; 88 base::Lock lock_;
85 // Note: The elements in |segments_| are arranged in such a way that they form 89 // Note: The elements in |segments_| are arranged in such a way that they form
86 // a heap. The LRU memory segment always first. 90 // a heap. The LRU memory segment always first.
87 typedef std::vector<MemorySegment> MemorySegmentVector; 91 typedef std::vector<MemorySegment> MemorySegmentVector;
88 MemorySegmentVector segments_; 92 MemorySegmentVector segments_;
89 size_t memory_limit_; 93 size_t memory_limit_;
90 size_t bytes_allocated_; 94 size_t bytes_allocated_;
91 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; 95 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
92 bool enforce_memory_policy_pending_; 96 bool enforce_memory_policy_pending_;
93 base::WeakPtrFactory<HostDiscardableSharedMemoryManager> weak_ptr_factory_; 97 base::WeakPtrFactory<HostDiscardableSharedMemoryManager> weak_ptr_factory_;
94 98
95 DISALLOW_COPY_AND_ASSIGN(HostDiscardableSharedMemoryManager); 99 DISALLOW_COPY_AND_ASSIGN(HostDiscardableSharedMemoryManager);
96 }; 100 };
97 101
98 } // namespace content 102 } // namespace content
99 103
100 #endif // CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ 104 #endif // CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/common/host_discardable_shared_memory_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698