summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chrome_content_browser_client.cc5
-rw-r--r--chrome/browser/chrome_content_browser_client.h1
-rw-r--r--chrome/browser/io_thread.cc7
-rw-r--r--chrome/browser/io_thread.h8
-rw-r--r--chrome/browser/media/media_internals.cc4
-rw-r--r--chrome/browser/media/media_internals.h8
-rw-r--r--chrome/browser/profiles/profile_io_data.cc9
-rw-r--r--chrome/browser/profiles/profile_io_data.h3
-rw-r--r--chrome/browser/ui/webui/media/media_internals_proxy.cc6
9 files changed, 32 insertions, 19 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 4d91175d..1915f6b 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -36,7 +36,6 @@
#include "chrome/browser/geolocation/chrome_access_token_store.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
-#include "chrome/browser/media/media_internals.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
@@ -1163,10 +1162,6 @@ void ChromeContentBrowserClient::RequestMediaAccessPermission(
#endif // TOOLKIT_VIEWS || OS_LINUX
}
-content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() {
- return MediaInternals::GetInstance();
-}
-
void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
const GURL& source_origin,
int callback_context,
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index f0ff699..79278fc 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -121,7 +121,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
virtual void RequestMediaAccessPermission(
const content::MediaStreamRequest* request,
const content::MediaResponseCallback& callback) OVERRIDE;
- virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
virtual void RequestDesktopNotificationPermission(
const GURL& source_origin,
int callback_context,
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 3229f7c..c539860 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -20,6 +20,7 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_event_router_forwarder.h"
+#include "chrome/browser/media/media_internals.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/chrome_url_request_context.h"
@@ -286,6 +287,10 @@ IOThread::Globals::Globals() {}
IOThread::Globals::~Globals() {}
+IOThread::Globals::MediaGlobals::MediaGlobals() {}
+
+IOThread::Globals::MediaGlobals::~MediaGlobals() {}
+
// |local_state| is passed in explicitly in order to (1) reduce implicit
// dependencies and (2) make IOThread more flexible for testing.
IOThread::IOThread(
@@ -369,6 +374,8 @@ void IOThread::Init() {
DCHECK(!globals_);
globals_ = new Globals;
+ globals_->media.media_internals.reset(new MediaInternals());
+
// Add an observer that will emit network change events to the ChromeNetLog.
// Assuming NetworkChangeNotifier dispatches in FIFO order, we should be
// logging the network change before other IO thread consumers respond to it.
diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h
index 2cffacf..d651faa 100644
--- a/chrome/browser/io_thread.h
+++ b/chrome/browser/io_thread.h
@@ -21,6 +21,7 @@
class ChromeNetLog;
class ExtensionEventRouterForwarder;
+class MediaInternals;
class PrefProxyConfigTrackerImpl;
class PrefService;
class SystemURLRequestContextGetter;
@@ -57,6 +58,13 @@ class IOThread : public content::BrowserThreadDelegate {
Globals();
~Globals();
+ struct MediaGlobals {
+ MediaGlobals();
+ ~MediaGlobals();
+ // MediaInternals singleton used to aggregate media information.
+ scoped_ptr<MediaInternals> media_internals;
+ } media;
+
// The "system" NetworkDelegate, used for Profile-agnostic network events.
scoped_ptr<net::NetworkDelegate> system_network_delegate;
scoped_ptr<net::HostResolver> host_resolver;
diff --git a/chrome/browser/media/media_internals.cc b/chrome/browser/media/media_internals.cc
index b2a494d..b85369b 100644
--- a/chrome/browser/media/media_internals.cc
+++ b/chrome/browser/media/media_internals.cc
@@ -13,10 +13,6 @@
#include "media/base/media_log.h"
#include "media/base/media_log_event.h"
-MediaInternals* MediaInternals::GetInstance() {
- return Singleton<MediaInternals>::get();
-}
-
MediaInternals::~MediaInternals() {}
void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) {
diff --git a/chrome/browser/media/media_internals.h b/chrome/browser/media/media_internals.h
index e6818d6..825925b 100644
--- a/chrome/browser/media/media_internals.h
+++ b/chrome/browser/media/media_internals.h
@@ -7,7 +7,6 @@
#pragma once
#include "base/memory/ref_counted.h"
-#include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "base/threading/non_thread_safe.h"
#include "base/values.h"
@@ -20,15 +19,12 @@ struct MediaLogEvent;
}
// This class stores information about currently active media.
-// It's constructed on the UI thread but all of its methods are called on the IO
-// thread.
+// All of its methods are called on the IO thread.
class MediaInternals : public content::MediaObserver,
public base::NonThreadSafe {
public:
virtual ~MediaInternals();
- static MediaInternals* GetInstance();
-
// Overridden from content::MediaObserver:
virtual void OnDeleteAudioStream(void* host, int stream_id) OVERRIDE;
virtual void OnSetAudioStreamPlaying(void* host,
@@ -51,8 +47,8 @@ class MediaInternals : public content::MediaObserver,
void SendEverything();
private:
+ friend class IOThread;
friend class MediaInternalsTest;
- friend struct DefaultSingletonTraits<MediaInternals>;
MediaInternals();
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index a029925..1556ad8 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/extensions/extension_protocols.h"
#include "chrome/browser/io_thread.h"
+#include "chrome/browser/media/media_internals.h"
#include "chrome/browser/net/chrome_cookie_notification_details.h"
#include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h"
#include "chrome/browser/net/chrome_net_log.h"
@@ -390,6 +391,12 @@ net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() {
return request_context_;
}
+content::MediaObserver* ProfileIOData::ResourceContext::GetMediaObserver() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ EnsureInitialized();
+ return media_observer_;
+}
+
// static
std::string ProfileIOData::GetSSLSessionCacheShard() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -488,6 +495,8 @@ void ProfileIOData::LazyInitialize() const {
resource_context_.host_resolver_ = io_thread_globals->host_resolver.get();
resource_context_.request_context_ = main_request_context_;
+ resource_context_.media_observer_ =
+ io_thread_globals->media.media_internals.get();
LazyInitializeInternal(profile_params_.get());
diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h
index 4cafe09..b6ff4c8 100644
--- a/chrome/browser/profiles/profile_io_data.h
+++ b/chrome/browser/profiles/profile_io_data.h
@@ -219,12 +219,15 @@ class ProfileIOData {
// ResourceContext implementation:
virtual net::HostResolver* GetHostResolver() OVERRIDE;
virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
+ virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
+
void EnsureInitialized();
ProfileIOData* const io_data_;
net::HostResolver* host_resolver_;
net::URLRequestContext* request_context_;
+ content::MediaObserver* media_observer_;
};
typedef base::hash_map<std::string, scoped_refptr<ChromeURLRequestContext> >
diff --git a/chrome/browser/ui/webui/media/media_internals_proxy.cc b/chrome/browser/ui/webui/media/media_internals_proxy.cc
index 792c0ac..6b1bc17 100644
--- a/chrome/browser/ui/webui/media/media_internals_proxy.cc
+++ b/chrome/browser/ui/webui/media/media_internals_proxy.cc
@@ -126,20 +126,20 @@ Value* MediaInternalsProxy::GetConstants() {
void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- MediaInternals::GetInstance()->AddObserver(this);
+ io_thread_->globals()->media.media_internals->AddObserver(this);
io_thread_->net_log()->AddThreadSafeObserver(this,
net::NetLog::LOG_ALL_BUT_BYTES);
}
void MediaInternalsProxy::StopObservingMediaInternalsOnIOThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- MediaInternals::GetInstance()->RemoveObserver(this);
+ io_thread_->globals()->media.media_internals->RemoveObserver(this);
io_thread_->net_log()->RemoveThreadSafeObserver(this);
}
void MediaInternalsProxy::GetEverythingOnIOThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- MediaInternals::GetInstance()->SendEverything();
+ io_thread_->globals()->media.media_internals->SendEverything();
}
void MediaInternalsProxy::UpdateUIOnUIThread(const string16& update) {