summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 02:31:56 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 02:31:56 +0000
commit11158e2d4794c6f91f4276a5160b685d2229bbc4 (patch)
tree8f2c391c422a7d7d65dad38090e47350e9f2d671 /chrome
parentf5a263d76dd8280a860fc084df63be5f669223ce (diff)
downloadchromium_src-11158e2d4794c6f91f4276a5160b685d2229bbc4.zip
chromium_src-11158e2d4794c6f91f4276a5160b685d2229bbc4.tar.gz
chromium_src-11158e2d4794c6f91f4276a5160b685d2229bbc4.tar.bz2
Move chrome://media-internals to content. This allows us to hide implementation details from the public API.
BUG=169170 Review URL: https://codereview.chromium.org/12153002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_resources.grd2
-rw-r--r--chrome/browser/chrome_content_browser_client.cc4
-rw-r--r--chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc163
-rw-r--r--chrome/browser/extensions/api/tab_capture/tab_capture_registry.h49
-rw-r--r--chrome/browser/extensions/extension_host.cc4
-rw-r--r--chrome/browser/media/media_capture_devices_dispatcher.cc165
-rw-r--r--chrome/browser/media/media_capture_devices_dispatcher.h81
-rw-r--r--chrome/browser/media/media_internals.cc254
-rw-r--r--chrome/browser/media/media_internals.h126
-rw-r--r--chrome/browser/media/media_internals_observer.h28
-rw-r--r--chrome/browser/media/media_internals_unittest.cc114
-rw-r--r--chrome/browser/media/media_stream_devices_controller.cc25
-rw-r--r--chrome/browser/policy/policy_browsertest.cc17
-rw-r--r--chrome/browser/resources/media_internals.html28
-rw-r--r--chrome/browser/resources/media_internals/cache_entry.js237
-rw-r--r--chrome/browser/resources/media_internals/disjoint_range_set.js145
-rw-r--r--chrome/browser/resources/media_internals/disjoint_range_set_test.html96
-rw-r--r--chrome/browser/resources/media_internals/event_list.js64
-rw-r--r--chrome/browser/resources/media_internals/item_store.js70
-rw-r--r--chrome/browser/resources/media_internals/media_internals.css83
-rw-r--r--chrome/browser/resources/media_internals/media_internals.js281
-rw-r--r--chrome/browser/resources/media_internals/media_player.js154
-rw-r--r--chrome/browser/resources/media_internals/metrics.js118
-rw-r--r--chrome/browser/resources/media_internals/util.js74
-rw-r--r--chrome/browser/ui/extensions/shell_window.cc4
-rw-r--r--chrome/browser/ui/tabs/tab_utils.cc8
-rw-r--r--chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc3
-rw-r--r--chrome/browser/ui/webui/media/media_internals_handler.cc45
-rw-r--r--chrome/browser/ui/webui/media/media_internals_handler.h40
-rw-r--r--chrome/browser/ui/webui/media/media_internals_proxy.cc178
-rw-r--r--chrome/browser/ui/webui/media/media_internals_proxy.h91
-rw-r--r--chrome/browser/ui/webui/media/media_internals_ui.cc45
-rw-r--r--chrome/browser/ui/webui/media/media_internals_ui.h19
-rw-r--r--chrome/browser/ui/webui/options/media_devices_selection_handler.cc18
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/chrome_browser_ui.gypi6
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--chrome/common/url_constants.cc1
-rw-r--r--chrome/common/url_constants.h1
39 files changed, 312 insertions, 2532 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 79c3077..9f268a9 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -122,8 +122,6 @@
<include name="IDR_INSTANT_CSS" file="resources\instant\instant.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_INSTANT_HTML" file="resources\instant\instant.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_INSTANT_JS" file="resources\instant\instant.js" flattenhtml="true" type="BINDATA" />
- <include name="IDR_MEDIA_INTERNALS_HTML" file="resources\media_internals.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
- <include name="IDR_MEDIA_INTERNALS_JS" file="resources\media_internals\media_internals.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_NET_EXPORT_HTML" file="resources\net_export\net_export.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_NET_EXPORT_JS" file="resources\net_export\net_export.js" flattenhtml="true" type="BINDATA" />
<if expr="not pp_ifdef('android')">
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index dbb93e23..0537428 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -41,7 +41,7 @@
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/instant/instant_service.h"
#include "chrome/browser/instant/instant_service_factory.h"
-#include "chrome/browser/media/media_internals.h"
+#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/nacl_host/nacl_process_host.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
@@ -1453,7 +1453,7 @@ void ChromeContentBrowserClient::AddCertificate(
}
content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() {
- return MediaInternals::GetInstance();
+ return MediaCaptureDevicesDispatcher::GetInstance();
}
void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc
index c4a3b11..d4621e1 100644
--- a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc
+++ b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/media/media_internals.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/common/chrome_notification_types.h"
@@ -32,74 +31,14 @@ TabCaptureRegistry::TabCaptureRequest::~TabCaptureRequest() {
}
TabCaptureRegistry::TabCaptureRegistry(Profile* profile)
- : proxy_(new MediaObserverProxy()), profile_(profile) {
- proxy_->Attach(this);
+ : profile_(profile) {
+ MediaCaptureDevicesDispatcher::GetInstance()->AddObserver(this);
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<Profile>(profile_));
}
TabCaptureRegistry::~TabCaptureRegistry() {
- proxy_->Detach();
-}
-
-void TabCaptureRegistry::HandleRequestUpdateOnUIThread(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevice& device,
- const content::MediaRequestState new_state) {
- EventRouter* router = profile_ ?
- extensions::ExtensionSystem::Get(profile_)->event_router() : NULL;
- if (!router)
- return;
-
- std::pair<int, int> key = std::make_pair(render_process_id, render_view_id);
-
- DeviceCaptureRequestMap::iterator request_it = requests_.find(key);
- if (request_it == requests_.end()) {
- LOG(ERROR) << "Receiving updates for invalid tab capture request.";
- return;
- }
-
- tab_capture::TabCaptureState state = tab_capture::TAB_CAPTURE_STATE_NONE;
- switch (new_state) {
- case content::MEDIA_REQUEST_STATE_REQUESTED:
- state = tab_capture::TAB_CAPTURE_STATE_REQUESTED;
- break;
- case content::MEDIA_REQUEST_STATE_PENDING_APPROVAL:
- state = tab_capture::TAB_CAPTURE_STATE_PENDING;
- break;
- case content::MEDIA_REQUEST_STATE_DONE:
- state = tab_capture::TAB_CAPTURE_STATE_ACTIVE;
- break;
- case content::MEDIA_REQUEST_STATE_CLOSING:
- state = tab_capture::TAB_CAPTURE_STATE_STOPPED;
- break;
- case content::MEDIA_REQUEST_STATE_ERROR:
- state = tab_capture::TAB_CAPTURE_STATE_ERROR;
- break;
- default:
- // TODO(justinlin): Implement muted state notification.
- break;
- }
-
- if (state == tab_capture::TAB_CAPTURE_STATE_NONE) {
- // This is a state we don't handle.
- return;
- }
-
- TabCaptureRegistry::TabCaptureRequest* request_info = &request_it->second;
- request_info->status = state;
-
- scoped_ptr<tab_capture::CaptureInfo> info(new tab_capture::CaptureInfo());
- info->tab_id = request_info->tab_id;
- info->status = request_info->status;
-
- scoped_ptr<base::ListValue> args(new ListValue());
- args->Append(info->ToValue().release());
- scoped_ptr<Event> event(new Event(
- events::kOnTabCaptureStatusChanged, args.Pass()));
- event->restrict_to_profile = profile_;
- router->DispatchEventToExtension(request_info->extension_id, event.Pass());
+ MediaCaptureDevicesDispatcher::GetInstance()->RemoveObserver(this);
}
const TabCaptureRegistry::CaptureRequestList
@@ -157,38 +96,12 @@ bool TabCaptureRegistry::VerifyRequest(int render_process_id,
render_process_id, render_view_id)) != requests_.end();
}
-void TabCaptureRegistry::MediaObserverProxy::Attach(
- TabCaptureRegistry* request_handler) {
- handler_ = request_handler;
- BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- base::Bind(&TabCaptureRegistry::MediaObserverProxy::
- RegisterAsMediaObserverOnIOThread, this, false));
-}
-
-void TabCaptureRegistry::MediaObserverProxy::Detach() {
- handler_ = NULL;
- BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- base::Bind(&TabCaptureRegistry::MediaObserverProxy::
- RegisterAsMediaObserverOnIOThread, this, true));
-}
-
-void TabCaptureRegistry::MediaObserverProxy::RegisterAsMediaObserverOnIOThread(
- bool unregister) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (MediaInternals::GetInstance()) {
- if (!unregister)
- MediaInternals::GetInstance()->AddObserver(this);
- else
- MediaInternals::GetInstance()->RemoveObserver(this);
- }
-}
-
-void TabCaptureRegistry::MediaObserverProxy::OnRequestUpdate(
+void TabCaptureRegistry::OnRequestUpdate(
int render_process_id,
int render_view_id,
const content::MediaStreamDevice& device,
const content::MediaRequestState new_state) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// TODO(justinlin): We drop audio device events since they will occur in
// parallel with the video device events (we would get duplicate events). When
@@ -197,21 +110,59 @@ void TabCaptureRegistry::MediaObserverProxy::OnRequestUpdate(
if (device.type != content::MEDIA_TAB_VIDEO_CAPTURE)
return;
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&TabCaptureRegistry::MediaObserverProxy::UpdateOnUIThread,
- this, render_process_id, render_view_id, device, new_state));
-}
+ EventRouter* router = profile_ ?
+ extensions::ExtensionSystem::Get(profile_)->event_router() : NULL;
+ if (!router)
+ return;
-void TabCaptureRegistry::MediaObserverProxy::UpdateOnUIThread(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevice& device,
- const content::MediaRequestState new_state) {
- if (handler_)
- handler_->HandleRequestUpdateOnUIThread(render_process_id,
- render_view_id,
- device,
- new_state);
+ std::pair<int, int> key = std::make_pair(render_process_id, render_view_id);
+
+ DeviceCaptureRequestMap::iterator request_it = requests_.find(key);
+ if (request_it == requests_.end()) {
+ LOG(ERROR) << "Receiving updates for invalid tab capture request.";
+ return;
+ }
+
+ tab_capture::TabCaptureState state = tab_capture::TAB_CAPTURE_STATE_NONE;
+ switch (new_state) {
+ case content::MEDIA_REQUEST_STATE_REQUESTED:
+ state = tab_capture::TAB_CAPTURE_STATE_REQUESTED;
+ break;
+ case content::MEDIA_REQUEST_STATE_PENDING_APPROVAL:
+ state = tab_capture::TAB_CAPTURE_STATE_PENDING;
+ break;
+ case content::MEDIA_REQUEST_STATE_DONE:
+ state = tab_capture::TAB_CAPTURE_STATE_ACTIVE;
+ break;
+ case content::MEDIA_REQUEST_STATE_CLOSING:
+ state = tab_capture::TAB_CAPTURE_STATE_STOPPED;
+ break;
+ case content::MEDIA_REQUEST_STATE_ERROR:
+ state = tab_capture::TAB_CAPTURE_STATE_ERROR;
+ break;
+ default:
+ // TODO(justinlin): Implement muted state notification.
+ break;
+ }
+
+ if (state == tab_capture::TAB_CAPTURE_STATE_NONE) {
+ // This is a state we don't handle.
+ return;
+ }
+
+ TabCaptureRegistry::TabCaptureRequest* request_info = &request_it->second;
+ request_info->status = state;
+
+ scoped_ptr<tab_capture::CaptureInfo> info(new tab_capture::CaptureInfo());
+ info->tab_id = request_info->tab_id;
+ info->status = request_info->status;
+
+ scoped_ptr<base::ListValue> args(new ListValue());
+ args->Append(info->ToValue().release());
+ scoped_ptr<Event> event(new Event(
+ events::kOnTabCaptureStatusChanged, args.Pass()));
+ event->restrict_to_profile = profile_;
+ router->DispatchEventToExtension(request_info->extension_id, event.Pass());
}
} // namespace extensions
diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.h b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.h
index e0dcf41..561247e 100644
--- a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.h
+++ b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.h
@@ -10,8 +10,7 @@
#include <utility>
#include <vector>
-#include "chrome/browser/media/media_internals.h"
-#include "chrome/browser/media/media_internals_observer.h"
+#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/common/extensions/api/tab_capture.h"
#include "content/public/browser/media_request_state.h"
@@ -26,7 +25,8 @@ namespace extensions {
namespace tab_capture = extensions::api::tab_capture;
class TabCaptureRegistry : public ProfileKeyedService,
- public content::NotificationObserver {
+ public content::NotificationObserver,
+ public MediaCaptureDevicesDispatcher::Observer {
public:
struct TabCaptureRequest {
TabCaptureRequest(std::string extension_id,
@@ -52,49 +52,20 @@ class TabCaptureRegistry : public ProfileKeyedService,
typedef std::map<const std::pair<int, int>, TabCaptureRequest>
DeviceCaptureRequestMap;
- class MediaObserverProxy : public MediaInternalsObserver,
- public base::RefCountedThreadSafe<
- MediaObserverProxy> {
- public:
- MediaObserverProxy() : handler_(NULL) {}
- void Attach(TabCaptureRegistry* handler);
- void Detach();
-
- private:
- friend class base::RefCountedThreadSafe<MediaObserverProxy>;
- virtual ~MediaObserverProxy() {}
-
- // MediaInternalsObserver.
- virtual void OnRequestUpdate(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevice& device,
- const content::MediaRequestState state) OVERRIDE;
-
- void RegisterAsMediaObserverOnIOThread(bool unregister);
- void UpdateOnUIThread(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevice& device,
- const content::MediaRequestState new_state);
-
- TabCaptureRegistry* handler_;
- };
-
virtual ~TabCaptureRegistry();
- void HandleRequestUpdateOnUIThread(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevice& device,
- const content::MediaRequestState state);
-
// content::NotificationObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- scoped_refptr<MediaObserverProxy> proxy_;
+ // MediaCaptureDevicesDispatcher::Observer implementation.
+ virtual void OnRequestUpdate(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevice& device,
+ const content::MediaRequestState state) OVERRIDE;
+
content::NotificationRegistrar registrar_;
Profile* const profile_;
DeviceCaptureRequestMap requests_;
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 1fcdf14..d8abc32 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -22,7 +22,7 @@
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/intents/web_intents_util.h"
-#include "chrome/browser/media/media_internals.h"
+#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h"
#include "chrome/browser/ui/browser.h"
@@ -652,7 +652,7 @@ void ExtensionHost::RequestMediaAccessPermission(
const content::MediaResponseCallback& callback) {
// Get the preferred default devices for the request.
content::MediaStreamDevices devices;
- media::GetDefaultDevicesForProfile(
+ MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevicesForProfile(
profile_,
content::IsAudioMediaType(request.audio_type),
content::IsVideoMediaType(request.video_type),
diff --git a/chrome/browser/media/media_capture_devices_dispatcher.cc b/chrome/browser/media/media_capture_devices_dispatcher.cc
index 91923c6..23136c9 100644
--- a/chrome/browser/media/media_capture_devices_dispatcher.cc
+++ b/chrome/browser/media/media_capture_devices_dispatcher.cc
@@ -4,7 +4,9 @@
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
+#include "chrome/browser/media/media_stream_capture_indicator.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_devices_monitor.h"
@@ -13,8 +15,34 @@
using content::BrowserThread;
using content::MediaStreamDevices;
+namespace {
+
+const content::MediaStreamDevice* FindDefaultDeviceWithId(
+ const content::MediaStreamDevices& devices,
+ const std::string& device_id) {
+ if (devices.empty())
+ return NULL;
+
+ content::MediaStreamDevices::const_iterator iter = devices.begin();
+ for (; iter != devices.end(); ++iter) {
+ if (iter->id == device_id) {
+ return &(*iter);
+ }
+ }
+
+ return &(*devices.begin());
+};
+
+} // namespace
+
+
+MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
+ return Singleton<MediaCaptureDevicesDispatcher>::get();
+}
+
MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
- : devices_enumerated_(false) {}
+ : devices_enumerated_(false),
+ media_stream_capture_indicator_(new MediaStreamCaptureIndicator()) {}
MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}
@@ -32,26 +60,6 @@ void MediaCaptureDevicesDispatcher::RegisterUserPrefs(
}
}
-void MediaCaptureDevicesDispatcher::AudioCaptureDevicesChanged(
- const MediaStreamDevices& devices) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread,
- this, devices));
-}
-
-void MediaCaptureDevicesDispatcher::VideoCaptureDevicesChanged(
- const MediaStreamDevices& devices) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread,
- this, devices));
-}
-
void MediaCaptureDevicesDispatcher::AddObserver(Observer* observer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!observers_.HasObserver(observer))
@@ -87,6 +95,109 @@ MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
return video_devices_;
}
+void MediaCaptureDevicesDispatcher::GetDefaultDevicesForProfile(
+ Profile* profile,
+ bool audio,
+ bool video,
+ content::MediaStreamDevices* devices) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(audio || video);
+
+ PrefService* prefs = profile->GetPrefs();
+ std::string default_device;
+ if (audio) {
+ default_device = prefs->GetString(prefs::kDefaultAudioCaptureDevice);
+ GetRequestedDevice(default_device, true, false, devices);
+ }
+
+ if (video) {
+ default_device = prefs->GetString(prefs::kDefaultVideoCaptureDevice);
+ GetRequestedDevice(default_device, false, true, devices);
+ }
+}
+
+void MediaCaptureDevicesDispatcher::GetRequestedDevice(
+ const std::string& requested_device_id,
+ bool audio,
+ bool video,
+ content::MediaStreamDevices* devices) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(audio || video);
+
+ if (audio) {
+ const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
+ const content::MediaStreamDevice* const device =
+ FindDefaultDeviceWithId(audio_devices, requested_device_id);
+ if (device)
+ devices->push_back(*device);
+ }
+ if (video) {
+ const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
+ const content::MediaStreamDevice* const device =
+ FindDefaultDeviceWithId(video_devices, requested_device_id);
+ if (device)
+ devices->push_back(*device);
+ }
+}
+
+scoped_refptr<MediaStreamCaptureIndicator>
+ MediaCaptureDevicesDispatcher::GetMediaStreamCaptureIndicator() {
+ return media_stream_capture_indicator_;
+}
+
+void MediaCaptureDevicesDispatcher::OnCaptureDevicesOpened(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevices& devices) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ media_stream_capture_indicator_->CaptureDevicesOpened(render_process_id,
+ render_view_id,
+ devices);
+}
+
+void MediaCaptureDevicesDispatcher::OnCaptureDevicesClosed(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevices& devices) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ media_stream_capture_indicator_->CaptureDevicesClosed(render_process_id,
+ render_view_id,
+ devices);
+}
+
+void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged(
+ const content::MediaStreamDevices& devices) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread,
+ base::Unretained(this), devices));
+}
+
+void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged(
+ const content::MediaStreamDevices& devices) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread,
+ base::Unretained(this), devices));
+}
+
+void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevice& device,
+ content::MediaRequestState state) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(
+ &MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread,
+ base::Unretained(this), render_process_id, render_view_id, device,
+ state));
+
+}
+
void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread(
const content::MediaStreamDevices& devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -104,3 +215,15 @@ void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread(
FOR_EACH_OBSERVER(Observer, observers_,
OnUpdateVideoDevices(video_devices_));
}
+
+void MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevice& device,
+ content::MediaRequestState state) {
+ FOR_EACH_OBSERVER(Observer, observers_,
+ OnRequestUpdate(render_process_id,
+ render_view_id,
+ device,
+ state));
+}
diff --git a/chrome/browser/media/media_capture_devices_dispatcher.h b/chrome/browser/media/media_capture_devices_dispatcher.h
index 3e7462a..b28bb2f 100644
--- a/chrome/browser/media/media_capture_devices_dispatcher.h
+++ b/chrome/browser/media/media_capture_devices_dispatcher.h
@@ -5,17 +5,20 @@
#ifndef CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
#define CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
-#include "base/memory/ref_counted.h"
+#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/singleton.h"
#include "base/observer_list.h"
+#include "content/public/browser/media_observer.h"
#include "content/public/common/media_stream_request.h"
+class MediaStreamCaptureIndicator;
class PrefServiceSyncable;
+class Profile;
-// This observer is owned by MediaInternals and deleted when MediaInternals
-// is deleted.
-class MediaCaptureDevicesDispatcher
- : public base::RefCountedThreadSafe<MediaCaptureDevicesDispatcher> {
+// This singleton is used to receive updates about media events from the content
+// layer.
+class MediaCaptureDevicesDispatcher : public content::MediaObserver {
public:
class Observer {
public:
@@ -29,20 +32,21 @@ class MediaCaptureDevicesDispatcher
virtual void OnUpdateVideoDevices(
const content::MediaStreamDevices& devices) {}
+ // Handle an information update related to a media stream request.
+ virtual void OnRequestUpdate(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevice& device,
+ const content::MediaRequestState state) {}
+
virtual ~Observer() {}
};
- MediaCaptureDevicesDispatcher();
+ static MediaCaptureDevicesDispatcher* GetInstance();
// Registers the preferences related to Media Stream default devices.
static void RegisterUserPrefs(PrefServiceSyncable* user_prefs);
- // Called on IO thread when one audio device is plugged in or unplugged.
- void AudioCaptureDevicesChanged(const content::MediaStreamDevices& devices);
-
- // Called on IO thread when one video device is plugged in or unplugged.
- void VideoCaptureDevicesChanged(const content::MediaStreamDevices& devices);
-
// Methods for observers. Called on UI thread.
// Observers should add themselves on construction and remove themselves
// on destruction.
@@ -51,14 +55,59 @@ class MediaCaptureDevicesDispatcher
const content::MediaStreamDevices& GetAudioCaptureDevices();
const content::MediaStreamDevices& GetVideoCaptureDevices();
+ // Helper to get the default devices which can be used by the media request,
+ // if the return list is empty, it means there is no available device on the
+ // OS.
+ // Called on the UI thread.
+ void GetDefaultDevicesForProfile(Profile* profile,
+ bool audio,
+ bool video,
+ content::MediaStreamDevices* devices);
+
+ // Helper for picking the device that was requested for an OpenDevice request.
+ // If the device requested is not available it will revert to using the first
+ // available one instead or will return an empty list if no devices of the
+ // requested kind are present.
+ void GetRequestedDevice(const std::string& requested_device_id,
+ bool audio,
+ bool video,
+ content::MediaStreamDevices* devices);
+
+ // Overridden from content::MediaObserver:
+ virtual void OnCaptureDevicesOpened(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevices& devices) OVERRIDE;
+ virtual void OnCaptureDevicesClosed(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevices& devices) OVERRIDE;
+ virtual void OnAudioCaptureDevicesChanged(
+ const content::MediaStreamDevices& devices) OVERRIDE;
+ virtual void OnVideoCaptureDevicesChanged(
+ const content::MediaStreamDevices& devices) OVERRIDE;
+ virtual void OnMediaRequestStateChanged(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevice& device,
+ content::MediaRequestState state) OVERRIDE;
+
+ scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator();
+
private:
- friend class base::RefCountedThreadSafe<MediaCaptureDevicesDispatcher>;
+ friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>;
+
+ MediaCaptureDevicesDispatcher();
virtual ~MediaCaptureDevicesDispatcher();
- // Called by the public Audio/VideoCaptureDevicesChanged() functions,
- // executed on UI thread.
+ // Called by the MediaObserver() functions, executed on UI thread.
void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices);
void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices);
+ void UpdateMediaRequestStateOnUIThread(
+ int render_process_id,
+ int render_view_id,
+ const content::MediaStreamDevice& device,
+ content::MediaRequestState state);
// A list of cached audio capture devices.
content::MediaStreamDevices audio_devices_;
@@ -72,6 +121,8 @@ class MediaCaptureDevicesDispatcher
// Flag to indicate if device enumeration has been done/doing.
// Only accessed on UI thread.
bool devices_enumerated_;
+
+ scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_;
};
#endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
diff --git a/chrome/browser/media/media_internals.cc b/chrome/browser/media/media_internals.cc
deleted file mode 100644
index fe1ec4a..0000000
--- a/chrome/browser/media/media_internals.cc
+++ /dev/null
@@ -1,254 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/media/media_internals.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "base/string16.h"
-#include "base/stringprintf.h"
-#include "chrome/browser/media/media_capture_devices_dispatcher.h"
-#include "chrome/browser/media/media_internals_observer.h"
-#include "chrome/browser/media/media_stream_capture_indicator.h"
-#include "chrome/browser/prefs/scoped_user_pref_update.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/pref_names.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/web_ui.h"
-#include "media/base/media_log.h"
-#include "media/base/media_log_event.h"
-
-using content::BrowserThread;
-
-namespace media {
-
-namespace {
-
-const content::MediaStreamDevice* FindDefaultDeviceWithId(
- const content::MediaStreamDevices& devices,
- const std::string& device_id) {
- if (devices.empty())
- return NULL;
-
- content::MediaStreamDevices::const_iterator iter = devices.begin();
- for (; iter != devices.end(); ++iter) {
- if (iter->id == device_id) {
- return &(*iter);
- }
- }
-
- return &(*devices.begin());
-};
-
-} // namespace
-
-void GetDefaultDevicesForProfile(Profile* profile,
- bool audio,
- bool video,
- content::MediaStreamDevices* devices) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(audio || video);
-
- PrefService* prefs = profile->GetPrefs();
- std::string default_device;
- if (audio) {
- default_device = prefs->GetString(prefs::kDefaultAudioCaptureDevice);
- GetRequestedDevice(default_device, true, false, devices);
- }
-
- if (video) {
- default_device = prefs->GetString(prefs::kDefaultVideoCaptureDevice);
- GetRequestedDevice(default_device, false, true, devices);
- }
-}
-
-void GetRequestedDevice(const std::string& requested_device_id,
- bool audio,
- bool video,
- content::MediaStreamDevices* devices) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(audio || video);
-
- MediaCaptureDevicesDispatcher* dispatcher =
- MediaInternals::GetInstance()->GetMediaCaptureDevicesDispatcher();
- if (audio) {
- const content::MediaStreamDevices& audio_devices =
- dispatcher->GetAudioCaptureDevices();
- const content::MediaStreamDevice* const device =
- media::FindDefaultDeviceWithId(audio_devices, requested_device_id);
- if (device)
- devices->push_back(*device);
- }
- if (video) {
- const content::MediaStreamDevices& video_devices =
- dispatcher->GetVideoCaptureDevices();
- const content::MediaStreamDevice* const device =
- media::FindDefaultDeviceWithId(video_devices, requested_device_id);
- if (device)
- devices->push_back(*device);
- }
-}
-
-} // namespace media
-
-MediaInternals* MediaInternals::GetInstance() {
- return Singleton<MediaInternals>::get();
-}
-
-MediaInternals::~MediaInternals() {}
-
-void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- std::string stream = base::StringPrintf("audio_streams.%p:%d",
- host, stream_id);
- DeleteItem(stream);
-}
-
-void MediaInternals::OnSetAudioStreamPlaying(
- void* host, int stream_id, bool playing) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- UpdateAudioStream(host, stream_id,
- "playing", Value::CreateBooleanValue(playing));
-}
-
-void MediaInternals::OnSetAudioStreamStatus(
- void* host, int stream_id, const std::string& status) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- UpdateAudioStream(host, stream_id,
- "status", Value::CreateStringValue(status));
-}
-
-void MediaInternals::OnSetAudioStreamVolume(
- void* host, int stream_id, double volume) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- UpdateAudioStream(host, stream_id,
- "volume", Value::CreateDoubleValue(volume));
-}
-
-void MediaInternals::OnMediaEvent(
- int render_process_id, const media::MediaLogEvent& event) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- // Notify observers that |event| has occured.
- DictionaryValue dict;
- dict.SetInteger("renderer", render_process_id);
- dict.SetInteger("player", event.id);
- dict.SetString("type", media::MediaLog::EventTypeToString(event.type));
- dict.SetDouble("time", event.time.ToDoubleT());
- dict.Set("params", event.params.DeepCopy());
- SendUpdate("media.onMediaEvent", &dict);
-}
-
-void MediaInternals::OnCaptureDevicesOpened(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevices& devices) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- media_stream_capture_indicator_->CaptureDevicesOpened(render_process_id,
- render_view_id,
- devices);
-}
-
-void MediaInternals::OnCaptureDevicesClosed(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevices& devices) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- media_stream_capture_indicator_->CaptureDevicesClosed(render_process_id,
- render_view_id,
- devices);
-}
-
-void MediaInternals::OnAudioCaptureDevicesChanged(
- const content::MediaStreamDevices& devices) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- media_devices_dispatcher_->AudioCaptureDevicesChanged(devices);
-}
-
-void MediaInternals::OnVideoCaptureDevicesChanged(
- const content::MediaStreamDevices& devices) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- media_devices_dispatcher_->VideoCaptureDevicesChanged(devices);
-}
-
-void MediaInternals::OnMediaRequestStateChanged(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevice& device,
- content::MediaRequestState state) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- if (observers_.size()) {
- FOR_EACH_OBSERVER(
- MediaInternalsObserver, observers_, OnRequestUpdate(render_process_id,
- render_view_id,
- device,
- state));
- }
-}
-
-void MediaInternals::AddObserver(MediaInternalsObserver* observer) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- observers_.AddObserver(observer);
-}
-
-void MediaInternals::RemoveObserver(MediaInternalsObserver* observer) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- observers_.RemoveObserver(observer);
-}
-
-void MediaInternals::SendEverything() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- SendUpdate("media.onReceiveEverything", &data_);
-}
-
-scoped_refptr<MediaCaptureDevicesDispatcher>
-MediaInternals::GetMediaCaptureDevicesDispatcher() {
- return media_devices_dispatcher_;
-}
-
-scoped_refptr<MediaStreamCaptureIndicator>
-MediaInternals::GetMediaStreamCaptureIndicator() {
- return media_stream_capture_indicator_.get();
-}
-
-MediaInternals::MediaInternals()
- : media_stream_capture_indicator_(new MediaStreamCaptureIndicator()),
- media_devices_dispatcher_(new MediaCaptureDevicesDispatcher()) {
-}
-
-void MediaInternals::UpdateAudioStream(
- void* host, int stream_id, const std::string& property, Value* value) {
- std::string stream = base::StringPrintf("audio_streams.%p:%d",
- host, stream_id);
- UpdateItem("media.addAudioStream", stream, property, value);
-}
-
-void MediaInternals::DeleteItem(const std::string& item) {
- data_.Remove(item, NULL);
- scoped_ptr<Value> value(Value::CreateStringValue(item));
- SendUpdate("media.onItemDeleted", value.get());
-}
-
-void MediaInternals::UpdateItem(
- const std::string& update_fn, const std::string& id,
- const std::string& property, Value* value) {
- DictionaryValue* item_properties;
- if (!data_.GetDictionary(id, &item_properties)) {
- item_properties = new DictionaryValue();
- data_.Set(id, item_properties);
- item_properties->SetString("id", id);
- }
- item_properties->Set(property, value);
- SendUpdate(update_fn, item_properties);
-}
-
-void MediaInternals::SendUpdate(const std::string& function, Value* value) {
- // Only bother serializing the update to JSON if someone is watching.
- if (observers_.size()) {
- std::vector<const Value*> args;
- args.push_back(value);
- string16 update = content::WebUI::GetJavascriptCall(function, args);
- FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update));
- }
-}
diff --git a/chrome/browser/media/media_internals.h b/chrome/browser/media/media_internals.h
deleted file mode 100644
index f417f39..0000000
--- a/chrome/browser/media/media_internals.h
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_
-#define CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_
-
-#include <string>
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/singleton.h"
-#include "base/observer_list.h"
-#include "base/values.h"
-#include "content/public/browser/media_observer.h"
-#include "content/public/common/media_stream_request.h"
-
-class MediaCaptureDevicesDispatcher;
-class MediaInternalsObserver;
-class MediaStreamCaptureIndicator;
-class Profile;
-
-namespace media {
-
-struct MediaLogEvent;
-
-// Helper to get the default devices which can be used by the media request,
-// if the return list is empty, it means there is no available device on the OS.
-// Called on the UI thread.
-void GetDefaultDevicesForProfile(Profile* profile,
- bool audio,
- bool video,
- content::MediaStreamDevices* devices);
-
-// Helper for picking the device that was requested for an OpenDevice request.
-// If the device requested is not available it will revert to using the first
-// available one instead or will return an empty list if no devices of the
-// requested kind are present.
-void GetRequestedDevice(const std::string& requested_device_id,
- bool audio,
- bool video,
- content::MediaStreamDevices* devices);
-}
-
-// 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.
-class MediaInternals : public content::MediaObserver {
- public:
- virtual ~MediaInternals();
-
- static MediaInternals* GetInstance();
-
- // Overridden from content::MediaObserver:
- virtual void OnDeleteAudioStream(void* host, int stream_id) OVERRIDE;
- virtual void OnSetAudioStreamPlaying(void* host,
- int stream_id,
- bool playing) OVERRIDE;
- virtual void OnSetAudioStreamStatus(void* host,
- int stream_id,
- const std::string& status) OVERRIDE;
- virtual void OnSetAudioStreamVolume(void* host,
- int stream_id,
- double volume) OVERRIDE;
- virtual void OnMediaEvent(int render_process_id,
- const media::MediaLogEvent& event) OVERRIDE;
- virtual void OnCaptureDevicesOpened(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevices& devices) OVERRIDE;
- virtual void OnCaptureDevicesClosed(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevices& devices) OVERRIDE;
- virtual void OnAudioCaptureDevicesChanged(
- const content::MediaStreamDevices& devices) OVERRIDE;
- virtual void OnVideoCaptureDevicesChanged(
- const content::MediaStreamDevices& devices) OVERRIDE;
- virtual void OnMediaRequestStateChanged(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevice& device,
- content::MediaRequestState state) OVERRIDE;
-
- // Methods for observers.
- // Observers should add themselves on construction and remove themselves
- // on destruction.
- void AddObserver(MediaInternalsObserver* observer);
- void RemoveObserver(MediaInternalsObserver* observer);
- void SendEverything();
-
- scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator();
- scoped_refptr<MediaCaptureDevicesDispatcher>
- GetMediaCaptureDevicesDispatcher();
-
- private:
- friend class MediaInternalsTest;
- friend struct DefaultSingletonTraits<MediaInternals>;
-
- MediaInternals();
-
- // Sets |property| of an audio stream to |value| and notifies observers.
- // (host, stream_id) is a unique id for the audio stream.
- // |host| will never be dereferenced.
- void UpdateAudioStream(void* host, int stream_id,
- const std::string& property, Value* value);
-
- // Removes |item| from |data_|.
- void DeleteItem(const std::string& item);
-
- // Sets data_.id.property = value and notifies attached UIs using update_fn.
- // id may be any depth, e.g. "video.decoders.1.2.3"
- void UpdateItem(const std::string& update_fn, const std::string& id,
- const std::string& property, Value* value);
-
- // Calls javascript |function|(|value|) on each attached UI.
- void SendUpdate(const std::string& function, Value* value);
-
- DictionaryValue data_;
- ObserverList<MediaInternalsObserver> observers_;
- scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_;
- scoped_refptr<MediaCaptureDevicesDispatcher> media_devices_dispatcher_;
-
- DISALLOW_COPY_AND_ASSIGN(MediaInternals);
-};
-
-#endif // CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_
diff --git a/chrome/browser/media/media_internals_observer.h b/chrome/browser/media/media_internals_observer.h
deleted file mode 100644
index 7c3afb8..0000000
--- a/chrome/browser/media/media_internals_observer.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_OBSERVER_H_
-#define CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_OBSERVER_H_
-
-#include "content/public/browser/media_request_state.h"
-#include "content/public/common/media_stream_request.h"
-
-// Used by MediaInternalsUI to receive callbacks on media events.
-// Callbacks will be on the IO thread.
-class MediaInternalsObserver {
- public:
- // Handle an information update consisting of a javascript function call.
- virtual void OnUpdate(const string16& javascript) {}
-
- // Handle an information update related to a media stream request.
- virtual void OnRequestUpdate(
- int render_process_id,
- int render_view_id,
- const content::MediaStreamDevice& device,
- const content::MediaRequestState state) {}
-
- virtual ~MediaInternalsObserver() {}
-};
-
-#endif // CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_OBSERVER_H_
diff --git a/chrome/browser/media/media_internals_unittest.cc b/chrome/browser/media/media_internals_unittest.cc
deleted file mode 100644
index bf9899e..0000000
--- a/chrome/browser/media/media_internals_unittest.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/media/media_internals.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
-#include "chrome/browser/media/media_internals_observer.h"
-#include "content/public/test/test_browser_thread.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-class MockMediaInternalsObserver : public MediaInternalsObserver {
- public:
- MOCK_METHOD1(OnUpdate, void(const string16& javascript));
-};
-
-class MediaInternalsTest : public testing::Test {
- public:
- MediaInternalsTest() : io_thread_(content::BrowserThread::IO, &loop_) {}
- DictionaryValue* data() {
- return &internals_->data_;
- }
-
- void DeleteItem(const std::string& item) {
- internals_->DeleteItem(item);
- }
-
- void UpdateItem(const std::string& item, const std::string& property,
- Value* value) {
- internals_->UpdateItem("", item, property, value);
- }
-
- void SendUpdate(const std::string& function, Value* value) {
- internals_->SendUpdate(function, value);
- }
-
- protected:
- virtual void SetUp() {
- internals_.reset(new MediaInternals());
- }
-
- MessageLoop loop_;
- content::TestBrowserThread io_thread_;
- scoped_ptr<MediaInternals> internals_;
-};
-
-TEST_F(MediaInternalsTest, UpdateAddsNewItem) {
- UpdateItem("some.item", "testing", Value::CreateBooleanValue(true));
- bool testing = false;
- std::string id;
-
- EXPECT_TRUE(data()->GetBoolean("some.item.testing", &testing));
- EXPECT_TRUE(testing);
-
- EXPECT_TRUE(data()->GetString("some.item.id", &id));
- EXPECT_EQ(id, "some.item");
-}
-
-TEST_F(MediaInternalsTest, UpdateModifiesExistingItem) {
- UpdateItem("some.item", "testing", Value::CreateBooleanValue(true));
- UpdateItem("some.item", "value", Value::CreateIntegerValue(5));
- UpdateItem("some.item", "testing", Value::CreateBooleanValue(false));
- bool testing = true;
- int value = 0;
- std::string id;
-
- EXPECT_TRUE(data()->GetBoolean("some.item.testing", &testing));
- EXPECT_FALSE(testing);
-
- EXPECT_TRUE(data()->GetInteger("some.item.value", &value));
- EXPECT_EQ(value, 5);
-
- EXPECT_TRUE(data()->GetString("some.item.id", &id));
- EXPECT_EQ(id, "some.item");
-}
-
-TEST_F(MediaInternalsTest, ObserversReceiveNotifications) {
- scoped_ptr<MockMediaInternalsObserver> observer(
- new MockMediaInternalsObserver());
-
- EXPECT_CALL(*observer.get(), OnUpdate(testing::_)).Times(1);
-
- internals_->AddObserver(observer.get());
- SendUpdate("fn", data());
-}
-
-TEST_F(MediaInternalsTest, RemovedObserversReceiveNoNotifications) {
- scoped_ptr<MockMediaInternalsObserver> observer(
- new MockMediaInternalsObserver());
-
- EXPECT_CALL(*observer.get(), OnUpdate(testing::_)).Times(0);
-
- internals_->AddObserver(observer.get());
- internals_->RemoveObserver(observer.get());
- SendUpdate("fn", data());
-}
-
-TEST_F(MediaInternalsTest, DeleteRemovesItem) {
- Value* out;
-
- UpdateItem("some.item", "testing", Value::CreateNullValue());
- EXPECT_TRUE(data()->Get("some.item", &out));
- EXPECT_TRUE(data()->Get("some", &out));
-
- DeleteItem("some.item");
- EXPECT_FALSE(data()->Get("some.item", &out));
- EXPECT_TRUE(data()->Get("some", &out));
-
- DeleteItem("some");
- EXPECT_FALSE(data()->Get("some.item", &out));
- EXPECT_FALSE(data()->Get("some", &out));
-}
diff --git a/chrome/browser/media/media_stream_devices_controller.cc b/chrome/browser/media/media_stream_devices_controller.cc
index 7bd73cc..5bf8e92 100644
--- a/chrome/browser/media/media_stream_devices_controller.cc
+++ b/chrome/browser/media/media_stream_devices_controller.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h"
#include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
-#include "chrome/browser/media/media_internals.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -25,12 +24,10 @@ using content::BrowserThread;
namespace {
bool HasAnyAvailableDevice() {
- MediaCaptureDevicesDispatcher* dispatcher =
- MediaInternals::GetInstance()->GetMediaCaptureDevicesDispatcher();
const content::MediaStreamDevices& audio_devices =
- dispatcher->GetAudioCaptureDevices();
+ MediaCaptureDevicesDispatcher::GetInstance()->GetAudioCaptureDevices();
const content::MediaStreamDevices& video_devices =
- dispatcher->GetVideoCaptureDevices();
+ MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices();
return !audio_devices.empty() || !video_devices.empty();
};
@@ -129,19 +126,21 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) {
case content::MEDIA_OPEN_DEVICE:
// For open device request pick the desired device or fall back to the
// first available of the given type.
- media::GetRequestedDevice(request_.requested_device_id,
- has_audio_,
- has_video_,
- &devices);
+ MediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
+ request_.requested_device_id,
+ has_audio_,
+ has_video_,
+ &devices);
break;
case content::MEDIA_DEVICE_ACCESS:
case content::MEDIA_GENERATE_STREAM:
case content::MEDIA_ENUMERATE_DEVICES:
// Get the default devices for the request.
- media::GetDefaultDevicesForProfile(profile_,
- has_audio_,
- has_video_,
- &devices);
+ MediaCaptureDevicesDispatcher::GetInstance()->
+ GetDefaultDevicesForProfile(profile_,
+ has_audio_,
+ has_video_,
+ &devices);
break;
}
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 5099278..b455aac 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -31,7 +31,6 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
-#include "chrome/browser/media/media_internals.h"
#include "chrome/browser/media/media_stream_devices_controller.h"
#include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/browser/plugins/plugin_prefs.h"
@@ -1840,13 +1839,11 @@ IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest,
base::Value::CreateBooleanValue(policy_value_));
UpdateProviderPolicy(policies);
- MediaCaptureDevicesDispatcher* dispatcher =
- MediaInternals::GetInstance()->GetMediaCaptureDevicesDispatcher();
-
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::IO, FROM_HERE,
- base::Bind(&MediaCaptureDevicesDispatcher::AudioCaptureDevicesChanged,
- dispatcher, audio_devices),
+ base::Bind(&MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged,
+ base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
+ audio_devices),
base::Bind(&MediaStreamDevicesControllerBrowserTest::FinishAudioTest,
this));
@@ -1866,13 +1863,11 @@ IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest,
base::Value::CreateBooleanValue(policy_value_));
UpdateProviderPolicy(policies);
- MediaCaptureDevicesDispatcher* dispatcher =
- MediaInternals::GetInstance()->GetMediaCaptureDevicesDispatcher();
-
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::IO, FROM_HERE,
- base::Bind(&MediaCaptureDevicesDispatcher::VideoCaptureDevicesChanged,
- dispatcher, video_devices),
+ base::Bind(&MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged,
+ base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
+ video_devices),
base::Bind(&MediaStreamDevicesControllerBrowserTest::FinishVideoTest,
this));
diff --git a/chrome/browser/resources/media_internals.html b/chrome/browser/resources/media_internals.html
deleted file mode 100644
index 9955747..0000000
--- a/chrome/browser/resources/media_internals.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE HTML>
-<html i18n-values="dir:textdirection;">
-<!--
-Copyright (c) 2012 The Chromium Authors. All rights reserved.
-Use of this source code is governed by a BSD-style license that can be
-found in the LICENSE file.
--->
- <head>
- <link rel="stylesheet" href="media_internals/media_internals.css">
- <script src="chrome://resources/js/cr.js"></script>
- <script src="chrome://resources/js/cr/ui.js"></script>
- <script src="chrome://resources/js/util.js"></script>
- <script src="chrome://media-internals/media_internals.js"></script>
- <script src="chrome://media-internals/strings.js"></script>
- <title>Media Internals</title>
- </head>
- <body>
- <h2>Active media players:</h2>
- <ul id="media-players"></ul>
- <h2>Active audio streams:</h2>
- <div id="audio-streams"></div>
- <h2>Cached resources:</h2>
- <div id="cache-entries"></div>
- <script src="chrome://resources/js/i18n_template.js"></script>
- <script src="chrome://resources/js/i18n_process.js"></script>
- <script src="chrome://resources/js/jstemplate_compiled.js"></script>
- </body>
-</html>
diff --git a/chrome/browser/resources/media_internals/cache_entry.js b/chrome/browser/resources/media_internals/cache_entry.js
deleted file mode 100644
index 275a8c7..0000000
--- a/chrome/browser/resources/media_internals/cache_entry.js
+++ /dev/null
@@ -1,237 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('media', function() {
- 'use strict';
-
- /**
- * This class represents a file cached by net.
- */
- function CacheEntry() {
- this.read_ = new media.DisjointRangeSet;
- this.written_ = new media.DisjointRangeSet;
- this.available_ = new media.DisjointRangeSet;
-
- // Set to true when we know the entry is sparse.
- this.sparse = false;
- this.key = null;
- this.size = null;
-
- // The <details> element representing this CacheEntry.
- this.details_ = document.createElement('details');
- this.details_.className = 'cache-entry';
- this.details_.open = false;
-
- // The <details> summary line. It contains a chart of requested file ranges
- // and the url if we know it.
- var summary = document.createElement('summary');
-
- this.summaryText_ = document.createTextNode('');
- summary.appendChild(this.summaryText_);
-
- summary.appendChild(document.createTextNode(' '));
-
- // Controls to modify this CacheEntry.
- var controls = document.createElement('span');
- controls.className = 'cache-entry-controls';
- summary.appendChild(controls);
- summary.appendChild(document.createElement('br'));
-
- // A link to clear recorded data from this CacheEntry.
- var clearControl = document.createElement('a');
- clearControl.href = 'javascript:void(0)';
- clearControl.onclick = this.clear.bind(this);
- clearControl.textContent = '(clear entry)';
- controls.appendChild(clearControl);
-
- this.details_.appendChild(summary);
-
- // The canvas for drawing cache writes.
- this.writeCanvas = document.createElement('canvas');
- this.writeCanvas.width = media.BAR_WIDTH;
- this.writeCanvas.height = media.BAR_HEIGHT;
- this.details_.appendChild(this.writeCanvas);
-
- // The canvas for drawing cache reads.
- this.readCanvas = document.createElement('canvas');
- this.readCanvas.width = media.BAR_WIDTH;
- this.readCanvas.height = media.BAR_HEIGHT;
- this.details_.appendChild(this.readCanvas);
-
- // A tabular representation of the data in the above canvas.
- this.detailTable_ = document.createElement('table');
- this.detailTable_.className = 'cache-table';
- this.details_.appendChild(this.detailTable_);
- }
-
- CacheEntry.prototype = {
- /**
- * Mark a range of bytes as read from the cache.
- * @param {int} start The first byte read.
- * @param {int} length The number of bytes read.
- */
- readBytes: function(start, length) {
- start = parseInt(start);
- length = parseInt(length);
- this.read_.add(start, start + length);
- this.available_.add(start, start + length);
- this.sparse = true;
- },
-
- /**
- * Mark a range of bytes as written to the cache.
- * @param {int} start The first byte written.
- * @param {int} length The number of bytes written.
- */
- writeBytes: function(start, length) {
- start = parseInt(start);
- length = parseInt(length);
- this.written_.add(start, start + length);
- this.available_.add(start, start + length);
- this.sparse = true;
- },
-
- /**
- * Merge this CacheEntry with another, merging recorded ranges and flags.
- * @param {CacheEntry} other The CacheEntry to merge into this one.
- */
- merge: function(other) {
- this.read_.merge(other.read_);
- this.written_.merge(other.written_);
- this.available_.merge(other.available_);
- this.sparse = this.sparse || other.sparse;
- this.key = this.key || other.key;
- this.size = this.size || other.size;
- },
-
- /**
- * Clear all recorded ranges from this CacheEntry and redraw this.details_.
- */
- clear: function() {
- this.read_ = new media.DisjointRangeSet;
- this.written_ = new media.DisjointRangeSet;
- this.available_ = new media.DisjointRangeSet;
- this.generateDetails();
- },
-
- /**
- * Helper for drawCacheReadsToCanvas() and drawCacheWritesToCanvas().
- *
- * Accepts the entries to draw, a canvas fill style, and the canvas to
- * draw on.
- */
- drawCacheEntriesToCanvas: function(entries, fillStyle, canvas) {
- // Don't bother drawing anything if we don't know the total size.
- if (!this.size) {
- return;
- }
-
- var width = canvas.width;
- var height = canvas.height;
- var context = canvas.getContext('2d');
- var fileSize = this.size;
-
- context.fillStyle = '#aaa';
- context.fillRect(0, 0, width, height);
-
- function drawRange(start, end) {
- var left = start / fileSize * width;
- var right = end / fileSize * width;
- context.fillRect(left, 0, right - left, height);
- }
-
- context.fillStyle = fillStyle;
- entries.map(function(start, end) {
- drawRange(start, end);
- });
- },
-
- /**
- * Draw cache writes to the given canvas.
- *
- * It should consist of a horizontal bar with highlighted sections to
- * represent which parts of a file have been written to the cache.
- *
- * e.g. |xxxxxx----------x|
- */
- drawCacheWritesToCanvas: function(canvas) {
- this.drawCacheEntriesToCanvas(this.written_, '#00a', canvas);
- },
-
- /**
- * Draw cache reads to the given canvas.
- *
- * It should consist of a horizontal bar with highlighted sections to
- * represent which parts of a file have been read from the cache.
- *
- * e.g. |xxxxxx----------x|
- */
- drawCacheReadsToCanvas: function(canvas) {
- this.drawCacheEntriesToCanvas(this.read_, '#0a0', canvas);
- },
-
- /**
- * Update this.details_ to contain everything we currently know about
- * this file.
- */
- generateDetails: function() {
- this.details_.id = this.key;
- this.summaryText_.textContent = this.key || 'Unknown File';
-
- this.detailTable_.textContent = '';
- var header = document.createElement('thead');
- var footer = document.createElement('tfoot');
- var body = document.createElement('tbody');
- this.detailTable_.appendChild(header);
- this.detailTable_.appendChild(footer);
- this.detailTable_.appendChild(body);
-
- var headerRow = document.createElement('tr');
- headerRow.appendChild(media.makeElement('th', 'Read From Cache'));
- headerRow.appendChild(media.makeElement('th', 'Written To Cache'));
- header.appendChild(headerRow);
-
- var footerRow = document.createElement('tr');
- var footerCell = document.createElement('td');
- footerCell.textContent = 'Out of ' + (this.size || 'unkown size');
- footerCell.setAttribute('colspan', 2);
- footerRow.appendChild(footerCell);
- footer.appendChild(footerRow);
-
- var read = this.read_.map(function(start, end) {
- return start + ' - ' + end;
- });
- var written = this.written_.map(function(start, end) {
- return start + ' - ' + end;
- });
-
- var length = Math.max(read.length, written.length);
- for (var i = 0; i < length; i++) {
- var row = document.createElement('tr');
- row.appendChild(media.makeElement('td', read[i] || ''));
- row.appendChild(media.makeElement('td', written[i] || ''));
- body.appendChild(row);
- }
-
- this.drawCacheWritesToCanvas(this.writeCanvas);
- this.drawCacheReadsToCanvas(this.readCanvas);
- },
-
- /**
- * Render this CacheEntry as a <li>.
- * @return {HTMLElement} A <li> representing this CacheEntry.
- */
- toListItem: function() {
- this.generateDetails();
-
- var result = document.createElement('li');
- result.appendChild(this.details_);
- return result;
- }
- };
-
- return {
- CacheEntry: CacheEntry
- };
-});
diff --git a/chrome/browser/resources/media_internals/disjoint_range_set.js b/chrome/browser/resources/media_internals/disjoint_range_set.js
deleted file mode 100644
index bd504bb..0000000
--- a/chrome/browser/resources/media_internals/disjoint_range_set.js
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('media', function() {
-
- /**
- * This class represents a collection of non-intersecting ranges. Ranges
- * specified by (start, end) can be added and removed at will. It is used to
- * record which sections of a media file have been cached, e.g. the first and
- * last few kB plus several MB in the middle.
- *
- * Example usage:
- * someRange.add(0, 100); // Contains 0-100.
- * someRange.add(150, 200); // Contains 0-100, 150-200.
- * someRange.remove(25, 75); // Contains 0-24, 76-100, 150-200.
- * someRange.add(25, 149); // Contains 0-200.
- */
- function DisjointRangeSet() {
- this.ranges_ = {};
- }
-
- DisjointRangeSet.prototype = {
- /**
- * Deletes all ranges intersecting with (start ... end) and returns the
- * extents of the cleared area.
- * @param {int} start The start of the range to remove.
- * @param {int} end The end of the range to remove.
- * @param {int} sloppiness 0 removes only strictly overlapping ranges, and
- * 1 removes adjacent ones.
- * @return {Object} The start and end of the newly cleared range.
- */
- clearRange: function(start, end, sloppiness) {
- var ranges = this.ranges_;
- var result = {start: start, end: end};
-
- for (var rangeStart in this.ranges_) {
- rangeEnd = this.ranges_[rangeStart];
- // A range intersects another if its start lies within the other range
- // or vice versa.
- if ((rangeStart >= start && rangeStart <= (end + sloppiness)) ||
- (start >= rangeStart && start <= (rangeEnd + sloppiness))) {
- delete ranges[rangeStart];
- result.start = Math.min(result.start, rangeStart);
- result.end = Math.max(result.end, rangeEnd);
- }
- }
-
- return result;
- },
-
- /**
- * Adds a range to this DisjointRangeSet.
- * Joins adjacent and overlapping ranges together.
- * @param {int} start The beginning of the range to add, inclusive.
- * @param {int} end The end of the range to add, inclusive.
- */
- add: function(start, end) {
- if (end < start)
- return;
-
- // Remove all touching ranges.
- result = this.clearRange(start, end, 1);
- // Add back a single contiguous range.
- this.ranges_[Math.min(start, result.start)] = Math.max(end, result.end);
- },
-
- /**
- * Combines a DisjointRangeSet with this one.
- * @param {DisjointRangeSet} ranges A DisjointRangeSet to be squished into
- * this one.
- */
- merge: function(other) {
- var ranges = this;
- other.forEach(function(start, end) { ranges.add(start, end); });
- },
-
- /**
- * Removes a range from this DisjointRangeSet.
- * Will split existing ranges if necessary.
- * @param {int} start The beginning of the range to remove, inclusive.
- * @param {int} end The end of the range to remove, inclusive.
- */
- remove: function(start, end) {
- if (end < start)
- return;
-
- // Remove instersecting ranges.
- result = this.clearRange(start, end, 0);
-
- // Add back non-overlapping ranges.
- if (result.start < start)
- this.ranges_[result.start] = start - 1;
- if (result.end > end)
- this.ranges_[end + 1] = result.end;
- },
-
- /**
- * Iterates over every contiguous range in this DisjointRangeSet, calling a
- * function for each (start, end).
- * @param {function(int, int)} iterator The function to call on each range.
- */
- forEach: function(iterator) {
- for (var start in this.ranges_)
- iterator(start, this.ranges_[start]);
- },
-
- /**
- * Maps this DisjointRangeSet to an array by calling a given function on the
- * start and end of each contiguous range, sorted by start.
- * @param {function(int, int)} mapper Maps a range to an array element.
- * @return {Array} An array of each mapper(range).
- */
- map: function(mapper) {
- var starts = [];
- for (var start in this.ranges_)
- starts.push(parseInt(start));
- starts.sort(function(a, b) {
- return a - b;
- });
-
- var ranges = this.ranges_;
- var results = starts.map(function(s) {
- return mapper(s, ranges[s]);
- });
-
- return results;
- },
-
- /**
- * Finds the maximum value present in any of the contained ranges.
- * @return {int} The maximum value contained by this DisjointRangeSet.
- */
- max: function() {
- var max = -Infinity;
- for (var start in this.ranges_)
- max = Math.max(max, this.ranges_[start]);
- return max;
- },
- };
-
- return {
- DisjointRangeSet: DisjointRangeSet
- };
-});
diff --git a/chrome/browser/resources/media_internals/disjoint_range_set_test.html b/chrome/browser/resources/media_internals/disjoint_range_set_test.html
deleted file mode 100644
index 39db9b3..0000000
--- a/chrome/browser/resources/media_internals/disjoint_range_set_test.html
+++ /dev/null
@@ -1,96 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright (c) 2011 The Chromium Authors. All rights reserved.
-Use of this source code is governed by a BSD-style license that can be
-found in the LICENSE file.
--->
- <head>
- <title></title>
- <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script>
- <script src="../../../../ui/webui/resources/js/cr.js"></script>
- <script src="disjoint_range_set.js"></script>
- <script>
- goog.require('goog.testing.jsunit');
- </script>
- </head>
- <body>
- <script>
-
- var range;
-
- function assertRangeEquals(ranges) {
- assertArrayEquals(
- ranges, range.map(function(start, end) { return [start, end]; }));
- };
-
- function setUp() {
- range = new media.DisjointRangeSet;
- };
-
- function testAdd() {
- range.add(1, 6);
- assertRangeEquals([[1, 6]]);
- range.add(-5, -3);
- assertRangeEquals([[-5, -3], [1, 6]]);
- };
-
- function testAddAdjacent() {
- range.add(3, 6);
- assertRangeEquals([[3, 6]]);
- range.add(1, 2);
- assertRangeEquals([[1, 6]]);
- range.add(7, 9);
- assertRangeEquals([[1, 9]]);
- };
-
- function testAddNotQuiteAdjacent() {
- range.add(3, 6);
- assertRangeEquals([[3, 6]]);
- range.add(0, 1);
- assertRangeEquals([[0, 1], [3, 6]]);
- range.add(8, 9);
- assertRangeEquals([[0, 1], [3, 6], [8, 9]]);
- };
-
- function testAddOverlapping() {
- range.add(1, 6);
- assertRangeEquals([[1, 6]]);
- range.add(5, 8);
- assertRangeEquals([[1, 8]]);
- range.add(0, 1);
- assertRangeEquals([[0, 8]]);
- };
-
- function testMax() {
- assertNull(range.max());
- range.add(1, 6);
- assertEquals(range.max(), 6);
- range.add(3, 8);
- assertEquals(range.max(), 8);
- range.remove(2, 3);
- assertEquals(range.max(), 8);
- range.remove(4, 10);
- assertEquals(range.max(), 1);
- range.remove(1, 1);
- assertNull(range.max());
- };
-
- function testRemove() {
- range.add(1, 20);
- assertRangeEquals([[1, 20]]);
- range.remove(0, 3);
- assertRangeEquals([[4, 20]]);
- range.remove(18, 20);
- assertRangeEquals([[4, 17]]);
- range.remove(5, 16);
- assertRangeEquals([[4, 4], [17, 17]]);
- };
-
- function testStartsEmpty() {
- assertRangeEquals([]);
- };
-
- </script>
- </body>
-</html>
diff --git a/chrome/browser/resources/media_internals/event_list.js b/chrome/browser/resources/media_internals/event_list.js
deleted file mode 100644
index fc13c05..0000000
--- a/chrome/browser/resources/media_internals/event_list.js
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('media', function() {
- 'use strict';
-
- /**
- * This class holds a list of MediaLogEvents.
- * It inherits from <li> and contains a tabular list of said events,
- * the time at which they occurred, and their parameters.
- */
- var EventList = cr.ui.define('li');
-
- EventList.prototype = {
- __proto__: HTMLLIElement.prototype,
- startTime_: null,
-
- /**
- * Decorate this list item as an EventList.
- */
- decorate: function() {
- this.table_ = document.createElement('table');
- var details = document.createElement('details');
- var summary = media.makeElement('summary', 'Log:');
- details.appendChild(summary);
- details.appendChild(this.table_);
- this.appendChild(details);
-
- var hRow = document.createElement('tr');
- hRow.appendChild(media.makeElement('th', 'Time:'));
- hRow.appendChild(media.makeElement('th', 'Event:'));
- hRow.appendChild(media.makeElement('th', 'Parameters:'));
- var header = document.createElement('thead');
- header.appendChild(hRow);
- this.table_.appendChild(header);
- },
-
- /**
- * Add an event to the list. It is stored as a new row in this.table_.
- * @param {Object} event The MediaLogEvent that has occurred.
- */
- addEvent: function(event) {
- var timeInMs = event.time * 1000; // Work with milliseconds.
- this.startTime_ = this.startTime_ || timeInMs;
- timeInMs -= this.startTime_;
-
- var row = document.createElement('tr');
- row.appendChild(media.makeElement('td', timeInMs.toFixed(1)));
- row.appendChild(media.makeElement('td', event.type));
- var params = [];
- for (var key in event.params) {
- params.push(key + ': ' + event.params[key]);
- }
-
- row.appendChild(media.makeElement('td', params.join(', ')));
- this.table_.appendChild(row);
- }
- };
-
- return {
- EventList: EventList
- };
-});
diff --git a/chrome/browser/resources/media_internals/item_store.js b/chrome/browser/resources/media_internals/item_store.js
deleted file mode 100644
index a6e3a6c..0000000
--- a/chrome/browser/resources/media_internals/item_store.js
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('media', function() {
-
- /**
- * This class stores hashes by their id field and provides basic methods for
- * iterating over the collection.
- * @constructor
- */
- function ItemStore() {
- this.items_ = {};
- }
-
- ItemStore.prototype = {
- /**
- * Get a sorted list of item ids.
- * @return {Array} A sorted array of ids.
- */
- ids: function() {
- var ids = [];
- for (var i in this.items_)
- ids.push(i);
- return ids.sort();
- },
-
- /**
- * Add an item to the store.
- * @param {Object} item The item to be added.
- * @param {string} item.id The id of the item.
- */
- addItem: function(item) {
- this.items_[item.id] = item;
- },
-
- /**
- * Add a dictionary of items to the store.
- * @param {Object} items A dictionary of individual items. The keys are
- * irrelevant but each must have an id field.
- */
- addItems: function(items) {
- for (id in items)
- this.addItem(items[id]);
- },
-
- /**
- * Remove an item from the store.
- * @param {string} id The id of the item to be removed.
- */
- removeItem: function(id) {
- delete this.items_[id];
- },
-
- /**
- * Map this itemStore to an Array. Items are sorted by id.
- * @param {function(*)} mapper The mapping function applied to each item.
- * @return {Array} An array of mapped items.
- */
- map: function(mapper) {
- var items = this.items_;
- var ids = this.ids();
- return ids.map(function(id) { return mapper(items[id]); });
- }
- };
-
- return {
- ItemStore: ItemStore
- };
-});
diff --git a/chrome/browser/resources/media_internals/media_internals.css b/chrome/browser/resources/media_internals/media_internals.css
deleted file mode 100644
index d83b6b7..0000000
--- a/chrome/browser/resources/media_internals/media_internals.css
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file. */
-
-body {
- font-family: sans-serif;
-}
-
-h2 {
- margin: 15px 0 5px 0;
-}
-
-ul,
-p,
-canvas {
- margin: 0;
-}
-
-[hidden] {
- display: none !important;
-}
-
-#media-players td,
-#media-players th {
- padding: 0 10px;
-}
-
-.audio-stream[status='created'] {
- color: blue;
-}
-
-.audio-stream[status='closed'] {
- text-decoration: line-through;
-}
-
-.audio-stream[status='error'] {
- color: red;
-}
-
-#cache-entries ul,
-#media-players ul,
-#media-players {
- list-style-type: none;
-}
-
-.cache-entry {
- margin: 0 0 5px 0;
-}
-
-.cache-entry-controls {
- font-size: smaller;
-}
-
-.cache-table {
- table-layout: fixed;
- width: 500px;
-}
-
-thead {
- text-align: left;
-}
-
-tfoot {
- text-align: right;
-}
-
-.buffered {
- display: table;
-}
-
-.buffered > div {
- display: table-row;
-}
-
-.buffered > div > div {
- display: table-cell;
- vertical-align: bottom;
-}
-
-.buffered > div > div:first-child {
- font-weight: bold;
- padding-right: 2px;
-}
diff --git a/chrome/browser/resources/media_internals/media_internals.js b/chrome/browser/resources/media_internals/media_internals.js
deleted file mode 100644
index c3e3a1e..0000000
--- a/chrome/browser/resources/media_internals/media_internals.js
+++ /dev/null
@@ -1,281 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-<include src="cache_entry.js"/>
-<include src="disjoint_range_set.js"/>
-<include src="event_list.js"/>
-<include src="item_store.js"/>
-<include src="media_player.js"/>
-<include src="metrics.js"/>
-<include src="util.js"/>
-
-cr.define('media', function() {
- 'use strict';
-
- // Stores information on open audio streams, referenced by id.
- var audioStreams = new media.ItemStore;
-
- // Active media players, indexed by 'render_id:player_id'.
- var mediaPlayers = {};
-
- // Cached files indexed by key and source id.
- var cacheEntriesByKey = {};
- var cacheEntries = {};
-
- // Map of event source -> url.
- var requestURLs = {};
-
- // Constants passed to us from Chrome.
- var eventTypes = {};
- var eventPhases = {};
-
- // The <div>s on the page in which to display information.
- var audioStreamDiv;
- var cacheDiv;
-
- // A timer used to limit the rate of redrawing the Media Players section.
- var redrawTimer = null;
-
- /**
- * Initialize variables and ask MediaInternals for all its data.
- */
- function initialize() {
- audioStreamDiv = $('audio-streams');
- cacheDiv = $('cache-entries');
-
- // Get information about all currently active media.
- chrome.send('getEverything');
- }
-
- /**
- * Write the set of audio streams to the DOM.
- */
- function printAudioStreams() {
-
- /**
- * Render a single stream as a <li>.
- * @param {Object} stream The stream to render.
- * @return {HTMLElement} A <li> containing the stream information.
- */
- function printStream(stream) {
- var out = document.createElement('li');
- out.id = stream.id;
- out.className = 'audio-stream';
- out.setAttribute('status', stream.status);
-
- out.textContent += 'Audio stream ' + stream.id.split('.')[1];
- out.textContent += ' is ' + (stream.playing ? 'playing' : 'paused');
- if (typeof stream.volume != 'undefined') {
- out.textContent += ' at ' + (stream.volume * 100).toFixed(0);
- out.textContent += '% volume.';
- }
- return out;
- }
-
- var out = document.createElement('ul');
- audioStreams.map(printStream).forEach(function(s) {
- out.appendChild(s);
- });
-
- audioStreamDiv.textContent = '';
- audioStreamDiv.appendChild(out);
- }
-
- /**
- * Redraw each MediaPlayer.
- */
- function printMediaPlayers() {
- for (var key in mediaPlayers) {
- mediaPlayers[key].redraw();
- }
- redrawTimer = null;
- }
-
- /**
- * Write the set of sparse CacheEntries to the DOM.
- */
- function printSparseCacheEntries() {
- var out = document.createElement('ul');
- for (var key in cacheEntriesByKey) {
- if (cacheEntriesByKey[key].sparse)
- out.appendChild(cacheEntriesByKey[key].toListItem());
- }
-
- cacheDiv.textContent = '';
- cacheDiv.appendChild(out);
- }
-
- /**
- * Receiving data for an audio stream.
- * Add it to audioStreams and update the page.
- * @param {Object} stream JSON representation of an audio stream.
- */
- function addAudioStream(stream) {
- audioStreams.addItem(stream);
- printAudioStreams();
- }
-
- /**
- * Receiving all data.
- * Add it all to the appropriate stores and update the page.
- * @param {Object} stuff JSON containing lists of data.
- * @param {Object} stuff.audio_streams A dictionary of audio streams.
- */
- function onReceiveEverything(stuff) {
- audioStreams.addItems(stuff.audio_streams);
- printAudioStreams();
- }
-
- /**
- * Removing an item from the appropriate store.
- * @param {string} id The id of the item to be removed, in the format
- * "item_type.identifying_info".
- */
- function onItemDeleted(id) {
- var type = id.split('.')[0];
- switch (type) {
- case 'audio_streams':
- audioStreams.removeItem(id);
- printAudioStreams();
- break;
- }
- }
-
- /**
- * A render process has ended, delete any media players associated with it.
- * @param {number} renderer The id of the render process.
- */
- function onRendererTerminated(renderer) {
- for (var key in mediaPlayers) {
- if (mediaPlayers[key].renderer == renderer) {
- $('media-players').removeChild(mediaPlayers[key]);
- delete mediaPlayers[key];
- break;
- }
- }
- printMediaPlayers();
- }
-
- /**
- * Receiving net events.
- * Update cache information and update that section of the page.
- * @param {Array} updates A list of net events that have occurred.
- */
- function onNetUpdate(updates) {
- updates.forEach(function(update) {
- var id = update.source.id;
- if (!cacheEntries[id])
- cacheEntries[id] = new media.CacheEntry;
-
- switch (eventPhases[update.phase] + '.' + eventTypes[update.type]) {
- case 'PHASE_BEGIN.DISK_CACHE_ENTRY_IMPL':
- var key = update.params.key;
-
- // Merge this source with anything we already know about this key.
- if (cacheEntriesByKey[key]) {
- cacheEntriesByKey[key].merge(cacheEntries[id]);
- cacheEntries[id] = cacheEntriesByKey[key];
- } else {
- cacheEntriesByKey[key] = cacheEntries[id];
- }
- cacheEntriesByKey[key].key = key;
- break;
-
- case 'PHASE_BEGIN.SPARSE_READ':
- cacheEntries[id].readBytes(update.params.offset,
- update.params.buff_len);
- cacheEntries[id].sparse = true;
- break;
-
- case 'PHASE_BEGIN.SPARSE_WRITE':
- cacheEntries[id].writeBytes(update.params.offset,
- update.params.buff_len);
- cacheEntries[id].sparse = true;
- break;
-
- case 'PHASE_BEGIN.URL_REQUEST_START_JOB':
- requestURLs[update.source.id] = update.params.url;
- break;
-
- case 'PHASE_NONE.HTTP_TRANSACTION_READ_RESPONSE_HEADERS':
- // Record the total size of the file if this was a range request.
- var range = /content-range:\s*bytes\s*\d+-\d+\/(\d+)/i.exec(
- update.params.headers);
- var key = requestURLs[update.source.id];
- delete requestURLs[update.source.id];
- if (range && key) {
- if (!cacheEntriesByKey[key]) {
- cacheEntriesByKey[key] = new media.CacheEntry;
- cacheEntriesByKey[key].key = key;
- }
- cacheEntriesByKey[key].size = range[1];
- }
- break;
- }
- });
-
- printSparseCacheEntries();
- }
-
- /**
- * Receiving values for constants. Store them for later use.
- * @param {Object} constants A dictionary of constants.
- * @param {Object} constants.eventTypes A dictionary of event name -> int.
- * @param {Object} constants.eventPhases A dictionary of event phase -> int.
- */
- function onReceiveConstants(constants) {
- var events = constants.eventTypes;
- for (var e in events) {
- eventTypes[events[e]] = e;
- }
-
- var phases = constants.eventPhases;
- for (var p in phases) {
- eventPhases[phases[p]] = p;
- }
- }
-
- /**
- * Receiving notification of a media event.
- * @param {Object} event The json representation of a MediaLogEvent.
- */
- function onMediaEvent(event) {
- var source = event.renderer + ':' + event.player;
- var item = mediaPlayers[source] ||
- new media.MediaPlayer({id: source, renderer: event.renderer});
- mediaPlayers[source] = item;
- item.addEvent(event);
-
- // Both media and net events could provide the size of the file.
- // Media takes priority, but keep the size in both places synchronized.
- if (cacheEntriesByKey[item.properties.url]) {
- item.properties.total_bytes = item.properties.total_bytes ||
- cacheEntriesByKey[item.properties.url].size;
- cacheEntriesByKey[item.properties.url].size = item.properties.total_bytes;
- }
-
- // Events tend to arrive in groups; don't redraw the page too often.
- if (!redrawTimer)
- redrawTimer = setTimeout(printMediaPlayers, 50);
- }
-
- return {
- initialize: initialize,
- addAudioStream: addAudioStream,
- cacheEntriesByKey: cacheEntriesByKey,
- onReceiveEverything: onReceiveEverything,
- onItemDeleted: onItemDeleted,
- onRendererTerminated: onRendererTerminated,
- onNetUpdate: onNetUpdate,
- onReceiveConstants: onReceiveConstants,
- onMediaEvent: onMediaEvent
- };
-});
-
-/**
- * Initialize everything once we have access to the DOM.
- */
-document.addEventListener('DOMContentLoaded', function() {
- media.initialize();
-});
diff --git a/chrome/browser/resources/media_internals/media_player.js b/chrome/browser/resources/media_internals/media_player.js
deleted file mode 100644
index a9d5d6b..0000000
--- a/chrome/browser/resources/media_internals/media_player.js
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('media', function() {
- 'use strict';
-
- /**
- * This class inherits from <li> and is designed to store and display
- * information about an open media player.
- */
- var MediaPlayer = cr.ui.define('li');
-
- MediaPlayer.prototype = {
- __proto__: HTMLLIElement.prototype,
- renderer: null,
- id: null,
-
- /**
- * Decorate this <li> as a MediaPlayer.
- */
- decorate: function() {
- this.properties = {};
-
- this.url_ = document.createElement('span');
- this.url_.textContent = 'URL Unknown';
-
- this.summary_ = document.createElement('summary');
- this.summary_.appendChild(this.url_);
-
- var bufferedDiv = document.createElement('div');
- bufferedDiv.className = 'buffered';
- this.summary_.appendChild(bufferedDiv);
-
- // Create our canvii.
- function createCanvas(label) {
- var canvas = document.createElement('canvas');
- canvas.width = media.BAR_WIDTH;
- canvas.height = media.BAR_HEIGHT;
- return canvas;
- }
- this.bufferedCanvas_ = createCanvas();
- this.cacheReadsCanvas_ = createCanvas();
- this.cacheWritesCanvas_ = createCanvas();
-
- // Create our per-canvas entry divs that are initially hidden.
- function addEntry(label, canvas) {
- var labelDiv = document.createElement('div');
- labelDiv.textContent = label;
- var canvasDiv = document.createElement('div');
- canvasDiv.appendChild(canvas);
- var entryDiv = document.createElement('div');
- entryDiv.appendChild(labelDiv);
- entryDiv.appendChild(canvasDiv);
- entryDiv.hidden = true;
- bufferedDiv.appendChild(entryDiv);
- return entryDiv;
- }
- this.bufferedEntry_ = addEntry('Buffered', this.bufferedCanvas_);
- this.cacheReadsEntry_ = addEntry('Cache Reads', this.cacheReadsCanvas_);
- this.cacheWritesEntry_ = addEntry(
- 'Cache Writes', this.cacheWritesCanvas_);
-
- this.details_ = document.createElement('details');
- this.details_.appendChild(this.summary_);
-
- this.propertyTable_ = document.createElement('table');
- this.events_ = new media.EventList;
- this.metrics_ = new media.Metrics;
-
- var properties = media.createDetailsLi();
- properties.summary.textContent = 'Properties:';
- properties.details.appendChild(this.propertyTable_);
-
- var ul = document.createElement('ul');
- ul.appendChild(properties);
- ul.appendChild(this.metrics_);
- ul.appendChild(this.events_);
- this.details_.appendChild(ul);
-
- this.appendChild(this.details_);
- $('media-players').appendChild(this);
- },
-
- /**
- * Record an event and update statistics etc.
- * @param {Object} event The event that occurred.
- */
- addEvent: function(event) {
- for (var key in event.params) {
- this.properties[key] = event.params[key];
- }
-
- if (event.type == 'LOAD' && event.params['url']) {
- this.url_.textContent = event.params['url'];
- }
-
- if (event.type == 'BUFFERED_EXTENTS_CHANGED') {
- return;
- }
- this.events_.addEvent(event);
- this.metrics_.addEvent(event);
- },
-
- /**
- * Update the summary line and properties table and redraw the canvas.
- * @return {HTMLElement} A <li> representing this MediaPlayer.
- */
- redraw: function() {
- media.appendDictionaryToTable(this.properties, this.propertyTable_);
-
- this.setAttribute('status', this.properties.state);
-
- // Don't bother drawing anything if we don't know the total size.
- var size = this.properties.total_bytes;
- if (!size) {
- return;
- }
-
- // Draw the state of BufferedResourceLoader.
- this.bufferedEntry_.hidden = false;
- var canvas = this.bufferedCanvas_;
- var context = canvas.getContext('2d');
- context.fillStyle = '#aaa';
- context.fillRect(0, 0, canvas.width, canvas.height);
-
- var left = this.properties.buffer_start / size * canvas.width;
- var middle = this.properties.buffer_current / size * canvas.width;
- var right = this.properties.buffer_end / size * canvas.width;
- context.fillStyle = '#a0a';
- context.fillRect(left, 0, middle - left, canvas.height);
- context.fillStyle = '#aa0';
- context.fillRect(middle, 0, right - middle, canvas.height);
-
- // Only show cached file information if we have something.
- var cacheEntry = media.cacheEntriesByKey[this.properties.url];
- if (!cacheEntry) {
- return;
- }
-
- // Draw cache reads.
- this.cacheReadsEntry_.hidden = false;
- cacheEntry.drawCacheReadsToCanvas(this.cacheReadsCanvas_);
-
- // Draw cache writes.
- this.cacheWritesEntry_.hidden = false;
- cacheEntry.drawCacheWritesToCanvas(this.cacheWritesCanvas_);
- },
- };
-
- return {
- MediaPlayer: MediaPlayer
- };
-});
diff --git a/chrome/browser/resources/media_internals/metrics.js b/chrome/browser/resources/media_internals/metrics.js
deleted file mode 100644
index 2c40f4a..0000000
--- a/chrome/browser/resources/media_internals/metrics.js
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('media', function() {
- 'use strict';
-
- // A set of parameter names. An entry of 'abc' allows metrics to specify
- // events with specific values of 'abc'.
- var metricProperties = {
- 'pipeline_state': true,
- };
-
- // A set of metrics to measure. The user will see the most recent and average
- // measurement of the time between each metric's start and end events.
- var metrics = {
- 'seek': {
- 'start': 'SEEK',
- 'end': 'pipeline_state=started'
- },
- 'first frame': {
- 'start': 'WEBMEDIAPLAYER_CREATED',
- 'end': 'pipeline_state=started'
- },
- };
-
- /**
- * This class measures times between the events specified above. It inherits
- * <li> and contains a table that displays the measurements.
- */
- var Metrics = cr.ui.define('li');
-
- Metrics.prototype = {
- __proto__: HTMLLIElement.prototype,
-
- /**
- * Decorate this <li> as a Metrics.
- */
- decorate: function() {
- this.table_ = document.createElement('table');
- var details = document.createElement('details');
- var summary = media.makeElement('summary', 'Metrics:');
- details.appendChild(summary);
- details.appendChild(this.table_);
- this.appendChild(details);
-
- var hRow = document.createElement('tr');
- hRow.appendChild(media.makeElement('th', 'Metric:'));
- hRow.appendChild(media.makeElement('th', 'Last Measure:'));
- hRow.appendChild(media.makeElement('th', 'Average:'));
- var header = document.createElement('thead');
- header.appendChild(hRow);
- this.table_.appendChild(header);
-
- for (var metric in metrics) {
- var last = document.createElement('td');
- var avg = document.createElement('td');
- this[metric] = {
- count: 0,
- total: 0,
- start: null,
- last: last,
- avg: avg
- };
- var row = document.createElement('tr');
- row.appendChild(media.makeElement('td', metric + ':'));
- row.appendChild(last);
- row.appendChild(avg);
- this.table_.appendChild(row);
- }
- },
-
- /**
- * An event has occurred. Update any metrics that refer to this type
- * of event. Can be called multiple times by addEvent below if the metrics
- * refer to specific parameters.
- * @param {Object} event The MediaLogEvent that has occurred.
- * @param {string} type The type of event.
- */
- addEventInternal: function(event, type) {
- var timeInMs = event.time * 1000; // Work with milliseconds.
-
- for (var metric in metrics) {
- var m = this[metric];
- if (type == metrics[metric].start && !m.start) {
- m.start = timeInMs;
- } else if (type == metrics[metric].end && m.start != null) {
- var last = timeInMs - m.start;
- m.last.textContent = last.toFixed(1);
- m.total += last;
- m.count++;
- if (m.count > 1)
- m.avg.textContent = (m.total / m.count).toFixed(1);
- m.start = null;
- }
- }
- },
-
- /**
- * An event has occurred. Update any metrics that refer to events of this
- * type or with this event's parameters.
- * @param {Object} event The MediaLogEvent that has occurred.
- */
- addEvent: function(event) {
- this.addEventInternal(event, event.type);
- for (var p in event.params) {
- if (p in metricProperties) {
- var type = p + '=' + event.params[p];
- this.addEventInternal(event, type);
- }
- }
- },
- };
-
- return {
- Metrics: Metrics,
- };
-});
diff --git a/chrome/browser/resources/media_internals/util.js b/chrome/browser/resources/media_internals/util.js
deleted file mode 100644
index c61ae0e..0000000
--- a/chrome/browser/resources/media_internals/util.js
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('media', function() {
- 'use strict';
-
- /**
- * The width and height of a bar drawn on a file canvas in pixels.
- */
- var BAR_WIDTH = 500;
- var BAR_HEIGHT = 16;
-
- /**
- * Draws a 1px white horizontal line across |context|.
- */
- function drawLine(context, top) {
- context.moveTo(0, top);
- context.lineTo(BAR_WIDTH, top);
- context.strokeStyle = '#fff';
- context.stroke();
- }
-
- /**
- * Creates an HTMLElement of type |type| with textContent |content|.
- * @param {string} type The type of element to create.
- * @param {string} content The content to place in the element.
- * @return {HTMLElement} A newly initialized element.
- */
- function makeElement(type, content) {
- var element = document.createElement(type);
- element.textContent = content;
- return element;
- }
-
- /**
- * Creates a new <li> containing a <details> with a <summary> and sets
- * properties to reference them.
- * @return {Object} The new <li>.
- */
- function createDetailsLi() {
- var li = document.createElement('li');
- li.details = document.createElement('details');
- li.summary = document.createElement('summary');
- li.appendChild(li.details);
- li.details.appendChild(li.summary);
- return li
- }
-
- /**
- * Appends each key-value pair in a dictionary to a row in a table.
- * @param {Object} dict The dictionary to append.
- * @param {HTMLElement} table The <table> element to append to.
- */
- function appendDictionaryToTable(dict, table) {
- table.textContent = '';
- for (var key in dict) {
- var tr = document.createElement('tr');
- tr.appendChild(makeElement('td', key + ':'));
- tr.appendChild(makeElement('td', dict[key]));
- table.appendChild(tr);
- }
- return table;
- }
-
- return {
- BAR_WIDTH: BAR_WIDTH,
- BAR_HEIGHT: BAR_HEIGHT,
- drawLine: drawLine,
- makeElement: makeElement,
- createDetailsLi: createDetailsLi,
- appendDictionaryToTable: appendDictionaryToTable
- };
-});
diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
index 37a8958..bdb9fcf 100644
--- a/chrome/browser/ui/extensions/shell_window.cc
+++ b/chrome/browser/ui/extensions/shell_window.cc
@@ -17,7 +17,7 @@
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
-#include "chrome/browser/media/media_internals.h"
+#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_id.h"
#include "chrome/browser/ui/browser.h"
@@ -253,7 +253,7 @@ void ShellWindow::RequestMediaAccessPermission(
const content::MediaResponseCallback& callback) {
// Get the preferred default devices for the request.
content::MediaStreamDevices devices;
- media::GetDefaultDevicesForProfile(
+ MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevicesForProfile(
profile_,
content::IsAudioMediaType(request.audio_type),
content::IsVideoMediaType(request.video_type),
diff --git a/chrome/browser/ui/tabs/tab_utils.cc b/chrome/browser/ui/tabs/tab_utils.cc
index a0ea14b..541de63 100644
--- a/chrome/browser/ui/tabs/tab_utils.cc
+++ b/chrome/browser/ui/tabs/tab_utils.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/ui/tabs/tab_utils.h"
-#include "chrome/browser/media/media_internals.h"
+#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/media_stream_capture_indicator.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -16,7 +16,8 @@ bool ShouldShowProjectingIndicator(content::WebContents* contents) {
int render_process_id = contents->GetRenderProcessHost()->GetID();
int render_view_id = contents->GetRenderViewHost()->GetRoutingID();
scoped_refptr<MediaStreamCaptureIndicator> indicator =
- MediaInternals::GetInstance()->GetMediaStreamCaptureIndicator();
+ MediaCaptureDevicesDispatcher::GetInstance()->
+ GetMediaStreamCaptureIndicator();
return indicator->IsBeingMirrored(render_process_id, render_view_id);
}
@@ -24,7 +25,8 @@ bool ShouldShowRecordingIndicator(content::WebContents* contents) {
int render_process_id = contents->GetRenderProcessHost()->GetID();
int render_view_id = contents->GetRenderViewHost()->GetRoutingID();
scoped_refptr<MediaStreamCaptureIndicator> indicator =
- MediaInternals::GetInstance()->GetMediaStreamCaptureIndicator();
+ MediaCaptureDevicesDispatcher::GetInstance()->
+ GetMediaStreamCaptureIndicator();
// The projecting indicator takes precedence over the recording indicator, but
// if we are projecting and we don't handle the projecting case we want to
// still show the recording indicator.
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index 90abe3f..8623084 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -32,7 +32,6 @@
#include "chrome/browser/ui/webui/inspect_ui.h"
#include "chrome/browser/ui/webui/instant_ui.h"
#include "chrome/browser/ui/webui/local_omnibox_popup/local_omnibox_popup_ui.h"
-#include "chrome/browser/ui/webui/media/media_internals_ui.h"
#include "chrome/browser/ui/webui/memory_internals/memory_internals_ui.h"
#include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
@@ -209,8 +208,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<InstantUI>;
if (url.host() == chrome::kChromeUILocalOmniboxPopupHost)
return &NewWebUI<LocalOmniboxPopupUI>;
- if (url.host() == chrome::kChromeUIMediaInternalsHost)
- return &NewWebUI<MediaInternalsUI>;
if (url.host() == chrome::kChromeUIMemoryInternalsHost &&
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableMemoryInternalsUI)) {
diff --git a/chrome/browser/ui/webui/media/media_internals_handler.cc b/chrome/browser/ui/webui/media/media_internals_handler.cc
deleted file mode 100644
index fe3968c..0000000
--- a/chrome/browser/ui/webui/media/media_internals_handler.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/media/media_internals_handler.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/ui/webui/media/media_internals_proxy.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-
-using content::BrowserThread;
-
-MediaInternalsMessageHandler::MediaInternalsMessageHandler()
- : proxy_(new MediaInternalsProxy()) {}
-
-MediaInternalsMessageHandler::~MediaInternalsMessageHandler() {
- proxy_->Detach();
-}
-
-void MediaInternalsMessageHandler::RegisterMessages() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- proxy_->Attach(this);
-
- web_ui()->RegisterMessageCallback("getEverything",
- base::Bind(&MediaInternalsMessageHandler::OnGetEverything,
- base::Unretained(this)));
-}
-
-void MediaInternalsMessageHandler::OnGetEverything(const ListValue* list) {
- proxy_->GetEverything();
-}
-
-void MediaInternalsMessageHandler::OnUpdate(const string16& update) {
- // Don't try to execute JavaScript in a RenderView that no longer exists.
- content::RenderViewHost* host =
- web_ui()->GetWebContents()->GetRenderViewHost();
- if (host)
- host->ExecuteJavascriptInWebFrame(string16(), update);
-}
diff --git a/chrome/browser/ui/webui/media/media_internals_handler.h b/chrome/browser/ui/webui/media/media_internals_handler.h
deleted file mode 100644
index 20c1def..0000000
--- a/chrome/browser/ui/webui/media/media_internals_handler.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_HANDLER_H_
-
-#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-class MediaInternalsProxy;
-
-namespace base {
-class ListValue;
-}
-
-// This class handles messages to and from MediaInternalsUI.
-// It does all its work on the IO thread through the proxy below.
-class MediaInternalsMessageHandler : public content::WebUIMessageHandler {
- public:
- MediaInternalsMessageHandler();
- virtual ~MediaInternalsMessageHandler();
-
- // WebUIMessageHandler implementation.
- virtual void RegisterMessages() OVERRIDE;
-
- // Javascript message handlers.
- void OnGetEverything(const base::ListValue* list);
-
- // MediaInternals message handlers.
- void OnUpdate(const string16& update);
-
- private:
- scoped_refptr<MediaInternalsProxy> proxy_;
-
- DISALLOW_COPY_AND_ASSIGN(MediaInternalsMessageHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_HANDLER_H_
diff --git a/chrome/browser/ui/webui/media/media_internals_proxy.cc b/chrome/browser/ui/webui/media/media_internals_proxy.cc
deleted file mode 100644
index d57af78..0000000
--- a/chrome/browser/ui/webui/media/media_internals_proxy.cc
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/media/media_internals_proxy.h"
-
-#include "base/bind.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/io_thread.h"
-#include "chrome/browser/media/media_internals.h"
-#include "chrome/browser/net/chrome_net_log.h"
-#include "chrome/browser/ui/webui/media/media_internals_handler.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_types.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/web_ui.h"
-
-using content::BrowserThread;
-
-static const int kMediaInternalsProxyEventDelayMilliseconds = 100;
-
-static const net::NetLog::EventType kNetEventTypeFilter[] = {
- net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL,
- net::NetLog::TYPE_SPARSE_READ,
- net::NetLog::TYPE_SPARSE_WRITE,
- net::NetLog::TYPE_URL_REQUEST_START_JOB,
- net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS,
-};
-
-MediaInternalsProxy::MediaInternalsProxy() {
- io_thread_ = g_browser_process->io_thread();
- registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
- content::NotificationService::AllBrowserContextsAndSources());
-}
-
-void MediaInternalsProxy::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK_EQ(type, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED);
- content::RenderProcessHost* process =
- content::Source<content::RenderProcessHost>(source).ptr();
- CallJavaScriptFunctionOnUIThread("media.onRendererTerminated",
- base::Value::CreateIntegerValue(process->GetID()));
-}
-
-void MediaInternalsProxy::Attach(MediaInternalsMessageHandler* handler) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- handler_ = handler;
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&MediaInternalsProxy::ObserveMediaInternalsOnIOThread, this));
-}
-
-void MediaInternalsProxy::Detach() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- handler_ = NULL;
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(
- &MediaInternalsProxy::StopObservingMediaInternalsOnIOThread, this));
-}
-
-void MediaInternalsProxy::GetEverything() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // Ask MediaInternals for all its data.
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&MediaInternalsProxy::GetEverythingOnIOThread, this));
-
- // Send the page names for constants.
- CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants());
-}
-
-void MediaInternalsProxy::OnUpdate(const string16& update) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&MediaInternalsProxy::UpdateUIOnUIThread, this, update));
-}
-
-void MediaInternalsProxy::OnAddEntry(const net::NetLog::Entry& entry) {
- bool is_event_interesting = false;
- for (size_t i = 0; i < arraysize(kNetEventTypeFilter); i++) {
- if (entry.type() == kNetEventTypeFilter[i]) {
- is_event_interesting = true;
- break;
- }
- }
-
- if (!is_event_interesting)
- return;
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&MediaInternalsProxy::AddNetEventOnUIThread, this,
- entry.ToValue()));
-}
-
-MediaInternalsProxy::~MediaInternalsProxy() {}
-
-Value* MediaInternalsProxy::GetConstants() {
- DictionaryValue* event_phases = new DictionaryValue();
- event_phases->SetInteger(
- net::NetLog::EventPhaseToString(net::NetLog::PHASE_NONE),
- net::NetLog::PHASE_NONE);
- event_phases->SetInteger(
- net::NetLog::EventPhaseToString(net::NetLog::PHASE_BEGIN),
- net::NetLog::PHASE_BEGIN);
- event_phases->SetInteger(
- net::NetLog::EventPhaseToString(net::NetLog::PHASE_END),
- net::NetLog::PHASE_END);
-
- DictionaryValue* constants = new DictionaryValue();
- constants->Set("eventTypes", net::NetLog::GetEventTypesAsValue());
- constants->Set("eventPhases", event_phases);
-
- return constants;
-}
-
-void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- MediaInternals::GetInstance()->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_->net_log()->RemoveThreadSafeObserver(this);
-}
-
-void MediaInternalsProxy::GetEverythingOnIOThread() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- MediaInternals::GetInstance()->SendEverything();
-}
-
-void MediaInternalsProxy::UpdateUIOnUIThread(const string16& update) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // Don't forward updates to a destructed UI.
- if (handler_)
- handler_->OnUpdate(update);
-}
-
-void MediaInternalsProxy::AddNetEventOnUIThread(Value* entry) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // Send the updates to the page in kMediaInternalsProxyEventDelayMilliseconds
- // if an update is not already pending.
- if (!pending_net_updates_.get()) {
- pending_net_updates_.reset(new ListValue());
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(
- &MediaInternalsProxy::SendNetEventsOnUIThread, this),
- base::TimeDelta::FromMilliseconds(
- kMediaInternalsProxyEventDelayMilliseconds));
- }
- pending_net_updates_->Append(entry);
-}
-
-void MediaInternalsProxy::SendNetEventsOnUIThread() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- CallJavaScriptFunctionOnUIThread("media.onNetUpdate",
- pending_net_updates_.release());
-}
-
-void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread(
- const std::string& function, Value* args) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- scoped_ptr<Value> args_value(args);
- std::vector<const Value*> args_vector;
- args_vector.push_back(args_value.get());
- string16 update = content::WebUI::GetJavascriptCall(function, args_vector);
- UpdateUIOnUIThread(update);
-}
diff --git a/chrome/browser/ui/webui/media/media_internals_proxy.h b/chrome/browser/ui/webui/media/media_internals_proxy.h
deleted file mode 100644
index bbc55ef..0000000
--- a/chrome/browser/ui/webui/media/media_internals_proxy.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_
-#define CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_
-
-#include "base/memory/ref_counted.h"
-#include "base/sequenced_task_runner_helpers.h"
-#include "base/string16.h"
-#include "chrome/browser/media/media_internals_observer.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-#include "net/base/net_log.h"
-
-class IOThread;
-class MediaInternalsMessageHandler;
-
-namespace base {
-class ListValue;
-class Value;
-}
-
-// This class is a proxy between MediaInternals (on the IO thread) and
-// MediaInternalsMessageHandler (on the UI thread).
-// It is ref_counted to ensure that it completes all pending Tasks on both
-// threads before destruction.
-class MediaInternalsProxy
- : public MediaInternalsObserver,
- public base::RefCountedThreadSafe<
- MediaInternalsProxy,
- content::BrowserThread::DeleteOnUIThread>,
- public net::NetLog::ThreadSafeObserver,
- public content::NotificationObserver {
- public:
- MediaInternalsProxy();
-
- // content::NotificationObserver implementation.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
- // Register a Handler and start receiving callbacks from MediaInternals.
- void Attach(MediaInternalsMessageHandler* handler);
-
- // Unregister the same and stop receiving callbacks.
- void Detach();
-
- // Have MediaInternals send all the data it has.
- void GetEverything();
-
- // MediaInternalsObserver implementation. Called on the IO thread.
- virtual void OnUpdate(const string16& update) OVERRIDE;
-
- // net::NetLog::ThreadSafeObserver implementation. Callable from any thread:
- virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE;
-
- private:
- friend struct content::BrowserThread::DeleteOnThread<
- content::BrowserThread::UI>;
- friend class base::DeleteHelper<MediaInternalsProxy>;
- virtual ~MediaInternalsProxy();
-
- // Build a dictionary mapping constant names to values.
- base::Value* GetConstants();
-
- void ObserveMediaInternalsOnIOThread();
- void StopObservingMediaInternalsOnIOThread();
- void GetEverythingOnIOThread();
- void UpdateUIOnUIThread(const string16& update);
-
- // Put |entry| on a list of events to be sent to the page.
- void AddNetEventOnUIThread(base::Value* entry);
-
- // Send all pending events to the page.
- void SendNetEventsOnUIThread();
-
- // Call a JavaScript function on the page. Takes ownership of |args|.
- void CallJavaScriptFunctionOnUIThread(const std::string& function,
- base::Value* args);
-
- MediaInternalsMessageHandler* handler_;
- IOThread* io_thread_;
- scoped_ptr<base::ListValue> pending_net_updates_;
- content::NotificationRegistrar registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(MediaInternalsProxy);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_
diff --git a/chrome/browser/ui/webui/media/media_internals_ui.cc b/chrome/browser/ui/webui/media/media_internals_ui.cc
deleted file mode 100644
index a58f3fb..0000000
--- a/chrome/browser/ui/webui/media/media_internals_ui.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/media/media_internals_ui.h"
-
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/media/media_internals_handler.h"
-#include "chrome/common/url_constants.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "grit/browser_resources.h"
-#include "ui/base/resource/resource_bundle.h"
-
-using content::WebContents;
-
-namespace {
-
-content::WebUIDataSource* CreateMediaInternalsHTMLSource() {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIMediaInternalsHost);
-
- source->SetJsonPath("strings.js");
- source->AddResourcePath("media_internals.js", IDR_MEDIA_INTERNALS_JS);
- source->SetDefaultResource(IDR_MEDIA_INTERNALS_HTML);
- return source;
-}
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// MediaInternalsUI
-//
-////////////////////////////////////////////////////////////////////////////////
-
-MediaInternalsUI::MediaInternalsUI(content::WebUI* web_ui)
- : WebUIController(web_ui) {
- web_ui->AddMessageHandler(new MediaInternalsMessageHandler());
-
- Profile* profile = Profile::FromWebUI(web_ui);
- content::WebUIDataSource::Add(profile, CreateMediaInternalsHTMLSource());
-}
diff --git a/chrome/browser/ui/webui/media/media_internals_ui.h b/chrome/browser/ui/webui/media/media_internals_ui.h
deleted file mode 100644
index 3d885bb..0000000
--- a/chrome/browser/ui/webui/media/media_internals_ui.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_UI_H_
-
-#include "content/public/browser/web_ui_controller.h"
-
-// The implementation for the chrome://media-internals page.
-class MediaInternalsUI : public content::WebUIController {
- public:
- explicit MediaInternalsUI(content::WebUI* web_ui);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MediaInternalsUI);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_UI_H_
diff --git a/chrome/browser/ui/webui/options/media_devices_selection_handler.cc b/chrome/browser/ui/webui/options/media_devices_selection_handler.cc
index a820278..7be608d 100644
--- a/chrome/browser/ui/webui/options/media_devices_selection_handler.cc
+++ b/chrome/browser/ui/webui/options/media_devices_selection_handler.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/ui/webui/options/media_devices_selection_handler.h"
#include "base/bind.h"
-#include "chrome/browser/media/media_internals.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
@@ -22,10 +21,7 @@ namespace options {
MediaDevicesSelectionHandler::MediaDevicesSelectionHandler() {}
MediaDevicesSelectionHandler::~MediaDevicesSelectionHandler() {
- // Register to the device observer list to get up-to-date device lists.
- MediaCaptureDevicesDispatcher* dispatcher =
- MediaInternals::GetInstance()->GetMediaCaptureDevicesDispatcher();
- dispatcher->RemoveObserver(this);
+ MediaCaptureDevicesDispatcher::GetInstance()->RemoveObserver(this);
}
void MediaDevicesSelectionHandler::GetLocalizedValues(DictionaryValue* values) {
@@ -41,9 +37,7 @@ void MediaDevicesSelectionHandler::GetLocalizedValues(DictionaryValue* values) {
void MediaDevicesSelectionHandler::InitializePage() {
// Register to the device observer list to get up-to-date device lists.
- MediaCaptureDevicesDispatcher* dispatcher =
- MediaInternals::GetInstance()->GetMediaCaptureDevicesDispatcher();
- dispatcher->AddObserver(this);
+ MediaCaptureDevicesDispatcher::GetInstance()->AddObserver(this);
// Update the device selection menus.
UpdateDevicesMenuForType(AUDIO);
@@ -132,15 +126,15 @@ void MediaDevicesSelectionHandler::UpdateDevicesMenu(
}
void MediaDevicesSelectionHandler::UpdateDevicesMenuForType(DeviceType type) {
- scoped_refptr<MediaCaptureDevicesDispatcher> dispatcher =
- MediaInternals::GetInstance()->GetMediaCaptureDevicesDispatcher();
content::MediaStreamDevices devices;
switch (type) {
case AUDIO:
- devices = dispatcher->GetAudioCaptureDevices();
+ devices = MediaCaptureDevicesDispatcher::GetInstance()->
+ GetAudioCaptureDevices();
break;
case VIDEO:
- devices = dispatcher->GetVideoCaptureDevices();
+ devices = MediaCaptureDevicesDispatcher::GetInstance()->
+ GetVideoCaptureDevices();
break;
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index adb5d6a..703430e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1025,8 +1025,6 @@
'browser/managed_mode/managed_user_service_factory.h',
'browser/media/media_capture_devices_dispatcher.cc',
'browser/media/media_capture_devices_dispatcher.h',
- 'browser/media/media_internals.cc',
- 'browser/media/media_internals.h',
'browser/media/media_stream_capture_indicator.cc',
'browser/media/media_stream_capture_indicator.h',
'browser/media/media_stream_devices_controller.cc',
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 8923e07..10e8010 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -1927,12 +1927,6 @@
'browser/ui/webui/inspect_ui.h',
'browser/ui/webui/instant_ui.cc',
'browser/ui/webui/instant_ui.h',
- 'browser/ui/webui/media/media_internals_handler.cc',
- 'browser/ui/webui/media/media_internals_handler.h',
- 'browser/ui/webui/media/media_internals_proxy.cc',
- 'browser/ui/webui/media/media_internals_proxy.h',
- 'browser/ui/webui/media/media_internals_ui.cc',
- 'browser/ui/webui/media/media_internals_ui.h',
'browser/ui/webui/memory_internals/memory_internals_ui.cc',
'browser/ui/webui/memory_internals/memory_internals_ui.h',
'browser/ui/webui/metrics_handler.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 6b3ba32..66b41c1 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -847,7 +847,6 @@
'browser/managed_mode/managed_mode_unittest.cc',
'browser/managed_mode/managed_mode_url_filter_unittest.cc',
'browser/managed_mode/managed_user_service_unittest.cc',
- 'browser/media/media_internals_unittest.cc',
'browser/media_gallery/linux/mtp_device_object_enumerator_unittest.cc',
'browser/media_gallery/media_file_system_registry_unittest.cc',
'browser/media_gallery/media_galleries_dialog_controller_mock.cc',
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 036dfe4..60aba1d 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -162,7 +162,6 @@ const char kChromeUIIPCHost[] = "ipc";
const char kChromeUIKeyboardHost[] = "keyboard";
const char kChromeUIKillHost[] = "kill";
const char kChromeUILocalOmniboxPopupHost[] = "local-omnibox-popup";
-const char kChromeUIMediaInternalsHost[] = "media-internals";
const char kChromeUIMemoryHost[] = "memory";
const char kChromeUIMemoryInternalsHost[] = "memory-internals";
const char kChromeUIMemoryRedirectHost[] = "memory-redirect";
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index d7ab844..34bf65c 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -157,7 +157,6 @@ extern const char kChromeUIIPCHost[];
extern const char kChromeUIKeyboardHost[];
extern const char kChromeUIKillHost[];
extern const char kChromeUILocalOmniboxPopupHost[];
-extern const char kChromeUIMediaInternalsHost[];
extern const char kChromeUIMemoryHost[];
extern const char kChromeUIMemoryInternalsHost[];
extern const char kChromeUIMemoryRedirectHost[];