| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/browser/cast_content_browser_client.h" | 5 #include "chromecast/browser/cast_content_browser_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "chromecast/base/cast_constants.h" | 23 #include "chromecast/base/cast_constants.h" |
| 24 #include "chromecast/base/cast_paths.h" | 24 #include "chromecast/base/cast_paths.h" |
| 25 #include "chromecast/base/chromecast_switches.h" | 25 #include "chromecast/base/chromecast_switches.h" |
| 26 #include "chromecast/browser/cast_browser_context.h" | 26 #include "chromecast/browser/cast_browser_context.h" |
| 27 #include "chromecast/browser/cast_browser_main_parts.h" | 27 #include "chromecast/browser/cast_browser_main_parts.h" |
| 28 #include "chromecast/browser/cast_browser_process.h" | 28 #include "chromecast/browser/cast_browser_process.h" |
| 29 #include "chromecast/browser/cast_network_delegate.h" | 29 #include "chromecast/browser/cast_network_delegate.h" |
| 30 #include "chromecast/browser/cast_quota_permission_context.h" | 30 #include "chromecast/browser/cast_quota_permission_context.h" |
| 31 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h" | 31 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h" |
| 32 #include "chromecast/browser/media/cma_message_filter_host.h" | |
| 33 #include "chromecast/browser/media/media_caps_impl.h" | 32 #include "chromecast/browser/media/media_caps_impl.h" |
| 34 #include "chromecast/browser/service/cast_service_simple.h" | 33 #include "chromecast/browser/service/cast_service_simple.h" |
| 35 #include "chromecast/browser/url_request_context_factory.h" | 34 #include "chromecast/browser/url_request_context_factory.h" |
| 36 #include "chromecast/common/global_descriptors.h" | 35 #include "chromecast/common/global_descriptors.h" |
| 37 #include "chromecast/media/audio/cast_audio_manager.h" | 36 #include "chromecast/media/audio/cast_audio_manager.h" |
| 38 #include "chromecast/media/cma/backend/media_pipeline_backend_manager.h" | 37 #include "chromecast/media/cma/backend/media_pipeline_backend_manager.h" |
| 39 #include "chromecast/public/media/media_pipeline_backend.h" | 38 #include "chromecast/public/media/media_pipeline_backend.h" |
| 40 #include "components/crash/content/app/breakpad_linux.h" | 39 #include "components/crash/content/app/breakpad_linux.h" |
| 41 #include "components/crash/content/browser/crash_handler_host_linux.h" | 40 #include "components/crash/content/browser/crash_handler_host_linux.h" |
| 42 #include "components/network_hints/browser/network_hints_message_filter.h" | 41 #include "components/network_hints/browser/network_hints_message_filter.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 const content::MainFunctionParams& parameters) { | 183 const content::MainFunctionParams& parameters) { |
| 185 DCHECK(!cast_browser_main_parts_); | 184 DCHECK(!cast_browser_main_parts_); |
| 186 cast_browser_main_parts_ = | 185 cast_browser_main_parts_ = |
| 187 new CastBrowserMainParts(parameters, url_request_context_factory_.get()); | 186 new CastBrowserMainParts(parameters, url_request_context_factory_.get()); |
| 188 CastBrowserProcess::GetInstance()->SetCastContentBrowserClient(this); | 187 CastBrowserProcess::GetInstance()->SetCastContentBrowserClient(this); |
| 189 return cast_browser_main_parts_; | 188 return cast_browser_main_parts_; |
| 190 } | 189 } |
| 191 | 190 |
| 192 void CastContentBrowserClient::RenderProcessWillLaunch( | 191 void CastContentBrowserClient::RenderProcessWillLaunch( |
| 193 content::RenderProcessHost* host) { | 192 content::RenderProcessHost* host) { |
| 194 #if !defined(OS_ANDROID) | |
| 195 scoped_refptr<media::CmaMessageFilterHost> cma_message_filter( | |
| 196 new media::CmaMessageFilterHost( | |
| 197 host->GetID(), | |
| 198 base::Bind(&CastContentBrowserClient::CreateMediaPipelineBackend, | |
| 199 base::Unretained(this)), | |
| 200 GetMediaTaskRunner(), media_resource_tracker())); | |
| 201 host->AddFilter(cma_message_filter.get()); | |
| 202 #endif // !defined(OS_ANDROID) | |
| 203 | |
| 204 // Forcibly trigger I/O-thread URLRequestContext initialization before | 193 // Forcibly trigger I/O-thread URLRequestContext initialization before |
| 205 // getting HostResolver. | 194 // getting HostResolver. |
| 206 content::BrowserThread::PostTaskAndReplyWithResult( | 195 content::BrowserThread::PostTaskAndReplyWithResult( |
| 207 content::BrowserThread::IO, FROM_HERE, | 196 content::BrowserThread::IO, FROM_HERE, |
| 208 base::Bind(&net::URLRequestContextGetter::GetURLRequestContext, | 197 base::Bind(&net::URLRequestContextGetter::GetURLRequestContext, |
| 209 base::Unretained( | 198 base::Unretained( |
| 210 url_request_context_factory_->GetSystemGetter())), | 199 url_request_context_factory_->GetSystemGetter())), |
| 211 base::Bind(&CastContentBrowserClient::AddNetworkHintsMessageFilter, | 200 base::Bind(&CastContentBrowserClient::AddNetworkHintsMessageFilter, |
| 212 base::Unretained(this), host->GetID())); | 201 base::Unretained(this), host->GetID())); |
| 213 } | 202 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // controlled by GetBreakpadClient()->EnableBreakpadForProcess(), therefore | 255 // controlled by GetBreakpadClient()->EnableBreakpadForProcess(), therefore |
| 267 // it's ok to add switch to every process here. | 256 // it's ok to add switch to every process here. |
| 268 if (breakpad::IsCrashReporterEnabled()) { | 257 if (breakpad::IsCrashReporterEnabled()) { |
| 269 command_line->AppendSwitch(switches::kEnableCrashReporter); | 258 command_line->AppendSwitch(switches::kEnableCrashReporter); |
| 270 } | 259 } |
| 271 | 260 |
| 272 // Renderer process command-line | 261 // Renderer process command-line |
| 273 if (process_type == switches::kRendererProcess) { | 262 if (process_type == switches::kRendererProcess) { |
| 274 // Any browser command-line switches that should be propagated to | 263 // Any browser command-line switches that should be propagated to |
| 275 // the renderer go here. | 264 // the renderer go here. |
| 276 | |
| 277 if (browser_command_line->HasSwitch(switches::kEnableCmaMediaPipeline)) | |
| 278 command_line->AppendSwitch(switches::kEnableCmaMediaPipeline); | |
| 279 if (browser_command_line->HasSwitch(switches::kAllowHiddenMediaPlayback)) | 265 if (browser_command_line->HasSwitch(switches::kAllowHiddenMediaPlayback)) |
| 280 command_line->AppendSwitch(switches::kAllowHiddenMediaPlayback); | 266 command_line->AppendSwitch(switches::kAllowHiddenMediaPlayback); |
| 281 } | 267 } |
| 282 | 268 |
| 283 #if defined(OS_LINUX) | 269 #if defined(OS_LINUX) |
| 284 // Necessary for accelerated 2d canvas. By default on Linux, Chromium assumes | 270 // Necessary for accelerated 2d canvas. By default on Linux, Chromium assumes |
| 285 // GLES2 contexts can be lost to a power-save mode, which breaks GPU canvas | 271 // GLES2 contexts can be lost to a power-save mode, which breaks GPU canvas |
| 286 // apps. | 272 // apps. |
| 287 if (process_type == switches::kGpuProcess) { | 273 if (process_type == switches::kGpuProcess) { |
| 288 command_line->AppendSwitch(switches::kGpuNoContextLost); | 274 command_line->AppendSwitch(switches::kGpuNoContextLost); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 #else | 459 #else |
| 474 ::media::ScopedAudioManagerPtr CastContentBrowserClient::CreateAudioManager( | 460 ::media::ScopedAudioManagerPtr CastContentBrowserClient::CreateAudioManager( |
| 475 ::media::AudioLogFactory* audio_log_factory) { | 461 ::media::AudioLogFactory* audio_log_factory) { |
| 476 return ::media::ScopedAudioManagerPtr(new media::CastAudioManager( | 462 return ::media::ScopedAudioManagerPtr(new media::CastAudioManager( |
| 477 GetMediaTaskRunner(), GetMediaTaskRunner(), audio_log_factory, | 463 GetMediaTaskRunner(), GetMediaTaskRunner(), audio_log_factory, |
| 478 media_pipeline_backend_manager())); | 464 media_pipeline_backend_manager())); |
| 479 } | 465 } |
| 480 | 466 |
| 481 std::unique_ptr<::media::CdmFactory> | 467 std::unique_ptr<::media::CdmFactory> |
| 482 CastContentBrowserClient::CreateCdmFactory() { | 468 CastContentBrowserClient::CreateCdmFactory() { |
| 483 // This should return a CdmFactory when either of the following conditions is | 469 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
| 484 // true: | |
| 485 // (1) When we are using the CMA pipeline (by setting the cmdline switch). | |
| 486 // (2) When we are using Mojo browser-side CDM (by setting GN args) | |
| 487 // If neither of these are true, this function should return nullptr. | |
| 488 #if !defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) | |
| 489 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 490 switches::kEnableCmaMediaPipeline)) | |
| 491 return nullptr; | |
| 492 #endif // !defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) | |
| 493 | |
| 494 return base::MakeUnique<media::CastBrowserCdmFactory>( | 470 return base::MakeUnique<media::CastBrowserCdmFactory>( |
| 495 GetMediaTaskRunner(), media_resource_tracker()); | 471 GetMediaTaskRunner(), media_resource_tracker()); |
| 472 #endif // defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
| 473 return nullptr; |
| 496 } | 474 } |
| 497 | 475 |
| 498 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 476 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 499 const base::CommandLine& command_line, | 477 const base::CommandLine& command_line, |
| 500 int child_process_id, | 478 int child_process_id, |
| 501 content::FileDescriptorInfo* mappings) { | 479 content::FileDescriptorInfo* mappings) { |
| 502 int crash_signal_fd = GetCrashSignalFD(command_line); | 480 int crash_signal_fd = GetCrashSignalFD(command_line); |
| 503 if (crash_signal_fd >= 0) { | 481 if (crash_signal_fd >= 0) { |
| 504 mappings->Share(kCrashDumpSignal, crash_signal_fd); | 482 mappings->Share(kCrashDumpSignal, crash_signal_fd); |
| 505 } | 483 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 process_type, dumps_path, false /* upload */); | 534 process_type, dumps_path, false /* upload */); |
| 557 // StartUploaderThread() even though upload is diferred. | 535 // StartUploaderThread() even though upload is diferred. |
| 558 // Breakpad-related memory is freed in the uploader thread. | 536 // Breakpad-related memory is freed in the uploader thread. |
| 559 crash_handler->StartUploaderThread(); | 537 crash_handler->StartUploaderThread(); |
| 560 return crash_handler; | 538 return crash_handler; |
| 561 } | 539 } |
| 562 #endif // !defined(OS_ANDROID) | 540 #endif // !defined(OS_ANDROID) |
| 563 | 541 |
| 564 } // namespace shell | 542 } // namespace shell |
| 565 } // namespace chromecast | 543 } // namespace chromecast |
| OLD | NEW |