Index: base/memory/discardable_memory_manager_unittest.cc |
diff --git a/base/memory/discardable_memory_manager_unittest.cc b/base/memory/discardable_memory_manager_unittest.cc |
index 58a9603ec86354685ac613199e204cd027deff7e..af7b3b34fef456d345085bacf8fd23bd6dabe2db 100644 |
--- a/base/memory/discardable_memory_manager_unittest.cc |
+++ b/base/memory/discardable_memory_manager_unittest.cc |
@@ -15,7 +15,7 @@ namespace { |
class TestAllocationImpl : public internal::DiscardableMemoryManagerAllocation { |
public: |
- TestAllocationImpl() : is_allocated_(false), is_locked_(false) {} |
+ TestAllocationImpl() : is_allocated_(false), is_locked_(false), bytes_(0) {} |
virtual ~TestAllocationImpl() { DCHECK(!is_locked_); } |
// Overridden from internal::DiscardableMemoryManagerAllocation: |
@@ -24,15 +24,19 @@ class TestAllocationImpl : public internal::DiscardableMemoryManagerAllocation { |
is_allocated_ = true; |
DCHECK(!is_locked_); |
is_locked_ = true; |
+ DCHECK(!bytes_ || bytes_ == bytes); |
reveman
2014/04/26 00:13:37
how about we remove the |bytes| parameter from All
Philippe
2014/04/28 12:23:14
Good idea, I was tempted to make the change too.
|
+ bytes_ = bytes; |
return was_allocated; |
} |
virtual void ReleaseLock() OVERRIDE { |
- DCHECK(is_locked_); |
+ DCHECK_EQ(is_locked_, is_allocated_); |
reveman
2014/04/26 00:13:37
hm, this seems unnecessary. What sequence of event
Philippe
2014/04/28 12:23:14
I think this was needed for the zero allocation (w
|
is_locked_ = false; |
} |
virtual void Purge() OVERRIDE { |
- DCHECK(is_allocated_); |
+ // Allocation only happens for non-zero sizes. |
+ DCHECK_EQ(is_allocated_, !!bytes_); |
is_allocated_ = false; |
+ bytes_ = 0; |
} |
bool is_locked() const { return is_locked_; } |
@@ -40,6 +44,7 @@ class TestAllocationImpl : public internal::DiscardableMemoryManagerAllocation { |
private: |
bool is_allocated_; |
bool is_locked_; |
+ size_t bytes_; |
}; |
class DiscardableMemoryManagerTestBase { |