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

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: SkCanvasVideoRenderer use WebGraphicsContext3D 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 "third_party/WebKit/public/platform/Platform.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 scoped_ptr<blink::WebGraphicsContext3DProvider>
481 GetSharedOffscreenGraphicsContext3DProvider() {
482 return make_scoped_ptr(
483 blink::Platform::current()
484 ->createSharedOffscreenGraphicsContext3DProvider());
485 }
486 #endif
487
488 using CreateRenderFrameImpl = RenderFrameImpl* (*)(RenderViewImpl*, int32);
489 CreateRenderFrameImpl g_create_render_frame_impl = nullptr;
490
477 } // namespace 491 } // namespace
478 492
479 static RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, int32) =
480 NULL;
481 493
482 // static 494 // static
483 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 495 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
484 int32 routing_id) { 496 int32 routing_id) {
485 DCHECK(routing_id != MSG_ROUTING_NONE); 497 DCHECK(routing_id != MSG_ROUTING_NONE);
486 498
487 if (g_create_render_frame_impl) 499 if (g_create_render_frame_impl)
488 return g_create_render_frame_impl(render_view, routing_id); 500 return g_create_render_frame_impl(render_view, routing_id);
489 else 501 else
490 return new RenderFrameImpl(render_view, routing_id); 502 return new RenderFrameImpl(render_view, routing_id);
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 #if defined(OS_ANDROID) 1744 #if defined(OS_ANDROID)
1733 return CreateAndroidWebMediaPlayer(url, client, initial_cdm); 1745 return CreateAndroidWebMediaPlayer(url, client, initial_cdm);
1734 #else 1746 #else
1735 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 1747 RenderThreadImpl* render_thread = RenderThreadImpl::current();
1736 media::WebMediaPlayerParams params( 1748 media::WebMediaPlayerParams params(
1737 base::Bind(&ContentRendererClient::DeferMediaLoad, 1749 base::Bind(&ContentRendererClient::DeferMediaLoad,
1738 base::Unretained(GetContentClient()->renderer()), 1750 base::Unretained(GetContentClient()->renderer()),
1739 static_cast<RenderFrame*>(this)), 1751 static_cast<RenderFrame*>(this)),
1740 render_thread->GetAudioRendererMixerManager()->CreateInput( 1752 render_thread->GetAudioRendererMixerManager()->CreateInput(
1741 render_view_->routing_id_, routing_id_), 1753 render_view_->routing_id_, routing_id_),
1742 *render_thread->GetAudioHardwareConfig(), 1754 *render_thread->GetAudioHardwareConfig(), new RenderMediaLog(),
1743 new RenderMediaLog(),
1744 render_thread->GetGpuFactories(), 1755 render_thread->GetGpuFactories(),
1745 render_thread->GetMediaThreadTaskRunner(), 1756 render_thread->GetMediaThreadTaskRunner(),
1746 render_thread->compositor_message_loop_proxy(), 1757 render_thread->compositor_message_loop_proxy(),
1747 base::Bind(&EncryptedMediaPlayerSupportImpl::Create), 1758 base::Bind(&EncryptedMediaPlayerSupportImpl::Create),
1748 initial_cdm); 1759 base::Bind(&GetSharedOffscreenGraphicsContext3DProvider), initial_cdm);
1749 1760
1750 scoped_ptr<media::Renderer> media_renderer = 1761 scoped_ptr<media::Renderer> media_renderer =
1751 GetContentClient()->renderer()->CreateMediaRenderer( 1762 GetContentClient()->renderer()->CreateMediaRenderer(
1752 this, render_thread->GetMediaThreadTaskRunner()); 1763 this, render_thread->GetMediaThreadTaskRunner());
1753 1764
1754 return new media::WebMediaPlayerImpl( 1765 return new media::WebMediaPlayerImpl(
1755 frame, client, weak_factory_.GetWeakPtr(), media_renderer.Pass(), params); 1766 frame, client, weak_factory_.GetWeakPtr(), media_renderer.Pass(), params);
1756 #endif // defined(OS_ANDROID) 1767 #endif // defined(OS_ANDROID)
1757 } 1768 }
1758 1769
(...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after
4199 4210
4200 #if defined(ENABLE_BROWSER_CDMS) 4211 #if defined(ENABLE_BROWSER_CDMS)
4201 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4212 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4202 if (!cdm_manager_) 4213 if (!cdm_manager_)
4203 cdm_manager_ = new RendererCdmManager(this); 4214 cdm_manager_ = new RendererCdmManager(this);
4204 return cdm_manager_; 4215 return cdm_manager_;
4205 } 4216 }
4206 #endif // defined(ENABLE_BROWSER_CDMS) 4217 #endif // defined(ENABLE_BROWSER_CDMS)
4207 4218
4208 } // namespace content 4219 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webmediaplayer_ms.cc ('k') | media/DEPS » ('j') | media/DEPS » ('J')

Powered by Google App Engine
This is Rietveld 408576698