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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 10108016: Refactored MediaStreamImpl to be a RenderViewObserver as the other delegates in RenderViewImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed messed up MockMediaStreamImpl. Created 8 years, 8 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/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 cached_has_main_frame_horizontal_scrollbar_(false), 458 cached_has_main_frame_horizontal_scrollbar_(false),
459 cached_has_main_frame_vertical_scrollbar_(false), 459 cached_has_main_frame_vertical_scrollbar_(false),
460 context_has_swapbuffers_complete_callback_(false), 460 context_has_swapbuffers_complete_callback_(false),
461 queried_for_swapbuffers_complete_callback_(false), 461 queried_for_swapbuffers_complete_callback_(false),
462 context_is_web_graphics_context_3d_command_buffer_impl_(false), 462 context_is_web_graphics_context_3d_command_buffer_impl_(false),
463 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 463 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
464 geolocation_dispatcher_(NULL), 464 geolocation_dispatcher_(NULL),
465 input_tag_speech_dispatcher_(NULL), 465 input_tag_speech_dispatcher_(NULL),
466 device_orientation_dispatcher_(NULL), 466 device_orientation_dispatcher_(NULL),
467 media_stream_dispatcher_(NULL), 467 media_stream_dispatcher_(NULL),
468 media_stream_impl_(NULL),
468 p2p_socket_dispatcher_(NULL), 469 p2p_socket_dispatcher_(NULL),
469 devtools_agent_(NULL), 470 devtools_agent_(NULL),
470 renderer_accessibility_(NULL), 471 renderer_accessibility_(NULL),
471 mouse_lock_dispatcher_(NULL), 472 mouse_lock_dispatcher_(NULL),
472 session_storage_namespace_id_(session_storage_namespace_id), 473 session_storage_namespace_id_(session_storage_namespace_id),
473 handling_select_range_(false), 474 handling_select_range_(false),
474 #if defined(OS_WIN) 475 #if defined(OS_WIN)
475 focused_plugin_id_(-1), 476 focused_plugin_id_(-1),
476 #endif 477 #endif
477 guest_(guest), 478 guest_(guest),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 587 }
587 #endif 588 #endif
588 589
589 #ifndef NDEBUG 590 #ifndef NDEBUG
590 // Make sure we are no longer referenced by the ViewMap. 591 // Make sure we are no longer referenced by the ViewMap.
591 ViewMap* views = g_view_map.Pointer(); 592 ViewMap* views = g_view_map.Pointer();
592 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) 593 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it)
593 DCHECK_NE(this, it->second) << "Failed to call Close?"; 594 DCHECK_NE(this, it->second) << "Failed to call Close?";
594 #endif 595 #endif
595 596
596 // MediaStreamImpl holds weak references to RenderViewObserver objects,
597 // ensure it's deleted before the observers.
598 media_stream_impl_ = NULL;
599
600 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); 597 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone());
601 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); 598 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct());
602 } 599 }
603 600
604 /*static*/ 601 /*static*/
605 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { 602 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) {
606 ViewMap* views = g_view_map.Pointer(); 603 ViewMap* views = g_view_map.Pointer();
607 ViewMap::iterator it = views->find(webview); 604 ViewMap::iterator it = views->find(webview);
608 return it == views->end() ? NULL : it->second; 605 return it == views->end() ? NULL : it->second;
609 } 606 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 frame_name, 648 frame_name,
652 next_page_id, 649 next_page_id,
653 screen_info, 650 screen_info,
654 guest, 651 guest,
655 accessibility_mode); 652 accessibility_mode);
656 } 653 }
657 654
658 WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler( 655 WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler(
659 WebPeerConnectionHandlerClient* client) { 656 WebPeerConnectionHandlerClient* client) {
660 EnsureMediaStreamImpl(); 657 EnsureMediaStreamImpl();
661 if (!media_stream_impl_.get()) 658 if (!media_stream_impl_)
662 return NULL; 659 return NULL;
663 return media_stream_impl_->CreatePeerConnectionHandler(client); 660 return media_stream_impl_->CreatePeerConnectionHandler(client);
664 } 661 }
665 662
666 WebPeerConnection00Handler* RenderViewImpl::CreatePeerConnectionHandlerJsep( 663 WebPeerConnection00Handler* RenderViewImpl::CreatePeerConnectionHandlerJsep(
667 WebPeerConnection00HandlerClient* client) { 664 WebPeerConnection00HandlerClient* client) {
668 EnsureMediaStreamImpl(); 665 EnsureMediaStreamImpl();
669 if (!media_stream_impl_.get()) 666 if (!media_stream_impl_)
670 return NULL; 667 return NULL;
671 return media_stream_impl_->CreatePeerConnectionHandlerJsep(client); 668 return media_stream_impl_->CreatePeerConnectionHandlerJsep(client);
672 } 669 }
673 670
674 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { 671 void RenderViewImpl::AddObserver(RenderViewObserver* observer) {
675 observers_.AddObserver(observer); 672 observers_.AddObserver(observer);
676 } 673 }
677 674
678 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { 675 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) {
679 observer->RenderViewGone(); 676 observer->RenderViewGone();
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 message_loop_factory->GetMessageLoop("GpuVideoDecoder"), 2216 message_loop_factory->GetMessageLoop("GpuVideoDecoder"),
2220 factories_loop, 2217 factories_loop,
2221 new RendererGpuVideoDecoderFactories( 2218 new RendererGpuVideoDecoderFactories(
2222 gpu_channel_host, factories_loop, context3d))); 2219 gpu_channel_host, factories_loop, context3d)));
2223 } 2220 }
2224 #endif 2221 #endif
2225 2222
2226 webkit_media::WebMediaPlayerImpl* media_player = 2223 webkit_media::WebMediaPlayerImpl* media_player =
2227 content::GetContentClient()->renderer()->OverrideCreateWebMediaPlayer( 2224 content::GetContentClient()->renderer()->OverrideCreateWebMediaPlayer(
2228 this, frame, client, AsWeakPtr(), collection, audio_source_provider, 2225 this, frame, client, AsWeakPtr(), collection, audio_source_provider,
2229 message_loop_factory, media_stream_impl_.get(), render_media_log); 2226 message_loop_factory, media_stream_impl_, render_media_log);
2230 #if defined(OS_ANDROID) 2227 #if defined(OS_ANDROID)
2231 // TODO(qinmin): Implement for android. 2228 // TODO(qinmin): Implement for android.
2232 // http://crbug.com/113218 2229 // http://crbug.com/113218
2233 #else 2230 #else
2234 if (!media_player) { 2231 if (!media_player) {
2235 media_player = new webkit_media::WebMediaPlayerImpl( 2232 media_player = new webkit_media::WebMediaPlayerImpl(
2236 frame, client, AsWeakPtr(), collection, audio_source_provider, 2233 frame, client, AsWeakPtr(), collection, audio_source_provider,
2237 message_loop_factory, media_stream_impl_.get(), render_media_log); 2234 message_loop_factory, media_stream_impl_, render_media_log);
2238 } 2235 }
2239 #endif 2236 #endif
2240 return media_player; 2237 return media_player;
2241 } 2238 }
2242 2239
2243 WebApplicationCacheHost* RenderViewImpl::createApplicationCacheHost( 2240 WebApplicationCacheHost* RenderViewImpl::createApplicationCacheHost(
2244 WebFrame* frame, WebApplicationCacheHostClient* client) { 2241 WebFrame* frame, WebApplicationCacheHostClient* client) {
2245 if (!frame || !frame->view()) 2242 if (!frame || !frame->view())
2246 return NULL; 2243 return NULL;
2247 return new RendererWebApplicationCacheHostImpl( 2244 return new RendererWebApplicationCacheHostImpl(
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
3299 3296
3300 #if defined(ENABLE_P2P_APIS) 3297 #if defined(ENABLE_P2P_APIS)
3301 if (!p2p_socket_dispatcher_) 3298 if (!p2p_socket_dispatcher_)
3302 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); 3299 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
3303 #endif 3300 #endif
3304 3301
3305 #if defined(ENABLE_WEBRTC) 3302 #if defined(ENABLE_WEBRTC)
3306 if (!media_stream_dispatcher_) 3303 if (!media_stream_dispatcher_)
3307 media_stream_dispatcher_ = new MediaStreamDispatcher(this); 3304 media_stream_dispatcher_ = new MediaStreamDispatcher(this);
3308 3305
3309 if (!media_stream_impl_.get()) { 3306 if (!media_stream_impl_) {
3310 MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory(); 3307 MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory();
3311 media_stream_impl_ = new MediaStreamImpl( 3308 media_stream_impl_ = new MediaStreamImpl(
3309 this,
3312 media_stream_dispatcher_, 3310 media_stream_dispatcher_,
3313 p2p_socket_dispatcher_, 3311 p2p_socket_dispatcher_,
3314 RenderThreadImpl::current()->video_capture_impl_manager(), 3312 RenderThreadImpl::current()->video_capture_impl_manager(),
3315 factory); 3313 factory);
3316 } 3314 }
3317 #endif 3315 #endif
3318 } 3316 }
3319 3317
3320 void RenderViewImpl::didChangeContentsSize(WebFrame* frame, 3318 void RenderViewImpl::didChangeContentsSize(WebFrame* frame,
3321 const WebSize& size) { 3319 const WebSize& size) {
(...skipping 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after
5258 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5256 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5259 return !!RenderThreadImpl::current()->compositor_thread(); 5257 return !!RenderThreadImpl::current()->compositor_thread();
5260 } 5258 }
5261 5259
5262 void RenderViewImpl::OnJavaBridgeInit() { 5260 void RenderViewImpl::OnJavaBridgeInit() {
5263 DCHECK(!java_bridge_dispatcher_.get()); 5261 DCHECK(!java_bridge_dispatcher_.get());
5264 #if defined(ENABLE_JAVA_BRIDGE) 5262 #if defined(ENABLE_JAVA_BRIDGE)
5265 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5263 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5266 #endif 5264 #endif
5267 } 5265 }
OLDNEW
« content/renderer/render_view_impl.h ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698