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

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

Issue 2222373002: Revert of Eliminate kMojoChannelToken usage for render processes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/child/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 #include "content/public/common/result_codes.h" 158 #include "content/public/common/result_codes.h"
159 #include "content/public/common/sandboxed_process_launcher_delegate.h" 159 #include "content/public/common/sandboxed_process_launcher_delegate.h"
160 #include "content/public/common/url_constants.h" 160 #include "content/public/common/url_constants.h"
161 #include "device/battery/battery_monitor_impl.h" 161 #include "device/battery/battery_monitor_impl.h"
162 #include "gpu/GLES2/gl2extchromium.h" 162 #include "gpu/GLES2/gl2extchromium.h"
163 #include "gpu/command_buffer/client/gpu_switches.h" 163 #include "gpu/command_buffer/client/gpu_switches.h"
164 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 164 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
165 #include "gpu/command_buffer/service/gpu_switches.h" 165 #include "gpu/command_buffer/service/gpu_switches.h"
166 #include "ipc/attachment_broker.h" 166 #include "ipc/attachment_broker.h"
167 #include "ipc/attachment_broker_privileged.h" 167 #include "ipc/attachment_broker_privileged.h"
168 #include "ipc/ipc.mojom.h"
169 #include "ipc/ipc_channel.h" 168 #include "ipc/ipc_channel.h"
170 #include "ipc/ipc_channel_mojo.h" 169 #include "ipc/ipc_channel_mojo.h"
171 #include "ipc/ipc_logging.h" 170 #include "ipc/ipc_logging.h"
172 #include "ipc/ipc_switches.h" 171 #include "ipc/ipc_switches.h"
173 #include "media/base/media_switches.h" 172 #include "media/base/media_switches.h"
174 #include "mojo/edk/embedder/embedder.h" 173 #include "mojo/edk/embedder/embedder.h"
175 #include "net/url_request/url_request_context_getter.h" 174 #include "net/url_request/url_request_context_getter.h"
176 #include "ppapi/shared_impl/ppapi_switches.h" 175 #include "ppapi/shared_impl/ppapi_switches.h"
177 #include "services/shell/public/cpp/connection.h" 176 #include "services/shell/public/cpp/connection.h"
178 #include "services/shell/public/cpp/interface_provider.h" 177 #include "services/shell/public/cpp/interface_provider.h"
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 // Crank up a thread and run the initialization there. With the way that 814 // Crank up a thread and run the initialization there. With the way that
816 // messages flow between the browser and renderer, this thread is required 815 // messages flow between the browser and renderer, this thread is required
817 // to prevent a deadlock in single-process mode. Since the primordial 816 // to prevent a deadlock in single-process mode. Since the primordial
818 // thread in the renderer process runs the WebKit code and can sometimes 817 // thread in the renderer process runs the WebKit code and can sometimes
819 // make blocking calls to the UI thread (i.e. this thread), they need to run 818 // make blocking calls to the UI thread (i.e. this thread), they need to run
820 // on separate threads. 819 // on separate threads.
821 in_process_renderer_.reset( 820 in_process_renderer_.reset(
822 g_renderer_main_thread_factory(InProcessChildThreadParams( 821 g_renderer_main_thread_factory(InProcessChildThreadParams(
823 channel_id, 822 channel_id,
824 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), 823 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
825 std::string(), mojo_child_connection_->service_token()))); 824 mojo_channel_token_,
825 mojo_child_connection_->service_token())));
826 826
827 base::Thread::Options options; 827 base::Thread::Options options;
828 #if defined(OS_WIN) && !defined(OS_MACOSX) 828 #if defined(OS_WIN) && !defined(OS_MACOSX)
829 // In-process plugins require this to be a UI message loop. 829 // In-process plugins require this to be a UI message loop.
830 options.message_loop_type = base::MessageLoop::TYPE_UI; 830 options.message_loop_type = base::MessageLoop::TYPE_UI;
831 #else 831 #else
832 // We can't have multiple UI loops on Linux and Android, so we don't support 832 // We can't have multiple UI loops on Linux and Android, so we don't support
833 // in-process plugins. 833 // in-process plugins.
834 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; 834 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT;
835 #endif 835 #endif
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 875
876 is_initialized_ = true; 876 is_initialized_ = true;
877 init_time_ = base::TimeTicks::Now(); 877 init_time_ = base::TimeTicks::Now();
878 return true; 878 return true;
879 } 879 }
880 880
881 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( 881 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy(
882 const std::string& channel_id) { 882 const std::string& channel_id) {
883 scoped_refptr<base::SingleThreadTaskRunner> runner = 883 scoped_refptr<base::SingleThreadTaskRunner> runner =
884 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); 884 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
885 IPC::mojom::ChannelBootstrapPtr bootstrap; 885 mojo_channel_token_ = mojo::edk::GenerateRandomToken();
886 GetRemoteInterfaces()->GetInterface(&bootstrap); 886 mojo::ScopedMessagePipeHandle handle =
887 mojo::edk::CreateParentMessagePipe(mojo_channel_token_, child_token_);
888
887 std::unique_ptr<IPC::ChannelFactory> channel_factory = 889 std::unique_ptr<IPC::ChannelFactory> channel_factory =
888 IPC::ChannelMojo::CreateServerFactory( 890 IPC::ChannelMojo::CreateServerFactory(std::move(handle), runner);
889 bootstrap.PassInterface().PassHandle(), runner);
890 891
891 // Do NOT expand ifdef or run time condition checks here! Synchronous 892 // Do NOT expand ifdef or run time condition checks here! Synchronous
892 // IPCs from browser process are banned. It is only narrowly allowed 893 // IPCs from browser process are banned. It is only narrowly allowed
893 // for Android WebView to maintain backward compatibility. 894 // for Android WebView to maintain backward compatibility.
894 // See crbug.com/526842 for details. 895 // See crbug.com/526842 for details.
895 #if defined(OS_ANDROID) 896 #if defined(OS_ANDROID)
896 if (GetContentClient()->UsingSynchronousCompositing()) { 897 if (GetContentClient()->UsingSynchronousCompositing()) {
897 return IPC::SyncChannel::Create( 898 return IPC::SyncChannel::Create(
898 std::move(channel_factory), this, runner.get(), true, &never_signaled_); 899 std::move(channel_factory), this, runner.get(), true, &never_signaled_);
899 } 900 }
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 command_line->AppendSwitch(switches::kEnablePinch); 1412 command_line->AppendSwitch(switches::kEnablePinch);
1412 1413
1413 #if defined(OS_WIN) 1414 #if defined(OS_WIN)
1414 command_line->AppendSwitchASCII( 1415 command_line->AppendSwitchASCII(
1415 switches::kDeviceScaleFactor, 1416 switches::kDeviceScaleFactor,
1416 base::DoubleToString(display::win::GetDPIScale())); 1417 base::DoubleToString(display::win::GetDPIScale()));
1417 #endif 1418 #endif
1418 1419
1419 AppendCompositorCommandLineFlags(command_line); 1420 AppendCompositorCommandLineFlags(command_line);
1420 1421
1422 if (!mojo_channel_token_.empty()) {
1423 command_line->AppendSwitchASCII(switches::kMojoChannelToken,
1424 mojo_channel_token_);
1425 }
1421 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, 1426 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
1422 mojo_child_connection_->service_token()); 1427 mojo_child_connection_->service_token());
1423 } 1428 }
1424 1429
1425 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( 1430 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
1426 const base::CommandLine& browser_cmd, 1431 const base::CommandLine& browser_cmd,
1427 base::CommandLine* renderer_cmd) const { 1432 base::CommandLine* renderer_cmd) const {
1428 // Propagate the following switches to the renderer command line (along 1433 // Propagate the following switches to the renderer command line (along
1429 // with any associated values) if present in the browser command line. 1434 // with any associated values) if present in the browser command line.
1430 static const char* const kSwitchNames[] = { 1435 static const char* const kSwitchNames[] = {
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 2827 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
2823 2828
2824 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias 2829 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias
2825 // enough information here so that we can determine what the bad message was. 2830 // enough information here so that we can determine what the bad message was.
2826 base::debug::Alias(&error); 2831 base::debug::Alias(&error);
2827 bad_message::ReceivedBadMessage(process.get(), 2832 bad_message::ReceivedBadMessage(process.get(),
2828 bad_message::RPH_MOJO_PROCESS_ERROR); 2833 bad_message::RPH_MOJO_PROCESS_ERROR);
2829 } 2834 }
2830 2835
2831 } // namespace content 2836 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/child/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698