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

Side by Side Diff: content/browser/media/session/pepper_playback_observer.h

Issue 2551093002: Route Pepper MediaSession messages to frames (Closed)
Patch Set: fixed Android build Created 4 years 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
« no previous file with comments | « no previous file | content/browser/media/session/pepper_playback_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_PEPPER_PLAYBACK_OBSERVER_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_PEPPER_PLAYBACK_OBSERVER_H_
6 #define CONTENT_BROWSER_MEDIA_SESSION_PEPPER_PLAYBACK_OBSERVER_H_ 6 #define CONTENT_BROWSER_MEDIA_SESSION_PEPPER_PLAYBACK_OBSERVER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <utility>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 class PepperPlayerDelegate; 17 class PepperPlayerDelegate;
17 class WebContentsImpl; 18 class RenderFrameHost;
19 class WebContents;
18 20
19 // Class observing Pepper playback changes from WebContents, and update 21 // Class observing Pepper playback changes from WebContents, and update
20 // MediaSession accordingly. Can only be a member of WebContentsImpl and must be 22 // MediaSession accordingly. Can only be a member of WebContents and must be
21 // destroyed in ~WebContentsImpl(). 23 // destroyed in ~WebContents().
22 class PepperPlaybackObserver { 24 class PepperPlaybackObserver {
23 public: 25 public:
24 explicit PepperPlaybackObserver(WebContentsImpl* contents); 26 explicit PepperPlaybackObserver(WebContents* contents);
25 virtual ~PepperPlaybackObserver(); 27 virtual ~PepperPlaybackObserver();
26 28
27 void PepperInstanceCreated(int32_t pp_instance); 29 void RenderFrameDeleted(RenderFrameHost* render_frame_host);
28 void PepperInstanceDeleted(int32_t pp_instance); 30
31 void PepperInstanceCreated(RenderFrameHost* render_frame_host,
32 int32_t pp_instance);
33 void PepperInstanceDeleted(RenderFrameHost* render_frame_host,
34 int32_t pp_instance);
29 // This method is called when a Pepper instance starts making sound. 35 // This method is called when a Pepper instance starts making sound.
30 void PepperStartsPlayback(int32_t pp_instance); 36 void PepperStartsPlayback(RenderFrameHost* render_frame_host,
37 int32_t pp_instance);
31 // This method is called when a Pepper instance stops making sound. 38 // This method is called when a Pepper instance stops making sound.
32 void PepperStopsPlayback(int32_t pp_instance); 39 void PepperStopsPlayback(RenderFrameHost* render_frame_host,
40 int32_t pp_instance);
33 41
34 private: 42 private:
43 using PlayerId = std::pair<RenderFrameHost*, int32_t>;
44
35 // Owning PepperPlayerDelegates. 45 // Owning PepperPlayerDelegates.
36 using PlayersMap = 46 using PlayersMap = std::map<PlayerId, std::unique_ptr<PepperPlayerDelegate>>;
37 std::map<int32_t, std::unique_ptr<PepperPlayerDelegate>>;
38 PlayersMap players_map_; 47 PlayersMap players_map_;
39 48
40 // Map for whether Pepper players have ever played sound. 49 // Map for whether Pepper players have ever played sound.
41 // Used for recording UMA. 50 // Used for recording UMA.
42 using PlayersPlayedSoundMap = 51 //
43 std::map<int32_t, bool>; 52 // The mapped player ids must be a super-set of player ids in |players_map_|,
53 // and the map is also used for cleaning up when RenderFrame is deleted or
54 // WebContents is destructed.
55 using PlayersPlayedSoundMap = std::map<PlayerId, bool>;
44 PlayersPlayedSoundMap players_played_sound_map_; 56 PlayersPlayedSoundMap players_played_sound_map_;
45 57
46 // Weak reference to WebContents. 58 // Weak reference to WebContents.
47 WebContentsImpl* contents_; 59 WebContents* contents_;
48 60
49 DISALLOW_COPY_AND_ASSIGN(PepperPlaybackObserver); 61 DISALLOW_COPY_AND_ASSIGN(PepperPlaybackObserver);
50 }; 62 };
51 63
52 } // namespace content 64 } // namespace content
53 65
54 #endif // CONTENT_BROWSER_MEDIA_SESSION_PEPPER_PLAYBACK_OBSERVER_H_ 66 #endif // CONTENT_BROWSER_MEDIA_SESSION_PEPPER_PLAYBACK_OBSERVER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/session/pepper_playback_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698