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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 445013002: media: Optimize HW Video to 2D Canvas copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK context_provider and rebase to ToT Created 6 years, 1 month 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 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 #if defined(OS_ANDROID) 147 #if defined(OS_ANDROID)
148 #include <cpu-features.h> 148 #include <cpu-features.h>
149 149
150 #include "content/common/gpu/client/context_provider_command_buffer.h" 150 #include "content/common/gpu/client/context_provider_command_buffer.h"
151 #include "content/renderer/android/synchronous_compositor_factory.h" 151 #include "content/renderer/android/synchronous_compositor_factory.h"
152 #include "content/renderer/java/gin_java_bridge_dispatcher.h" 152 #include "content/renderer/java/gin_java_bridge_dispatcher.h"
153 #include "content/renderer/media/android/renderer_media_player_manager.h" 153 #include "content/renderer/media/android/renderer_media_player_manager.h"
154 #include "content/renderer/media/android/stream_texture_factory_impl.h" 154 #include "content/renderer/media/android/stream_texture_factory_impl.h"
155 #include "content/renderer/media/android/webmediaplayer_android.h" 155 #include "content/renderer/media/android/webmediaplayer_android.h"
156 #else
157 #include "webkit/common/gpu/context_provider_web_context.h"
156 #endif 158 #endif
157 159
158 #if defined(ENABLE_PEPPER_CDMS) 160 #if defined(ENABLE_PEPPER_CDMS)
159 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" 161 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h"
160 #elif defined(ENABLE_BROWSER_CDMS) 162 #elif defined(ENABLE_BROWSER_CDMS)
161 #include "content/renderer/media/crypto/renderer_cdm_manager.h" 163 #include "content/renderer/media/crypto/renderer_cdm_manager.h"
162 #endif 164 #endif
163 165
164 using blink::WebContextMenuData; 166 using blink::WebContextMenuData;
165 using blink::WebData; 167 using blink::WebData;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 if (urls[i] != GURL(kSwappedOutURL)) 243 if (urls[i] != GURL(kSwappedOutURL))
242 result->push_back(urls[i]); 244 result->push_back(urls[i]);
243 else 245 else
244 result->push_back(blank_url); 246 result->push_back(blank_url);
245 } 247 }
246 } 248 }
247 249
248 // Returns the original request url. If there is no redirect, the original 250 // Returns the original request url. If there is no redirect, the original
249 // url is the same as ds->request()->url(). If the WebDataSource belongs to a 251 // url is the same as ds->request()->url(). If the WebDataSource belongs to a
250 // frame was loaded by loadData, the original url will be ds->unreachableURL() 252 // frame was loaded by loadData, the original url will be ds->unreachableURL()
251 static GURL GetOriginalRequestURL(WebDataSource* ds) { 253 GURL GetOriginalRequestURL(WebDataSource* ds) {
252 // WebDataSource has unreachable URL means that the frame is loaded through 254 // WebDataSource has unreachable URL means that the frame is loaded through
253 // blink::WebFrame::loadData(), and the base URL will be in the redirect 255 // blink::WebFrame::loadData(), and the base URL will be in the redirect
254 // chain. However, we never visited the baseURL. So in this case, we should 256 // chain. However, we never visited the baseURL. So in this case, we should
255 // use the unreachable URL as the original URL. 257 // use the unreachable URL as the original URL.
256 if (ds->hasUnreachableURL()) 258 if (ds->hasUnreachableURL())
257 return ds->unreachableURL(); 259 return ds->unreachableURL();
258 260
259 std::vector<GURL> redirects; 261 std::vector<GURL> redirects;
260 GetRedirectChain(ds, &redirects); 262 GetRedirectChain(ds, &redirects);
261 if (!redirects.empty()) 263 if (!redirects.empty())
262 return redirects.at(0); 264 return redirects.at(0);
263 265
264 return ds->originalRequest().url(); 266 return ds->originalRequest().url();
265 } 267 }
266 268
267 NOINLINE static void CrashIntentionally() { 269 NOINLINE void CrashIntentionally() {
268 // NOTE(shess): Crash directly rather than using NOTREACHED() so 270 // NOTE(shess): Crash directly rather than using NOTREACHED() so
269 // that the signature is easier to triage in crash reports. 271 // that the signature is easier to triage in crash reports.
270 volatile int* zero = NULL; 272 volatile int* zero = NULL;
271 *zero = 0; 273 *zero = 0;
272 } 274 }
273 275
274 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) 276 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN)
275 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { 277 NOINLINE void MaybeTriggerAsanError(const GURL& url) {
276 // NOTE(rogerm): We intentionally perform an invalid heap access here in 278 // NOTE(rogerm): We intentionally perform an invalid heap access here in
277 // order to trigger an Address Sanitizer (ASAN) error report. 279 // order to trigger an Address Sanitizer (ASAN) error report.
278 const char kCrashDomain[] = "crash"; 280 const char kCrashDomain[] = "crash";
279 const char kHeapOverflow[] = "/heap-overflow"; 281 const char kHeapOverflow[] = "/heap-overflow";
280 const char kHeapUnderflow[] = "/heap-underflow"; 282 const char kHeapUnderflow[] = "/heap-underflow";
281 const char kUseAfterFree[] = "/use-after-free"; 283 const char kUseAfterFree[] = "/use-after-free";
282 #if defined(SYZYASAN) 284 #if defined(SYZYASAN)
283 const char kCorruptHeapBlock[] = "/corrupt-heap-block"; 285 const char kCorruptHeapBlock[] = "/corrupt-heap-block";
284 const char kCorruptHeap[] = "/corrupt-heap"; 286 const char kCorruptHeap[] = "/corrupt-heap";
285 #endif 287 #endif
(...skipping 14 matching lines...) Expand all
300 #if defined(SYZYASAN) 302 #if defined(SYZYASAN)
301 } else if (crash_type == kCorruptHeapBlock) { 303 } else if (crash_type == kCorruptHeapBlock) {
302 base::debug::AsanCorruptHeapBlock(); 304 base::debug::AsanCorruptHeapBlock();
303 } else if (crash_type == kCorruptHeap) { 305 } else if (crash_type == kCorruptHeap) {
304 base::debug::AsanCorruptHeap(); 306 base::debug::AsanCorruptHeap();
305 #endif 307 #endif
306 } 308 }
307 } 309 }
308 #endif // ADDRESS_SANITIZER || SYZYASAN 310 #endif // ADDRESS_SANITIZER || SYZYASAN
309 311
310 static void MaybeHandleDebugURL(const GURL& url) { 312 void MaybeHandleDebugURL(const GURL& url) {
311 if (!url.SchemeIs(kChromeUIScheme)) 313 if (!url.SchemeIs(kChromeUIScheme))
312 return; 314 return;
313 if (url == GURL(kChromeUICrashURL)) { 315 if (url == GURL(kChromeUICrashURL)) {
314 CrashIntentionally(); 316 CrashIntentionally();
315 } else if (url == GURL(kChromeUIDumpURL)) { 317 } else if (url == GURL(kChromeUIDumpURL)) {
316 // This URL will only correctly create a crash dump file if content is 318 // This URL will only correctly create a crash dump file if content is
317 // hosted in a process that has correctly called 319 // hosted in a process that has correctly called
318 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation 320 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation
319 // of base::debug::DumpWithoutCrashing for more details. 321 // of base::debug::DumpWithoutCrashing for more details.
320 base::debug::DumpWithoutCrashing(); 322 base::debug::DumpWithoutCrashing();
321 } else if (url == GURL(kChromeUIKillURL)) { 323 } else if (url == GURL(kChromeUIKillURL)) {
322 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); 324 base::KillProcess(base::GetCurrentProcessHandle(), 1, false);
323 } else if (url == GURL(kChromeUIHangURL)) { 325 } else if (url == GURL(kChromeUIHangURL)) {
324 for (;;) { 326 for (;;) {
325 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); 327 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
326 } 328 }
327 } else if (url == GURL(kChromeUIShorthangURL)) { 329 } else if (url == GURL(kChromeUIShorthangURL)) {
328 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); 330 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20));
329 } 331 }
330 332
331 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) 333 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN)
332 MaybeTriggerAsanError(url); 334 MaybeTriggerAsanError(url);
333 #endif // ADDRESS_SANITIZER || SYZYASAN 335 #endif // ADDRESS_SANITIZER || SYZYASAN
334 } 336 }
335 337
336 // Returns false unless this is a top-level navigation. 338 // Returns false unless this is a top-level navigation.
337 static bool IsTopLevelNavigation(WebFrame* frame) { 339 bool IsTopLevelNavigation(WebFrame* frame) {
338 return frame->parent() == NULL; 340 return frame->parent() == NULL;
339 } 341 }
340 342
341 // Returns false unless this is a top-level navigation that crosses origins. 343 // Returns false unless this is a top-level navigation that crosses origins.
342 static bool IsNonLocalTopLevelNavigation(const GURL& url, 344 bool IsNonLocalTopLevelNavigation(const GURL& url,
343 WebFrame* frame, 345 WebFrame* frame,
344 WebNavigationType type, 346 WebNavigationType type,
345 bool is_form_post) { 347 bool is_form_post) {
346 if (!IsTopLevelNavigation(frame)) 348 if (!IsTopLevelNavigation(frame))
347 return false; 349 return false;
348 350
349 // Navigations initiated within Webkit are not sent out to the external host 351 // Navigations initiated within Webkit are not sent out to the external host
350 // in the following cases. 352 // in the following cases.
351 // 1. The url scheme is not http/https 353 // 1. The url scheme is not http/https
352 // 2. The origin of the url and the opener is the same in which case the 354 // 2. The origin of the url and the opener is the same in which case the
353 // opener relationship is maintained. 355 // opener relationship is maintained.
354 // 3. Reloads/form submits/back forward navigations 356 // 3. Reloads/form submits/back forward navigations
355 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme)) 357 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme))
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 extra_data = &kEmptyData; 469 extra_data = &kEmptyData;
468 CommonNavigationParams params; 470 CommonNavigationParams params;
469 params.url = request.url(); 471 params.url = request.url();
470 params.referrer = Referrer( 472 params.referrer = Referrer(
471 GURL(request.httpHeaderField(WebString::fromUTF8("Referer")).latin1()), 473 GURL(request.httpHeaderField(WebString::fromUTF8("Referer")).latin1()),
472 request.referrerPolicy()); 474 request.referrerPolicy());
473 params.transition = extra_data->transition_type(); 475 params.transition = extra_data->transition_type();
474 return params; 476 return params;
475 } 477 }
476 478
479 #if !defined(OS_ANDROID)
480 media::Context3DProvider GetSharedMainThreadContext3DProvider() {
481 cc::ContextProvider* provider =
482 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
483 if (!provider)
484 return {nullptr, nullptr};
jamesr 2014/11/13 20:39:16 please don't use this initialization syntax
485 return {provider->ContextGL(), provider->GrContext()};
486 }
487 #endif
488
489 RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*,
490 int32) = nullptr;
jamesr 2014/11/13 20:39:16 could you use a type alias to make this more reada
491
477 } // namespace 492 } // namespace
478 493
479 static RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, int32) =
480 NULL;
481 494
482 // static 495 // static
483 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 496 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
484 int32 routing_id) { 497 int32 routing_id) {
485 DCHECK(routing_id != MSG_ROUTING_NONE); 498 DCHECK(routing_id != MSG_ROUTING_NONE);
486 499
487 if (g_create_render_frame_impl) 500 if (g_create_render_frame_impl)
488 return g_create_render_frame_impl(render_view, routing_id); 501 return g_create_render_frame_impl(render_view, routing_id);
489 else 502 else
490 return new RenderFrameImpl(render_view, routing_id); 503 return new RenderFrameImpl(render_view, routing_id);
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 #if defined(OS_ANDROID) 1745 #if defined(OS_ANDROID)
1733 return CreateAndroidWebMediaPlayer(url, client, initial_cdm); 1746 return CreateAndroidWebMediaPlayer(url, client, initial_cdm);
1734 #else 1747 #else
1735 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 1748 RenderThreadImpl* render_thread = RenderThreadImpl::current();
1736 media::WebMediaPlayerParams params( 1749 media::WebMediaPlayerParams params(
1737 base::Bind(&ContentRendererClient::DeferMediaLoad, 1750 base::Bind(&ContentRendererClient::DeferMediaLoad,
1738 base::Unretained(GetContentClient()->renderer()), 1751 base::Unretained(GetContentClient()->renderer()),
1739 static_cast<RenderFrame*>(this)), 1752 static_cast<RenderFrame*>(this)),
1740 render_thread->GetAudioRendererMixerManager()->CreateInput( 1753 render_thread->GetAudioRendererMixerManager()->CreateInput(
1741 render_view_->routing_id_, routing_id_), 1754 render_view_->routing_id_, routing_id_),
1742 *render_thread->GetAudioHardwareConfig(), 1755 *render_thread->GetAudioHardwareConfig(), new RenderMediaLog(),
1743 new RenderMediaLog(),
1744 render_thread->GetGpuFactories(), 1756 render_thread->GetGpuFactories(),
1745 render_thread->GetMediaThreadTaskRunner(), 1757 render_thread->GetMediaThreadTaskRunner(),
1746 render_thread->compositor_message_loop_proxy(), 1758 render_thread->compositor_message_loop_proxy(),
1747 base::Bind(&EncryptedMediaPlayerSupportImpl::Create), 1759 base::Bind(&EncryptedMediaPlayerSupportImpl::Create),
1748 initial_cdm); 1760 base::Bind(&GetSharedMainThreadContext3DProvider), initial_cdm);
1749 return new media::WebMediaPlayerImpl( 1761 return new media::WebMediaPlayerImpl(
1750 frame, client, weak_factory_.GetWeakPtr(), nullptr, params); 1762 frame, client, weak_factory_.GetWeakPtr(), nullptr, params);
1751 #endif // defined(OS_ANDROID) 1763 #endif // defined(OS_ANDROID)
1752 } 1764 }
1753 1765
1754 blink::WebContentDecryptionModule* 1766 blink::WebContentDecryptionModule*
1755 RenderFrameImpl::createContentDecryptionModule( 1767 RenderFrameImpl::createContentDecryptionModule(
1756 blink::WebLocalFrame* frame, 1768 blink::WebLocalFrame* frame,
1757 const blink::WebSecurityOrigin& security_origin, 1769 const blink::WebSecurityOrigin& security_origin,
1758 const blink::WebString& key_system) { 1770 const blink::WebString& key_system) {
(...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after
4191 4203
4192 #if defined(ENABLE_BROWSER_CDMS) 4204 #if defined(ENABLE_BROWSER_CDMS)
4193 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4205 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4194 if (!cdm_manager_) 4206 if (!cdm_manager_)
4195 cdm_manager_ = new RendererCdmManager(this); 4207 cdm_manager_ = new RendererCdmManager(this);
4196 return cdm_manager_; 4208 return cdm_manager_;
4197 } 4209 }
4198 #endif // defined(ENABLE_BROWSER_CDMS) 4210 #endif // defined(ENABLE_BROWSER_CDMS)
4199 4211
4200 } // namespace content 4212 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698