OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/resources/tile_priority.h" | 5 #include "cc/resources/tile_priority.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
(...skipping 23 matching lines...) Expand all Loading... |
34 "NON_IDEAL_RESOLUTION")); | 34 "NON_IDEAL_RESOLUTION")); |
35 } | 35 } |
36 DCHECK(false) << "Unrecognized TileResolution value " << resolution; | 36 DCHECK(false) << "Unrecognized TileResolution value " << resolution; |
37 return scoped_ptr<base::Value>(new base::StringValue( | 37 return scoped_ptr<base::Value>(new base::StringValue( |
38 "<unknown TileResolution value>")); | 38 "<unknown TileResolution value>")); |
39 } | 39 } |
40 | 40 |
41 scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin) { | 41 scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin) { |
42 switch (bin) { | 42 switch (bin) { |
43 case TilePriority::NOW: | 43 case TilePriority::NOW: |
44 return scoped_ptr<base::Value>(base::Value::CreateStringValue("NOW")); | 44 return scoped_ptr<base::Value>(new base::StringValue("NOW")); |
45 case TilePriority::SOON: | 45 case TilePriority::SOON: |
46 return scoped_ptr<base::Value>(base::Value::CreateStringValue("SOON")); | 46 return scoped_ptr<base::Value>(new base::StringValue("SOON")); |
47 case TilePriority::EVENTUALLY: | 47 case TilePriority::EVENTUALLY: |
48 return scoped_ptr<base::Value>( | 48 return scoped_ptr<base::Value>(new base::StringValue("EVENTUALLY")); |
49 base::Value::CreateStringValue("EVENTUALLY")); | |
50 } | 49 } |
51 DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin; | 50 DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin; |
52 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 51 return scoped_ptr<base::Value>( |
53 "<unknown TilePriority::PriorityBin value>")); | 52 new base::StringValue("<unknown TilePriority::PriorityBin value>")); |
54 } | 53 } |
55 | 54 |
56 scoped_ptr<base::Value> TilePriority::AsValue() const { | 55 scoped_ptr<base::Value> TilePriority::AsValue() const { |
57 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 56 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
58 state->Set("resolution", TileResolutionAsValue(resolution).release()); | 57 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
59 state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release()); | 58 state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release()); |
60 state->Set("distance_to_visible", | 59 state->Set("distance_to_visible", |
61 MathUtil::AsValueSafely(distance_to_visible).release()); | 60 MathUtil::AsValueSafely(distance_to_visible).release()); |
62 return state.PassAs<base::Value>(); | 61 return state.PassAs<base::Value>(); |
63 } | 62 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 state->Set("memory_limit_policy", | 104 state->Set("memory_limit_policy", |
106 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); | 105 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); |
107 state->SetInteger("soft_memory_limit_in_bytes", soft_memory_limit_in_bytes); | 106 state->SetInteger("soft_memory_limit_in_bytes", soft_memory_limit_in_bytes); |
108 state->SetInteger("hard_memory_limit_in_bytes", hard_memory_limit_in_bytes); | 107 state->SetInteger("hard_memory_limit_in_bytes", hard_memory_limit_in_bytes); |
109 state->SetInteger("num_resources_limit", num_resources_limit); | 108 state->SetInteger("num_resources_limit", num_resources_limit); |
110 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); | 109 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); |
111 return state.PassAs<base::Value>(); | 110 return state.PassAs<base::Value>(); |
112 } | 111 } |
113 | 112 |
114 } // namespace cc | 113 } // namespace cc |
OLD | NEW |