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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 #else | 449 #else |
464 ::media::ScopedAudioManagerPtr CastContentBrowserClient::CreateAudioManager( | 450 ::media::ScopedAudioManagerPtr CastContentBrowserClient::CreateAudioManager( |
465 ::media::AudioLogFactory* audio_log_factory) { | 451 ::media::AudioLogFactory* audio_log_factory) { |
466 return ::media::ScopedAudioManagerPtr(new media::CastAudioManager( | 452 return ::media::ScopedAudioManagerPtr(new media::CastAudioManager( |
467 GetMediaTaskRunner(), GetMediaTaskRunner(), audio_log_factory, | 453 GetMediaTaskRunner(), GetMediaTaskRunner(), audio_log_factory, |
468 media_pipeline_backend_manager())); | 454 media_pipeline_backend_manager())); |
469 } | 455 } |
470 | 456 |
471 std::unique_ptr<::media::CdmFactory> | 457 std::unique_ptr<::media::CdmFactory> |
472 CastContentBrowserClient::CreateCdmFactory() { | 458 CastContentBrowserClient::CreateCdmFactory() { |
473 // This should return a CdmFactory when either of the following conditions is | 459 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
474 // true: | |
475 // (1) When we are using the CMA pipeline (by setting the cmdline switch). | |
476 // (2) When we are using Mojo browser-side CDM (by setting GN args) | |
477 // If neither of these are true, this function should return nullptr. | |
478 #if !defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) | |
479 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
480 switches::kEnableCmaMediaPipeline)) | |
481 return nullptr; | |
482 #endif // !defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) | |
483 | |
484 return base::MakeUnique<media::CastBrowserCdmFactory>( | 460 return base::MakeUnique<media::CastBrowserCdmFactory>( |
485 GetMediaTaskRunner(), media_resource_tracker()); | 461 GetMediaTaskRunner(), media_resource_tracker()); |
| 462 #endif // defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
| 463 return nullptr; |
486 } | 464 } |
487 | 465 |
488 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 466 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
489 const base::CommandLine& command_line, | 467 const base::CommandLine& command_line, |
490 int child_process_id, | 468 int child_process_id, |
491 content::FileDescriptorInfo* mappings) { | 469 content::FileDescriptorInfo* mappings) { |
492 int crash_signal_fd = GetCrashSignalFD(command_line); | 470 int crash_signal_fd = GetCrashSignalFD(command_line); |
493 if (crash_signal_fd >= 0) { | 471 if (crash_signal_fd >= 0) { |
494 mappings->Share(kCrashDumpSignal, crash_signal_fd); | 472 mappings->Share(kCrashDumpSignal, crash_signal_fd); |
495 } | 473 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 process_type, dumps_path, false /* upload */); | 524 process_type, dumps_path, false /* upload */); |
547 // StartUploaderThread() even though upload is diferred. | 525 // StartUploaderThread() even though upload is diferred. |
548 // Breakpad-related memory is freed in the uploader thread. | 526 // Breakpad-related memory is freed in the uploader thread. |
549 crash_handler->StartUploaderThread(); | 527 crash_handler->StartUploaderThread(); |
550 return crash_handler; | 528 return crash_handler; |
551 } | 529 } |
552 #endif // !defined(OS_ANDROID) | 530 #endif // !defined(OS_ANDROID) |
553 | 531 |
554 } // namespace shell | 532 } // namespace shell |
555 } // namespace chromecast | 533 } // namespace chromecast |
OLD | NEW |