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

Unified Diff: base/memory/discardable_memory_manager_unittest.cc

Issue 195863005: Use DiscardableMemoryManager on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix base.gypi Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
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 {
« base/memory/discardable_memory_manager.cc ('K') | « base/memory/discardable_memory_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698