Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: content/renderer/render_view_impl.cc

Issue 8060055: Adding support for MediaStream and PeerConnection functionality (Closed) Base URL: http://git.chromium.org/chromium/chromium.git@trunk
Patch Set: Changed type of port allocator and moved ownership of it, fixed mem leaks in unit tests. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index f03c700f40141e1a8b3f517e969128b782bbc6f4..773ed31b9916c6a2eff38f0badb741bec456c759 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -59,6 +59,8 @@
#include "content/renderer/load_progress_tracker.h"
#include "content/renderer/media/audio_message_filter.h"
#include "content/renderer/media/audio_renderer_impl.h"
+#include "content/renderer/media/media_stream_dependency_factory.h"
+#include "content/renderer/media/media_stream_dispatcher.h"
#include "content/renderer/media/media_stream_impl.h"
#include "content/renderer/media/render_media_log.h"
#include "content/renderer/mhtml_generator.h"
@@ -104,6 +106,8 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandler.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandlerClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h"
@@ -130,6 +134,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLResponse.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/javascript_message_type.h"
@@ -358,6 +363,7 @@ RenderViewImpl::RenderViewImpl(
geolocation_dispatcher_(NULL),
speech_input_dispatcher_(NULL),
device_orientation_dispatcher_(NULL),
+ media_stream_dispatcher_(NULL),
p2p_socket_dispatcher_(NULL),
devtools_agent_(NULL),
renderer_accessibility_(NULL),
@@ -416,7 +422,8 @@ RenderViewImpl::RenderViewImpl(
host_window_ = parent_hwnd;
#if defined(ENABLE_P2P_APIS)
- p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
+ if (!p2p_socket_dispatcher_)
+ p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
#endif
new MHTMLGenerator(this);
@@ -430,12 +437,6 @@ RenderViewImpl::RenderViewImpl(
new IdleUserDetector(this);
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kEnableMediaStream)) {
- media_stream_impl_ = new MediaStreamImpl(
- RenderThreadImpl::current()->video_capture_impl_manager());
- }
-
content::GetContentClient()->renderer()->RenderViewCreated(this);
}
@@ -471,6 +472,10 @@ RenderViewImpl::~RenderViewImpl() {
DCHECK_NE(this, it->second) << "Failed to call Close?";
#endif
+ // MediaStreamImpl holds weak references to RenderViewObserver objects,
+ // ensure it's deleted before the observers.
+ media_stream_impl_ = NULL;
+
FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone());
FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct());
}
@@ -529,6 +534,15 @@ void RenderViewImpl::SetNextPageID(int32 next_page_id) {
next_page_id_ = next_page_id;
}
+WebKit::WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler(
+ WebKit::WebPeerConnectionHandlerClient* client) {
+ const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+ if (!cmd_line->HasSwitch(switches::kEnableMediaStream))
+ return NULL;
+ EnsureMediaStreamImpl();
+ return media_stream_impl_->CreatePeerConnectionHandler(client);
+}
+
void RenderViewImpl::AddObserver(RenderViewObserver* observer) {
observers_.AddObserver(observer);
}
@@ -2967,6 +2981,25 @@ void RenderViewImpl::CheckPreferredSize() {
preferred_size_));
}
+void RenderViewImpl::EnsureMediaStreamImpl() {
+#if defined(ENABLE_P2P_APIS)
+ if (!p2p_socket_dispatcher_)
+ p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
+#endif
+
+ if (!media_stream_dispatcher_)
+ media_stream_dispatcher_ = new MediaStreamDispatcher(this);
+
+ if (!media_stream_impl_.get()) {
+ MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory();
+ media_stream_impl_ = new MediaStreamImpl(
+ media_stream_dispatcher_,
+ p2p_socket_dispatcher_,
+ RenderThreadImpl::current()->video_capture_impl_manager(),
+ factory);
+ }
+}
+
void RenderViewImpl::didChangeContentsSize(WebFrame* frame,
const WebSize& size) {
if (webview()->mainFrame() != frame)
@@ -4683,6 +4716,14 @@ WebKit::WebPageVisibilityState RenderViewImpl::visibilityState() const {
return current_state;
}
+WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() {
+ const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+ if (!cmd_line->HasSwitch(switches::kEnableMediaStream))
+ return NULL;
+ EnsureMediaStreamImpl();
+ return media_stream_impl_;
+}
+
bool RenderViewImpl::IsNonLocalTopLevelNavigation(
const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) {
// Must be a top level frame.

Powered by Google App Engine
This is Rietveld 408576698