disable two ClientCertStoreChromeOSTest.* unit_tests on Valgrind bots
[chromium-blink-merge.git] / cc / tiles / tile_priority.cc
blob0efe51e59728af49a4782b81f4d69aebafa829cb
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
3 // found in the LICENSE file.
5 #include "cc/tiles/tile_priority.h"
7 #include "base/numerics/safe_conversions.h"
8 #include "base/trace_event/trace_event_argument.h"
9 #include "base/values.h"
10 #include "cc/base/math_util.h"
12 namespace cc {
14 std::string WhichTreeToString(WhichTree tree) {
15 switch (tree) {
16 case ACTIVE_TREE:
17 return "ACTIVE_TREE";
18 case PENDING_TREE:
19 return "PENDING_TREE";
20 default:
21 DCHECK(false) << "Unrecognized WhichTree value " << tree;
22 return "<unknown WhichTree value>";
26 std::string TileResolutionToString(TileResolution resolution) {
27 switch (resolution) {
28 case LOW_RESOLUTION:
29 return "LOW_RESOLUTION";
30 case HIGH_RESOLUTION:
31 return "HIGH_RESOLUTION";
32 case NON_IDEAL_RESOLUTION:
33 return "NON_IDEAL_RESOLUTION";
35 DCHECK(false) << "Unrecognized TileResolution value " << resolution;
36 return "<unknown TileResolution value>";
39 std::string TilePriorityBinToString(TilePriority::PriorityBin bin) {
40 switch (bin) {
41 case TilePriority::NOW:
42 return "NOW";
43 case TilePriority::SOON:
44 return "SOON";
45 case TilePriority::EVENTUALLY:
46 return "EVENTUALLY";
48 DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin;
49 return "<unknown TilePriority::PriorityBin value>";
52 void TilePriority::AsValueInto(base::trace_event::TracedValue* state) const {
53 state->SetString("resolution", TileResolutionToString(resolution));
54 state->SetString("priority_bin", TilePriorityBinToString(priority_bin));
55 state->SetDouble("distance_to_visible",
56 MathUtil::AsDoubleSafely(distance_to_visible));
59 std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy) {
60 switch (policy) {
61 case ALLOW_NOTHING:
62 return "ALLOW_NOTHING";
63 case ALLOW_ABSOLUTE_MINIMUM:
64 return "ALLOW_ABSOLUTE_MINIMUM";
65 case ALLOW_PREPAINT_ONLY:
66 return "ALLOW_PREPAINT_ONLY";
67 case ALLOW_ANYTHING:
68 return "ALLOW_ANYTHING";
69 default:
70 DCHECK(false) << "Unrecognized policy value";
71 return "<unknown>";
75 std::string TreePriorityToString(TreePriority prio) {
76 switch (prio) {
77 case SAME_PRIORITY_FOR_BOTH_TREES:
78 return "SAME_PRIORITY_FOR_BOTH_TREES";
79 case SMOOTHNESS_TAKES_PRIORITY:
80 return "SMOOTHNESS_TAKES_PRIORITY";
81 case NEW_CONTENT_TAKES_PRIORITY:
82 return "NEW_CONTENT_TAKES_PRIORITY";
83 default:
84 DCHECK(false) << "Unrecognized priority value " << prio;
85 return "<unknown>";
89 void GlobalStateThatImpactsTilePriority::AsValueInto(
90 base::trace_event::TracedValue* state) const {
91 state->SetString("memory_limit_policy",
92 TileMemoryLimitPolicyToString(memory_limit_policy));
93 state->SetInteger("soft_memory_limit_in_bytes",
94 base::saturated_cast<int>(soft_memory_limit_in_bytes));
95 state->SetInteger("hard_memory_limit_in_bytes",
96 base::saturated_cast<int>(hard_memory_limit_in_bytes));
97 state->SetInteger("num_resources_limit",
98 base::saturated_cast<int>(num_resources_limit));
99 state->SetString("tree_priority", TreePriorityToString(tree_priority));
102 } // namespace cc