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

Side by Side Diff: content/renderer/media/media_stream_impl.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_impl.h" 5 #include "content/renderer/media/media_stream_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 vc_manager_(vc_manager), 86 vc_manager_(vc_manager),
87 signaling_thread_(NULL), 87 signaling_thread_(NULL),
88 worker_thread_(NULL), 88 worker_thread_(NULL),
89 chrome_worker_thread_("Chrome_libJingle_WorkerThread") { 89 chrome_worker_thread_("Chrome_libJingle_WorkerThread") {
90 } 90 }
91 91
92 MediaStreamImpl::~MediaStreamImpl() { 92 MediaStreamImpl::~MediaStreamImpl() {
93 CleanupPeerConnectionFactory(); 93 CleanupPeerConnectionFactory();
94 } 94 }
95 95
96 WebKit::WebPeerConnection00Handler*
97 MediaStreamImpl::CreatePeerConnectionHandlerJsep(
98 WebKit::WebPeerConnection00HandlerClient* client) {
99 // Save histogram data so we can see how much PeerConnetion is used.
100 // The histogram counts the number of calls to the JS API
101 // webKitPeerConnection00.
102 UpdateWebRTCMethodCount(kWebkitPeerConnection);
103 DCHECK(CalledOnValidThread());
104 if (!EnsurePeerConnectionFactory())
105 return NULL;
106
107 PeerConnectionHandlerJsep* pc_handler = new PeerConnectionHandlerJsep(
108 client,
109 dependency_factory_.get());
110 return pc_handler;
111 }
112
113 void MediaStreamImpl::StopLocalMediaStream( 96 void MediaStreamImpl::StopLocalMediaStream(
114 const WebKit::WebMediaStreamDescriptor& stream) { 97 const WebKit::WebMediaStreamDescriptor& stream) {
115 DVLOG(1) << "MediaStreamImpl::StopLocalMediaStream"; 98 DVLOG(1) << "MediaStreamImpl::StopLocalMediaStream";
116 99
117 MediaStreamExtraData* extra_data = 100 MediaStreamExtraData* extra_data =
118 static_cast<MediaStreamExtraData*>(stream.extraData()); 101 static_cast<MediaStreamExtraData*>(stream.extraData());
119 if (extra_data && extra_data->local_stream()) { 102 if (extra_data && extra_data->local_stream()) {
120 media_stream_dispatcher_->StopStream(extra_data->local_stream()->label()); 103 media_stream_dispatcher_->StopStream(extra_data->local_stream()->label());
121 local_media_streams_.erase(extra_data->local_stream()->label()); 104 local_media_streams_.erase(extra_data->local_stream()->label());
122 } else { 105 } else {
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 socket_factory_.get())) { 422 socket_factory_.get())) {
440 LOG(ERROR) << "Could not create PeerConnection factory"; 423 LOG(ERROR) << "Could not create PeerConnection factory";
441 return false; 424 return false;
442 } 425 }
443 } 426 }
444 427
445 return true; 428 return true;
446 } 429 }
447 430
448 void MediaStreamImpl::CleanupPeerConnectionFactory() { 431 void MediaStreamImpl::CleanupPeerConnectionFactory() {
449 if (dependency_factory_.get()) 432 if (dependency_factory_)
450 dependency_factory_->ReleasePeerConnectionFactory(); 433 dependency_factory_->ReleasePeerConnectionFactory();
piman 2012/09/06 17:04:45 Should this logic move to RenderThreadImpl? IIUC y
perkj_chrome 2012/09/12 13:54:38 This have not moved to the dependency factory and
451 if (network_manager_) { 434 if (network_manager_) {
452 // The network manager needs to free its resources on the thread they were 435 // The network manager needs to free its resources on the thread they were
453 // created, which is the worked thread. 436 // created, which is the worked thread.
454 if (chrome_worker_thread_.IsRunning()) { 437 if (chrome_worker_thread_.IsRunning()) {
455 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 438 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
456 &MediaStreamImpl::DeleteIpcNetworkManager, 439 &MediaStreamImpl::DeleteIpcNetworkManager,
457 base::Unretained(this))); 440 base::Unretained(this)));
458 // Stopping the thread will wait until all tasks have been 441 // Stopping the thread will wait until all tasks have been
459 // processed before returning. We wait for the above task to finish before 442 // processed before returning. We wait for the above task to finish before
460 // letting the the function continue to avoid any potential race issues. 443 // letting the the function continue to avoid any potential race issues.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 MediaStreamExtraData::MediaStreamExtraData( 538 MediaStreamExtraData::MediaStreamExtraData(
556 webrtc::MediaStreamInterface* remote_stream) 539 webrtc::MediaStreamInterface* remote_stream)
557 : remote_stream_(remote_stream) { 540 : remote_stream_(remote_stream) {
558 } 541 }
559 MediaStreamExtraData::MediaStreamExtraData( 542 MediaStreamExtraData::MediaStreamExtraData(
560 webrtc::LocalMediaStreamInterface* local_stream) 543 webrtc::LocalMediaStreamInterface* local_stream)
561 : local_stream_(local_stream) { 544 : local_stream_(local_stream) {
562 } 545 }
563 MediaStreamExtraData::~MediaStreamExtraData() { 546 MediaStreamExtraData::~MediaStreamExtraData() {
564 } 547 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698