Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: cc/resources/tile_priority.cc

Issue 380763002: Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed memory leak found by Linux ASAN Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/tile_priority.h ('k') | cc/scheduler/delay_based_time_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/debug/trace_event_argument.h"
7 #include "base/values.h" 8 #include "base/values.h"
8 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
9 10
10 namespace cc { 11 namespace cc {
11 12
12 scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree) { 13 std::string WhichTreeToString(WhichTree tree) {
13 switch (tree) { 14 switch (tree) {
14 case ACTIVE_TREE: 15 case ACTIVE_TREE:
15 return scoped_ptr<base::Value>(new base::StringValue("ACTIVE_TREE")); 16 return "ACTIVE_TREE";
16 case PENDING_TREE: 17 case PENDING_TREE:
17 return scoped_ptr<base::Value>(new base::StringValue("PENDING_TREE")); 18 return "PENDING_TREE";
18 default: 19 default:
19 DCHECK(false) << "Unrecognized WhichTree value " << tree; 20 DCHECK(false) << "Unrecognized WhichTree value " << tree;
20 return scoped_ptr<base::Value>(new base::StringValue( 21 return "<unknown WhichTree value>";
21 "<unknown WhichTree value>"));
22 } 22 }
23 } 23 }
24 24
25 scoped_ptr<base::Value> TileResolutionAsValue( 25 std::string TileResolutionToString(TileResolution resolution) {
26 TileResolution resolution) {
27 switch (resolution) { 26 switch (resolution) {
28 case LOW_RESOLUTION: 27 case LOW_RESOLUTION:
29 return scoped_ptr<base::Value>(new base::StringValue("LOW_RESOLUTION")); 28 return "LOW_RESOLUTION";
30 case HIGH_RESOLUTION: 29 case HIGH_RESOLUTION:
31 return scoped_ptr<base::Value>(new base::StringValue("HIGH_RESOLUTION")); 30 return "HIGH_RESOLUTION";
32 case NON_IDEAL_RESOLUTION: 31 case NON_IDEAL_RESOLUTION:
33 return scoped_ptr<base::Value>(new base::StringValue( 32 return "NON_IDEAL_RESOLUTION";
34 "NON_IDEAL_RESOLUTION"));
35 } 33 }
36 DCHECK(false) << "Unrecognized TileResolution value " << resolution; 34 DCHECK(false) << "Unrecognized TileResolution value " << resolution;
37 return scoped_ptr<base::Value>(new base::StringValue( 35 return "<unknown TileResolution value>";
38 "<unknown TileResolution value>"));
39 } 36 }
40 37
41 scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin) { 38 std::string TilePriorityBinToString(TilePriority::PriorityBin bin) {
42 switch (bin) { 39 switch (bin) {
43 case TilePriority::NOW: 40 case TilePriority::NOW:
44 return scoped_ptr<base::Value>(new base::StringValue("NOW")); 41 return "NOW";
45 case TilePriority::SOON: 42 case TilePriority::SOON:
46 return scoped_ptr<base::Value>(new base::StringValue("SOON")); 43 return "SOON";
47 case TilePriority::EVENTUALLY: 44 case TilePriority::EVENTUALLY:
48 return scoped_ptr<base::Value>(new base::StringValue("EVENTUALLY")); 45 return "EVENTUALLY";
49 } 46 }
50 DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin; 47 DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin;
51 return scoped_ptr<base::Value>( 48 return "<unknown TilePriority::PriorityBin value>";
52 new base::StringValue("<unknown TilePriority::PriorityBin value>"));
53 } 49 }
54 50
55 scoped_ptr<base::Value> TilePriority::AsValue() const { 51 void TilePriority::AsValueInto(base::debug::TracedValue* state) const {
56 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 52 state->SetString("resolution", TileResolutionToString(resolution));
57 state->Set("resolution", TileResolutionAsValue(resolution).release()); 53 state->SetString("priority_bin", TilePriorityBinToString(priority_bin));
58 state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release()); 54 state->SetDouble("distance_to_visible",
59 state->Set("distance_to_visible", 55 MathUtil::AsDoubleSafely(distance_to_visible));
60 MathUtil::AsValueSafely(distance_to_visible).release());
61 return state.PassAs<base::Value>();
62 } 56 }
63 57
64 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( 58 std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy) {
65 TileMemoryLimitPolicy policy) {
66 switch (policy) { 59 switch (policy) {
67 case ALLOW_NOTHING: 60 case ALLOW_NOTHING:
68 return scoped_ptr<base::Value>(new base::StringValue("ALLOW_NOTHING")); 61 return "ALLOW_NOTHING";
69 case ALLOW_ABSOLUTE_MINIMUM: 62 case ALLOW_ABSOLUTE_MINIMUM:
70 return scoped_ptr<base::Value>(new base::StringValue( 63 return "ALLOW_ABSOLUTE_MINIMUM";
71 "ALLOW_ABSOLUTE_MINIMUM"));
72 case ALLOW_PREPAINT_ONLY: 64 case ALLOW_PREPAINT_ONLY:
73 return scoped_ptr<base::Value>(new base::StringValue( 65 return "ALLOW_PREPAINT_ONLY";
74 "ALLOW_PREPAINT_ONLY"));
75 case ALLOW_ANYTHING: 66 case ALLOW_ANYTHING:
76 return scoped_ptr<base::Value>(new base::StringValue( 67 return "ALLOW_ANYTHING";
77 "ALLOW_ANYTHING"));
78 default: 68 default:
79 DCHECK(false) << "Unrecognized policy value"; 69 DCHECK(false) << "Unrecognized policy value";
80 return scoped_ptr<base::Value>(new base::StringValue( 70 return "<unknown>";
81 "<unknown>"));
82 } 71 }
83 } 72 }
84 73
85 scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) { 74 std::string TreePriorityToString(TreePriority prio) {
86 switch (prio) { 75 switch (prio) {
87 case SAME_PRIORITY_FOR_BOTH_TREES: 76 case SAME_PRIORITY_FOR_BOTH_TREES:
88 return scoped_ptr<base::Value>(new base::StringValue( 77 return "SAME_PRIORITY_FOR_BOTH_TREES";
89 "SAME_PRIORITY_FOR_BOTH_TREES"));
90 case SMOOTHNESS_TAKES_PRIORITY: 78 case SMOOTHNESS_TAKES_PRIORITY:
91 return scoped_ptr<base::Value>(new base::StringValue( 79 return "SMOOTHNESS_TAKES_PRIORITY";
92 "SMOOTHNESS_TAKES_PRIORITY"));
93 case NEW_CONTENT_TAKES_PRIORITY: 80 case NEW_CONTENT_TAKES_PRIORITY:
94 return scoped_ptr<base::Value>(new base::StringValue( 81 return "NEW_CONTENT_TAKES_PRIORITY";
95 "NEW_CONTENT_TAKES_PRIORITY"));
96 default: 82 default:
97 DCHECK(false) << "Unrecognized priority value " << prio; 83 DCHECK(false) << "Unrecognized priority value " << prio;
98 return scoped_ptr<base::Value>(new base::StringValue("<unknown>")); 84 return "<unknown>";
99 } 85 }
100 } 86 }
101 87
102 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { 88 void GlobalStateThatImpactsTilePriority::AsValueInto(
103 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 89 base::debug::TracedValue* state) const {
104 state->Set("memory_limit_policy", 90 state->SetString("memory_limit_policy",
105 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); 91 TileMemoryLimitPolicyToString(memory_limit_policy));
106 state->SetInteger("soft_memory_limit_in_bytes", soft_memory_limit_in_bytes); 92 state->SetInteger("soft_memory_limit_in_bytes", soft_memory_limit_in_bytes);
107 state->SetInteger("hard_memory_limit_in_bytes", hard_memory_limit_in_bytes); 93 state->SetInteger("hard_memory_limit_in_bytes", hard_memory_limit_in_bytes);
108 state->SetInteger("num_resources_limit", num_resources_limit); 94 state->SetInteger("num_resources_limit", num_resources_limit);
109 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); 95 state->SetString("tree_priority", TreePriorityToString(tree_priority));
110 return state.PassAs<base::Value>();
111 } 96 }
112 97
113 } // namespace cc 98 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_priority.h ('k') | cc/scheduler/delay_based_time_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698