OLD | NEW |
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_android.h" | 5 #include "content/browser/android/media_player_manager_android.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/browser/android/cookie_getter_impl.h" | 8 #include "content/browser/android/media_resource_getter_impl.h" |
9 #include "content/common/media/media_player_messages.h" | 9 #include "content/common/media/media_player_messages.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
11 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
12 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/public/browser/storage_partition.h" |
13 | 14 |
14 using media::MediaPlayerBridge; | 15 using media::MediaPlayerBridge; |
15 | 16 |
16 // Threshold on the number of media players per renderer before we start | 17 // Threshold on the number of media players per renderer before we start |
17 // attempting to release inactive media players. | 18 // attempting to release inactive media players. |
18 static const int kMediaPlayerThreshold = 1; | 19 static const int kMediaPlayerThreshold = 1; |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 | 22 |
22 MediaPlayerManagerAndroid::MediaPlayerManagerAndroid( | 23 MediaPlayerManagerAndroid::MediaPlayerManagerAndroid( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void MediaPlayerManagerAndroid::SetVideoSurface(jobject surface) { | 88 void MediaPlayerManagerAndroid::SetVideoSurface(jobject surface) { |
88 MediaPlayerBridge* player = GetFullscreenPlayer(); | 89 MediaPlayerBridge* player = GetFullscreenPlayer(); |
89 if (player) { | 90 if (player) { |
90 player->SetVideoSurface(surface); | 91 player->SetVideoSurface(surface); |
91 Send(new MediaPlayerMsg_DidEnterFullscreen( | 92 Send(new MediaPlayerMsg_DidEnterFullscreen( |
92 routing_id(), player->player_id())); | 93 routing_id(), player->player_id())); |
93 } | 94 } |
94 } | 95 } |
95 | 96 |
96 void MediaPlayerManagerAndroid::OnInitialize( | 97 void MediaPlayerManagerAndroid::OnInitialize( |
97 int player_id, const std::string& url, | 98 int player_id, const GURL& url, const GURL& first_party_for_cookies) { |
98 const std::string& first_party_for_cookies) { | |
99 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); | 99 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); |
100 it != players_.end(); ++it) { | 100 it != players_.end(); ++it) { |
101 if ((*it)->player_id() == player_id) { | 101 if ((*it)->player_id() == player_id) { |
102 players_.erase(it); | 102 players_.erase(it); |
103 break; | 103 break; |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 RenderProcessHost* host = render_view_host()->GetProcess(); | 107 RenderProcessHost* host = render_view_host()->GetProcess(); |
108 BrowserContext* context = host->GetBrowserContext(); | 108 BrowserContext* context = host->GetBrowserContext(); |
| 109 StoragePartition* partition = host->GetStoragePartition(); |
| 110 fileapi::FileSystemContext* file_system_context = |
| 111 partition ? partition->GetFileSystemContext() : NULL; |
109 players_.push_back(new MediaPlayerBridge( | 112 players_.push_back(new MediaPlayerBridge( |
110 player_id, url, first_party_for_cookies, | 113 player_id, url, first_party_for_cookies, |
111 new CookieGetterImpl(context, host->GetID(), routing_id()), | 114 new MediaResourceGetterImpl(context, file_system_context, host->GetID(), |
| 115 routing_id()), |
112 context->IsOffTheRecord(), this, | 116 context->IsOffTheRecord(), this, |
113 base::Bind(&MediaPlayerManagerAndroid::OnError, base::Unretained(this)), | 117 base::Bind(&MediaPlayerManagerAndroid::OnError, base::Unretained(this)), |
114 base::Bind(&MediaPlayerManagerAndroid::OnVideoSizeChanged, | 118 base::Bind(&MediaPlayerManagerAndroid::OnVideoSizeChanged, |
115 base::Unretained(this)), | 119 base::Unretained(this)), |
116 base::Bind(&MediaPlayerManagerAndroid::OnBufferingUpdate, | 120 base::Bind(&MediaPlayerManagerAndroid::OnBufferingUpdate, |
117 base::Unretained(this)), | 121 base::Unretained(this)), |
118 base::Bind(&MediaPlayerManagerAndroid::OnPrepared, | 122 base::Bind(&MediaPlayerManagerAndroid::OnPrepared, |
119 base::Unretained(this)), | 123 base::Unretained(this)), |
120 base::Bind(&MediaPlayerManagerAndroid::OnPlaybackComplete, | 124 base::Bind(&MediaPlayerManagerAndroid::OnPlaybackComplete, |
121 base::Unretained(this)), | 125 base::Unretained(this)), |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 296 } |
293 } | 297 } |
294 } | 298 } |
295 | 299 |
296 void MediaPlayerManagerAndroid::ReleaseMediaResources( | 300 void MediaPlayerManagerAndroid::ReleaseMediaResources( |
297 MediaPlayerBridge* player) { | 301 MediaPlayerBridge* player) { |
298 // Nothing needs to be done. | 302 // Nothing needs to be done. |
299 } | 303 } |
300 | 304 |
301 } // namespace content | 305 } // namespace content |
OLD | NEW |