Skip to content

Commit

Permalink
Add UMAs for media galleries scanning.
Browse files Browse the repository at this point in the history
BUG=161119

Review URL: https://codereview.chromium.org/171423002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254001 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
vandebo@chromium.org committed Feb 28, 2014
1 parent a168bba commit 6867098
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ void MediaGalleriesEventRouter::OnScanCancelled(
void MediaGalleriesEventRouter::OnScanFinished(
const std::string& extension_id, int gallery_count,
const MediaGalleryScanResult& file_counts) {
media_galleries::UsageCount(media_galleries::SCAN_FINISHED);
MediaGalleries::ScanProgressDetails details;
details.type = MediaGalleries::SCAN_PROGRESS_TYPE_FINISH;
details.gallery_count.reset(new int(gallery_count));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ void MediaGalleriesDialogController::DidForgetGallery(
// TODO(scr): remove from new_galleries_ if it's in there. Should
// new_galleries be a set? Why don't new_galleries allow context clicking?
DCHECK(ContainsKey(known_galleries_, pref_id));
media_galleries::UsageCount(media_galleries::DIALOG_FORGET_GALLERY);
forgotten_gallery_ids_.insert(pref_id);
dialog_->UpdateGalleries();
}
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/media_galleries/media_galleries_histograms.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ enum MediaGalleriesUsages {
START_MEDIA_SCAN,
CANCEL_MEDIA_SCAN,
ADD_SCAN_RESULTS,
SCAN_FINISHED,
ADD_SCAN_RESULTS_CANCELLED,
ADD_SCAN_RESULTS_ACCEPTED,
ADD_SCAN_RESULTS_FORGET_GALLERY,
DIALOG_FORGET_GALLERY,
MEDIA_GALLERIES_NUM_USAGES
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "base/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
Expand Down Expand Up @@ -171,6 +172,7 @@ void MediaGalleriesScanResultDialogController::DidClickOpenFolderViewer(

void MediaGalleriesScanResultDialogController::DidForgetGallery(
MediaGalleryPrefId pref_id) {
media_galleries::UsageCount(media_galleries::ADD_SCAN_RESULTS_FORGET_GALLERY);
results_to_remove_.insert(pref_id);
scan_results_.erase(pref_id);
dialog_->UpdateResults();
Expand All @@ -185,20 +187,31 @@ void MediaGalleriesScanResultDialogController::DialogFinished(bool accepted) {

if (accepted) {
DCHECK(preferences_);
media_galleries::UsageCount(media_galleries::ADD_SCAN_RESULTS_ACCEPTED);
int granted = 0;
int total = 0;
for (ScanResults::const_iterator it = scan_results_.begin();
it != scan_results_.end();
++it) {
if (it->second.selected) {
bool changed = preferences_->SetGalleryPermissionForExtension(
*extension_, it->first, true);
DCHECK(changed);
granted++;
}
total++;
}
if (total > 0) {
UMA_HISTOGRAM_PERCENTAGE("MediaGalleries.ScanGalleriesGranted",
(granted * 100 / total));
}
for (MediaGalleryPrefIdSet::const_iterator it = results_to_remove_.begin();
it != results_to_remove_.end();
++it) {
preferences_->ForgetGalleryById(*it);
}
} else {
media_galleries::UsageCount(media_galleries::ADD_SCAN_RESULTS_CANCELLED);
}

on_finish_.Run();
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/media_galleries/media_scan_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/file_util.h"
#include "base/files/file_enumerator.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/time/time.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h"
Expand Down Expand Up @@ -205,6 +206,8 @@ void AddScanResultsForProfile(
gallery.last_attach_time, file_counts.audio_count,
file_counts.image_count, file_counts.video_count);
}
UMA_HISTOGRAM_COUNTS_10000("MediaGalleries.ScanGalleriesPopulated",
unique_found_folders.size() + to_update.size());
}

// A single directory may contain many folders with media in them, without
Expand Down Expand Up @@ -461,6 +464,8 @@ void MediaScanManager::OnScanCompleted(
return;
}

UMA_HISTOGRAM_COUNTS_10000("MediaGalleries.ScanDirectoriesFound",
found_folders.size());
content::BrowserThread::PostTaskAndReplyWithResult(
content::BrowserThread::FILE, FROM_HERE,
base::Bind(FindContainerScanResults,
Expand Down
36 changes: 32 additions & 4 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7398,6 +7398,25 @@ other types of suffix sets.
</summary>
</histogram>

<histogram name="MediaGalleries.ScanDirectoriesFound">
<summary>
The number of directories with media files found during a scan.
</summary>
</histogram>

<histogram name="MediaGalleries.ScanGalleriesGranted" units="%">
<summary>
The percentage of galleries accepted (not deselected) from the scan result
dialog.
</summary>
</histogram>

<histogram name="MediaGalleries.ScanGalleriesPopulated">
<summary>
The number of galleries added or updated in preferences after a scan.
</summary>
</histogram>

<histogram name="MediaGalleries.Usage" enum="MediaGalleriesUsageType">
<summary>Various usage counts for media galleries.</summary>
</histogram>
Expand Down Expand Up @@ -29057,9 +29076,9 @@ other types of suffix sets.
</enum>

<enum name="MediaGalleriesUsageType" type="int">
<int value="0" label="Gallery added from dialog"/>
<int value="1" label="Gallery permission added from dialog"/>
<int value="2" label="Gallery permission removed from dialog"/>
<int value="0" label="Gallery added from permission dialog"/>
<int value="1" label="Gallery permission added from permission dialog"/>
<int value="2" label="Gallery permission removed from permission dialog"/>
<int value="3" label="GetMediaFileSystems API invocations"/>
<int value="4" label="Profiles With API Usage (corrected in M35)"/>
<int value="5" label="Dialog shown"/>
Expand All @@ -29069,7 +29088,16 @@ other types of suffix sets.
<int value="9" label="Preferences initialized"/>
<int value="10" label="Preferences initialization failed"/>
<int value="11" label="GetAllMediaFileSystemMetadata API invocations"/>
<int value="12" label="AddUserSelectedFolder API invocations"/>
<int value="12" label="GetMetadata API invocations"/>
<int value="13" label="AddUserSelectedFolder API invocations"/>
<int value="14" label="StartMediaScan API invocations"/>
<int value="15" label="CancelMediaScan API invocations"/>
<int value="16" label="AddScanResults API invocations"/>
<int value="17" label="A media scan completed"/>
<int value="18" label="AddScanResults dialog cancelled"/>
<int value="19" label="AddScanResults dialog accepted"/>
<int value="20" label="Gallery removed from AddScanResults dialog"/>
<int value="21" label="Gallery removed from permission dialog"/>
</enum>

<enum name="MediaKeyError" type="int">
Expand Down

0 comments on commit 6867098

Please sign in to comment.