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

Side by Side Diff: chrome/browser/metrics/desktop_engagement/audible_contents_tracker.h

Issue 2142983002: Add desktop engagement metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_AUDIBLE_CONTENTS_TRACKER_H_
6 #define CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_AUDIBLE_CONTENTS_TRACKER_H_
7
8 #include <set>
9
10 #include "base/callback.h"
11 #include "chrome/browser/ui/browser_list_observer.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
13
14 namespace metrics {
15
16 // BrowserList / TabStripModelObserver used for tracking audio status.
17 class AudibleContentsTracker : public chrome::BrowserListObserver,
18 public TabStripModelObserver {
19 public:
20 // Interface for an observer of the AudibleContentsTracker. The only client
21 // of this class is the DesktopEngagementService, but an observer interface
22 // has been created for ease of testing.
23 class Observer {
24 public:
25 Observer() {}
26 ~Observer() {}
chrisha 2016/07/29 15:21:26 virtual ~Observer() as this is an abstract base cl
gayane -on leave until 09-2017 2016/07/29 19:37:39 Done.
27
28 // Invoked when a first audio source starts playing after a period of no
29 // audio sources. Overridden by tests.
30 virtual void OnAudioStart();
31
32 // Invoked when all audio sources stop playing. Overridden by tests.
33 virtual void OnAudioEnd();
Alexei Svitkine (slow) 2016/07/28 21:31:45 Make this a pure virtual class and just have Deskt
chrisha 2016/07/29 15:21:25 +1
gayane -on leave until 09-2017 2016/07/29 19:37:38 Acknowledged.
gayane -on leave until 09-2017 2016/07/29 19:37:39 Done.
34
35 private:
36 DISALLOW_COPY_AND_ASSIGN(Observer);
37 };
38
39 // Creates an audible contents tracker that dispatches its messages to the
40 // provided |observer|.
41 explicit AudibleContentsTracker(Observer* observer);
42 ~AudibleContentsTracker() override;
43
44 // Creates the |AudibleContentsTracker| instance and its observer which
45 // observe and notify audio status changes.
46 static void Initialize();
47
48 private:
49 // chrome::BrowserListObserver:
50 void OnBrowserAdded(Browser* browser) override;
51 void OnBrowserRemoved(Browser* browser) override;
52
53 // TabStripModelObserver:
54 void TabClosingAt(TabStripModel* model,
55 content::WebContents* web_contents,
56 int index) override;
57 void TabChangedAt(content::WebContents* web_contents,
58 int index,
59 TabChangeType change_type) override;
60 void TabReplacedAt(TabStripModel* model,
61 content::WebContents* old_web_contents,
62 content::WebContents* new_web_contents,
63 int index) override;
64
65 // Used for managing audible_contents_, and invoking OnAudioStart and
66 // OnAudioEnd callbacks.
67 void AddAudibleWebContents(content::WebContents* web_contents);
68 void RemoveAudibleWebContents(content::WebContents* web_contents);
69
70 Observer* observer_;
71
72 // The set of WebContents that are currently playing audio.
73 std::set<content::WebContents*> audible_contents_;
74
75 DISALLOW_COPY_AND_ASSIGN(AudibleContentsTracker);
76 };
77
78 } // namespace metrics
79
80 #endif // CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_AUDIBLE_CONTENTS_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698