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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2578983003: Add AudioStreamRegistry. Move stream counting logic (Closed)
Patch Set: Thread checking. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 #include "content/browser/permissions/permission_service_context.h" 94 #include "content/browser/permissions/permission_service_context.h"
95 #include "content/browser/permissions/permission_service_impl.h" 95 #include "content/browser/permissions/permission_service_impl.h"
96 #include "content/browser/profiler_message_filter.h" 96 #include "content/browser/profiler_message_filter.h"
97 #include "content/browser/push_messaging/push_messaging_message_filter.h" 97 #include "content/browser/push_messaging/push_messaging_message_filter.h"
98 #include "content/browser/quota_dispatcher_host.h" 98 #include "content/browser/quota_dispatcher_host.h"
99 #include "content/browser/renderer_host/clipboard_message_filter.h" 99 #include "content/browser/renderer_host/clipboard_message_filter.h"
100 #include "content/browser/renderer_host/database_message_filter.h" 100 #include "content/browser/renderer_host/database_message_filter.h"
101 #include "content/browser/renderer_host/file_utilities_message_filter.h" 101 #include "content/browser/renderer_host/file_utilities_message_filter.h"
102 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" 102 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
103 #include "content/browser/renderer_host/media/audio_renderer_host.h" 103 #include "content/browser/renderer_host/media/audio_renderer_host.h"
104 #include "content/browser/renderer_host/media/audio_stream_registry_impl.h"
104 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" 105 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h"
105 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" 106 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h"
106 #include "content/browser/renderer_host/media/video_capture_host.h" 107 #include "content/browser/renderer_host/media/video_capture_host.h"
107 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_p rovider_impl.h" 108 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_p rovider_impl.h"
108 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" 109 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h"
109 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" 110 #include "content/browser/renderer_host/pepper/pepper_message_filter.h"
110 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" 111 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h"
111 #include "content/browser/renderer_host/render_message_filter.h" 112 #include "content/browser/renderer_host/render_message_filter.h"
112 #include "content/browser/renderer_host/render_view_host_delegate.h" 113 #include "content/browser/renderer_host/render_view_host_delegate.h"
113 #include "content/browser/renderer_host/render_view_host_impl.h" 114 #include "content/browser/renderer_host/render_view_host_impl.h"
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 is_process_backgrounded_(false), 671 is_process_backgrounded_(false),
671 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), 672 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
672 browser_context_(browser_context), 673 browser_context_(browser_context),
673 storage_partition_impl_(storage_partition_impl), 674 storage_partition_impl_(storage_partition_impl),
674 sudden_termination_allowed_(true), 675 sudden_termination_allowed_(true),
675 ignore_input_events_(false), 676 ignore_input_events_(false),
676 is_for_guests_only_(is_for_guests_only), 677 is_for_guests_only_(is_for_guests_only),
677 gpu_observer_registered_(false), 678 gpu_observer_registered_(false),
678 delayed_cleanup_needed_(false), 679 delayed_cleanup_needed_(false),
679 within_process_died_observer_(false), 680 within_process_died_observer_(false),
681 audio_stream_registry_(new AudioStreamRegistryImpl(id_)),
o1ka 2016/12/16 09:48:16 It would be cleaner to have a factory method in Au
Max Morin 2016/12/19 16:29:03 Done. The interface in AudioStreamRegistry is for
680 #if BUILDFLAG(ENABLE_WEBRTC) 682 #if BUILDFLAG(ENABLE_WEBRTC)
681 webrtc_eventlog_host_(id_), 683 webrtc_eventlog_host_(id_),
682 #endif 684 #endif
683 max_worker_count_(0), 685 max_worker_count_(0),
684 permission_service_context_(new PermissionServiceContext(this)), 686 permission_service_context_(new PermissionServiceContext(this)),
685 channel_connected_(false), 687 channel_connected_(false),
686 sent_render_process_ready_(false), 688 sent_render_process_ready_(false),
687 #if defined(OS_ANDROID) 689 #if defined(OS_ANDROID)
688 never_signaled_(base::WaitableEvent::ResetPolicy::MANUAL, 690 never_signaled_(base::WaitableEvent::ResetPolicy::MANUAL,
689 base::WaitableEvent::InitialState::NOT_SIGNALED), 691 base::WaitableEvent::InitialState::NOT_SIGNALED),
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 MediaStreamManager* media_stream_manager = 1064 MediaStreamManager* media_stream_manager =
1063 BrowserMainLoop::GetInstance()->media_stream_manager(); 1065 BrowserMainLoop::GetInstance()->media_stream_manager();
1064 // The AudioInputRendererHost and AudioRendererHost needs to be available for 1066 // The AudioInputRendererHost and AudioRendererHost needs to be available for
1065 // lookup, so it's stashed in a member variable. 1067 // lookup, so it's stashed in a member variable.
1066 audio_input_renderer_host_ = new AudioInputRendererHost( 1068 audio_input_renderer_host_ = new AudioInputRendererHost(
1067 GetID(), base::GetProcId(GetHandle()), audio_manager, 1069 GetID(), base::GetProcId(GetHandle()), audio_manager,
1068 media_stream_manager, AudioMirroringManager::GetInstance(), 1070 media_stream_manager, AudioMirroringManager::GetInstance(),
1069 BrowserMainLoop::GetInstance()->user_input_monitor()); 1071 BrowserMainLoop::GetInstance()->user_input_monitor());
1070 AddFilter(audio_input_renderer_host_.get()); 1072 AddFilter(audio_input_renderer_host_.get());
1071 audio_renderer_host_ = new AudioRendererHost( 1073 audio_renderer_host_ = new AudioRendererHost(
1072 GetID(), audio_manager, AudioMirroringManager::GetInstance(), 1074 GetID(), audio_stream_registry_.get(), audio_manager,
1073 media_stream_manager, 1075 AudioMirroringManager::GetInstance(), media_stream_manager,
1074 browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); 1076 browser_context->GetResourceContext()->GetMediaDeviceIDSalt());
1075 AddFilter(audio_renderer_host_.get()); 1077 AddFilter(audio_renderer_host_.get());
1076 AddFilter( 1078 AddFilter(
1077 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service())); 1079 new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service()));
1078 AddFilter(new AppCacheDispatcherHost( 1080 AddFilter(new AppCacheDispatcherHost(
1079 storage_partition_impl_->GetAppCacheService(), GetID())); 1081 storage_partition_impl_->GetAppCacheService(), GetID()));
1080 AddFilter(new ClipboardMessageFilter(blob_storage_context)); 1082 AddFilter(new ClipboardMessageFilter(blob_storage_context));
1081 AddFilter(new DOMStorageMessageFilter( 1083 AddFilter(new DOMStorageMessageFilter(
1082 storage_partition_impl_->GetDOMStorageContext())); 1084 storage_partition_impl_->GetDOMStorageContext()));
1083 AddFilter(new IndexedDBDispatcherHost( 1085 AddFilter(new IndexedDBDispatcherHost(
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2754 void RenderProcessHostImpl::UpdateProcessPriority() { 2756 void RenderProcessHostImpl::UpdateProcessPriority() {
2755 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { 2757 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) {
2756 is_process_backgrounded_ = false; 2758 is_process_backgrounded_ = false;
2757 return; 2759 return;
2758 } 2760 }
2759 2761
2760 // We background a process as soon as it hosts no active audio streams and no 2762 // We background a process as soon as it hosts no active audio streams and no
2761 // visible widgets -- the callers must call this function whenever we 2763 // visible widgets -- the callers must call this function whenever we
2762 // transition in/out of those states. 2764 // transition in/out of those states.
2763 const bool should_background = 2765 const bool should_background =
2764 visible_widgets_ == 0 && !audio_renderer_host_->HasActiveAudio() && 2766 visible_widgets_ == 0 && !audio_stream_registry_->HasActiveAudio() &&
2765 !base::CommandLine::ForCurrentProcess()->HasSwitch( 2767 !base::CommandLine::ForCurrentProcess()->HasSwitch(
2766 switches::kDisableRendererBackgrounding); 2768 switches::kDisableRendererBackgrounding);
2767 2769
2768 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. 2770 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed.
2769 #if !defined(OS_ANDROID) 2771 #if !defined(OS_ANDROID)
2770 if (is_process_backgrounded_ == should_background) 2772 if (is_process_backgrounded_ == should_background)
2771 return; 2773 return;
2772 #endif 2774 #endif
2773 2775
2774 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", 2776 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority",
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3003 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 3005 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
3004 3006
3005 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. 3007 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing.
3006 // Capture the error message in a crash key value. 3008 // Capture the error message in a crash key value.
3007 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); 3009 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error);
3008 bad_message::ReceivedBadMessage(render_process_id, 3010 bad_message::ReceivedBadMessage(render_process_id,
3009 bad_message::RPH_MOJO_PROCESS_ERROR); 3011 bad_message::RPH_MOJO_PROCESS_ERROR);
3010 } 3012 }
3011 3013
3012 } // namespace content 3014 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698