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

Side by Side Diff: content/renderer/media/media_stream_dependency_factory.cc

Issue 10919122: Move creation of PeerConnection from the RenderView to the RenderThreadImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed UMA_HISTOGRAM_ENUMERATION and cleaned up. Created 8 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/media_stream_dependency_factory.h" 5 #include "content/renderer/media/media_stream_dependency_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/metrics/histogram.h"
10 #include "content/renderer/media/peer_connection_handler_jsep.h"
9 #include "content/renderer/media/video_capture_impl_manager.h" 11 #include "content/renderer/media/video_capture_impl_manager.h"
10 #include "content/renderer/media/video_capture_module_impl.h" 12 #include "content/renderer/media/video_capture_module_impl.h"
11 #include "content/renderer/media/webrtc_audio_device_impl.h" 13 #include "content/renderer/media/webrtc_audio_device_impl.h"
12 #include "content/renderer/p2p/ipc_network_manager.h" 14 #include "content/renderer/p2p/ipc_network_manager.h"
13 #include "content/renderer/p2p/ipc_socket_factory.h" 15 #include "content/renderer/p2p/ipc_socket_factory.h"
14 #include "content/renderer/p2p/port_allocator.h" 16 #include "content/renderer/p2p/port_allocator.h"
15 #include "jingle/glue/thread_wrapper.h" 17 #include "jingle/glue/thread_wrapper.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
17 19
20 namespace {
darin (slow to review) 2012/09/06 18:24:59 nit: add new line below here.
perkj_chrome 2012/09/12 11:53:15 Moved to webrtc_uma_histograms.
21 // Helper enum used for histogramming calls to WebRTC APIs from JavaScript.
22 // TODO(perkj): This is a duplicate of the code in media_stream_impl.
23 // The enum and UpdateWebRTCMethodCount must bee kept in sync with
darin (slow to review) 2012/09/06 18:24:59 bee -> be
perkj_chrome 2012/09/12 13:54:38 Done.
24 // media_stream_impl. Find a better way of doing this.
piman 2012/09/06 17:04:45 Can we just move it to a common header?
perkj_chrome 2012/09/12 11:53:15 Done.
25 enum JavaScriptAPIName {
26 kWebkitGetUserMedia,
darin (slow to review) 2012/09/06 18:24:59 nit: chromium follows the old google c++ style rul
perkj_chrome 2012/09/12 13:54:38 Done.
27 kWebkitPeerConnection,
28 kInvalidName
29 };
30
31 // Helper method used to collect information about the number of times
32 // different WebRTC API:s are called from JavaScript.
33 // The histogram can be viewed at chrome://histograms/WebRTC.webkitApiCount.
34 static void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) {
darin (slow to review) 2012/09/06 18:24:59 nit: "static" keyword inside anonymous namespace i
perkj_chrome 2012/09/12 11:53:15 Done.
35 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, kInvalidName);
36 }
37
38 } // namespace
39
18 class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface { 40 class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface {
19 public: 41 public:
20 P2PPortAllocatorFactory( 42 P2PPortAllocatorFactory(
21 content::P2PSocketDispatcher* socket_dispatcher, 43 content::P2PSocketDispatcher* socket_dispatcher,
22 talk_base::NetworkManager* network_manager, 44 talk_base::NetworkManager* network_manager,
23 talk_base::PacketSocketFactory* socket_factory) 45 talk_base::PacketSocketFactory* socket_factory)
24 : socket_dispatcher_(socket_dispatcher), 46 : socket_dispatcher_(socket_dispatcher),
25 network_manager_(network_manager), 47 network_manager_(network_manager),
26 socket_factory_(socket_factory) { 48 socket_factory_(socket_factory) {
27 } 49 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 talk_base::PacketSocketFactory* socket_factory_; 88 talk_base::PacketSocketFactory* socket_factory_;
67 }; 89 };
68 90
69 MediaStreamDependencyFactory::MediaStreamDependencyFactory( 91 MediaStreamDependencyFactory::MediaStreamDependencyFactory(
70 VideoCaptureImplManager* vc_manager) 92 VideoCaptureImplManager* vc_manager)
71 : vc_manager_(vc_manager) { 93 : vc_manager_(vc_manager) {
72 } 94 }
73 95
74 MediaStreamDependencyFactory::~MediaStreamDependencyFactory() {} 96 MediaStreamDependencyFactory::~MediaStreamDependencyFactory() {}
75 97
98 WebKit::WebPeerConnection00Handler*
99 MediaStreamDependencyFactory::CreatePeerConnectionHandlerJsep(
100 WebKit::WebPeerConnection00HandlerClient* client) {
101
102 // Save histogram data so we can see how much PeerConnetion is used.
103 // The histogram counts the number of calls to the JS API
104 // webKitPeerConnection00.
105 UpdateWebRTCMethodCount(kWebkitPeerConnection);
106
107 PeerConnectionHandlerJsep* pc_handler = new PeerConnectionHandlerJsep(
108 client,
109 this);
110 return pc_handler;
piman 2012/09/06 17:04:45 style nit: if you just return new PeerConnectionHa
perkj_chrome 2012/09/12 13:54:38 Done.
111 }
112
76 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory( 113 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory(
77 talk_base::Thread* worker_thread, 114 talk_base::Thread* worker_thread,
78 talk_base::Thread* signaling_thread, 115 talk_base::Thread* signaling_thread,
79 content::P2PSocketDispatcher* socket_dispatcher, 116 content::P2PSocketDispatcher* socket_dispatcher,
80 talk_base::NetworkManager* network_manager, 117 talk_base::NetworkManager* network_manager,
81 talk_base::PacketSocketFactory* socket_factory) { 118 talk_base::PacketSocketFactory* socket_factory) {
82 if (!pc_factory_.get()) { 119 if (!pc_factory_.get()) {
83 talk_base::scoped_refptr<P2PPortAllocatorFactory> pa_factory = 120 talk_base::scoped_refptr<P2PPortAllocatorFactory> pa_factory =
84 new talk_base::RefCountedObject<P2PPortAllocatorFactory>( 121 new talk_base::RefCountedObject<P2PPortAllocatorFactory>(
85 socket_dispatcher, 122 socket_dispatcher,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 MediaStreamDependencyFactory::CreateSessionDescription(const std::string& sdp) { 180 MediaStreamDependencyFactory::CreateSessionDescription(const std::string& sdp) {
144 return webrtc::CreateSessionDescription(sdp); 181 return webrtc::CreateSessionDescription(sdp);
145 } 182 }
146 183
147 webrtc::IceCandidateInterface* MediaStreamDependencyFactory::CreateIceCandidate( 184 webrtc::IceCandidateInterface* MediaStreamDependencyFactory::CreateIceCandidate(
148 const std::string& sdp_mid, 185 const std::string& sdp_mid,
149 int sdp_mline_index, 186 int sdp_mline_index,
150 const std::string& sdp) { 187 const std::string& sdp) {
151 return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp); 188 return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp);
152 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698