Introduce ProfilerMetricsProvider
[chromium-blink-merge.git] / chrome / browser / bookmarks / bookmark_stats.cc
blob5c3f37d8df01b1ac15c86a5abe8dc4e7836c1eae
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/bookmarks/bookmark_stats.h"
7 #include "base/metrics/histogram.h"
8 #include "components/bookmarks/browser/bookmark_model.h"
9 #include "content/public/browser/user_metrics.h"
11 void RecordBookmarkLaunch(const BookmarkNode* node,
12 BookmarkLaunchLocation location) {
13 if (location == BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR ||
14 location == BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR) {
15 content::RecordAction(
16 base::UserMetricsAction("ClickedBookmarkBarURLButton"));
18 UMA_HISTOGRAM_ENUMERATION(
19 "Bookmarks.LaunchLocation", location, BOOKMARK_LAUNCH_LOCATION_LIMIT);
21 if (!node)
22 return;
24 // In the cases where a bookmark node is provided, record the depth of the
25 // bookmark in the tree.
26 int depth = 0;
27 for (const BookmarkNode* iter = node; iter != NULL; iter = iter->parent()) {
28 depth++;
30 // Record |depth - 2| to offset the invisible root node and permanent nodes
31 // (Bookmark Bar, Mobile Bookmarks or Other Bookmarks)
32 UMA_HISTOGRAM_COUNTS("Bookmarks.LaunchDepth", depth - 2);
35 void RecordBookmarkFolderOpen(BookmarkLaunchLocation location) {
36 if (location == BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR ||
37 location == BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR) {
38 content::RecordAction(
39 base::UserMetricsAction("ClickedBookmarkBarFolder"));
43 void RecordBookmarkAppsPageOpen(BookmarkLaunchLocation location) {
44 if (location == BOOKMARK_LAUNCH_LOCATION_DETACHED_BAR ||
45 location == BOOKMARK_LAUNCH_LOCATION_ATTACHED_BAR) {
46 content::RecordAction(
47 base::UserMetricsAction("ClickedBookmarkBarAppsShortcutButton"));