Chromium Code Reviews| Index: gpu/command_buffer/client/mapped_memory.h |
| diff --git a/gpu/command_buffer/client/mapped_memory.h b/gpu/command_buffer/client/mapped_memory.h |
| index ec70c430de5969f66e652242b8554254e6c932b0..0446ad5b616906880af331dcf302c753b1714cd0 100644 |
| --- a/gpu/command_buffer/client/mapped_memory.h |
| +++ b/gpu/command_buffer/client/mapped_memory.h |
| @@ -79,7 +79,7 @@ class GPU_EXPORT MemoryChunk { |
| allocator_.FreePendingToken(pointer, token); |
| } |
| - // Frees any blocks who's tokens have passed. |
| + // Frees any blocks whose tokens have passed. |
| void FreeUnused() { |
| allocator_.FreeUnused(); |
| } |
| @@ -90,11 +90,15 @@ class GPU_EXPORT MemoryChunk { |
| pointer < reinterpret_cast<const int8*>(shm_.ptr) + shm_.size; |
| } |
| - // Returns true of any memory in this chuck is in use. |
| + // Returns true of any memory in this chunk is in use. |
| bool InUse() { |
| return allocator_.InUse(); |
| } |
| + size_t bytes_in_use() const { |
| + return allocator_.bytes_in_use(); |
| + } |
| + |
| private: |
| int32 shm_id_; |
| gpu::Buffer shm_; |
| @@ -103,10 +107,15 @@ class GPU_EXPORT MemoryChunk { |
| DISALLOW_COPY_AND_ASSIGN(MemoryChunk); |
| }; |
| -// Manages MemoryChucks. |
| +// Manages MemoryChunks. |
| class GPU_EXPORT MappedMemoryManager { |
| public: |
| - explicit MappedMemoryManager(CommandBufferHelper* helper); |
| + enum MemoryLimit { |
| + kNoLimit = 0, |
| + }; |
| + |
| + MappedMemoryManager(CommandBufferHelper* helper, |
| + size_t memory_limit); |
|
no sievers
2013/08/20 22:48:10
nit: also unused_memory_reclaim_limit here and mov
kaanb
2013/08/20 22:56:02
Done.
|
| ~MappedMemoryManager(); |
| @@ -146,10 +155,15 @@ class GPU_EXPORT MappedMemoryManager { |
| void FreeUnused(); |
| // Used for testing |
| - size_t num_chunks() { |
| + size_t num_chunks() const { |
| return chunks_.size(); |
| } |
| + // Used for testing |
| + size_t allocated_memory() const { |
| + return allocated_memory_; |
| + } |
| + |
| private: |
| typedef ScopedVector<MemoryChunk> MemoryChunkVector; |
| @@ -157,6 +171,8 @@ class GPU_EXPORT MappedMemoryManager { |
| unsigned int chunk_size_multiple_; |
| CommandBufferHelper* helper_; |
| MemoryChunkVector chunks_; |
| + size_t allocated_memory_; |
| + size_t max_free_bytes_; |
| DISALLOW_COPY_AND_ASSIGN(MappedMemoryManager); |
| }; |