OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "content/browser/media/session/media_session_controllers_manager.h" |
16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
17 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
| 21 |
20 class PowerSaveBlocker; | 22 class PowerSaveBlocker; |
21 | 23 |
22 // This class manages all RenderFrame based media related managers at the | 24 // This class manages all RenderFrame based media related managers at the |
23 // browser side. It receives IPC messages from media RenderFrameObservers and | 25 // browser side. It receives IPC messages from media RenderFrameObservers and |
24 // forwards them to the corresponding managers. The managers are responsible | 26 // forwards them to the corresponding managers. The managers are responsible |
25 // for sending IPCs back to the RenderFrameObservers at the render side. | 27 // for sending IPCs back to the RenderFrameObservers at the render side. |
26 class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver { | 28 class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver { |
27 public: | 29 public: |
28 explicit MediaWebContentsObserver(WebContents* web_contents); | 30 explicit MediaWebContentsObserver(WebContents* web_contents); |
29 ~MediaWebContentsObserver() override; | 31 ~MediaWebContentsObserver() override; |
(...skipping 10 matching lines...) Expand all Loading... |
40 void WasHidden() override; | 42 void WasHidden() override; |
41 | 43 |
42 bool has_audio_power_save_blocker_for_testing() const { | 44 bool has_audio_power_save_blocker_for_testing() const { |
43 return !!audio_power_save_blocker_; | 45 return !!audio_power_save_blocker_; |
44 } | 46 } |
45 | 47 |
46 bool has_video_power_save_blocker_for_testing() const { | 48 bool has_video_power_save_blocker_for_testing() const { |
47 return !!video_power_save_blocker_; | 49 return !!video_power_save_blocker_; |
48 } | 50 } |
49 | 51 |
| 52 protected: |
| 53 MediaSessionControllersManager* session_controllers_manager() { |
| 54 return &session_controllers_manager_; |
| 55 } |
| 56 |
50 private: | 57 private: |
51 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id); | 58 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id); |
52 void OnMediaPaused(RenderFrameHost* render_frame_host, | 59 void OnMediaPaused(RenderFrameHost* render_frame_host, |
53 int delegate_id, | 60 int delegate_id, |
54 bool reached_end_of_stream); | 61 bool reached_end_of_stream); |
55 void OnMediaPlaying(RenderFrameHost* render_frame_host, | 62 void OnMediaPlaying(RenderFrameHost* render_frame_host, |
56 int delegate_id, | 63 int delegate_id, |
57 bool has_video, | 64 bool has_video, |
58 bool has_audio, | 65 bool has_audio, |
59 bool is_remote, | 66 bool is_remote, |
(...skipping 24 matching lines...) Expand all Loading... |
84 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, | 91 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, |
85 ActiveMediaPlayerMap* player_map, | 92 ActiveMediaPlayerMap* player_map, |
86 std::set<MediaPlayerId>* removed_players); | 93 std::set<MediaPlayerId>* removed_players); |
87 | 94 |
88 // Tracking variables and associated power save blockers for media playback. | 95 // Tracking variables and associated power save blockers for media playback. |
89 ActiveMediaPlayerMap active_audio_players_; | 96 ActiveMediaPlayerMap active_audio_players_; |
90 ActiveMediaPlayerMap active_video_players_; | 97 ActiveMediaPlayerMap active_video_players_; |
91 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; | 98 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; |
92 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; | 99 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; |
93 | 100 |
| 101 MediaSessionControllersManager session_controllers_manager_; |
| 102 |
94 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); | 103 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); |
95 }; | 104 }; |
96 | 105 |
97 } // namespace content | 106 } // namespace content |
98 | 107 |
99 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 108 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |