Chromium Code Reviews| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 #include "content/public/common/process_type.h" | 129 #include "content/public/common/process_type.h" |
| 130 #include "content/public/common/resource_type.h" | 130 #include "content/public/common/resource_type.h" |
| 131 #include "content/public/common/result_codes.h" | 131 #include "content/public/common/result_codes.h" |
| 132 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 132 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 133 #include "content/public/common/url_constants.h" | 133 #include "content/public/common/url_constants.h" |
| 134 #include "gpu/command_buffer/service/gpu_switches.h" | 134 #include "gpu/command_buffer/service/gpu_switches.h" |
| 135 #include "ipc/ipc_channel.h" | 135 #include "ipc/ipc_channel.h" |
| 136 #include "ipc/ipc_logging.h" | 136 #include "ipc/ipc_logging.h" |
| 137 #include "ipc/ipc_switches.h" | 137 #include "ipc/ipc_switches.h" |
| 138 #include "ipc/mojo/ipc_channel_mojo.h" | 138 #include "ipc/mojo/ipc_channel_mojo.h" |
| 139 #include "ipc/mojo/ipc_channel_mojo_host.h" | |
| 139 #include "media/base/media_switches.h" | 140 #include "media/base/media_switches.h" |
| 140 #include "net/url_request/url_request_context_getter.h" | 141 #include "net/url_request/url_request_context_getter.h" |
| 141 #include "ppapi/shared_impl/ppapi_switches.h" | 142 #include "ppapi/shared_impl/ppapi_switches.h" |
| 142 #include "storage/browser/fileapi/sandbox_file_system_backend.h" | 143 #include "storage/browser/fileapi/sandbox_file_system_backend.h" |
| 143 #include "third_party/skia/include/core/SkBitmap.h" | 144 #include "third_party/skia/include/core/SkBitmap.h" |
| 144 #include "ui/base/ui_base_switches.h" | 145 #include "ui/base/ui_base_switches.h" |
| 145 #include "ui/events/event_switches.h" | 146 #include "ui/events/event_switches.h" |
| 146 #include "ui/gfx/switches.h" | 147 #include "ui/gfx/switches.h" |
| 147 #include "ui/gl/gl_switches.h" | 148 #include "ui/gl/gl_switches.h" |
| 148 #include "ui/native_theme/native_theme_switches.h" | 149 #include "ui/native_theme/native_theme_switches.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 | 420 |
| 420 // static | 421 // static |
| 421 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { | 422 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { |
| 422 g_max_renderer_count_override = count; | 423 g_max_renderer_count_override = count; |
| 423 } | 424 } |
| 424 | 425 |
| 425 RenderProcessHostImpl::RenderProcessHostImpl( | 426 RenderProcessHostImpl::RenderProcessHostImpl( |
| 426 BrowserContext* browser_context, | 427 BrowserContext* browser_context, |
| 427 StoragePartitionImpl* storage_partition_impl, | 428 StoragePartitionImpl* storage_partition_impl, |
| 428 bool is_isolated_guest) | 429 bool is_isolated_guest) |
| 429 : fast_shutdown_started_(false), | 430 : channel_host_(new IPC::ChannelMojoHost( |
|
viettrungluu
2014/09/17 17:33:15
Do you want to create this even if ShouldUseMojoCh
Hajime Morrita
2014/09/17 19:33:48
Good point. make it lazy.
| |
| 431 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))), | |
| 432 fast_shutdown_started_(false), | |
| 430 deleting_soon_(false), | 433 deleting_soon_(false), |
| 431 #ifndef NDEBUG | 434 #ifndef NDEBUG |
| 432 is_self_deleted_(false), | 435 is_self_deleted_(false), |
| 433 #endif | 436 #endif |
| 434 pending_views_(0), | 437 pending_views_(0), |
| 435 mojo_application_host_(new MojoApplicationHost), | 438 mojo_application_host_(new MojoApplicationHost), |
| 436 visible_widgets_(0), | 439 visible_widgets_(0), |
| 437 backgrounded_(true), | 440 backgrounded_(true), |
| 438 is_initialized_(false), | 441 is_initialized_(false), |
| 439 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 442 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 return command_line.HasSwitch(switches::kEnableRendererMojoChannel); | 646 return command_line.HasSwitch(switches::kEnableRendererMojoChannel); |
| 644 } | 647 } |
| 645 | 648 |
| 646 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( | 649 scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( |
| 647 const std::string& channel_id) { | 650 const std::string& channel_id) { |
| 648 scoped_refptr<base::SingleThreadTaskRunner> runner = | 651 scoped_refptr<base::SingleThreadTaskRunner> runner = |
| 649 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 652 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 650 if (ShouldUseMojoChannel()) { | 653 if (ShouldUseMojoChannel()) { |
| 651 VLOG(1) << "Mojo Channel is enabled on host"; | 654 VLOG(1) << "Mojo Channel is enabled on host"; |
| 652 return IPC::ChannelProxy::Create( | 655 return IPC::ChannelProxy::Create( |
| 653 IPC::ChannelMojo::CreateFactory( | 656 IPC::ChannelMojo::CreateServerFactory(channel_host_.get(), channel_id), |
| 654 channel_id, IPC::Channel::MODE_SERVER, runner), | 657 this, |
| 655 this, runner.get()); | 658 runner.get()); |
| 656 } | 659 } |
| 657 | 660 |
| 658 return IPC::ChannelProxy::Create( | 661 return IPC::ChannelProxy::Create( |
| 659 channel_id, IPC::Channel::MODE_SERVER, this, runner.get()); | 662 channel_id, IPC::Channel::MODE_SERVER, this, runner.get()); |
| 660 } | 663 } |
| 661 | 664 |
| 662 void RenderProcessHostImpl::CreateMessageFilters() { | 665 void RenderProcessHostImpl::CreateMessageFilters() { |
| 663 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 666 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 664 AddFilter(new ResourceSchedulerFilter(GetID())); | 667 AddFilter(new ResourceSchedulerFilter(GetID())); |
| 665 MediaInternals* media_internals = MediaInternals::GetInstance(); | 668 MediaInternals* media_internals = MediaInternals::GetInstance(); |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2063 NotificationService::current()->Notify( | 2066 NotificationService::current()->Notify( |
| 2064 NOTIFICATION_RENDERER_PROCESS_CREATED, | 2067 NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 2065 Source<RenderProcessHost>(this), | 2068 Source<RenderProcessHost>(this), |
| 2066 NotificationService::NoDetails()); | 2069 NotificationService::NoDetails()); |
| 2067 | 2070 |
| 2068 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. | 2071 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
| 2069 // This way, Mojo can be safely used from the renderer in response to any | 2072 // This way, Mojo can be safely used from the renderer in response to any |
| 2070 // Chrome IPC message. | 2073 // Chrome IPC message. |
| 2071 mojo_application_host_->Activate(this, GetHandle()); | 2074 mojo_application_host_->Activate(this, GetHandle()); |
| 2072 | 2075 |
| 2076 channel_host_->OnClientLaunched(child_process_launcher_->GetHandle()); | |
| 2077 | |
| 2073 while (!queued_messages_.empty()) { | 2078 while (!queued_messages_.empty()) { |
| 2074 Send(queued_messages_.front()); | 2079 Send(queued_messages_.front()); |
| 2075 queued_messages_.pop(); | 2080 queued_messages_.pop(); |
| 2076 } | 2081 } |
| 2077 | 2082 |
| 2078 #if defined(ENABLE_WEBRTC) | 2083 #if defined(ENABLE_WEBRTC) |
| 2079 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) | 2084 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) |
| 2080 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); | 2085 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); |
| 2081 #endif | 2086 #endif |
| 2082 } | 2087 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2203 | 2208 |
| 2204 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2209 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
| 2205 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2210 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2206 DCHECK_GT(worker_ref_count_, 0); | 2211 DCHECK_GT(worker_ref_count_, 0); |
| 2207 --worker_ref_count_; | 2212 --worker_ref_count_; |
| 2208 if (worker_ref_count_ == 0) | 2213 if (worker_ref_count_ == 0) |
| 2209 Cleanup(); | 2214 Cleanup(); |
| 2210 } | 2215 } |
| 2211 | 2216 |
| 2212 } // namespace content | 2217 } // namespace content |
| OLD | NEW |