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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/tile_priority.h ('k') | cc/scheduler/delay_based_time_source.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/tile_priority.cc
diff --git a/cc/resources/tile_priority.cc b/cc/resources/tile_priority.cc
index 18678d2123ba4f0bc00a806d8dda42513bd0c787..26826af450e192fd6b0f60fba13fa2198478d63d 100644
--- a/cc/resources/tile_priority.cc
+++ b/cc/resources/tile_priority.cc
@@ -4,110 +4,95 @@
#include "cc/resources/tile_priority.h"
+#include "base/debug/trace_event_argument.h"
#include "base/values.h"
#include "cc/base/math_util.h"
namespace cc {
-scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree) {
+std::string WhichTreeToString(WhichTree tree) {
switch (tree) {
case ACTIVE_TREE:
- return scoped_ptr<base::Value>(new base::StringValue("ACTIVE_TREE"));
+ return "ACTIVE_TREE";
case PENDING_TREE:
- return scoped_ptr<base::Value>(new base::StringValue("PENDING_TREE"));
+ return "PENDING_TREE";
default:
DCHECK(false) << "Unrecognized WhichTree value " << tree;
- return scoped_ptr<base::Value>(new base::StringValue(
- "<unknown WhichTree value>"));
+ return "<unknown WhichTree value>";
}
}
-scoped_ptr<base::Value> TileResolutionAsValue(
- TileResolution resolution) {
+std::string TileResolutionToString(TileResolution resolution) {
switch (resolution) {
case LOW_RESOLUTION:
- return scoped_ptr<base::Value>(new base::StringValue("LOW_RESOLUTION"));
+ return "LOW_RESOLUTION";
case HIGH_RESOLUTION:
- return scoped_ptr<base::Value>(new base::StringValue("HIGH_RESOLUTION"));
+ return "HIGH_RESOLUTION";
case NON_IDEAL_RESOLUTION:
- return scoped_ptr<base::Value>(new base::StringValue(
- "NON_IDEAL_RESOLUTION"));
+ return "NON_IDEAL_RESOLUTION";
}
DCHECK(false) << "Unrecognized TileResolution value " << resolution;
- return scoped_ptr<base::Value>(new base::StringValue(
- "<unknown TileResolution value>"));
+ return "<unknown TileResolution value>";
}
-scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin) {
+std::string TilePriorityBinToString(TilePriority::PriorityBin bin) {
switch (bin) {
case TilePriority::NOW:
- return scoped_ptr<base::Value>(new base::StringValue("NOW"));
+ return "NOW";
case TilePriority::SOON:
- return scoped_ptr<base::Value>(new base::StringValue("SOON"));
+ return "SOON";
case TilePriority::EVENTUALLY:
- return scoped_ptr<base::Value>(new base::StringValue("EVENTUALLY"));
+ return "EVENTUALLY";
}
DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin;
- return scoped_ptr<base::Value>(
- new base::StringValue("<unknown TilePriority::PriorityBin value>"));
+ return "<unknown TilePriority::PriorityBin value>";
}
-scoped_ptr<base::Value> TilePriority::AsValue() const {
- scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
- state->Set("resolution", TileResolutionAsValue(resolution).release());
- state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release());
- state->Set("distance_to_visible",
- MathUtil::AsValueSafely(distance_to_visible).release());
- return state.PassAs<base::Value>();
+void TilePriority::AsValueInto(base::debug::TracedValue* state) const {
+ state->SetString("resolution", TileResolutionToString(resolution));
+ state->SetString("priority_bin", TilePriorityBinToString(priority_bin));
+ state->SetDouble("distance_to_visible",
+ MathUtil::AsDoubleSafely(distance_to_visible));
}
-scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue(
- TileMemoryLimitPolicy policy) {
+std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy) {
switch (policy) {
case ALLOW_NOTHING:
- return scoped_ptr<base::Value>(new base::StringValue("ALLOW_NOTHING"));
+ return "ALLOW_NOTHING";
case ALLOW_ABSOLUTE_MINIMUM:
- return scoped_ptr<base::Value>(new base::StringValue(
- "ALLOW_ABSOLUTE_MINIMUM"));
+ return "ALLOW_ABSOLUTE_MINIMUM";
case ALLOW_PREPAINT_ONLY:
- return scoped_ptr<base::Value>(new base::StringValue(
- "ALLOW_PREPAINT_ONLY"));
+ return "ALLOW_PREPAINT_ONLY";
case ALLOW_ANYTHING:
- return scoped_ptr<base::Value>(new base::StringValue(
- "ALLOW_ANYTHING"));
+ return "ALLOW_ANYTHING";
default:
DCHECK(false) << "Unrecognized policy value";
- return scoped_ptr<base::Value>(new base::StringValue(
- "<unknown>"));
+ return "<unknown>";
}
}
-scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) {
+std::string TreePriorityToString(TreePriority prio) {
switch (prio) {
case SAME_PRIORITY_FOR_BOTH_TREES:
- return scoped_ptr<base::Value>(new base::StringValue(
- "SAME_PRIORITY_FOR_BOTH_TREES"));
+ return "SAME_PRIORITY_FOR_BOTH_TREES";
case SMOOTHNESS_TAKES_PRIORITY:
- return scoped_ptr<base::Value>(new base::StringValue(
- "SMOOTHNESS_TAKES_PRIORITY"));
+ return "SMOOTHNESS_TAKES_PRIORITY";
case NEW_CONTENT_TAKES_PRIORITY:
- return scoped_ptr<base::Value>(new base::StringValue(
- "NEW_CONTENT_TAKES_PRIORITY"));
+ return "NEW_CONTENT_TAKES_PRIORITY";
default:
DCHECK(false) << "Unrecognized priority value " << prio;
- return scoped_ptr<base::Value>(new base::StringValue("<unknown>"));
+ return "<unknown>";
}
}
-scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const {
- scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
- state->Set("memory_limit_policy",
- TileMemoryLimitPolicyAsValue(memory_limit_policy).release());
+void GlobalStateThatImpactsTilePriority::AsValueInto(
+ base::debug::TracedValue* state) const {
+ state->SetString("memory_limit_policy",
+ TileMemoryLimitPolicyToString(memory_limit_policy));
state->SetInteger("soft_memory_limit_in_bytes", soft_memory_limit_in_bytes);
state->SetInteger("hard_memory_limit_in_bytes", hard_memory_limit_in_bytes);
state->SetInteger("num_resources_limit", num_resources_limit);
- state->Set("tree_priority", TreePriorityAsValue(tree_priority).release());
- return state.PassAs<base::Value>();
+ state->SetString("tree_priority", TreePriorityToString(tree_priority));
}
} // namespace cc
« 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