| Index: base/memory/discardable_shared_memory.h
|
| diff --git a/base/memory/discardable_shared_memory.h b/base/memory/discardable_shared_memory.h
|
| index ca2accf1a2ebb51e6f027ab13882c0f1e30b0747..a408dc2cc22c0de13c233469bff486168f2c09cd 100644
|
| --- a/base/memory/discardable_shared_memory.h
|
| +++ b/base/memory/discardable_shared_memory.h
|
| @@ -5,6 +5,10 @@
|
| #ifndef BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_
|
| #define BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_
|
|
|
| +#ifndef NDEBUG
|
| +#include <set>
|
| +#endif
|
| +
|
| #include "base/base_export.h"
|
| #include "base/memory/shared_memory.h"
|
| #include "base/time/time.h"
|
| @@ -32,21 +36,24 @@ class BASE_EXPORT DiscardableSharedMemory {
|
| bool Map(size_t size);
|
|
|
| // The actual size of the mapped memory (may be larger than requested).
|
| - size_t mapped_size() const { return shared_memory_.mapped_size(); }
|
| + size_t mapped_size() const { return mapped_size_; }
|
|
|
| // Returns a shared memory handle for this DiscardableSharedMemory object.
|
| SharedMemoryHandle handle() const { return shared_memory_.handle(); }
|
|
|
| - // Locks the memory so that it will not be purged by the system. Returns
|
| - // true if successful and the memory is still resident. Locking can fail
|
| - // for three reasons; object might have been purged, our last known usage
|
| + // Locks a range of memory so that it will not be purged by the system.
|
| + // Returns true if successful and the memory is still resident. Locking can
|
| + // fail for three reasons; object might have been purged, our last known usage
|
| // timestamp might be out of date or memory might already be locked. Last
|
| // know usage time is updated to the actual last usage timestamp if memory
|
| - // is still resident or 0 if not.
|
| - bool Lock();
|
| + // is still resident or 0 if not. The range of memory must be unlocked. The
|
| + // result of trying to lock an already locked range is undefined.
|
| + bool Lock(size_t offset, size_t length);
|
|
|
| - // Unlock previously successfully locked memory.
|
| - void Unlock();
|
| + // Unlock a previously successfully locked range of memory. The range of
|
| + // memory must be locked. The result of trying to unlock a not
|
| + // previously locked range is undefined.
|
| + void Unlock(size_t offset, size_t length);
|
|
|
| // Gets a pointer to the opened discardable memory space. Discardable memory
|
| // must have been mapped via Map().
|
| @@ -99,6 +106,11 @@ class BASE_EXPORT DiscardableSharedMemory {
|
| virtual Time Now() const;
|
|
|
| SharedMemory shared_memory_;
|
| + size_t mapped_size_;
|
| + size_t locked_page_count_;
|
| +#ifndef NDEBUG
|
| + std::set<size_t> locked_pages_;
|
| +#endif
|
| Time last_known_usage_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory);
|
|
|