* before going on, must read http://www.chromium.org/developers/design-documents/inter-process-communication
I demonstrate how Browser process receives "OnRequestResource" request from Render process.
1. ChannelProxy and Channel creation on ui thread
- when loading url, RenderProcessHost is created.- at that time, ChannelProxy and Channel are craeted.
- after creating Channel in ChannelProxy::Init(), post OnChannelOpened task to io thread.
context_->ipc_task_runner()->PostTask(FROM_HERE, base::Bind(&Context::OnChannelOpened, context_.get()));
FYI, RenderProcessHostImpl::Init() installs many(~30) filters into ChannelProxy via RenderProcessHostImpl::CreateMessageFilters() after creating ChannelProxy.
IPC::Channel::Channel() at ipc_channel_posix.cc:955 0x1abe7f0 IPC::ChannelProxy::Context::CreateChannel() at ipc_channel_proxy.cc:68 0x1abfbc3 IPC::ChannelProxy::Init() at ipc_channel_proxy.cc:329 0x1ac0d8d IPC::ChannelProxy::ChannelProxy() at ipc_channel_proxy.cc:294 0x1ac0a07 content::RenderProcessHostImpl::Init() at render_process_host_impl.cc:495 0x5bd1b3 content::RenderViewHostImpl::CreateRenderView() at render_view_host_impl.cc:236 0x5d03fb content::WebContentsImpl::CreateRenderViewForRenderManager() at web_contents_impl.cc:3,494 0x666e55 content::RenderViewHostManager::InitRenderView() at render_view_host_manager.cc:663 0x89f0cc content::RenderViewHostManager::CreateRenderView() at render_view_host_manager.cc:639 0x89ef95 content::RenderViewHostManager::UpdateRendererStateForNavigate() at render_view_host_manager.cc:814 0x89fc7d content::RenderViewHostManager::Navigate() at render_view_host_manager.cc:122 0x89d35a content::WebContentsImpl::NavigateToEntry() at web_contents_impl.cc:1,713 0x65f469 content::WebContentsImpl::NavigateToPendingEntry() at web_contents_impl.cc:1,680 0x65f126 content::NavigationControllerImpl::NavigateToPendingEntry() at navigation_controller_impl.cc:1,537 0x898edb content::NavigationControllerImpl::LoadEntry() at navigation_controller_impl.cc:398 0x893c0e content::NavigationControllerImpl::LoadURLWithParams() at navigation_controller_impl.cc:685 0x894f73 content::Shell::LoadURLForFrame() at shell.cc:180 0x458723 content::Shell::LoadURL() at shell.cc:172 0x45866d content::Shell::OnURLEntryActivate() at shell_gtk.cc:284 0x45bc41 content::Shell::OnURLEntryActivateThunk() at shell.h:207 0x45bf12 g_closure_invoke() at gclosure.c:777 0x7ffff7048140
2. Channel connection established on io thread
For example, register OnLibeventNotification callback.- register callback on fd
event_set(evt.get(), fd, event_mask, OnLibeventNotification, controller);- set Watcher (ChannelImpl extends) that is stored in Closure.
controller->set_watcher(delegate);Back trace
base::MessagePumpLibevent::WatchFileDescriptor() at message_pump_libevent.cc:186 0x925adf base::MessageLoopForIO::WatchFileDescriptor() at message_loop.cc:829 0x972a2a IPC::Channel::ChannelImpl::AcceptConnection() at ipc_channel_posix.cc:671 0x1abd265 IPC::Channel::ChannelImpl::Connect() at ipc_channel_posix.cc:345 0x1abb2b4 IPC::Channel::Connect() at ipc_channel_posix.cc:963 0x1abe8ea IPC::ChannelProxy::Context::OnChannelOpened() at ipc_channel_proxy.cc:145 0x1ac00bb base::internal::RunnableAdapter{void () at bind_internal.h:134 0x1ac36a1 base::internal::InvokeHelper{false, void, base::internal::RunnableAdapter{void () at bind_internal.h:871 0x1ac32fc base::internal::Invoker{1, base::internal::BindState{base::internal::RunnableAdapter{void () at bind_internal.h:1,173 0x1ac2e37 base::Callback{void () at callback.h:396 0x44840a base::MessageLoop::RunTask() at message_loop.cc:484 0x971c03
3. Receive "OnRequestResource" request on io thread.
- MessagePumpLibevent::FileDescriptorWatcher::OnFileCanReadWithoutBlocking dispatches the event to Watcher(ChannelImpl)- ChannelImpl dispatches the event to Channel::Context
- BrowserMessageFilter intercepts the event
- BrowserMessageFilter dispatches the event to ResourceMessageFilter
It is very consistent with chromium's doc: http://dev.chromium.org/developers/design-documents/multi-process-resource-loading
content::ResourceDispatcherHostImpl::OnRequestResource() at resource_dispatcher_host_impl.cc:884 0x585dcd ResourceHostMsg_RequestResource::Dispatch{content::ResourceDispatcherHostImpl, content::ResourceDispatcherHostImpl, int, ResourceHostMsg_Request const&}() at resource_messages.h:269 0x58efe2 content::ResourceDispatcherHostImpl::OnMessageReceived() at resource_dispatcher_host_impl.cc:841 0x58565f content::ResourceMessageFilter::OnMessageReceived() at resource_message_filter.cc:49 0x5a8029 content::BrowserMessageFilter::DispatchMessage() at browser_message_filter.cc:136 0x4daafa content::BrowserMessageFilter::OnMessageReceived() at browser_message_filter.cc:52 0x4da62a IPC::ChannelProxy::Context::TryFilters() at ipc_channel_proxy.cc:79 0x1abfc63 IPC::ChannelProxy::Context::OnMessageReceived() at ipc_channel_proxy.cc:93 0x1abfce7 IPC::internal::ChannelReader::DispatchInputData() at ipc_channel_reader.cc:90 0x1ac44a8 IPC::internal::ChannelReader::ProcessIncomingMessages() at ipc_channel_reader.cc:32 0x1ac4031 IPC::Channel::ChannelImpl::OnFileCanReadWithoutBlocking() at ipc_channel_posix.cc:641 0x1abd047 base::MessagePumpLibevent::FileDescriptorWatcher::OnFileCanReadWithoutBlocking() at message_pump_libevent.cc:102 0x924f10 base::MessagePumpLibevent::OnLibeventNotification() at message_pump_libevent.cc:359 0x926966 event_process_active() at event.c:385 0x1c53385 event_base_loop() at event.c:525 0x1c536a8 base::MessagePumpLibevent::Run() at message_pump_libevent.cc:262 0x925ee9 base::MessageLoop::RunInternal() at message_loop.cc:441 0x97179e base::MessageLoop::RunHandler() at message_loop.cc:414 0x971648 base::RunLoop::Run() at run_loop.cc:45 0x9a2020 base::MessageLoop::Run() at message_loop.cc:321 0x970ee6 base::Thread::Run() at thread.cc:159 0x9d6092
No comments:
Post a Comment