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

Side by Side Diff: content/browser/media/media_web_contents_observer.h

Issue 1580493004: Plumb audio focus support for spitzer clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate_hookup
Patch Set: Rebase. Created 4 years, 10 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
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/callback_forward.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.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 {
20 class PowerSaveBlocker; 21 class PowerSaveBlocker;
21 22
22 // This class manages all RenderFrame based media related managers at the 23 // This class manages all RenderFrame based media related managers at the
23 // browser side. It receives IPC messages from media RenderFrameObservers and 24 // browser side. It receives IPC messages from media RenderFrameObservers and
(...skipping 16 matching lines...) Expand all
40 void WasHidden() override; 41 void WasHidden() override;
41 42
42 bool has_audio_power_save_blocker_for_testing() const { 43 bool has_audio_power_save_blocker_for_testing() const {
43 return !!audio_power_save_blocker_; 44 return !!audio_power_save_blocker_;
44 } 45 }
45 46
46 bool has_video_power_save_blocker_for_testing() const { 47 bool has_video_power_save_blocker_for_testing() const {
47 return !!video_power_save_blocker_; 48 return !!video_power_save_blocker_;
48 } 49 }
49 50
51 // Executes |focus_cb| on the calling thread once the given render frame has
52 // audio focus. Clients are responsible for invalidating |focus_cb| if their
53 // lifetime changes or the callback is unnecessary.
54 //
55 // This call does not request focus, it only waits for a focus request for the
56 // given render frame to be approved. The focus request must be initiated via
57 // the WebMediaPlayerDelegate interface in the renderer.
58 //
59 // Focus is never denied, only delayed until the underlying platform approves
60 // the request. |focus_cb| may never be called if the given render frame goes
61 // away. Callers are expected to have their own monitoring for such events in
62 // order to properly handle the lack of a callback.
63 static void WaitForAudioFocusAsync(int render_process_id,
64 int render_frame_id,
65 const base::Closure& focus_cb);
66
67 protected:
68 virtual void WaitForAudioFocusAsyncInternal(int render_frame_id,
69 const base::Closure& focus_cb);
70
50 private: 71 private:
51 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id); 72 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id);
52 void OnMediaPaused(RenderFrameHost* render_frame_host, 73 void OnMediaPaused(RenderFrameHost* render_frame_host,
53 int delegate_id, 74 int delegate_id,
54 bool reached_end_of_stream); 75 bool reached_end_of_stream);
55 void OnMediaPlaying(RenderFrameHost* render_frame_host, 76 void OnMediaPlaying(RenderFrameHost* render_frame_host,
56 int delegate_id, 77 int delegate_id,
57 bool has_video, 78 bool has_video,
58 bool has_audio, 79 bool has_audio,
59 bool is_remote, 80 bool is_remote,
(...skipping 30 matching lines...) Expand all
90 ActiveMediaPlayerMap active_video_players_; 111 ActiveMediaPlayerMap active_video_players_;
91 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; 112 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_;
92 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; 113 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_;
93 114
94 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); 115 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver);
95 }; 116 };
96 117
97 } // namespace content 118 } // namespace content
98 119
99 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ 120 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698