Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "managed_memory_policy.h" | 5 #include "managed_memory_policy.h" |
| 6 | 6 |
| 7 #include "priority_calculator.h" | 7 #include "priority_calculator.h" |
| 8 | 8 |
| 9 namespace cc { | 9 namespace cc { |
| 10 | 10 |
| 11 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytesLimitWhenVisible) | 11 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytesLimitWhenVisible) |
| 12 : bytesLimitWhenVisible(bytesLimitWhenVisible) | 12 : bytesLimitWhenVisible(bytesLimitWhenVisible) |
| 13 , priorityCutoffWhenVisible(PriorityCalculator::allowEverythingCutoff()) | 13 , priorityCutoffWhenVisible(CUTOFF_ALLOW_EVERYTHING) |
| 14 , bytesLimitWhenNotVisible(0) | 14 , bytesLimitWhenNotVisible(0) |
| 15 , priorityCutoffWhenNotVisible(PriorityCalculator::allowNothingCutoff()) | 15 , priorityCutoffWhenNotVisible(CUTOFF_ALLOW_NOTHING) |
| 16 { | 16 { |
| 17 } | 17 } |
| 18 | 18 |
| 19 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytesLimitWhenVisible, | 19 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytesLimitWhenVisible, |
| 20 int priorityCutoffWhenVisible, | 20 PriorityCutoff priorityCutoffWhenVisibl e, |
| 21 size_t bytesLimitWhenNotVisible, | 21 size_t bytesLimitWhenNotVisible, |
| 22 int priorityCutoffWhenNotVisible) | 22 PriorityCutoff priorityCutoffWhenNotVis ible) |
| 23 : bytesLimitWhenVisible(bytesLimitWhenVisible) | 23 : bytesLimitWhenVisible(bytesLimitWhenVisible) |
| 24 , priorityCutoffWhenVisible(priorityCutoffWhenVisible) | 24 , priorityCutoffWhenVisible(priorityCutoffWhenVisible) |
| 25 , bytesLimitWhenNotVisible(bytesLimitWhenNotVisible) | 25 , bytesLimitWhenNotVisible(bytesLimitWhenNotVisible) |
| 26 , priorityCutoffWhenNotVisible(priorityCutoffWhenNotVisible) | 26 , priorityCutoffWhenNotVisible(priorityCutoffWhenNotVisible) |
| 27 { | 27 { |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const | 30 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const |
| 31 { | 31 { |
| 32 return bytesLimitWhenVisible == other.bytesLimitWhenVisible && | 32 return bytesLimitWhenVisible == other.bytesLimitWhenVisible && |
| 33 priorityCutoffWhenVisible == other.priorityCutoffWhenVisible && | 33 priorityCutoffWhenVisible == other.priorityCutoffWhenVisible && |
| 34 bytesLimitWhenNotVisible == other.bytesLimitWhenNotVisible && | 34 bytesLimitWhenNotVisible == other.bytesLimitWhenNotVisible && |
| 35 priorityCutoffWhenNotVisible == other.priorityCutoffWhenNotVisible; | 35 priorityCutoffWhenNotVisible == other.priorityCutoffWhenNotVisible; |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const | 38 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const |
| 39 { | 39 { |
| 40 return !(*this == other); | 40 return !(*this == other); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // static | |
| 44 int ManagedMemoryPolicy::priorityCutoffToValue(PriorityCutoff priorityCutoff) | |
| 45 { | |
| 46 switch (priorityCutoff) { | |
|
ccameron
2012/12/26 23:55:54
These are just 1:1 mappings of different types.
| |
| 47 case CUTOFF_ALLOW_NOTHING: | |
| 48 return PriorityCalculator::allowNothingCutoff(); | |
| 49 case CUTOFF_ALLOW_REQUIRED_ONLY: | |
| 50 return PriorityCalculator::allowVisibleOnlyCutoff(); | |
| 51 case CUTOFF_ALLOW_NICE_TO_HAVE: | |
| 52 return PriorityCalculator::allowVisibleAndNearbyCutoff(); | |
| 53 case CUTOFF_ALLOW_EVERYTHING: | |
| 54 return PriorityCalculator::allowEverythingCutoff(); | |
| 55 } | |
| 56 NOTREACHED(); | |
| 57 return PriorityCalculator::allowNothingCutoff(); | |
| 58 } | |
| 59 | |
| 60 // static | |
| 61 TileMemoryLimitPolicy ManagedMemoryPolicy::priorityCutoffToTileMemoryLimitPolicy (PriorityCutoff priorityCutoff) | |
| 62 { | |
| 63 switch (priorityCutoff) { | |
| 64 case CUTOFF_ALLOW_NOTHING: | |
| 65 return ALLOW_NOTHING; | |
| 66 case CUTOFF_ALLOW_REQUIRED_ONLY: | |
| 67 return ALLOW_ABSOLUTE_MINIMUM; | |
| 68 case CUTOFF_ALLOW_NICE_TO_HAVE: | |
| 69 return ALLOW_PREPAINT_ONLY; | |
| 70 case CUTOFF_ALLOW_EVERYTHING: | |
| 71 return ALLOW_ANYTHING; | |
| 72 } | |
| 73 NOTREACHED(); | |
| 74 return ALLOW_NOTHING; | |
| 75 } | |
| 76 | |
| 43 } // namespace cc | 77 } // namespace cc |
| OLD | NEW |