Android 平台下:
MessageLoop::Run
|
MessagePump(this)::Run
|
MessagePumpAndroid(UI线程) MessagePumpLibevent(IO线程) MessagePumpDefault(其他线程)
(自定义task和UI消息) (自定义task和IO消息) (自定义task)
|
|
DoWork
DoDelayedWork
DoIdleWork
1. 自定义task
MessageLoop::PostTask(task)
|
| ---> incoming_queue_.push(task) (自定义task queue)
|
| ---> message_loop_->ScheduleWork() | ---> MessagePumpAndroid::ScheduleWork ---> Java_SystemMessageHandler_setTimer()
| ---> MessagePumpLibevent::ScheduleWork ---> write(wakeup_pipe_in_, &buf, 1)
| ---> MessagePumpDefault::ScheduleWork ---> WaitableEvent.Signal()
2. render进程向browser进程发消息
bool RenderWidget::Send(IPC::Message* msg)
|
RenderThreadImpl::Send(IPC::Message* msg)
|
ChildThread::Send(IPC::Message* msg)
|
SyncChannel::Send(IPC::Message* msg)
|
ChannelProxy::Send(msg)
3. browser进程向render进程发消息
bool RenderWidgetHostImpl::Send(IPC::Message* msg)
|
bool RenderProcessHostImpl::Send(IPC::Message* msg)
|
IPC::ChannelProxy::Send(msg)
|
ipc_task_runner()->PostTask(ChannelProxy::Context::OnSendMessage)
|
ChannelProxy::Context::OnSendMessage
|
bool Channel::ChannelImpl::Send(Message* message)
|
| ---> output_queue_.push(message)
|
| ---> Channel::ChannelImpl::ProcessOutgoingMessages() ---> write(pipe_, out_bytes, amt_to_write)