| Index: chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
|
| diff --git a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
|
| index 1d166ff656aab4c965e13be5eab87e92c1c2cdbe..c269ca691ea6a2881718df188741e340abeb6081 100644
|
| --- a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
|
| +++ b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
|
| @@ -58,6 +58,17 @@ const char kMostVisitedNavigationHistogramName[] =
|
| const char kMostVisitedNavigationHistogramWithProvider[] =
|
| "NewTabPage.MostVisited.%s";
|
|
|
| +std::string GetSourceName(NTPLoggingTileSource tile_source) {
|
| + switch (tile_source) {
|
| + case NTP_TILE_SOURCE_CLIENT:
|
| + return "client";
|
| + case NTP_TILE_SOURCE_SERVER:
|
| + return "server";
|
| + }
|
| + NOTREACHED();
|
| + return std::string();
|
| +}
|
| +
|
| } // namespace
|
|
|
| DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger);
|
| @@ -207,47 +218,37 @@ void NTPUserDataLogger::LogEvent(NTPLoggingEventType event,
|
| }
|
|
|
| void NTPUserDataLogger::LogMostVisitedImpression(
|
| - int position, const base::string16& provider) {
|
| - // Log the Most Visited navigation for navigations that have providers and
|
| - // those that dont.
|
| + int position, NTPLoggingTileSource tile_source) {
|
| UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position,
|
| kNumMostVisited);
|
|
|
| - // If a provider is specified, log the metric specific to it.
|
| - if (!provider.empty()) {
|
| - // Cannot rely on UMA histograms macro because the name of the histogram is
|
| - // generated dynamically.
|
| - base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
|
| - base::StringPrintf(kMostVisitedImpressionHistogramWithProvider,
|
| - base::UTF16ToUTF8(provider).c_str()),
|
| - 1,
|
| - kNumMostVisited,
|
| - kNumMostVisited + 1,
|
| - base::Histogram::kUmaTargetedHistogramFlag);
|
| - counter->Add(position);
|
| - }
|
| + // Cannot rely on UMA histograms macro because the name of the histogram is
|
| + // generated dynamically.
|
| + base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
|
| + base::StringPrintf(kMostVisitedImpressionHistogramWithProvider,
|
| + GetSourceName(tile_source).c_str()),
|
| + 1,
|
| + kNumMostVisited,
|
| + kNumMostVisited + 1,
|
| + base::Histogram::kUmaTargetedHistogramFlag);
|
| + counter->Add(position);
|
| }
|
|
|
| void NTPUserDataLogger::LogMostVisitedNavigation(
|
| - int position, const base::string16& provider) {
|
| - // Log the Most Visited navigation for navigations that have providers and
|
| - // those that dont.
|
| + int position, NTPLoggingTileSource tile_source) {
|
| UMA_HISTOGRAM_ENUMERATION(kMostVisitedNavigationHistogramName, position,
|
| kNumMostVisited);
|
|
|
| - // If a provider is specified, log the metric specific to it.
|
| - if (!provider.empty()) {
|
| - // Cannot rely on UMA histograms macro because the name of the histogram is
|
| - // generated dynamically.
|
| - base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
|
| - base::StringPrintf(kMostVisitedNavigationHistogramWithProvider,
|
| - base::UTF16ToUTF8(provider).c_str()),
|
| - 1,
|
| - kNumMostVisited,
|
| - kNumMostVisited + 1,
|
| - base::Histogram::kUmaTargetedHistogramFlag);
|
| - counter->Add(position);
|
| - }
|
| + // Cannot rely on UMA histograms macro because the name of the histogram is
|
| + // generated dynamically.
|
| + base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
|
| + base::StringPrintf(kMostVisitedNavigationHistogramWithProvider,
|
| + GetSourceName(tile_source).c_str()),
|
| + 1,
|
| + kNumMostVisited,
|
| + kNumMostVisited + 1,
|
| + base::Histogram::kUmaTargetedHistogramFlag);
|
| + counter->Add(position);
|
|
|
| // Records the action. This will be available as a time-stamped stream
|
| // server-side and can be used to compute time-to-long-dwell.
|
|
|