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

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

Issue 2333113002: Rename DesktopEngagement* to DesktopSessionDuration*. (Closed)
Patch Set: Change name Created 4 years, 3 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 virtual ~Observer() {}
27
28 // Invoked when a first audio source starts playing after a period of no
29 // audio sources.
30 virtual void OnAudioStart() = 0;
31
32 // Invoked when all audio sources stop playing.
33 virtual void OnAudioEnd() = 0;
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 private:
45 // chrome::BrowserListObserver:
46 void OnBrowserAdded(Browser* browser) override;
47 void OnBrowserRemoved(Browser* browser) override;
48
49 // TabStripModelObserver:
50 void TabClosingAt(TabStripModel* model,
51 content::WebContents* web_contents,
52 int index) override;
53 void TabChangedAt(content::WebContents* web_contents,
54 int index,
55 TabChangeType change_type) override;
56 void TabReplacedAt(TabStripModel* model,
57 content::WebContents* old_web_contents,
58 content::WebContents* new_web_contents,
59 int index) override;
60
61 // Used for managing audible_contents_, and invoking OnAudioStart and
62 // OnAudioEnd callbacks.
63 void AddAudibleWebContents(content::WebContents* web_contents);
64 void RemoveAudibleWebContents(content::WebContents* web_contents);
65
66 Observer* observer_;
67
68 // The set of WebContents that are currently playing audio.
69 std::set<content::WebContents*> audible_contents_;
70
71 DISALLOW_COPY_AND_ASSIGN(AudibleContentsTracker);
72 };
73
74 } // namespace metrics
75
76 #endif // CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_AUDIBLE_CONTENTS_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698