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

Side by Side Diff: content/browser/android/media_player_manager_impl.cc

Issue 15876006: Allow some Android media player implementation to be overridden by embedders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/android/media_player_manager_impl.h" 5 #include "content/browser/android/media_player_manager_impl.h"
6 6
7 #include "content/browser/android/media_resource_getter_impl.h" 7 #include "content/browser/android/media_resource_getter_impl.h"
8 #include "content/browser/web_contents/web_contents_view_android.h" 8 #include "content/browser/web_contents/web_contents_view_android.h"
9 #include "content/common/media/media_player_messages_android.h" 9 #include "content/common/media/media_player_messages_android.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 player->SetVideoSurface(surface); 120 player->SetVideoSurface(surface);
121 Send(new MediaPlayerMsg_DidEnterFullscreen( 121 Send(new MediaPlayerMsg_DidEnterFullscreen(
122 routing_id(), player->player_id())); 122 routing_id(), player->player_id()));
123 } 123 }
124 } 124 }
125 125
126 void MediaPlayerManagerImpl::OnInitialize( 126 void MediaPlayerManagerImpl::OnInitialize(
127 int player_id, const GURL& url, 127 int player_id, const GURL& url,
128 bool is_media_source, 128 bool is_media_source,
129 const GURL& first_party_for_cookies) { 129 const GURL& first_party_for_cookies) {
130 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); 130 RemovePlayer(player_id);
131 it != players_.end(); ++it) {
132 if ((*it)->player_id() == player_id) {
133 players_.erase(it);
134 break;
135 }
136 }
137 131
138 RenderProcessHost* host = render_view_host()->GetProcess(); 132 RenderProcessHost* host = render_view_host()->GetProcess();
139 players_.push_back(media::MediaPlayerAndroid::Create( 133 AddPlayer(media::MediaPlayerAndroid::Create(
140 player_id, url, is_media_source, first_party_for_cookies, 134 player_id, url, is_media_source, first_party_for_cookies,
141 host->GetBrowserContext()->IsOffTheRecord(), this)); 135 host->GetBrowserContext()->IsOffTheRecord(), this));
142 } 136 }
143 137
144 media::MediaResourceGetter* MediaPlayerManagerImpl::GetMediaResourceGetter() { 138 media::MediaResourceGetter* MediaPlayerManagerImpl::GetMediaResourceGetter() {
145 if (!media_resource_getter_.get()) { 139 if (!media_resource_getter_.get()) {
146 RenderProcessHost* host = render_view_host()->GetProcess(); 140 RenderProcessHost* host = render_view_host()->GetProcess();
147 BrowserContext* context = host->GetBrowserContext(); 141 BrowserContext* context = host->GetBrowserContext();
148 StoragePartition* partition = host->GetStoragePartition(); 142 StoragePartition* partition = host->GetStoragePartition();
149 fileapi::FileSystemContext* file_system_context = 143 fileapi::FileSystemContext* file_system_context =
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void MediaPlayerManagerImpl::OnReleaseResources(int player_id) { 186 void MediaPlayerManagerImpl::OnReleaseResources(int player_id) {
193 MediaPlayerAndroid* player = GetPlayer(player_id); 187 MediaPlayerAndroid* player = GetPlayer(player_id);
194 // Don't release the fullscreen player when tab visibility changes, 188 // Don't release the fullscreen player when tab visibility changes,
195 // it will be released when user hit the back/home button or when 189 // it will be released when user hit the back/home button or when
196 // OnDestroyPlayer is called. 190 // OnDestroyPlayer is called.
197 if (player && player_id != fullscreen_player_id_) 191 if (player && player_id != fullscreen_player_id_)
198 player->Release(); 192 player->Release();
199 } 193 }
200 194
201 void MediaPlayerManagerImpl::OnDestroyPlayer(int player_id) { 195 void MediaPlayerManagerImpl::OnDestroyPlayer(int player_id) {
202 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); 196 RemovePlayer(player_id);
203 it != players_.end(); ++it) {
204 if ((*it)->player_id() == player_id) {
205 players_.erase(it);
206 break;
207 }
208 }
209 if (fullscreen_player_id_ == player_id) 197 if (fullscreen_player_id_ == player_id)
210 fullscreen_player_id_ = -1; 198 fullscreen_player_id_ = -1;
211 } 199 }
212 200
213 void MediaPlayerManagerImpl::DestroyAllMediaPlayers() { 201 void MediaPlayerManagerImpl::DestroyAllMediaPlayers() {
214 players_.clear(); 202 players_.clear();
215 if (fullscreen_player_id_ != -1) { 203 if (fullscreen_player_id_ != -1) {
216 video_view_.DestroyContentVideoView(); 204 video_view_.DestroyContentVideoView();
217 fullscreen_player_id_ = -1; 205 fullscreen_player_id_ = -1;
218 } 206 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 routing_id(), (*it)->player_id())); 353 routing_id(), (*it)->player_id()));
366 } 354 }
367 } 355 }
368 } 356 }
369 357
370 void MediaPlayerManagerImpl::ReleaseMediaResources( 358 void MediaPlayerManagerImpl::ReleaseMediaResources(
371 MediaPlayerAndroid* player) { 359 MediaPlayerAndroid* player) {
372 // Nothing needs to be done. 360 // Nothing needs to be done.
373 } 361 }
374 362
363 void MediaPlayerManagerImpl::AddPlayer(MediaPlayerAndroid* player) {
364 DCHECK(!GetPlayer(player->player_id()));
365 players_.push_back(player);
366 }
367
368 void MediaPlayerManagerImpl::RemovePlayer(int player_id) {
369 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin();
370 it != players_.end(); ++it) {
371 if ((*it)->player_id() == player_id) {
372 players_.erase(it);
373 break;
374 }
375 }
376 }
377
375 } // namespace content 378 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698