| Index: chrome/browser/resources/profiler/profiler.js | 
| diff --git a/chrome/browser/resources/profiler/profiler.js b/chrome/browser/resources/profiler/profiler.js | 
| index ec573ad57a3f680368aad011973a9979db400f4c..d018814f6358c509b212aa2e37103afdf1be49bf 100644 | 
| --- a/chrome/browser/resources/profiler/profiler.js | 
| +++ b/chrome/browser/resources/profiler/profiler.js | 
| @@ -127,6 +127,17 @@ var MainView = (function() { | 
| var KEY_QUEUE_TIME = END_KEY++; | 
| var KEY_AVG_QUEUE_TIME = END_KEY++; | 
| var KEY_MAX_QUEUE_TIME = END_KEY++; | 
| +  if (loadTimeData.getBoolean('enableMemoryTaskProfiler')) { | 
| +    var KEY_AVG_ALLOC_OPS = END_KEY++; | 
| +    var KEY_AVG_FREE_OPS = END_KEY++; | 
| +    var KEY_AVG_NET_BYTES = END_KEY++; | 
| +    var KEY_MAX_ALLOCATED_BYTES = END_KEY++; | 
| +    var KEY_ALLOC_OPS = END_KEY++; | 
| +    var KEY_FREE_OPS = END_KEY++; | 
| +    var KEY_ALLOCATED_BYTES = END_KEY++; | 
| +    var KEY_FREED_BYTES = END_KEY++; | 
| +    var KEY_ALLOC_OVERHEAD_BYTES = END_KEY++; | 
| +  } | 
| var KEY_BIRTH_THREAD = END_KEY++; | 
| var KEY_DEATH_THREAD = END_KEY++; | 
| var KEY_PROCESS_TYPE = END_KEY++; | 
| @@ -243,6 +254,47 @@ var MainView = (function() { | 
| })(); | 
|  | 
| /** | 
| +   * This aggregator computes an average by summing the difference of two | 
| +   * numeric fields, summing a count, and then dividing the totals. | 
| +   */ | 
| +  var AvgDiffAggregator = (function() { | 
| +    function Aggregator(numeratorPosKey, numeratorNegKey, divisorKey) { | 
| +      this.numeratorPosKey_ = numeratorPosKey; | 
| +      this.numeratorNegKey_ = numeratorNegKey; | 
| +      this.divisorKey_ = divisorKey; | 
| + | 
| +      this.numeratorSum_ = 0; | 
| +      this.divisorSum_ = 0; | 
| +    } | 
| + | 
| +    Aggregator.prototype = { | 
| +      consume: function(e) { | 
| +        this.numeratorSum_ += | 
| +            e[this.numeratorPosKey_] - e[this.numeratorNegKey_]; | 
| +        this.divisorSum_ += e[this.divisorKey_]; | 
| +      }, | 
| + | 
| +      getValue: function() { | 
| +        return this.numeratorSum_ / this.divisorSum_; | 
| +      }, | 
| + | 
| +      getValueAsText: function() { | 
| +        return formatNumberAsText(this.getValue()); | 
| +      }, | 
| +    }; | 
| + | 
| +    return { | 
| +      create: function(numeratorPosKey, numeratorNegKey, divisorKey) { | 
| +        return { | 
| +          create: function(key) { | 
| +            return new Aggregator(numeratorPosKey, numeratorNegKey, divisorKey); | 
| +          }, | 
| +        }; | 
| +      } | 
| +    }; | 
| +  })(); | 
| + | 
| +  /** | 
| * This aggregator finds the maximum for a numeric field. | 
| */ | 
| var MaxAggregator = (function() { | 
| @@ -418,6 +470,93 @@ var MainView = (function() { | 
| diff: diffFuncForCount, | 
| }; | 
|  | 
| +  if (loadTimeData.getBoolean('enableMemoryTaskProfiler')) { | 
| +    KEY_PROPERTIES[KEY_AVG_ALLOC_OPS] = { | 
| +      name: 'Avg Allocations', | 
| +      cellAlignment: 'right', | 
| +      sortDescending: true, | 
| +      textPrinter: formatNumberAsText, | 
| +      aggregator: AvgAggregator.create(KEY_ALLOC_OPS, KEY_COUNT), | 
| +    }; | 
| + | 
| +    KEY_PROPERTIES[KEY_AVG_FREE_OPS] = { | 
| +      name: 'Avg Frees', | 
| +      cellAlignment: 'right', | 
| +      sortDescending: true, | 
| +      textPrinter: formatNumberAsText, | 
| +      aggregator: AvgAggregator.create(KEY_FREE_OPS, KEY_COUNT), | 
| +    }; | 
| + | 
| +    KEY_PROPERTIES[KEY_AVG_NET_BYTES] = { | 
| +      name: 'Avg Net Bytes', | 
| +      cellAlignment: 'right', | 
| +      sortDescending: true, | 
| +      textPrinter: formatNumberAsText, | 
| +      aggregator: AvgDiffAggregator.create(KEY_ALLOCATED_BYTES, | 
| +                                           KEY_FREED_BYTES, KEY_COUNT), | 
| +    }; | 
| + | 
| +    KEY_PROPERTIES[KEY_ALLOC_OPS] = { | 
| +      name: 'Allocation count', | 
| +      cellAlignment: 'right', | 
| +      sortDescending: true, | 
| +      textPrinter: formatNumberAsText, | 
| +      inputJsonKey: 'death_data.alloc_ops', | 
| +      aggregator: SumAggregator, | 
| +      diff: diffFuncForCount, | 
| +    }; | 
| + | 
| +    KEY_PROPERTIES[KEY_FREE_OPS] = { | 
| +      name: 'Free Count', | 
| +      cellAlignment: 'right', | 
| +      sortDescending: true, | 
| +      textPrinter: formatNumberAsText, | 
| +      inputJsonKey: 'death_data.free_ops', | 
| +      aggregator: SumAggregator, | 
| +      diff: diffFuncForCount, | 
| +    }; | 
| + | 
| +    KEY_PROPERTIES[KEY_ALLOCATED_BYTES] = { | 
| +      name: 'Allocated bytes', | 
| +      cellAlignment: 'right', | 
| +      sortDescending: true, | 
| +      textPrinter: formatNumberAsText, | 
| +      inputJsonKey: 'death_data.allocated_bytes', | 
| +      aggregator: SumAggregator, | 
| +      diff: diffFuncForCount, | 
| +    }; | 
| + | 
| +    KEY_PROPERTIES[KEY_FREED_BYTES] = { | 
| +      name: 'Freed bytes', | 
| +      cellAlignment: 'right', | 
| +      sortDescending: true, | 
| +      textPrinter: formatNumberAsText, | 
| +      inputJsonKey: 'death_data.freed_bytes', | 
| +      aggregator: SumAggregator, | 
| +      diff: diffFuncForCount, | 
| +    }; | 
| + | 
| +    KEY_PROPERTIES[KEY_ALLOC_OVERHEAD_BYTES] = { | 
| +      name: 'Overhead bytes', | 
| +      cellAlignment: 'right', | 
| +      sortDescending: true, | 
| +      textPrinter: formatNumberAsText, | 
| +      inputJsonKey: 'death_data.alloc_overhead_bytes', | 
| +      aggregator: SumAggregator, | 
| +      diff: diffFuncForCount, | 
| +    }; | 
| + | 
| +    KEY_PROPERTIES[KEY_MAX_ALLOCATED_BYTES] = { | 
| +      name: 'Max allocated (outstanding) bytes', | 
| +      cellAlignment: 'right', | 
| +      sortDescending: true, | 
| +      textPrinter: formatNumberAsText, | 
| +      inputJsonKey: 'death_data.max_allocated_bytes', | 
| +      aggregator: MaxAggregator, | 
| +      diff: diffFuncForMax, | 
| +    }; | 
| +  } | 
| + | 
| KEY_PROPERTIES[KEY_AVG_RUN_TIME] = { | 
| name: 'Avg run time', | 
| cellAlignment: 'right', | 
| @@ -482,6 +621,16 @@ var MainView = (function() { | 
| KEY_QUEUE_TIME, | 
| ]; | 
|  | 
| +  if (loadTimeData.getBoolean('enableMemoryTaskProfiler')) { | 
| +    INITIALLY_HIDDEN_KEYS = INITIALLY_HIDDEN_KEYS.concat([ | 
| +      KEY_ALLOC_OPS, | 
| +      KEY_FREE_OPS, | 
| +      KEY_ALLOCATED_BYTES, | 
| +      KEY_FREED_BYTES, | 
| +      KEY_ALLOC_OVERHEAD_BYTES, | 
| +    ]); | 
| +  } | 
| + | 
| /** | 
| * The ordered list of grouping choices to expose in the "Group by" | 
| * dropdowns. We don't include the numeric properties, since they | 
| @@ -1916,7 +2065,7 @@ var MainView = (function() { | 
| for (var i = 0; i < this.snapshots_.length; ++i) { | 
| var checkbox = this.getSnapshotCheckbox_(i); | 
| checkbox.parentNode.parentNode.className = | 
| -            checkbox.checked ? 'selected_snapshot' : ''; | 
| +            checkbox.checked ? 'selected-snapshot' : ''; | 
| } | 
| }, | 
|  | 
|  |