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

Unified Diff: chrome/browser/resources/file_manager/js/image_editor/image_util.js

Issue 8819013: Add UMA metrics to Photo Editor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 years 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
Index: chrome/browser/resources/file_manager/js/image_editor/image_util.js
diff --git a/chrome/browser/resources/file_manager/js/image_editor/image_util.js b/chrome/browser/resources/file_manager/js/image_editor/image_util.js
index 84607589edf89f3fc548ecd1c1e5074ab2f3f674..1594ca05e906ee98fb3f74973a460c890b7924a2 100644
--- a/chrome/browser/resources/file_manager/js/image_editor/image_util.js
+++ b/chrome/browser/resources/file_manager/js/image_editor/image_util.js
@@ -19,12 +19,16 @@ ImageUtil.trace = (function() {
};
PerformanceTrace.prototype.report = function(key, value) {
- if (!this.container_) return;
if (!(key in this.lines_)) {
- var div = this.lines_[key] = document.createElement('div');
- this.container_.appendChild(div);
+ if (this.container_) {
+ var div = this.lines_[key] = document.createElement('div');
+ this.container_.appendChild(div);
+ } else {
+ this.lines_[key] = {};
+ }
}
this.lines_[key].textContent = key + ': ' + value;
+ if (localStorage.logTrace) this.dumpLine(key);
};
PerformanceTrace.prototype.resetTimer = function(key) {
@@ -35,6 +39,15 @@ ImageUtil.trace = (function() {
this.report(key, (Date.now() - this.timers_[key]) + 'ms');
};
+ PerformanceTrace.prototype.dump = function() {
+ for (var key in this.lines_)
+ this.dumpLine(key);
+ };
+
+ PerformanceTrace.prototype.dumpLine = function(key) {
+ console.log('trace.' + this.lines_[key].textContent);
+ };
+
return new PerformanceTrace();
})();
@@ -350,6 +363,7 @@ ImageUtil.ImageLoader.prototype.load = function(
var self = this;
function startLoad() {
+ ImageUtil.metrics.startInterval(ImageUtil.getMetricName('LoadTime'));
self.timeout_ = null;
// The clients of this class sometimes request the same url repeatedly.
// The onload fires only if the src is different from the previous value.
@@ -404,8 +418,6 @@ ImageUtil.ImageLoader.prototype.convertImage_ = function(image) {
canvas.height = image.height;
}
- ImageUtil.trace.resetTimer('load-convert');
-
var context = canvas.getContext('2d');
context.save();
context.translate(canvas.width / 2, canvas.height / 2);
@@ -429,7 +441,9 @@ ImageUtil.ImageLoader.prototype.copyStrip_ = function(
if (lastRow == image.height) {
context.restore();
- ImageUtil.trace.reportTimer('load-convert');
+ if (this.url_.substr(0, 5) != 'data:') { // Ignore data urls.
+ ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('LoadTime'));
+ }
var callback = this.callback_;
this.callback_ = null;
callback(context.canvas);
@@ -473,3 +487,11 @@ ImageUtil.replaceFileNameInFullName = function(fullName, name) {
else
return name;
};
+
+ImageUtil.metrics = null;
+
+ImageUtil.getMetricName = function(name) { return 'PhotoEditor.' + name }
+
+// Used for metrics reporting, keep in sync with the histogram description.
+ImageUtil.FILE_TYPES = ['jpg', 'png', 'gif', 'bmp', 'webp'];
+

Powered by Google App Engine
This is Rietveld 408576698