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/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 is_allocated_ = false; | 35 is_allocated_ = false; |
36 } | 36 } |
37 | 37 |
38 bool is_locked() const { return is_locked_; } | 38 bool is_locked() const { return is_locked_; } |
39 | 39 |
40 private: | 40 private: |
41 bool is_allocated_; | 41 bool is_allocated_; |
42 bool is_locked_; | 42 bool is_locked_; |
43 }; | 43 }; |
44 | 44 |
| 45 // Tests can assume that the default limit is at least 1024. Tests that rely on |
| 46 // something else needs to explicit set the limit. |
| 47 const size_t kDefaultMemoryLimit = 1024; |
| 48 const size_t kDefaultBytesToKeepUnderModeratePressure = kDefaultMemoryLimit; |
| 49 |
45 class DiscardableMemoryManagerTestBase { | 50 class DiscardableMemoryManagerTestBase { |
46 public: | 51 public: |
47 DiscardableMemoryManagerTestBase() { | 52 DiscardableMemoryManagerTestBase() |
| 53 : manager_(kDefaultMemoryLimit, |
| 54 kDefaultBytesToKeepUnderModeratePressure) { |
48 manager_.RegisterMemoryPressureListener(); | 55 manager_.RegisterMemoryPressureListener(); |
49 } | 56 } |
50 | 57 |
51 protected: | 58 protected: |
52 enum LockStatus { | 59 enum LockStatus { |
53 LOCK_STATUS_FAILED, | 60 LOCK_STATUS_FAILED, |
54 LOCK_STATUS_PURGED, | 61 LOCK_STATUS_PURGED, |
55 LOCK_STATUS_SUCCESS | 62 LOCK_STATUS_SUCCESS |
56 }; | 63 }; |
57 | 64 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 Unretained(this))); | 424 Unretained(this))); |
418 memory_usage_thread_.message_loop()->PostTask( | 425 memory_usage_thread_.message_loop()->PostTask( |
419 FROM_HERE, | 426 FROM_HERE, |
420 Bind(&ThreadedDiscardableMemoryManagerTest::SignalHelper, | 427 Bind(&ThreadedDiscardableMemoryManagerTest::SignalHelper, |
421 Unretained(this))); | 428 Unretained(this))); |
422 thread_sync_.Wait(); | 429 thread_sync_.Wait(); |
423 } | 430 } |
424 | 431 |
425 } // namespace | 432 } // namespace |
426 } // namespace base | 433 } // namespace base |
OLD | NEW |