diff options
author | slan <slan@chromium.org> | 2015-04-30 11:51:08 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-30 18:51:44 +0000 |
commit | 830b0c5dda907f2560ab003e588172c43768293a (patch) | |
tree | 53c45c9fd5bd71c4b43f3427fcc4769ef3b27f1b /chromecast | |
parent | 3eb445c435fefc0d2e1ee0f2c1d1ffdfe9955e6c (diff) | |
download | chromium_src-830b0c5dda907f2560ab003e588172c43768293a.zip chromium_src-830b0c5dda907f2560ab003e588172c43768293a.tar.gz chromium_src-830b0c5dda907f2560ab003e588172c43768293a.tar.bz2 |
Set the AudioManager factory before the browser main loop.
Adds a function to set the AudioManagerFactory for the browser, and a
trivial implementation of this which does not set a factory, opting
instead to use the statically-linked factory method in Chrome.
Change-Id: I1a2df165fbd5c166a13b440876d031c937558cbb
BUG=None
Review URL: https://codereview.chromium.org/1113053002
Cr-Commit-Position: refs/heads/master@{#327751}
Diffstat (limited to 'chromecast')
-rw-r--r-- | chromecast/browser/DEPS | 1 | ||||
-rw-r--r-- | chromecast/browser/cast_browser_main_parts.cc | 13 | ||||
-rw-r--r-- | chromecast/browser/cast_browser_main_parts.h | 9 | ||||
-rw-r--r-- | chromecast/browser/cast_content_browser_client.cc | 4 | ||||
-rw-r--r-- | chromecast/browser/cast_content_browser_client.h | 8 | ||||
-rw-r--r-- | chromecast/browser/cast_content_browser_client_simple.cc | 8 |
6 files changed, 39 insertions, 4 deletions
diff --git a/chromecast/browser/DEPS b/chromecast/browser/DEPS index bd203a8..c4a4b0e 100644 --- a/chromecast/browser/DEPS +++ b/chromecast/browser/DEPS @@ -10,5 +10,6 @@ include_rules = [ "+components/network_hints/browser", "+content/public/browser", "+gin/v8_initializer.h", + "+media/audio", "+media/base", ] diff --git a/chromecast/browser/cast_browser_main_parts.cc b/chromecast/browser/cast_browser_main_parts.cc index 1c0ca15..7922d74 100644 --- a/chromecast/browser/cast_browser_main_parts.cc +++ b/chromecast/browser/cast_browser_main_parts.cc @@ -4,6 +4,7 @@ #include "chromecast/browser/cast_browser_main_parts.h" +#include <string> #if !defined(OS_ANDROID) #include <signal.h> #include <sys/prctl.h> @@ -33,6 +34,8 @@ #include "chromecast/net/connectivity_checker.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/content_switches.h" +#include "media/audio/audio_manager.h" +#include "media/audio/audio_manager_factory.h" #include "media/base/browser_cdm_factory.h" #include "media/base/media_switches.h" @@ -192,11 +195,13 @@ void AddDefaultCommandLineSwitches(base::CommandLine* command_line) { CastBrowserMainParts::CastBrowserMainParts( const content::MainFunctionParams& parameters, - URLRequestContextFactory* url_request_context_factory) + URLRequestContextFactory* url_request_context_factory, + scoped_ptr<::media::AudioManagerFactory> audio_manager_factory) : BrowserMainParts(), cast_browser_process_(new CastBrowserProcess()), parameters_(parameters), - url_request_context_factory_(url_request_context_factory) { + url_request_context_factory_(url_request_context_factory), + audio_manager_factory_(audio_manager_factory.Pass()) { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); AddDefaultCommandLineSwitches(command_line); } @@ -212,6 +217,10 @@ void CastBrowserMainParts::PreMainMessageLoopStart() { // Net/DNS metrics. metrics::PreregisterAllGroupedHistograms(); + // Set the platform's implementation of AudioManagerFactory. + if (audio_manager_factory_) + ::media::AudioManager::SetFactory(audio_manager_factory_.release()); + #if defined(OS_ANDROID) net::NetworkChangeNotifier::SetFactory( new net::NetworkChangeNotifierFactoryAndroid()); diff --git a/chromecast/browser/cast_browser_main_parts.h b/chromecast/browser/cast_browser_main_parts.h index 7c9baf4..49954ce 100644 --- a/chromecast/browser/cast_browser_main_parts.h +++ b/chromecast/browser/cast_browser_main_parts.h @@ -11,6 +11,10 @@ #include "content/public/browser/browser_main_parts.h" #include "content/public/common/main_function_params.h" +namespace media { +class AudioManagerFactory; +} + namespace chromecast { namespace shell { class CastBrowserProcess; @@ -18,9 +22,11 @@ class URLRequestContextFactory; class CastBrowserMainParts : public content::BrowserMainParts { public: + // This class does not take ownership of |url_request_content_factory|. CastBrowserMainParts( const content::MainFunctionParams& parameters, - URLRequestContextFactory* url_request_context_factory); + URLRequestContextFactory* url_request_context_factory, + scoped_ptr<::media::AudioManagerFactory> audio_manager_factory); ~CastBrowserMainParts() override; // content::BrowserMainParts implementation: @@ -35,6 +41,7 @@ class CastBrowserMainParts : public content::BrowserMainParts { scoped_ptr<CastBrowserProcess> cast_browser_process_; const content::MainFunctionParams parameters_; // For running browser tests. URLRequestContextFactory* const url_request_context_factory_; + scoped_ptr<::media::AudioManagerFactory> audio_manager_factory_; DISALLOW_COPY_AND_ASSIGN(CastBrowserMainParts); }; diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc index 4a07649..a6178e4 100644 --- a/chromecast/browser/cast_content_browser_client.cc +++ b/chromecast/browser/cast_content_browser_client.cc @@ -38,6 +38,7 @@ #include "content/public/common/url_constants.h" #include "content/public/common/web_preferences.h" #include "gin/v8_initializer.h" +#include "media/audio/audio_manager_factory.h" #include "net/ssl/ssl_cert_request_info.h" #include "net/url_request/url_request_context_getter.h" #include "ui/gl/gl_switches.h" @@ -66,7 +67,8 @@ CastContentBrowserClient::~CastContentBrowserClient() { content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts( const content::MainFunctionParams& parameters) { return new CastBrowserMainParts(parameters, - url_request_context_factory_.get()); + url_request_context_factory_.get(), + PlatformCreateAudioManagerFactory()); } void CastContentBrowserClient::RenderProcessWillLaunch( diff --git a/chromecast/browser/cast_content_browser_client.h b/chromecast/browser/cast_content_browser_client.h index 0d25e61..5e5c262 100644 --- a/chromecast/browser/cast_content_browser_client.h +++ b/chromecast/browser/cast_content_browser_client.h @@ -6,6 +6,8 @@ #define CHROMECAST_BROWSER_CAST_CONTENT_BROWSER_CLIENT_H_ #include <map> +#include <string> +#include <vector> #include "base/macros.h" #include "base/memory/scoped_ptr.h" @@ -19,6 +21,10 @@ namespace content { class BrowserMessageFilter; } +namespace media { +class AudioManagerFactory; +} + namespace net { class HostResolver; } @@ -109,6 +115,8 @@ class CastContentBrowserClient: public content::ContentBrowserClient { GURL requesting_url, int render_process_id); + scoped_ptr<::media::AudioManagerFactory> PlatformCreateAudioManagerFactory(); + #if !defined(OS_ANDROID) // Returns the crash signal FD corresponding to the current process type. int GetCrashSignalFD(const base::CommandLine& command_line); diff --git a/chromecast/browser/cast_content_browser_client_simple.cc b/chromecast/browser/cast_content_browser_client_simple.cc index 34012b4..bde5a71 100644 --- a/chromecast/browser/cast_content_browser_client_simple.cc +++ b/chromecast/browser/cast_content_browser_client_simple.cc @@ -5,6 +5,7 @@ #include "chromecast/browser/cast_content_browser_client.h" #include "content/public/browser/browser_message_filter.h" +#include "media/audio/audio_manager_factory.h" namespace chromecast { namespace shell { @@ -18,5 +19,12 @@ CastContentBrowserClient::PlatformGetBrowserMessageFilters() { return std::vector<scoped_refptr<content::BrowserMessageFilter>>(); } +scoped_ptr<::media::AudioManagerFactory> +CastContentBrowserClient::PlatformCreateAudioManagerFactory() { + // Return nullptr. The factory will not be set, and the statically linked + // implementation of AudioManager will be used. + return scoped_ptr<::media::AudioManagerFactory>(); +} + } // namespace shell } // namespace chromecast |