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

Side by Side Diff: content/browser/media/android/browser_media_player_manager.h

Issue 2742333002: Remove ScopedVector from content/browser/ [1]. (Closed)
Patch Set: Created 3 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_
6 #define CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ 6 #define CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector>
10 11
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "content/browser/android/content_video_view.h" 15 #include "content/browser/android/content_video_view.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
18 #include "media/base/android/media_player_android.h" 18 #include "media/base/android/media_player_android.h"
19 #include "media/base/android/media_player_manager.h" 19 #include "media/base/android/media_player_manager.h"
20 #include "media/base/android/media_url_interceptor.h" 20 #include "media/base/android/media_url_interceptor.h"
21 #include "ui/gfx/geometry/rect_f.h" 21 #include "ui/gfx/geometry/rect_f.h"
22 #include "ui/gl/android/scoped_java_surface.h" 22 #include "ui/gl/android/scoped_java_surface.h"
23 #include "url/gurl.h" 23 #include "url/gurl.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 virtual void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player); 107 virtual void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player);
108 108
109 protected: 109 protected:
110 // Clients must use Create() or subclass constructor. 110 // Clients must use Create() or subclass constructor.
111 explicit BrowserMediaPlayerManager(RenderFrameHost* render_frame_host); 111 explicit BrowserMediaPlayerManager(RenderFrameHost* render_frame_host);
112 112
113 WebContents* web_contents() const { return web_contents_; } 113 WebContents* web_contents() const { return web_contents_; }
114 114
115 // Adds a given player to the list. Not private to allow embedders 115 // Adds a given player to the list. Not private to allow embedders
116 // to extend the manager and still utilize the base player management. 116 // to extend the manager and still utilize the base player management.
117 void AddPlayer(media::MediaPlayerAndroid* player, int delegate_id); 117 void AddPlayer(std::unique_ptr<media::MediaPlayerAndroid> player,
118 int delegate_id);
118 119
119 // Removes the player with the specified id. 120 // Removes the player with the specified id.
120 void DestroyPlayer(int player_id); 121 void DestroyPlayer(int player_id);
121 122
122 // Release resources associated to a player. 123 // Release resources associated to a player.
123 virtual void ReleaseResources(int player_id); 124 virtual void ReleaseResources(int player_id);
124 125
125 // Replaces a player with the specified id with a given MediaPlayerAndroid 126 // Replaces a player with the specified id with a given MediaPlayerAndroid
126 // object. This will also return the original MediaPlayerAndroid object that 127 // object. This will also return the original MediaPlayerAndroid object that
127 // was replaced. 128 // was replaced.
(...skipping 16 matching lines...) Expand all
144 // is stuck in an error. 145 // is stuck in an error.
145 virtual void OnDecoderResourcesReleased(int player_id); 146 virtual void OnDecoderResourcesReleased(int player_id);
146 147
147 int RoutingID(); 148 int RoutingID();
148 149
149 // Helper function to send messages to RenderFrameObserver. 150 // Helper function to send messages to RenderFrameObserver.
150 bool Send(IPC::Message* msg); 151 bool Send(IPC::Message* msg);
151 152
152 private: 153 private:
153 // Constructs a MediaPlayerAndroid object. 154 // Constructs a MediaPlayerAndroid object.
154 media::MediaPlayerAndroid* CreateMediaPlayer( 155 std::unique_ptr<media::MediaPlayerAndroid> CreateMediaPlayer(
155 const MediaPlayerHostMsg_Initialize_Params& media_player_params, 156 const MediaPlayerHostMsg_Initialize_Params& media_player_params,
156 bool hide_url_log); 157 bool hide_url_log);
157 158
158 // Instructs |player| to release its java player. This will not remove the 159 // Instructs |player| to release its java player. This will not remove the
159 // player from |players_|. 160 // player from |players_|.
160 void ReleasePlayer(media::MediaPlayerAndroid* player); 161 void ReleasePlayer(media::MediaPlayerAndroid* player);
161 162
162 // Called when user approves media playback after being throttled. 163 // Called when user approves media playback after being throttled.
163 void OnPlaybackPermissionGranted(int player_id, bool granted); 164 void OnPlaybackPermissionGranted(int player_id, bool granted);
164 165
165 // Helper method to start playback. 166 // Helper method to start playback.
166 void StartInternal(int player_id); 167 void StartInternal(int player_id);
167 168
168 RenderFrameHost* const render_frame_host_; 169 RenderFrameHost* const render_frame_host_;
169 170
170 // An array of managed players. 171 // An array of managed players.
171 ScopedVector<media::MediaPlayerAndroid> players_; 172 std::vector<std::unique_ptr<media::MediaPlayerAndroid>> players_;
172 173
173 typedef std::map<int, bool> ActivePlayerMap; 174 typedef std::map<int, bool> ActivePlayerMap;
174 // Players that have requested decoding resources. Even though resource is 175 // Players that have requested decoding resources. Even though resource is
175 // requested, a player may be in a paused or error state and the manager 176 // requested, a player may be in a paused or error state and the manager
176 // will release its resources later. 177 // will release its resources later.
177 ActivePlayerMap active_players_; 178 ActivePlayerMap active_players_;
178 179
179 // The fullscreen video view object or NULL if video is not played in 180 // The fullscreen video view object or NULL if video is not played in
180 // fullscreen. 181 // fullscreen.
181 std::unique_ptr<ContentVideoView> video_view_; 182 std::unique_ptr<ContentVideoView> video_view_;
(...skipping 15 matching lines...) Expand all
197 198
198 // NOTE: Weak pointers must be invalidated before all other member variables. 199 // NOTE: Weak pointers must be invalidated before all other member variables.
199 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; 200 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_;
200 201
201 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); 202 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager);
202 }; 203 };
203 204
204 } // namespace content 205 } // namespace content
205 206
206 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ 207 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698