| OLD | NEW |
| 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 #include "base/memory/discardable_memory_manager.h" | 5 #include "base/memory/discardable_memory_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 return was_allocated; | 26 return was_allocated; |
| 27 } | 27 } |
| 28 void ReleaseLock() override { | 28 void ReleaseLock() override { |
| 29 DCHECK(is_locked_); | 29 DCHECK(is_locked_); |
| 30 is_locked_ = false; | 30 is_locked_ = false; |
| 31 } | 31 } |
| 32 void Purge() override { | 32 void Purge() override { |
| 33 DCHECK(is_allocated_); | 33 DCHECK(is_allocated_); |
| 34 is_allocated_ = false; | 34 is_allocated_ = false; |
| 35 } | 35 } |
| 36 virtual bool IsMemoryResident() const override { |
| 37 DCHECK(is_allocated_); |
| 38 return true; |
| 39 } |
| 36 | 40 |
| 37 bool is_locked() const { return is_locked_; } | 41 bool is_locked() const { return is_locked_; } |
| 38 | 42 |
| 39 private: | 43 private: |
| 40 bool is_allocated_; | 44 bool is_allocated_; |
| 41 bool is_locked_; | 45 bool is_locked_; |
| 42 }; | 46 }; |
| 43 | 47 |
| 44 // Tests can assume that the default limit is at least 1024. Tests that rely on | 48 // Tests can assume that the default limit is at least 1024. Tests that rely on |
| 45 // something else needs to explicit set the limit. | 49 // something else needs to explicit set the limit. |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 Unretained(this))); | 485 Unretained(this))); |
| 482 memory_usage_thread_.message_loop()->PostTask( | 486 memory_usage_thread_.message_loop()->PostTask( |
| 483 FROM_HERE, | 487 FROM_HERE, |
| 484 Bind(&ThreadedDiscardableMemoryManagerTest::SignalHelper, | 488 Bind(&ThreadedDiscardableMemoryManagerTest::SignalHelper, |
| 485 Unretained(this))); | 489 Unretained(this))); |
| 486 thread_sync_.Wait(); | 490 thread_sync_.Wait(); |
| 487 } | 491 } |
| 488 | 492 |
| 489 } // namespace | 493 } // namespace |
| 490 } // namespace base | 494 } // namespace base |
| OLD | NEW |