| OLD | NEW |
| 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 // 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 #if defined(OS_WIN) | 314 #if defined(OS_WIN) |
| 315 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, | 315 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, |
| 316 bool* success) { | 316 bool* success) { |
| 317 AddBaseHandleClosePolicy(policy); | 317 AddBaseHandleClosePolicy(policy); |
| 318 GetContentClient()->browser()->PreSpawnRenderer(policy, success); | 318 GetContentClient()->browser()->PreSpawnRenderer(policy, success); |
| 319 } | 319 } |
| 320 | 320 |
| 321 #elif defined(OS_POSIX) | 321 #elif defined(OS_POSIX) |
| 322 virtual bool ShouldUseZygote() OVERRIDE { | 322 virtual bool ShouldUseZygote() OVERRIDE { |
| 323 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 323 const base::CommandLine& browser_command_line = |
| 324 CommandLine::StringType renderer_prefix = | 324 *base::CommandLine::ForCurrentProcess(); |
| 325 base::CommandLine::StringType renderer_prefix = |
| 325 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 326 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| 326 return renderer_prefix.empty(); | 327 return renderer_prefix.empty(); |
| 327 } | 328 } |
| 328 virtual int GetIpcFd() OVERRIDE { | 329 virtual int GetIpcFd() OVERRIDE { |
| 329 return ipc_fd_; | 330 return ipc_fd_; |
| 330 } | 331 } |
| 331 #endif // OS_WIN | 332 #endif // OS_WIN |
| 332 | 333 |
| 333 private: | 334 private: |
| 334 #if defined(OS_POSIX) | 335 #if defined(OS_POSIX) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 475 |
| 475 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 476 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
| 476 | 477 |
| 477 CHECK(!g_exited_main_message_loop); | 478 CHECK(!g_exited_main_message_loop); |
| 478 RegisterHost(GetID(), this); | 479 RegisterHost(GetID(), this); |
| 479 g_all_hosts.Get().set_check_on_null_data(true); | 480 g_all_hosts.Get().set_check_on_null_data(true); |
| 480 // Initialize |child_process_activity_time_| to a reasonable value. | 481 // Initialize |child_process_activity_time_| to a reasonable value. |
| 481 mark_child_process_activity_time(); | 482 mark_child_process_activity_time(); |
| 482 | 483 |
| 483 if (!GetBrowserContext()->IsOffTheRecord() && | 484 if (!GetBrowserContext()->IsOffTheRecord() && |
| 484 !CommandLine::ForCurrentProcess()->HasSwitch( | 485 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 485 switches::kDisableGpuShaderDiskCache)) { | 486 switches::kDisableGpuShaderDiskCache)) { |
| 486 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 487 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 487 base::Bind(&CacheShaderInfo, GetID(), | 488 base::Bind(&CacheShaderInfo, GetID(), |
| 488 storage_partition_impl_->GetPath())); | 489 storage_partition_impl_->GetPath())); |
| 489 } | 490 } |
| 490 | 491 |
| 491 // Note: When we create the RenderProcessHostImpl, it's technically | 492 // Note: When we create the RenderProcessHostImpl, it's technically |
| 492 // backgrounded, because it has no visible listeners. But the process | 493 // backgrounded, because it has no visible listeners. But the process |
| 493 // doesn't actually exist yet, so we'll Background it later, after | 494 // doesn't actually exist yet, so we'll Background it later, after |
| 494 // creation. | 495 // creation. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 544 |
| 544 // We may have some unsent messages at this point, but that's OK. | 545 // We may have some unsent messages at this point, but that's OK. |
| 545 channel_.reset(); | 546 channel_.reset(); |
| 546 while (!queued_messages_.empty()) { | 547 while (!queued_messages_.empty()) { |
| 547 delete queued_messages_.front(); | 548 delete queued_messages_.front(); |
| 548 queued_messages_.pop(); | 549 queued_messages_.pop(); |
| 549 } | 550 } |
| 550 | 551 |
| 551 UnregisterHost(GetID()); | 552 UnregisterHost(GetID()); |
| 552 | 553 |
| 553 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 554 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 554 switches::kDisableGpuShaderDiskCache)) { | 555 switches::kDisableGpuShaderDiskCache)) { |
| 555 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 556 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 556 base::Bind(&RemoveShaderInfo, GetID())); | 557 base::Bind(&RemoveShaderInfo, GetID())); |
| 557 } | 558 } |
| 558 | 559 |
| 559 #if defined(OS_ANDROID) | 560 #if defined(OS_ANDROID) |
| 560 CompositorImpl::DestroyAllSurfaceTextures(GetID()); | 561 CompositorImpl::DestroyAllSurfaceTextures(GetID()); |
| 561 #endif | 562 #endif |
| 562 } | 563 } |
| 563 | 564 |
| 564 void RenderProcessHostImpl::EnableSendQueue() { | 565 void RenderProcessHostImpl::EnableSendQueue() { |
| 565 is_initialized_ = false; | 566 is_initialized_ = false; |
| 566 } | 567 } |
| 567 | 568 |
| 568 bool RenderProcessHostImpl::Init() { | 569 bool RenderProcessHostImpl::Init() { |
| 569 // calling Init() more than once does nothing, this makes it more convenient | 570 // calling Init() more than once does nothing, this makes it more convenient |
| 570 // for the view host which may not be sure in some cases | 571 // for the view host which may not be sure in some cases |
| 571 if (channel_) | 572 if (channel_) |
| 572 return true; | 573 return true; |
| 573 | 574 |
| 574 CommandLine::StringType renderer_prefix; | 575 base::CommandLine::StringType renderer_prefix; |
| 575 #if defined(OS_POSIX) | 576 #if defined(OS_POSIX) |
| 576 // A command prefix is something prepended to the command line of the spawned | 577 // A command prefix is something prepended to the command line of the spawned |
| 577 // process. It is supported only on POSIX systems. | 578 // process. It is supported only on POSIX systems. |
| 578 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 579 const base::CommandLine& browser_command_line = |
| 580 *base::CommandLine::ForCurrentProcess(); |
| 579 renderer_prefix = | 581 renderer_prefix = |
| 580 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 582 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| 581 #endif // defined(OS_POSIX) | 583 #endif // defined(OS_POSIX) |
| 582 | 584 |
| 583 #if defined(OS_LINUX) | 585 #if defined(OS_LINUX) |
| 584 int flags = renderer_prefix.empty() ? ChildProcessHost::CHILD_ALLOW_SELF : | 586 int flags = renderer_prefix.empty() ? ChildProcessHost::CHILD_ALLOW_SELF : |
| 585 ChildProcessHost::CHILD_NORMAL; | 587 ChildProcessHost::CHILD_NORMAL; |
| 586 #else | 588 #else |
| 587 int flags = ChildProcessHost::CHILD_NORMAL; | 589 int flags = ChildProcessHost::CHILD_NORMAL; |
| 588 #endif | 590 #endif |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 628 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
| 627 #endif | 629 #endif |
| 628 in_process_renderer_->StartWithOptions(options); | 630 in_process_renderer_->StartWithOptions(options); |
| 629 | 631 |
| 630 g_in_process_thread = in_process_renderer_->message_loop(); | 632 g_in_process_thread = in_process_renderer_->message_loop(); |
| 631 | 633 |
| 632 OnProcessLaunched(); // Fake a callback that the process is ready. | 634 OnProcessLaunched(); // Fake a callback that the process is ready. |
| 633 } else { | 635 } else { |
| 634 // Build command line for renderer. We call AppendRendererCommandLine() | 636 // Build command line for renderer. We call AppendRendererCommandLine() |
| 635 // first so the process type argument will appear first. | 637 // first so the process type argument will appear first. |
| 636 CommandLine* cmd_line = new CommandLine(renderer_path); | 638 base::CommandLine* cmd_line = new base::CommandLine(renderer_path); |
| 637 if (!renderer_prefix.empty()) | 639 if (!renderer_prefix.empty()) |
| 638 cmd_line->PrependWrapper(renderer_prefix); | 640 cmd_line->PrependWrapper(renderer_prefix); |
| 639 AppendRendererCommandLine(cmd_line); | 641 AppendRendererCommandLine(cmd_line); |
| 640 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 642 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| 641 | 643 |
| 642 // Spawn the child process asynchronously to avoid blocking the UI thread. | 644 // Spawn the child process asynchronously to avoid blocking the UI thread. |
| 643 // As long as there's no renderer prefix, we can use the zygote process | 645 // As long as there's no renderer prefix, we can use the zygote process |
| 644 // at this stage. | 646 // at this stage. |
| 645 child_process_launcher_.reset(new ChildProcessLauncher( | 647 child_process_launcher_.reset(new ChildProcessLauncher( |
| 646 new RendererSandboxedProcessLauncherDelegate(channel_.get()), | 648 new RendererSandboxedProcessLauncherDelegate(channel_.get()), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 670 return; // Waiting on someone to require Mojo. | 672 return; // Waiting on someone to require Mojo. |
| 671 | 673 |
| 672 if (!GetHandle()) | 674 if (!GetHandle()) |
| 673 return; // Waiting on renderer startup. | 675 return; // Waiting on renderer startup. |
| 674 | 676 |
| 675 if (!mojo_application_host_->did_activate()) | 677 if (!mojo_application_host_->did_activate()) |
| 676 mojo_application_host_->Activate(this, GetHandle()); | 678 mojo_application_host_->Activate(this, GetHandle()); |
| 677 } | 679 } |
| 678 | 680 |
| 679 bool RenderProcessHostImpl::ShouldUseMojoChannel() const { | 681 bool RenderProcessHostImpl::ShouldUseMojoChannel() const { |
| 680 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 682 const base::CommandLine& command_line = |
| 683 *base::CommandLine::ForCurrentProcess(); |
| 681 return command_line.HasSwitch(switches::kEnableRendererMojoChannel); | 684 return command_line.HasSwitch(switches::kEnableRendererMojoChannel); |
| 682 } | 685 } |
| 683 | 686 |
| 684 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( | 687 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( |
| 685 const std::string& channel_id) { | 688 const std::string& channel_id) { |
| 686 scoped_refptr<base::SingleThreadTaskRunner> runner = | 689 scoped_refptr<base::SingleThreadTaskRunner> runner = |
| 687 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 690 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 688 if (ShouldUseMojoChannel()) { | 691 if (ShouldUseMojoChannel()) { |
| 689 VLOG(1) << "Mojo Channel is enabled on host"; | 692 VLOG(1) << "Mojo Channel is enabled on host"; |
| 690 return IPC::ChannelProxy::Create( | 693 return IPC::ChannelProxy::Create( |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 AddFilter(new QuotaDispatcherHost( | 882 AddFilter(new QuotaDispatcherHost( |
| 880 GetID(), | 883 GetID(), |
| 881 storage_partition_impl_->GetQuotaManager(), | 884 storage_partition_impl_->GetQuotaManager(), |
| 882 GetContentClient()->browser()->CreateQuotaPermissionContext())); | 885 GetContentClient()->browser()->CreateQuotaPermissionContext())); |
| 883 AddFilter(new GamepadBrowserMessageFilter()); | 886 AddFilter(new GamepadBrowserMessageFilter()); |
| 884 AddFilter(new DeviceMotionMessageFilter()); | 887 AddFilter(new DeviceMotionMessageFilter()); |
| 885 AddFilter(new DeviceOrientationMessageFilter()); | 888 AddFilter(new DeviceOrientationMessageFilter()); |
| 886 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); | 889 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); |
| 887 AddFilter(new HistogramMessageFilter()); | 890 AddFilter(new HistogramMessageFilter()); |
| 888 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 891 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
| 889 if (CommandLine::ForCurrentProcess()->HasSwitch( | 892 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 890 switches::kEnableMemoryBenchmarking)) | 893 switches::kEnableMemoryBenchmarking)) |
| 891 AddFilter(new MemoryBenchmarkMessageFilter()); | 894 AddFilter(new MemoryBenchmarkMessageFilter()); |
| 892 #endif | 895 #endif |
| 893 AddFilter(new VibrationMessageFilter()); | 896 AddFilter(new VibrationMessageFilter()); |
| 894 AddFilter(new PushMessagingMessageFilter( | 897 AddFilter(new PushMessagingMessageFilter( |
| 895 GetID(), storage_partition_impl_->GetServiceWorkerContext())); | 898 GetID(), storage_partition_impl_->GetServiceWorkerContext())); |
| 896 AddFilter(new BatteryStatusMessageFilter()); | 899 AddFilter(new BatteryStatusMessageFilter()); |
| 897 #if defined(OS_ANDROID) | 900 #if defined(OS_ANDROID) |
| 898 AddFilter(new ScreenOrientationMessageFilterAndroid()); | 901 AddFilter(new ScreenOrientationMessageFilterAndroid()); |
| 899 #endif | 902 #endif |
| (...skipping 29 matching lines...) Expand all Loading... |
| 929 IPC::Listener* listener) { | 932 IPC::Listener* listener) { |
| 930 listeners_.AddWithID(listener, routing_id); | 933 listeners_.AddWithID(listener, routing_id); |
| 931 } | 934 } |
| 932 | 935 |
| 933 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { | 936 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { |
| 934 DCHECK(listeners_.Lookup(routing_id) != NULL); | 937 DCHECK(listeners_.Lookup(routing_id) != NULL); |
| 935 listeners_.Remove(routing_id); | 938 listeners_.Remove(routing_id); |
| 936 | 939 |
| 937 #if defined(OS_WIN) | 940 #if defined(OS_WIN) |
| 938 // Dump the handle table if handle auditing is enabled. | 941 // Dump the handle table if handle auditing is enabled. |
| 939 const CommandLine& browser_command_line = | 942 const base::CommandLine& browser_command_line = |
| 940 *CommandLine::ForCurrentProcess(); | 943 *base::CommandLine::ForCurrentProcess(); |
| 941 if (browser_command_line.HasSwitch(switches::kAuditHandles) || | 944 if (browser_command_line.HasSwitch(switches::kAuditHandles) || |
| 942 browser_command_line.HasSwitch(switches::kAuditAllHandles)) { | 945 browser_command_line.HasSwitch(switches::kAuditAllHandles)) { |
| 943 DumpHandles(); | 946 DumpHandles(); |
| 944 | 947 |
| 945 // We wait to close the channels until the child process has finished | 948 // We wait to close the channels until the child process has finished |
| 946 // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone. | 949 // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone. |
| 947 return; | 950 return; |
| 948 } | 951 } |
| 949 #endif | 952 #endif |
| 950 // Keep the one renderer thread around forever in single process mode. | 953 // Keep the one renderer thread around forever in single process mode. |
| 951 if (!run_renderer_in_process()) | 954 if (!run_renderer_in_process()) |
| 952 Cleanup(); | 955 Cleanup(); |
| 953 } | 956 } |
| 954 | 957 |
| 955 void RenderProcessHostImpl::AddObserver(RenderProcessHostObserver* observer) { | 958 void RenderProcessHostImpl::AddObserver(RenderProcessHostObserver* observer) { |
| 956 observers_.AddObserver(observer); | 959 observers_.AddObserver(observer); |
| 957 } | 960 } |
| 958 | 961 |
| 959 void RenderProcessHostImpl::RemoveObserver( | 962 void RenderProcessHostImpl::RemoveObserver( |
| 960 RenderProcessHostObserver* observer) { | 963 RenderProcessHostObserver* observer) { |
| 961 observers_.RemoveObserver(observer); | 964 observers_.RemoveObserver(observer); |
| 962 } | 965 } |
| 963 | 966 |
| 964 void RenderProcessHostImpl::ReceivedBadMessage() { | 967 void RenderProcessHostImpl::ReceivedBadMessage() { |
| 965 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 968 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 966 if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC)) | 969 if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC)) |
| 967 return; | 970 return; |
| 968 | 971 |
| 969 if (run_renderer_in_process()) { | 972 if (run_renderer_in_process()) { |
| 970 // In single process mode it is better if we don't suicide but just | 973 // In single process mode it is better if we don't suicide but just |
| 971 // crash. | 974 // crash. |
| 972 CHECK(false); | 975 CHECK(false); |
| 973 } | 976 } |
| 974 // We kill the renderer but don't include a NOTREACHED, because we want the | 977 // We kill the renderer but don't include a NOTREACHED, because we want the |
| 975 // browser to try to survive when it gets illegal messages from the renderer. | 978 // browser to try to survive when it gets illegal messages from the renderer. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1003 } | 1006 } |
| 1004 | 1007 |
| 1005 bool RenderProcessHostImpl::IsIsolatedGuest() const { | 1008 bool RenderProcessHostImpl::IsIsolatedGuest() const { |
| 1006 return is_isolated_guest_; | 1009 return is_isolated_guest_; |
| 1007 } | 1010 } |
| 1008 | 1011 |
| 1009 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { | 1012 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { |
| 1010 return storage_partition_impl_; | 1013 return storage_partition_impl_; |
| 1011 } | 1014 } |
| 1012 | 1015 |
| 1013 static void AppendCompositorCommandLineFlags(CommandLine* command_line) { | 1016 static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { |
| 1014 if (IsPinchVirtualViewportEnabled()) | 1017 if (IsPinchVirtualViewportEnabled()) |
| 1015 command_line->AppendSwitch(cc::switches::kEnablePinchVirtualViewport); | 1018 command_line->AppendSwitch(cc::switches::kEnablePinchVirtualViewport); |
| 1016 | 1019 |
| 1017 if (IsDelegatedRendererEnabled()) | 1020 if (IsDelegatedRendererEnabled()) |
| 1018 command_line->AppendSwitch(switches::kEnableDelegatedRenderer); | 1021 command_line->AppendSwitch(switches::kEnableDelegatedRenderer); |
| 1019 | 1022 |
| 1020 if (IsImplSidePaintingEnabled()) | 1023 if (IsImplSidePaintingEnabled()) |
| 1021 command_line->AppendSwitch(switches::kEnableImplSidePainting); | 1024 command_line->AppendSwitch(switches::kEnableImplSidePainting); |
| 1022 | 1025 |
| 1023 if (content::IsGpuRasterizationEnabled()) | 1026 if (content::IsGpuRasterizationEnabled()) |
| 1024 command_line->AppendSwitch(switches::kEnableGpuRasterization); | 1027 command_line->AppendSwitch(switches::kEnableGpuRasterization); |
| 1025 | 1028 |
| 1026 if (content::IsForceGpuRasterizationEnabled()) | 1029 if (content::IsForceGpuRasterizationEnabled()) |
| 1027 command_line->AppendSwitch(switches::kForceGpuRasterization); | 1030 command_line->AppendSwitch(switches::kForceGpuRasterization); |
| 1028 | 1031 |
| 1029 // Appending disable-gpu-feature switches due to software rendering list. | 1032 // Appending disable-gpu-feature switches due to software rendering list. |
| 1030 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); | 1033 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); |
| 1031 DCHECK(gpu_data_manager); | 1034 DCHECK(gpu_data_manager); |
| 1032 gpu_data_manager->AppendRendererCommandLine(command_line); | 1035 gpu_data_manager->AppendRendererCommandLine(command_line); |
| 1033 } | 1036 } |
| 1034 | 1037 |
| 1035 void RenderProcessHostImpl::AppendRendererCommandLine( | 1038 void RenderProcessHostImpl::AppendRendererCommandLine( |
| 1036 CommandLine* command_line) const { | 1039 base::CommandLine* command_line) const { |
| 1037 // Pass the process type first, so it shows first in process listings. | 1040 // Pass the process type first, so it shows first in process listings. |
| 1038 command_line->AppendSwitchASCII(switches::kProcessType, | 1041 command_line->AppendSwitchASCII(switches::kProcessType, |
| 1039 switches::kRendererProcess); | 1042 switches::kRendererProcess); |
| 1040 | 1043 |
| 1041 // Now send any options from our own command line we want to propagate. | 1044 // Now send any options from our own command line we want to propagate. |
| 1042 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 1045 const base::CommandLine& browser_command_line = |
| 1046 *base::CommandLine::ForCurrentProcess(); |
| 1043 PropagateBrowserCommandLineToRenderer(browser_command_line, command_line); | 1047 PropagateBrowserCommandLineToRenderer(browser_command_line, command_line); |
| 1044 | 1048 |
| 1045 // Pass on the browser locale. | 1049 // Pass on the browser locale. |
| 1046 const std::string locale = | 1050 const std::string locale = |
| 1047 GetContentClient()->browser()->GetApplicationLocale(); | 1051 GetContentClient()->browser()->GetApplicationLocale(); |
| 1048 command_line->AppendSwitchASCII(switches::kLang, locale); | 1052 command_line->AppendSwitchASCII(switches::kLang, locale); |
| 1049 | 1053 |
| 1050 // If we run base::FieldTrials, we want to pass to their state to the | 1054 // If we run base::FieldTrials, we want to pass to their state to the |
| 1051 // renderer so that it can act in accordance with each state, or record | 1055 // renderer so that it can act in accordance with each state, or record |
| 1052 // histograms relating to the base::FieldTrial states. | 1056 // histograms relating to the base::FieldTrial states. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1065 | 1069 |
| 1066 #if defined(OS_WIN) | 1070 #if defined(OS_WIN) |
| 1067 command_line->AppendSwitchASCII(switches::kDeviceScaleFactor, | 1071 command_line->AppendSwitchASCII(switches::kDeviceScaleFactor, |
| 1068 base::DoubleToString(gfx::GetDPIScale())); | 1072 base::DoubleToString(gfx::GetDPIScale())); |
| 1069 #endif | 1073 #endif |
| 1070 | 1074 |
| 1071 AppendCompositorCommandLineFlags(command_line); | 1075 AppendCompositorCommandLineFlags(command_line); |
| 1072 } | 1076 } |
| 1073 | 1077 |
| 1074 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( | 1078 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
| 1075 const CommandLine& browser_cmd, | 1079 const base::CommandLine& browser_cmd, |
| 1076 CommandLine* renderer_cmd) const { | 1080 base::CommandLine* renderer_cmd) const { |
| 1077 // Propagate the following switches to the renderer command line (along | 1081 // Propagate the following switches to the renderer command line (along |
| 1078 // with any associated values) if present in the browser command line. | 1082 // with any associated values) if present in the browser command line. |
| 1079 static const char* const kSwitchNames[] = { | 1083 static const char* const kSwitchNames[] = { |
| 1080 switches::kAllowInsecureWebSocketFromHttpsOrigin, | 1084 switches::kAllowInsecureWebSocketFromHttpsOrigin, |
| 1081 switches::kAllowLoopbackInPeerConnection, | 1085 switches::kAllowLoopbackInPeerConnection, |
| 1082 switches::kAudioBufferSize, | 1086 switches::kAudioBufferSize, |
| 1083 switches::kAuditAllHandles, | 1087 switches::kAuditAllHandles, |
| 1084 switches::kAuditHandles, | 1088 switches::kAuditHandles, |
| 1085 switches::kBlinkPlatformLogChannels, | 1089 switches::kBlinkPlatformLogChannels, |
| 1086 switches::kBlockCrossSiteDocuments, | 1090 switches::kBlockCrossSiteDocuments, |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1720 | 1724 |
| 1721 // static | 1725 // static |
| 1722 bool RenderProcessHost::run_renderer_in_process() { | 1726 bool RenderProcessHost::run_renderer_in_process() { |
| 1723 return g_run_renderer_in_process_; | 1727 return g_run_renderer_in_process_; |
| 1724 } | 1728 } |
| 1725 | 1729 |
| 1726 // static | 1730 // static |
| 1727 void RenderProcessHost::SetRunRendererInProcess(bool value) { | 1731 void RenderProcessHost::SetRunRendererInProcess(bool value) { |
| 1728 g_run_renderer_in_process_ = value; | 1732 g_run_renderer_in_process_ = value; |
| 1729 | 1733 |
| 1730 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1734 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 1731 if (value) { | 1735 if (value) { |
| 1732 if (!command_line->HasSwitch(switches::kLang)) { | 1736 if (!command_line->HasSwitch(switches::kLang)) { |
| 1733 // Modify the current process' command line to include the browser locale, | 1737 // Modify the current process' command line to include the browser locale, |
| 1734 // as the renderer expects this flag to be set. | 1738 // as the renderer expects this flag to be set. |
| 1735 const std::string locale = | 1739 const std::string locale = |
| 1736 GetContentClient()->browser()->GetApplicationLocale(); | 1740 GetContentClient()->browser()->GetApplicationLocale(); |
| 1737 command_line->AppendSwitchASCII(switches::kLang, locale); | 1741 command_line->AppendSwitchASCII(switches::kLang, locale); |
| 1738 } | 1742 } |
| 1739 // TODO(piman): we should really send configuration through bools rather | 1743 // TODO(piman): we should really send configuration through bools rather |
| 1740 // than by parsing strings, i.e. sending an IPC rather than command line | 1744 // than by parsing strings, i.e. sending an IPC rather than command line |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1757 | 1761 |
| 1758 // static | 1762 // static |
| 1759 bool RenderProcessHost::ShouldTryToUseExistingProcessHost( | 1763 bool RenderProcessHost::ShouldTryToUseExistingProcessHost( |
| 1760 BrowserContext* browser_context, const GURL& url) { | 1764 BrowserContext* browser_context, const GURL& url) { |
| 1761 // Experimental: | 1765 // Experimental: |
| 1762 // If --enable-strict-site-isolation or --site-per-process is enabled, do not | 1766 // If --enable-strict-site-isolation or --site-per-process is enabled, do not |
| 1763 // try to reuse renderer processes when over the limit. (We could allow pages | 1767 // try to reuse renderer processes when over the limit. (We could allow pages |
| 1764 // from the same site to share, if we knew what the given process was | 1768 // from the same site to share, if we knew what the given process was |
| 1765 // dedicated to. Allowing no sharing is simpler for now.) This may cause | 1769 // dedicated to. Allowing no sharing is simpler for now.) This may cause |
| 1766 // resource exhaustion issues if too many sites are open at once. | 1770 // resource exhaustion issues if too many sites are open at once. |
| 1767 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1771 const base::CommandLine& command_line = |
| 1772 *base::CommandLine::ForCurrentProcess(); |
| 1768 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || | 1773 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || |
| 1769 command_line.HasSwitch(switches::kSitePerProcess)) | 1774 command_line.HasSwitch(switches::kSitePerProcess)) |
| 1770 return false; | 1775 return false; |
| 1771 | 1776 |
| 1772 if (run_renderer_in_process()) | 1777 if (run_renderer_in_process()) |
| 1773 return true; | 1778 return true; |
| 1774 | 1779 |
| 1775 // NOTE: Sometimes it's necessary to create more render processes than | 1780 // NOTE: Sometimes it's necessary to create more render processes than |
| 1776 // GetMaxRendererProcessCount(), for instance when we want to create | 1781 // GetMaxRendererProcessCount(), for instance when we want to create |
| 1777 // a renderer process for a browser context that has no existing | 1782 // a renderer process for a browser context that has no existing |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1814 } | 1819 } |
| 1815 | 1820 |
| 1816 // static | 1821 // static |
| 1817 bool RenderProcessHost::ShouldUseProcessPerSite( | 1822 bool RenderProcessHost::ShouldUseProcessPerSite( |
| 1818 BrowserContext* browser_context, | 1823 BrowserContext* browser_context, |
| 1819 const GURL& url) { | 1824 const GURL& url) { |
| 1820 // Returns true if we should use the process-per-site model. This will be | 1825 // Returns true if we should use the process-per-site model. This will be |
| 1821 // the case if the --process-per-site switch is specified, or in | 1826 // the case if the --process-per-site switch is specified, or in |
| 1822 // process-per-site-instance for particular sites (e.g., WebUI). | 1827 // process-per-site-instance for particular sites (e.g., WebUI). |
| 1823 // Note that --single-process is handled in ShouldTryToUseExistingProcessHost. | 1828 // Note that --single-process is handled in ShouldTryToUseExistingProcessHost. |
| 1824 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1829 const base::CommandLine& command_line = |
| 1830 *base::CommandLine::ForCurrentProcess(); |
| 1825 if (command_line.HasSwitch(switches::kProcessPerSite)) | 1831 if (command_line.HasSwitch(switches::kProcessPerSite)) |
| 1826 return true; | 1832 return true; |
| 1827 | 1833 |
| 1828 // We want to consolidate particular sites like WebUI even when we are using | 1834 // We want to consolidate particular sites like WebUI even when we are using |
| 1829 // the process-per-tab or process-per-site-instance models. | 1835 // the process-per-tab or process-per-site-instance models. |
| 1830 // Note: DevTools pages have WebUI type but should not reuse the same host. | 1836 // Note: DevTools pages have WebUI type but should not reuse the same host. |
| 1831 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( | 1837 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( |
| 1832 browser_context, url) && | 1838 browser_context, url) && |
| 1833 !url.SchemeIs(kChromeDevToolsScheme)) { | 1839 !url.SchemeIs(kChromeDevToolsScheme)) { |
| 1834 return true; | 1840 return true; |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2345 } | 2351 } |
| 2346 | 2352 |
| 2347 void RenderProcessHostImpl::OnDeletedGpuMemoryBuffer( | 2353 void RenderProcessHostImpl::OnDeletedGpuMemoryBuffer( |
| 2348 gfx::GpuMemoryBufferType type, | 2354 gfx::GpuMemoryBufferType type, |
| 2349 const gfx::GpuMemoryBufferId& id) { | 2355 const gfx::GpuMemoryBufferId& id) { |
| 2350 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2356 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2351 GpuMemoryBufferImpl::DeletedByChildProcess(type, id, GetHandle()); | 2357 GpuMemoryBufferImpl::DeletedByChildProcess(type, id, GetHandle()); |
| 2352 } | 2358 } |
| 2353 | 2359 |
| 2354 } // namespace content | 2360 } // namespace content |
| OLD | NEW |