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

Unified Diff: chrome/browser/extensions/file_manager_util.cc

Issue 7465017: Adding UMA stats support for file open events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/file_manager_util.cc
===================================================================
--- chrome/browser/extensions/file_manager_util.cc (revision 94575)
+++ chrome/browser/extensions/file_manager_util.cc (working copy)
@@ -5,6 +5,7 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
@@ -50,6 +51,15 @@
*/
};
+// List of all extensions we want to be shown in histogram that keep track of
+// files that were unsuccessfully tried to be opened.
+// The list has to be synced with histogram values.
+const char* kUMATrackingExtensions[] = {
+ "other", ".doc", ".docx", ".odt", ".rtf", ".pdf", ".ppt", ".pptx", ".odp",
+ ".xls", ".xlsx", ".ods", ".csv", ".odf", ".rar", ".asf", ".wma", ".wmv",
+ ".mov", ".mpg", ".log"
+};
+
bool IsSupportedBrowserExtension(const char* ext) {
for (size_t i = 0; i < arraysize(kBrowserSupportedExtensions); i++) {
if (base::strcasecmp(ext, kBrowserSupportedExtensions[i]) == 0) {
@@ -73,6 +83,19 @@
return GURL(kFileBrowserExtensionUrl);
}
+// Returns index |ext| has in the |array|. If there is no |ext| in |array|, last
+// element's index is return (last element should have irrelevant value).
+int UMAExtensionIndex(const char *ext,
+ const char** array,
+ size_t array_size) {
+ for (size_t i = 0; i < array_size; i++) {
+ if (base::strcasecmp(ext, array[i]) == 0) {
+ return i;
+ }
+ }
+ return 0;
+}
+
// static
GURL FileManagerUtil::GetFileBrowserUrl() {
return GURL(kBaseFileBrowserUrl);
@@ -183,7 +206,14 @@
return;
}
- // Unknown file type. Show an error message.
+ // Unknown file type. Record UMA and show an error message.
+ size_t extension_index = UMAExtensionIndex(ext.data(),
+ kUMATrackingExtensions,
+ arraysize(kUMATrackingExtensions));
+ UMA_HISTOGRAM_ENUMERATION("FileBrowser.OpeningFileType",
+ extension_index,
+ arraysize(kUMATrackingExtensions) - 1);
+
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableFunction(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698