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

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

Issue 1903663004: IPC: Fix attachment brokering race condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from tsepez. Created 4 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
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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 if (renderer_path.empty()) 721 if (renderer_path.empty())
722 return false; 722 return false;
723 723
724 channel_connected_ = false; 724 channel_connected_ = false;
725 sent_render_process_ready_ = false; 725 sent_render_process_ready_ = false;
726 726
727 // Setup the IPC channel. 727 // Setup the IPC channel.
728 const std::string channel_id = 728 const std::string channel_id =
729 IPC::Channel::GenerateVerifiedChannelID(std::string()); 729 IPC::Channel::GenerateVerifiedChannelID(std::string());
730 channel_ = CreateChannelProxy(channel_id); 730 channel_ = CreateChannelProxy(channel_id);
731 #if USE_ATTACHMENT_BROKER
732 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel(
733 channel_.get(), content::BrowserThread::GetMessageLoopProxyForThread(
734 content::BrowserThread::IO));
735 #endif
736 731
737 // Call the embedder first so that their IPC filters have priority. 732 // Call the embedder first so that their IPC filters have priority.
738 GetContentClient()->browser()->RenderProcessWillLaunch(this); 733 GetContentClient()->browser()->RenderProcessWillLaunch(this);
739 734
740 CreateMessageFilters(); 735 CreateMessageFilters();
741 RegisterMojoServices(); 736 RegisterMojoServices();
742 737
743 if (run_renderer_in_process()) { 738 if (run_renderer_in_process()) {
744 DCHECK(g_renderer_main_thread_factory); 739 DCHECK(g_renderer_main_thread_factory);
745 // Crank up a thread and run the initialization there. With the way that 740 // Crank up a thread and run the initialization there. With the way that
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 // for Android WebView to maintain backward compatibility. 816 // for Android WebView to maintain backward compatibility.
822 // See crbug.com/526842 for details. 817 // See crbug.com/526842 for details.
823 #if defined(OS_ANDROID) 818 #if defined(OS_ANDROID)
824 if (GetContentClient()->UsingSynchronousCompositing()) { 819 if (GetContentClient()->UsingSynchronousCompositing()) {
825 return IPC::SyncChannel::Create( 820 return IPC::SyncChannel::Create(
826 IPC::ChannelMojo::CreateServerFactory(std::move(handle)), this, 821 IPC::ChannelMojo::CreateServerFactory(std::move(handle)), this,
827 runner.get(), true, &never_signaled_); 822 runner.get(), true, &never_signaled_);
828 } 823 }
829 #endif // OS_ANDROID 824 #endif // OS_ANDROID
830 825
831 return IPC::ChannelProxy::Create( 826 std::unique_ptr<IPC::ChannelProxy> channel(
Charlie Reis 2016/04/22 20:00:45 Your CL description makes it sounds like this call
erikchen 2016/04/25 20:10:57 I considered this. The reason I chose not to do th
832 IPC::ChannelMojo::CreateServerFactory(std::move(handle)), this, 827 new IPC::ChannelProxy(this, runner.get()));
833 runner.get()); 828 #if USE_ATTACHMENT_BROKER
829 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel(
830 channel.get(), content::BrowserThread::GetMessageLoopProxyForThread(
831 content::BrowserThread::IO));
832 #endif
833 channel->Init(IPC::ChannelMojo::CreateServerFactory(std::move(handle)), true);
834 return channel;
834 } 835 }
835 836
836 // Do NOT expand ifdef or run time condition checks here! See comment above. 837 // Do NOT expand ifdef or run time condition checks here! See comment above.
837 #if defined(OS_ANDROID) 838 #if defined(OS_ANDROID)
838 if (GetContentClient()->UsingSynchronousCompositing()) { 839 if (GetContentClient()->UsingSynchronousCompositing()) {
839 return IPC::SyncChannel::Create(channel_id, IPC::Channel::MODE_SERVER, this, 840 return IPC::SyncChannel::Create(channel_id, IPC::Channel::MODE_SERVER, this,
840 runner.get(), true, &never_signaled_); 841 runner.get(), true, &never_signaled_);
841 } 842 }
842 #endif // OS_ANDROID 843 #endif // OS_ANDROID
843 844
844 return IPC::ChannelProxy::Create(channel_id, IPC::Channel::MODE_SERVER, this, 845 std::unique_ptr<IPC::ChannelProxy> channel(
845 runner.get()); 846 new IPC::ChannelProxy(this, runner.get()));
847 #if USE_ATTACHMENT_BROKER
848 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel(
849 channel.get(), content::BrowserThread::GetMessageLoopProxyForThread(
850 content::BrowserThread::IO));
851 #endif
852 channel->Init(channel_id, IPC::Channel::MODE_SERVER, true);
853 return channel;
846 } 854 }
847 855
848 void RenderProcessHostImpl::CreateMessageFilters() { 856 void RenderProcessHostImpl::CreateMessageFilters() {
849 DCHECK_CURRENTLY_ON(BrowserThread::UI); 857 DCHECK_CURRENTLY_ON(BrowserThread::UI);
850 const base::CommandLine& browser_command_line = 858 const base::CommandLine& browser_command_line =
851 *base::CommandLine::ForCurrentProcess(); 859 *base::CommandLine::ForCurrentProcess();
852 AddFilter(new ResourceSchedulerFilter(GetID())); 860 AddFilter(new ResourceSchedulerFilter(GetID()));
853 MediaInternals* media_internals = MediaInternals::GetInstance(); 861 MediaInternals* media_internals = MediaInternals::GetInstance();
854 media::AudioManager* audio_manager = 862 media::AudioManager* audio_manager =
855 BrowserMainLoop::GetInstance()->audio_manager(); 863 BrowserMainLoop::GetInstance()->audio_manager();
(...skipping 1969 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 2833
2826 // Skip widgets in other processes. 2834 // Skip widgets in other processes.
2827 if (rvh->GetProcess()->GetID() != GetID()) 2835 if (rvh->GetProcess()->GetID() != GetID())
2828 continue; 2836 continue;
2829 2837
2830 rvh->OnWebkitPreferencesChanged(); 2838 rvh->OnWebkitPreferencesChanged();
2831 } 2839 }
2832 } 2840 }
2833 2841
2834 } // namespace content 2842 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698