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

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 93828)
+++ 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"
@@ -48,6 +49,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[] = {
+ ".doc", ".docx", ".ppt", ".pptx", ".xls", ".xlsx", ".csv", ".zip", ".rar",
+ ".asf", ".wma", ".wmv", ".mov", ".avi", ".mp4", ".mpg", ".log", ".rtf",
+ ".odf", ".odp", ".ods", ".odt", ".pdf", "other"
zel 2011/08/01 01:39:49 let's make "other" being the first one on the list
tbarzic 2011/08/02 18:05:54 Done.
+};
+
bool IsSupportedBrowserExtension(const char* ext) {
for (size_t i = 0; i < arraysize(kBrowserSupportedExtensions); i++) {
if (base::strcasecmp(ext, kBrowserSupportedExtensions[i]) == 0) {
@@ -66,6 +76,19 @@
return false;
}
+// 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 array_size - 1;
+}
+
// static
GURL FileManagerUtil::GetFileBrowserUrl() {
return GURL(kBaseFileBrowserUrl);
@@ -165,7 +188,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",
zel 2011/08/01 01:39:49 you need to add this to histogram.xml file as well
tbarzic 2011/08/02 18:05:54 I know
+ 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