打开一个tab到加载完成的流程

shell新开一个tab到敲入 url浏览网页的流程,从shellnativeblink. 如何传递命令的.Native blink 收到命令后如何处理。如何加载网页,如何解析,渲染的。

先纵向过一下所有涉及到的模块,然后再各个模块横向拓展开分析

TitleBar包含一个TabPageView.

TabPageView引用了一个TabPageView.TabPageListener.

TabPageView.TabPageListener.onNewTab()响应新tab事件.

...各种tab的初始化...

WebViewTab.loadUrl()

->WebViewV16.loadUrl()

->MyWebView.loadUrl()

->WebView.loadUrl()

->WebViewChromium.loadUrl()

->WebViewChromium.loadUrlOnUiThread()

->AwContents.loadUrl()

->ContentViewCore::loadUrl()

->nativeLoadUrl()

-----------native 界限---------------

->ContentViewCoreImpl::LoadUrl(),content模块

->GetWebContents()->GetController()->LoadURLWithParams

->NavigationControllerImpl::LoadURLWithParams()

->LoadEntry()

->SetPendingEntry()

NavigateToPendingEntry()

->WebContentsImpl::NavigateToPendingEntry().webContents什么作用,怎么建立的?

->WebContentsImpl::NavigateToEntry(),

通过render_manager_创建一个RenderViewHostImpl,

然后通知observersAboutToNavigateRenderView

然后调用RenderViewHostImpl.Navigate()

然后通知observers:NavigateToPendingEntry().

最后调用delegate_(也就是WebContentsDelegateAndroid)的DidNavigateToPendingEntry()。

其中,RenderViewHostImpl.Navigate()调用:

->Send(newViewMsg_Navigate(GetRoutingID(), params)), 发送message.

------------------线程/进程界限,下面是render---------------

RenderViewImpl::OnMessageReceived(),render线程。RenderViewImpl怎么在那建立的?render线程什么时候建立的?

->RenderViewImpl::OnNavigate()

->WebFrame::loadRequest(WebURLRequest),WebFrame是什么?

->FrameLoader::load(FrameLoadRequest&passedRequest)

->DocumentLoader::startLoadingMainResource()

->ResourceFetcher::requestMainResource()

->Resource::load()

->createresourceLoader然后ResourceLoader::start()

->WebURLLoaderImpl::loadAsynchronously()

->WebURLLoaderImpl::Context::Start()

->IPCResourceLoaderBridge::Start()这个bridge就是resourceloaderbridge.

->ResoureDispatcher::message_sender()->send(ResourceHostMsg_RequestResource),message_sender()得到一个IPC::Sender对象。发送ResourceHostMsg_RequestResource消息。等待host处理。

-------------------------线程/进程界限,下面是browser----------------------------------

->ResourceMessageFilter::OnMessageReceived(),content/browser/loader模块,这个filter是怎么注册的,注册到哪里的?

->ResourceDispatcherHostImpl::OnMessageReceived()

->ResourceDispatcherHostImpl::OnRequestResource()

->ResourceDispatcherHostImpl::BeginRequest()

->ResourceDispatcherHostImpl::BeginRequestInternal()

->ResourceDispatcherHostImpl::StartLoading()

->ResourceLoader::StartRequest()

->ResourceLoader::StartRequestInternal()

->URLRequest::Start()

->URLRequest::StartJob(URLRequestJob*job),这里的job其实是URLRequestHttpJob,是被URLRequestHttpJob::Factory()函数创建的,URLRequestHttpJob::Factorybuitin的创建requestjobfactory.Builtinfactory支持httphttps.

->URLRequestHttpJob::Start()

->URLRequestHttpJob::DoStartTransaction(),调用此函数前,可能处理一些cookie的事情。

host处理ResourceHostMsg_RequestResource消息的逻辑

->net::HttpCache::Transaction::start()//URLRequestHttpJob::OnStartCompleted作为一个callback传入这个transaction.当底层数据到达后,会调用该callback.

->HttpNetworkTransactin::start()



//->HttpNetworkTransaction::Start(),发送requesteheaders并等待response.之后调用//callback:,调用个start时,把URLRequestHttpJob::OnStartCompleted作为start_callback//传了进去,当以后,数据就收到后,会从iothread一直触发callback倒调用这个callback

//->HttpNetworkTransaction::DoLoop()//状态机



下面是browserthread处理ResourceHostMsg_RequestResource的消息的过程中,加载完cookiecallstack,加载完cookie后,刚进入Transaction::start的第一行的callstack:

#0 net::HttpCache::Transaction::Start(net::HttpRequestInfo const*,base::Callback<void (int)> const&, net::BoundNetLog const&)(this=0x68a171d8, request=0x68a767d0, callback=..., net_log=...) //

at../../net/http/http_cache_transaction.cc:295//这个start会把一个callback传入httpCache::transaction,当以后数据来了后,会被回调的。

#1 0x6242239e in net::URLRequestHttpJob::StartTransactionInternal(this=0x68a76708) at../../net/url_request/url_request_http_job.cc:504//从这里看出,启动的transactionHttpCache::transaction.

#2 0x62422460 in net::URLRequestHttpJob::MaybeStartTransactionInternal(this=0x68a76708, result=0) at../../net/url_request/url_request_http_job.cc:469

#3 0x62422566 in net::URLRequestHttpJob::OnCookiesLoaded(this=0x68a76708, cookie_line=...) at../../net/url_request/url_request_http_job.cc:650

#4 0x61bdf3e6 in Run (a1=..., object=<optimized out>,this=0x63ef2468) at ../../base/bind_internal.h:190

#5 base::internal::InvokeHelper<true, void,base::internal::RunnableAdapter<void(content::ProxyDecryptor::*)(std::string const&)>, void(base::WeakPtr<content::ProxyDecryptor> const&, std::stringconst&)>::MakeItSo(base::internal::RunnableAdapter<void(content::ProxyDecryptor::*)(std::string const&)>,base::WeakPtr<content::ProxyDecryptor> const&, std::stringconst&) (runnable=..., weak_ptr=..., a2=...)

at../../base/bind_internal.h:909

#6 0x6233c5aa in base::Callback<void (std::stringconst&)>::Run(std::string const&) const (this=<optimizedout>, a1=...) at ../../base/callback.h:436

#7 0x6233c65a in Run (a1=..., object=<optimized out>,this=0x63ef2488) at ../../base/bind_internal.h:209

#8 MakeItSo (a2=..., a1=<optimized out>, runnable=...) at../../base/bind_internal.h:898

#9 base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(base::Callback<void (std::string const&)>::*)(std::stringconst&) const>, void (base::Callback<void (std::stringconst&)> const*, std::string const&), void(base::internal::UnretainedWrapper<base::Callback<void(std::string const&)> >, std::string)>, void(base::Callback<void (std::string const&)> const*,std::string const&)>::Run(base::internal::BindStateBase*)(base=0x68a777d0) at ../../base/bind_internal.h:1253

#100x6233ccc4 in Run (this=0x63ef24e4) at ../../base/callback.h:396

#11net::CookieMonster::CookieMonsterTask::InvokeCallback(base::Callback<void()>) (this=0x68cb1c50, callback=...) at../../net/cookies/cookie_monster.cc:399

#120x62340a38 in net::CookieMonster::GetCookiesWithOptionsTask::Run(this=0x68cb1c50) at ../../net/cookies/cookie_monster.cc:779

#130x62340190 in net::CookieMonster::DoCookieTaskForURL(this=0x59518d18, task_item=..., url=...) at../../net/cookies/cookie_monster.cc:1063

#140x6234025e in net::CookieMonster::GetCookiesWithOptionsAsync(GURLconst&, net::CookieOptions const&, base::Callback<void(std::string const&)> const&) (this=0x59518d18, url=...,options=..., callback=...)

at../../net/cookies/cookie_monster.cc:1003

#150x62421e6a in net::URLRequestHttpJob::DoLoadCookies (this=0x68a76708)at ../../net/url_request/url_request_http_job.cc:632

#160x61bdf3e6 in Run (a1=..., object=<optimized out>,this=0x63ef26f0) at ../../base/bind_internal.h:190

#17base::internal::InvokeHelper<true, void,base::internal::RunnableAdapter<void(content::ProxyDecryptor::*)(std::string const&)>, void(base::WeakPtr<content::ProxyDecryptor> const&, std::stringconst&)>::MakeItSo(base::internal::RunnableAdapter<void(content::ProxyDecryptor::*)(std::string const&)>,base::WeakPtr<content::ProxyDecryptor> const&, std::stringconst&) (runnable=..., weak_ptr=..., a2=...)

at../../base/bind_internal.h:909

#180x6233c59a in base::Callback<void(std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> >const&)>::Run(std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&) const

(this=<optimizedout>, a1=...) at ../../base/callback.h:436

#190x6233c602 in Run (a1=..., object=<optimized out>,this=0x63ef2710) at ../../base/bind_internal.h:209

#20MakeItSo (a2=..., a1=<optimized out>, runnable=...) at../../base/bind_internal.h:898

#21base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(base::Callback<void (std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> >const&)>::*)(std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&) const>,void (base::Callback<void (std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&)>const*, std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&), void(base::internal::UnretainedWrapper<base::Callback<void(std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&)> >,std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> >)>, void(base::Callback<void (std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&)>const*, std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> >const&)>::Run(base::internal::BindStateBase*)(base=0x68a53718) at ../../base/bind_internal.h:1253

#220x6233ccc4 in Run (this=0x63ef276c) at ../../base/callback.h:396

#23net::CookieMonster::CookieMonsterTask::InvokeCallback(base::Callback<void()>) (this=0x68c43988, callback=...) at../../net/cookies/cookie_monster.cc:399

#240x62340b14 in Run (this=0x68c43988) at../../net/cookies/cookie_monster.cc:529

#25net::CookieMonster::GetAllCookiesForURLWithOptionsTask::Run(this=0x68c43988) at ../../net/cookies/cookie_monster.cc:524

#260x62340190 in net::CookieMonster::DoCookieTaskForURL(this=0x59518d18, task_item=..., url=...) at../../net/cookies/cookie_monster.cc:1063

#270x62340370 in net::CookieMonster::GetAllCookiesForURLAsync(GURLconst&, base::Callback<void (std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&)>const&) (this=0x59518d18,

url=...,callback=...) at ../../net/cookies/cookie_monster.cc:927

#280x624225f4 in net::URLRequestHttpJob::AddCookieHeaderAndStart(this=0x68a76708) at../../net/url_request/url_request_http_job.cc:617

#290x62423e56 in net::URLRequestHttpJob::Start(this=0x68a76708) at../../net/url_request/url_request_http_job.cc:358

#300x6241c276 in net::URLRequest::StartJob (this=0x68c81318,job=<optimized out>) at../../net/url_request/url_request.cc:639

#310x6241d232 in net::URLRequest::BeforeRequestComplete(this=0x68c81318, error=0) at../../net/url_request/url_request.cc:609

#320x6241d32a in net::URLRequest::Start (this=0x68c81318) at../../net/url_request/url_request.cc:571

#330x61cbc432 in content::ResourceLoader::StartRequestInternal(this=0x655b1ee0) at../../content/browser/loader/resource_loader.cc:472

#340x61cbc4d2 in content::ResourceLoader::StartRequest (this=0x655b1ee0)at ../../content/browser/loader/resource_loader.cc:105

#350x61cba300 in content::ResourceDispatcherHostImpl::StartLoading(this=0x5966ce90, info=<optimized out>, loader=...) at../../content/browser/loader/resource_dispatcher_host_impl.cc:1578

#360x61cba69a incontent::ResourceDispatcherHostImpl::BeginRequestInternal(this=0x5966ce90, request=..., handler=...) at../../content/browser/loader/resource_dispatcher_host_impl.cc:1570

#370x61cbb31c in content::ResourceDispatcherHostImpl::BeginRequest(this=0x5966ce90, request_id=1, request_data=..., sync_result=0x0,route_id=3)

at../../content/browser/loader/resource_dispatcher_host_impl.cc:1102

#380x61cbb428 in content::ResourceDispatcherHostImpl::OnRequestResource(this=0x5966ce90, message=..., request_id=1, request_data=...) at../../content/browser/loader/resource_dispatcher_host_impl.cc:855

#390x61cb60d0 inResourceHostMsg_RequestResource::Dispatch<content::ResourceDispatcherHostImpl,content::ResourceDispatcherHostImpl, int, ResourceHostMsg_Requestconst&> (msg=0x63ef41c8, obj=0x5966ce90,

sender=<optimizedout>, func=

(void(content::ResourceDispatcherHostImpl::*)(content::ResourceDispatcherHostImpl* const, const IPC::Message &, int, const ResourceHostMsg_Request&)) 0x61cbb40b<content::ResourceDispatcherHostImpl::OnRequestResource(IPC::Messageconst&, int, ResourceHostMsg_Request const&)>) at../../content/common/resource_messages.h:275 //处理resourcerequest

#400x61cb91b2 in content::ResourceDispatcherHostImpl::OnMessageReceived(this=0x5966ce90, message=..., filter=<optimized out>,message_was_ok=0x63ef3fb7)

at../../content/browser/loader/resource_dispatcher_host_impl.cc:813

#410x61c12b26 in content::BrowserMessageFilter::DispatchMessage(this=0x59756e80, message=...) at../../content/public/browser/browser_message_filter.cc:157

#420x61c12c40 in content::BrowserMessageFilter::OnMessageReceived(this=0x59756e80, message=...) at../../content/public/browser/browser_message_filter.cc:56

#430x618c3326 in IPC::ChannelProxy::Context::TryFilters(this=0x597562a8, message=...) at ../../ipc/ipc_channel_proxy.cc:79

#440x618c343a in IPC::ChannelProxy::Context::OnMessageReceived(this=0x597562a8, message=...) at ../../ipc/ipc_channel_proxy.cc:93

#450x618c4cfe in IPC::internal::ChannelReader::DispatchInputData(this=0x5975a878, input_data=<optimized out>,input_data_len=<optimized out>) at../../ipc/ipc_channel_reader.cc:90

#460x618c4e04 in IPC::internal::ChannelReader::ProcessIncomingMessages(this=0x5975a878) at ../../ipc/ipc_channel_reader.cc:32

#470x618c29c6 in IPC::Channel::ChannelImpl::OnFileCanReadWithoutBlocking(this=0x5975a878, fd=<optimized out>) at../../ipc/ipc_channel_posix.cc:641

#480x619178c0 inbase::MessagePumpLibevent::FileDescriptorWatcher::OnFileCanReadWithoutBlocking(this=0x5975b8b8, fd=52, pump=0x59521e58) at../../base/message_loop/message_pump_libevent.cc:99

#490x61917952 in base::MessagePumpLibevent::OnLibeventNotification(fd=52, flags=<optimized out>, context=<optimized out>)at ../../base/message_loop/message_pump_libevent.cc:356

#500x61bb8d1a in event_process_active (base=<optimized out>) at../../third_party/libevent/event.c:385

#51event_base_loop (base=<optimized out>, flags=1) at../../third_party/libevent/event.c:525

#520x619170c2 in base::MessagePumpLibevent::Run (this=0x59521e58,delegate=0x63ef4cb8) at../../base/message_loop/message_pump_libevent.cc:269

#530x61932db2 in base::MessageLoop::RunInternal (this=0x63ef4cb8) at../../base/message_loop/message_loop.cc:436

#540x6193d718 in base::RunLoop::Run (this=0x63ef4a90) at../../base/run_loop.cc:45

#550x619321c4 in base::MessageLoop::Run (this=<optimized out>) at../../base/message_loop/message_loop.cc:307

#560x61c36b52 in content::BrowserThreadImpl::IOThreadRun(this=<optimized out>,message_loop=<optimized out>) at../../content/browser/browser_thread_impl.cc:162 //browser这边的iothread.

#570x61c371f6 in content::BrowserThreadImpl::Run (this=0x10001,message_loop=0x63ef4cb8) at../../content/browser/browser_thread_impl.cc:188

#580x61948e4a in base::Thread::ThreadMain (this=0x59521db8) at../../base/threading/thread.cc:203

#590x6194614a in base::(anonymous namespace)::ThreadFunc(params=<optimized out>) at../../base/threading/platform_thread_posix.cc:80

#600x401d2a5c in __thread_entry () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#610x401d2bd8 in pthread_create () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#620x00000000 in ?? ()





下面是browser处理ResourceHostMsg_RequestResource时,cookie被加载完毕后,在Transactin::start函数里,走到第312行,进入Doloop(),准备发送requestcallstack:他会启动HttpNetworkTransaction::start.并且传入一个callback:Transaction::OnIOComplete作为io_callback_:

#0 net::HttpNetworkTransaction::Start(net::HttpRequestInfo const*,base::Callback<void (int)> const&, net::BoundNetLog const&)(this=0x68a577c8, request_info=0x68a767d0, callback=..., net_log=...)

at../../net/http/http_network_transaction.cc:170//启动HttpNetworktransaction.他应该会启动更下层的HttpStream层,以及下层的socket层。

#1 0x6239251c in net::HttpCache::Transaction::DoSendRequest(this=0x68a171d8) at ../../net/http/http_cache_transaction.cc:859//准备发送request,就会启动httpNetworkTransaction::start.

#2 0x62395dee in net::HttpCache::Transaction::DoLoop(this=0x68a171d8, result=<optimized out>) at../../net/http/http_cache_transaction.cc:631

#3 0x62397142 innet::HttpCache::Transaction::Start(net::HttpRequestInfo const*,base::Callback<void (int)> const&, net::BoundNetLog const&)(this=0x68a171d8, request=0x68a767d0, callback=..., net_log=...)

at../../net/http/http_cache_transaction.cc:312

#4 0x6242239e in net::URLRequestHttpJob::StartTransactionInternal(this=0x68a76708) at../../net/url_request/url_request_http_job.cc:504

#5 0x62422460 in net::URLRequestHttpJob::MaybeStartTransactionInternal(this=0x68a76708, result=0) at../../net/url_request/url_request_http_job.cc:469

#6 0x62422566 in net::URLRequestHttpJob::OnCookiesLoaded(this=0x68a76708, cookie_line=...) at../../net/url_request/url_request_http_job.cc:650

#7 0x61bdf3e6 in Run (a1=..., object=<optimized out>,this=0x63ef2468) at ../../base/bind_internal.h:190

#8 base::internal::InvokeHelper<true, void,base::internal::RunnableAdapter<void(content::ProxyDecryptor::*)(std::string const&)>, void(base::WeakPtr<content::ProxyDecryptor> const&, std::stringconst&)>::MakeItSo(base::internal::RunnableAdapter<void(content::ProxyDecryptor::*)(std::string const&)>,base::WeakPtr<content::ProxyDecryptor> const&, std::stringconst&) (runnable=..., weak_ptr=..., a2=...)

at../../base/bind_internal.h:909

#9 0x6233c5aa in base::Callback<void (std::stringconst&)>::Run(std::string const&) const (this=<optimizedout>, a1=...) at ../../base/callback.h:436

#100x6233c65a in Run (a1=..., object=<optimized out>,this=0x63ef2488) at ../../base/bind_internal.h:209

#11MakeItSo (a2=..., a1=<optimized out>, runnable=...) at../../base/bind_internal.h:898

#12base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(base::Callback<void (std::string const&)>::*)(std::stringconst&) const>, void (base::Callback<void (std::stringconst&)> const*, std::string const&), void(base::internal::UnretainedWrapper<base::Callback<void(std::string const&)> >, std::string)>, void(base::Callback<void (std::string const&)> const*,std::string const&)>::Run(base::internal::BindStateBase*)(base=0x68a777d0) at ../../base/bind_internal.h:1253

#130x6233ccc4 in Run (this=0x63ef24e4) at ../../base/callback.h:396

#14net::CookieMonster::CookieMonsterTask::InvokeCallback(base::Callback<void()>) (this=0x68cb1c50, callback=...) at../../net/cookies/cookie_monster.cc:399

#150x62340a38 in net::CookieMonster::GetCookiesWithOptionsTask::Run(this=0x68cb1c50) at ../../net/cookies/cookie_monster.cc:779

#160x62340190 in net::CookieMonster::DoCookieTaskForURL(this=0x59518d18, task_item=..., url=...) at../../net/cookies/cookie_monster.cc:1063

#170x6234025e in net::CookieMonster::GetCookiesWithOptionsAsync(GURLconst&, net::CookieOptions const&, base::Callback<void(std::string const&)> const&) (this=0x59518d18, url=...,options=..., callback=...)

at../../net/cookies/cookie_monster.cc:1003

#180x62421e6a in net::URLRequestHttpJob::DoLoadCookies(this=0x68a76708) at../../net/url_request/url_request_http_job.cc:632

#190x61bdf3e6 in Run (a1=..., object=<optimized out>,this=0x63ef26f0) at ../../base/bind_internal.h:190

#20base::internal::InvokeHelper<true, void,base::internal::RunnableAdapter<void(content::ProxyDecryptor::*)(std::string const&)>, void(base::WeakPtr<content::ProxyDecryptor> const&, std::stringconst&)>::MakeItSo(base::internal::RunnableAdapter<void(content::ProxyDecryptor::*)(std::string const&)>,base::WeakPtr<content::ProxyDecryptor> const&, std::stringconst&) (runnable=..., weak_ptr=..., a2=...)

at../../base/bind_internal.h:909

#210x6233c59a in base::Callback<void(std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> >const&)>::Run(std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&) const

(this=<optimizedout>, a1=...) at ../../base/callback.h:436

#220x6233c602 in Run (a1=..., object=<optimized out>,this=0x63ef2710) at ../../base/bind_internal.h:209

#23MakeItSo (a2=..., a1=<optimized out>, runnable=...) at../../base/bind_internal.h:898

#24base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(base::Callback<void (std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> >const&)>::*)(std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&) const>,void (base::Callback<void (std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&)>const*, std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&), void(base::internal::UnretainedWrapper<base::Callback<void(std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&)> >,std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> >)>, void(base::Callback<void (std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&)>const*, std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> >const&)>::Run(base::internal::BindStateBase*)(base=0x68a53718) at ../../base/bind_internal.h:1253

#250x6233ccc4 in Run (this=0x63ef276c) at ../../base/callback.h:396

#26net::CookieMonster::CookieMonsterTask::InvokeCallback(base::Callback<void()>) (this=0x68c43988, callback=...) at../../net/cookies/cookie_monster.cc:399

#270x62340b14 in Run (this=0x68c43988) at../../net/cookies/cookie_monster.cc:529

#28net::CookieMonster::GetAllCookiesForURLWithOptionsTask::Run(this=0x68c43988) at ../../net/cookies/cookie_monster.cc:524

#290x62340190 in net::CookieMonster::DoCookieTaskForURL(this=0x59518d18, task_item=..., url=...) at../../net/cookies/cookie_monster.cc:1063

#300x62340370 in net::CookieMonster::GetAllCookiesForURLAsync(GURLconst&, base::Callback<void (std::vector<net::CanonicalCookie,std::allocator<net::CanonicalCookie> > const&)>const&) (this=0x59518d18,

url=...,callback=...) at ../../net/cookies/cookie_monster.cc:927

#310x624225f4 in net::URLRequestHttpJob::AddCookieHeaderAndStart(this=0x68a76708) at../../net/url_request/url_request_http_job.cc:617

#320x62423e56 in net::URLRequestHttpJob::Start (this=0x68a76708) at../../net/url_request/url_request_http_job.cc:358

#330x6241c276 in net::URLRequest::StartJob (this=0x68c81318,job=<optimized out>) at../../net/url_request/url_request.cc:639

#340x6241d232 in net::URLRequest::BeforeRequestComplete(this=0x68c81318, error=0) at../../net/url_request/url_request.cc:609

#350x6241d32a in net::URLRequest::Start (this=0x68c81318) at../../net/url_request/url_request.cc:571

#360x61cbc432 in content::ResourceLoader::StartRequestInternal(this=0x655b1ee0) at../../content/browser/loader/resource_loader.cc:472

#370x61cbc4d2 in content::ResourceLoader::StartRequest(this=0x655b1ee0) at../../content/browser/loader/resource_loader.cc:105

#380x61cba300 in content::ResourceDispatcherHostImpl::StartLoading(this=0x5966ce90, info=<optimized out>, loader=...) at../../content/browser/loader/resource_dispatcher_host_impl.cc:1578

#390x61cba69a incontent::ResourceDispatcherHostImpl::BeginRequestInternal(this=0x5966ce90, request=..., handler=...) at../../content/browser/loader/resource_dispatcher_host_impl.cc:1570

#400x61cbb31c in content::ResourceDispatcherHostImpl::BeginRequest(this=0x5966ce90, request_id=1, request_data=..., sync_result=0x0,route_id=3)

at../../content/browser/loader/resource_dispatcher_host_impl.cc:1102

#410x61cbb428 in content::ResourceDispatcherHostImpl::OnRequestResource(this=0x5966ce90, message=..., request_id=1, request_data=...) at../../content/browser/loader/resource_dispatcher_host_impl.cc:855

#420x61cb60d0 inResourceHostMsg_RequestResource::Dispatch<content::ResourceDispatcherHostImpl,content::ResourceDispatcherHostImpl, int, ResourceHostMsg_Requestconst&> (msg=0x63ef41c8, obj=0x5966ce90,

sender=<optimizedout>, func=

(void(content::ResourceDispatcherHostImpl::*)(content::ResourceDispatcherHostImpl* const, const IPC::Message &, int, const ResourceHostMsg_Request&)) 0x61cbb40b<content::ResourceDispatcherHostImpl::OnRequestResource(IPC::Messageconst&, int, ResourceHostMsg_Request const&)>) at../../content/common/resource_messages.h:275

#430x61cb91b2 in content::ResourceDispatcherHostImpl::OnMessageReceived(this=0x5966ce90, message=..., filter=<optimized out>,message_was_ok=0x63ef3fb7)

at../../content/browser/loader/resource_dispatcher_host_impl.cc:813

#440x61c12b26 in content::BrowserMessageFilter::DispatchMessage(this=0x59756e80, message=...) at../../content/public/browser/browser_message_filter.cc:157

#450x61c12c40 in content::BrowserMessageFilter::OnMessageReceived(this=0x59756e80, message=...) at../../content/public/browser/browser_message_filter.cc:56

#460x618c3326 in IPC::ChannelProxy::Context::TryFilters(this=0x597562a8, message=...) at ../../ipc/ipc_channel_proxy.cc:79

#470x618c343a in IPC::ChannelProxy::Context::OnMessageReceived(this=0x597562a8, message=...) at ../../ipc/ipc_channel_proxy.cc:93

#480x618c4cfe in IPC::internal::ChannelReader::DispatchInputData(this=0x5975a878, input_data=<optimized out>,input_data_len=<optimized out>) at../../ipc/ipc_channel_reader.cc:90

#490x618c4e04 in IPC::internal::ChannelReader::ProcessIncomingMessages(this=0x5975a878) at ../../ipc/ipc_channel_reader.cc:32

#500x618c29c6 in IPC::Channel::ChannelImpl::OnFileCanReadWithoutBlocking(this=0x5975a878, fd=<optimized out>) at../../ipc/ipc_channel_posix.cc:641

#510x619178c0 inbase::MessagePumpLibevent::FileDescriptorWatcher::OnFileCanReadWithoutBlocking(this=0x5975b8b8, fd=52, pump=0x59521e58) at../../base/message_loop/message_pump_libevent.cc:99

#520x61917952 in base::MessagePumpLibevent::OnLibeventNotification(fd=52, flags=<optimized out>, context=<optimized out>)at ../../base/message_loop/message_pump_libevent.cc:356

#530x61bb8d1a in event_process_active (base=<optimized out>) at../../third_party/libevent/event.c:385

#54event_base_loop (base=<optimized out>, flags=1) at../../third_party/libevent/event.c:525

#550x619170c2 in base::MessagePumpLibevent::Run (this=0x59521e58,delegate=0x63ef4cb8) at../../base/message_loop/message_pump_libevent.cc:269

#560x61932db2 in base::MessageLoop::RunInternal (this=0x63ef4cb8) at../../base/message_loop/message_loop.cc:436

#570x6193d718 in base::RunLoop::Run (this=0x63ef4a90) at../../base/run_loop.cc:45

#580x619321c4 in base::MessageLoop::Run (this=<optimized out>) at../../base/message_loop/message_loop.cc:307

#590x61c36b52 in content::BrowserThreadImpl::IOThreadRun(this=<optimized out>, message_loop=<optimized out>) at../../content/browser/browser_thread_impl.cc:162







被动等待,当数据都收到后:-------------下面还是browseriothread------但是和上述操作异步---

由于iothread也是使用了messageloopmessagepump机制。所以iothread发送数据和检查数据,接收数据都是在自己的消息循环里异步执行的。当自己的消息循环空闲时,他就检查是否有socket上有数据可读,如果没有,就继续循环,如果有,就调用相应的callback,向上面通知数据来了。从底层的socket层触发的事件,利用各层的callback,向上通知,从tcpsocket=>sslsocket=>streamparser=>httpNetworkTransaction=>HttpCache::transaction=>UrlRequestJob.

#0 net::URLRequestHttpJob::ReadRawData (this=0x65064950,buf=0x65ab7510, buf_size=32768, bytes_read=0x63ef1a58) at../../net/url_request/url_request_http_job.cc:1252

#1 0x62225bea in net::URLRequestJob::ReadRawDataHelper(this=0x65064950, buf=0x65ab7510, buf_size=32768,bytes_read=0x63ef1a58) at../../net/url_request/url_request_job.cc:680

#2 0x62225ce6 in net::URLRequestJob::ReadRawDataForFilter(this=0x65064950, bytes_read=0x63ef1a58) at../../net/url_request/url_request_job.cc:666

#3 0x62225e26 in net::URLRequestJob::ReadFilteredData (this=0x65064950,bytes_read=0x63ef2738) at../../net/url_request/url_request_job.cc:530

#4 0x6222629a in net::URLRequestJob::Read (this=0x65064950,buf=0x65ac2658, buf_size=32768, bytes_read=0x63ef2738) at../../net/url_request/url_request_job.cc:88

#5 0x6221bf10 in net::URLRequest::Read (this=0x65063fb8,dest=0x65ac2658, dest_size=32768, bytes_read=0x63ef2738) at../../net/url_request/url_request.cc:725

#6 0x61abc23c in content::ResourceLoader::ReadMore (this=0x61075be0,bytes_read=0x63ef2738) at../../content/browser/loader/resource_loader.cc:639

#7 0x61abc2f2 in content::ResourceLoader::StartReading(this=0x61075be0, is_continuation=<optimized out>) at../../content/browser/loader/resource_loader.cc:590

#8 0x61abd684 in content::ResourceLoader::OnResponseStarted(this=0x61075be0, unused=0x65063fb8) at../../content/browser/loader/resource_loader.cc:380

#9 0x6221c378 in net::URLRequest::NotifyResponseStarted(this=0x65063fb8) at ../../net/url_request/url_request.cc:778

#100x62225974 in net::URLRequestJob::NotifyHeadersComplete(this=0x65064950) at ../../net/url_request/url_request_job.cc:364

#110x62224820 in net::URLRequestHttpJob::NotifyHeadersComplete(this=0x65064950) at../../net/url_request/url_request_http_job.cc:424

#120x622249ae in net::URLRequestHttpJob::SaveNextCookie(this=0x65064950) at../../net/url_request/url_request_http_job.cc:739

#130x62224c06 innet::URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(this=0x65064950, result=<optimized out>) at../../net/url_request/url_request_http_job.cc:685

#140x62224dee in net::URLRequestHttpJob::OnStartCompleted(this=0x65064950, result=<optimized out>) at../../net/url_request/url_request_http_job.cc:891

#150x619ca038 in base::internal::RunnableAdapter<void(content::InputEventFilter::*)(IPC::Message const&)>::Run(this=<optimized out>, object=<optimized out>, a1=...) at../../base/bind_internal.h:190

#160x62221190 in MakeItSo (a1=0x65064950, runnable=..., a2=<optimizedout>) at ../../base/bind_internal.h:898

#17base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void(net::URLRequestHttpJob::*)(int)>, void (net::URLRequestHttpJob*,int), void(base::internal::UnretainedWrapper<net::URLRequestHttpJob>)>,void (net::URLRequestHttpJob*,int)>::Run(base::internal::BindStateBase*, int const&)(base=<optimized out>, x2=<optimized out>) at../../base/bind_internal.h:1224

#180x62192782 in Run (a1=@0x63ef3154: 0, this=0x63ef315c) at../../base/callback.h:436

#19net::HttpCache::Transaction::DoCallback(this=0x6507fe08, rv=0) at../../net/http/http_cache_transaction.cc:538//这里调用了URLRequestHttpJob::OnStartCompleted.这个callback是调用

#200x621927f4 in net::HttpCache::Transaction::HandleResult(this=0x6507fe08, rv=0) at../../net/http/http_cache_transaction.cc:544

#210x62196322 in net::HttpCache::Transaction::DoLoop(this=0x6507fe08, result=<optimized out>) at../../net/http/http_cache_transaction.cc:771 //Transaction的状态机

#220x62196816 in net::HttpCache::Transaction::OnIOComplete(this=0x6507fe08, result=0) at../../net/http/http_cache_transaction.cc:2449//Transaction注册到下层的callback

#230x614fe016 in Run (object=<optimized out>, this=0x63ef4330,a1=<optimized out>) at ../../base/bind_internal.h:190

#24base::internal::InvokeHelper<true, void,base::internal::RunnableAdapter<void(cc::OutputSurface::*)(cc::CompositorFrameAck const*)>, void(base::WeakPtr<cc::OutputSurface> const&,cc::CompositorFrameAck*const&)>::MakeItSo(base::internal::RunnableAdapter<void(cc::OutputSurface::*)(cc::CompositorFrameAck const*)>,base::WeakPtr<cc::OutputSurface> const&,cc::CompositorFrameAck* const&) (runnable=..., weak_ptr=...,

a2=@0x63ef4354:0x0) at ../../base/bind_internal.h:909

#250x6219b53c in Run (a1=@0x63ef4354: 0, this=0x63ef435c) at../../base/callback.h:436

#26net::HttpNetworkTransaction::DoCallback(this=0x6568c6b8, rv=0) at../../net/http/http_network_transaction.cc:541//HttpNetworkTransactioncallback

#270x62198b70 in Run (this=0x63ef44b8, object=<optimized out>,a1=<optimized out>) at ../../base/bind_internal.h:190

#28MakeItSo (a1=<optimized out>, runnable=..., a2=<optimizedout>) at ../../base/bind_internal.h:898

#29base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void(net::HttpNetworkTransaction::*)(int)>, void(net::HttpNetworkTransaction*, int), void(base::internal::UnretainedWrapper<net::HttpNetworkTransaction>)>,void (net::HttpNetworkTransaction*,int)>::Run(base::internal::BindStateBase*, int const&)(base=<optimized out>, x2=<optimized out>) at../../base/bind_internal.h:1224

#300x621b2ac8 in Run (a1=@0x63ef44cc: 625, this=0x63ef44d0) at../../base/callback.h:436

#31net::HttpStreamParser::OnIOComplete(this=0x650cd5f8, result=<optimized out>) at../../net/http/http_stream_parser.cc:355//HttpStreamParseriocompletecallback

#320x614fe016 in Run (object=<optimized out>, this=0x63ef44e8,a1=<optimized out>) at ../../base/bind_internal.h:190

#33base::internal::InvokeHelper<true, void,base::internal::RunnableAdapter<void(cc::OutputSurface::*)(cc::CompositorFrameAck const*)>, void(base::WeakPtr<cc::OutputSurface> const&,cc::CompositorFrameAck*const&)>::MakeItSo(base::internal::RunnableAdapter<void(cc::OutputSurface::*)(cc::CompositorFrameAck const*)>,base::WeakPtr<cc::OutputSurface> const&,cc::CompositorFrameAck* const&) (runnable=..., weak_ptr=...,

a2=@0x63ef4504:0x271) at ../../base/bind_internal.h:909

#340x621e88b0 in Run (a1=@0x63ef4504: 625, this=0x63ef4508) at../../base/callback.h:436

#35net::SSLClientSocketOpenSSL::DoReadCallback(this=<optimized out>, rv=625) at../../net/socket/ssl_client_socket_openssl.cc:715 //sslsocket层的读取数据的callback

#360x621e8470 in Run (this=0x63ef4518, object=<optimized out>,a1=<optimized out>) at ../../base/bind_internal.h:190

#37MakeItSo (a1=<optimized out>, runnable=..., a2=<optimizedout>) at ../../base/bind_internal.h:898

#38base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void(net::SSLClientSocketOpenSSL::*)(int)>, void(net::SSLClientSocketOpenSSL*, int), void(base::internal::UnretainedWrapper<net::SSLClientSocketOpenSSL>)>,void (net::SSLClientSocketOpenSSL*,int)>::Run(base::internal::BindStateBase*, int const&)(base=<optimized out>, x2=<optimized out>) at../../base/bind_internal.h:1224

#390x621eed3c in Run (a1=@0x63ef4534: 2102, this=0x63ef453c) at../../base/callback.h:436

#40net::TCPClientSocketLibevent::DoReadCallback (this=0x59273a68, rv=0)at ../../net/socket/tcp_client_socket_libevent.cc:639

#410x621eee68 in net::TCPClientSocketLibevent::DidCompleteRead(this=0x59273a68) at../../net/socket/tcp_client_socket_libevent.cc:702 //Tcpsocket层的callback,这个函数尝试去读socket,如果能读到数据,结果ok,就调用上层的callback.如果没有得到有效数据,而且读得结果是IO_PENDING,就返回不做什么操作,等下一次空闲的时候,继续尝试。所以这个函数下面的若干调用,都是消息循环在不断触发各种事件的检查。

#420x617178c0 inbase::MessagePumpLibevent::FileDescriptorWatcher::OnFileCanReadWithoutBlocking(this=0x59273ab0, fd=130, pump=0x59701f70) at../../base/message_loop/message_pump_libevent.cc:99

#430x61717952 in base::MessagePumpLibevent::OnLibeventNotification(fd=130, flags=<optimized out>, context=<optimized out>)at ../../base/message_loop/message_pump_libevent.cc:356

#440x619b8d1a in event_process_active (base=<optimized out>) at../../third_party/libevent/event.c:385

#45event_base_loop(base=<optimized out>, flags=1) at../../third_party/libevent/event.c:525 //这个函数是messageloop在空闲的时候调用的,通过检查有没有发生什么event,如果发生了,就处理该event,结果在这里发现某些filedescriptor也就是socket有数据了,就可以处理他们了。

#460x617170c2 in base::MessagePumpLibevent::Run (this=0x59701f70,delegate=0x63ef4cb8) at../../base/message_loop/message_pump_libevent.cc:269

#470x61732db2 in base::MessageLoop::RunInternal (this=0x63ef4cb8) at../../base/message_loop/message_loop.cc:436

#480x6173d718 in base::RunLoop::Run (this=0x63ef4a90) at../../base/run_loop.cc:45

#490x617321c4 in base::MessageLoop::Run (this=<optimized out>) at../../base/message_loop/message_loop.cc:307

#500x61a36b52 in content::BrowserThreadImpl::IOThreadRun(this=<optimized out>, message_loop=<optimized out>) at../../content/browser/browser_thread_impl.cc:162 //依然是browseriothread.



有时间研究一下,UrlRequestHttpJob, HttpCache::Transcation, HttpNetworkTransaction,以及HttpStreamParser,SSLClientSocketOpenSSL, TCPClientSocketLibevent之间的层级关系。如何互相初始化,以及callback设置关系,还有流程。这有一篇资料:http://www.chromium.org/developers/design-documents/network-stack/









下面是browseriothread接收完数据后如何进一步处理的流程:

URLRequestHttpJob::ReadRawData()

->URLRequestHttpJob::OnReadCompleted()

->URLRequestJob::NotifyReadComplete(()

->URLRequest::NotifyReadCompleted(intbytes_read)

->network_delegate_->NotifyCompleted(this,job_.get() != NULL), URLRequest里面的network_delegate是谁?怀疑是 AwNetworkDelegate。但是他并没有做什么事情。

还调用:delegate_->OnReadCompleted(this,bytes_read);delegate是谁?是ResourceLoader

ResourceLoader::OnReadCompleted()

->ResourceLoader::CompleteRead(bytes_read);

->ResourceLoader::ResponseCompleted()

->handler_->OnReadCompleted(info->GetRequestID(),bytes_read, &defer)), 这个handler最终调用AsyncResourceHandler.

->filter_->Send(

newResourceMsg_SetDataBuffer(routing_id_, request_id, handle,size,..)//render发送数据前,第一次发送数据时需要发送这个共享数据的消息,告诉render数据的位置。

filter_->Send(

newResourceMsg_DataReceived(routing_id_, request_id, data_offset,

bytes_read,encoded_data_length))//然后发送第一份数据。发送以后的数据也是这个样子。





如果说发现该资源所有的数据都接受完毕,就会走到下面的逻辑:

->LayeredResourceHandler::OnResponseCompleted()//当发现接收完所有的数据后才走这里和下面的代码

->BufferedResourceHandler::OnResponseCompleted()

->AsyncResourceHandler::OnResponseCompleted(

->ResourceMessageFilter::Send(newResourceMsg_RequestComplete(routing_id_,),调用这个ResourceMessageFilter的父类BrowserMessageFilterSend

->channel_->Send(ResourceMsg_RequestComplete)



总之:browseriothread收到数据后就通过ResourceMsg_SetDataBufferResourceMsg_DataReceived这两个消息把数据共享给render.browser发现数据接受完毕,就发送ResourceMsg_RequestCompleterender.





下面看render处理ResourceMsg_DataReceived的流程。

ResourceDispatcher::OnReceivedData(constIPC::Message& message,

->request_info->peer->OnReceivedData,peerWebUrlLoaderImpl::context

->client_->didReceiveData(loader_,data, data_length,encoded_data_length);//webUrlLoaderImpl::contextclientResourceLoader.

->ResourceLoader::didReceiveData()

->

  • m_host->didReceiveData(m_resource,data, length, encodedDataLength, m_options);//m_hostResourceFetcher.

    ->FrameLoader里的ResourceLoadNotifier->dispatchDidReceiveData()

    -> if(Page*page = m_frame->page())

page->progress()->incrementProgress(identifier,data, dataLength);//更新进度

  • m_resource->appendData(data,length); //m_resourcerawResource.

    ->RawResource::appendData()//他会调用Resource::appendData(),这样资源数据就保存在了内存里。因为这个resource同时也被MemoryCache维护着,所以资源就进入了cache里。

    ->RawResourceClient::dataReceived(),//RawResourceClient在这里是DOcumentLoader.他也继承自RawResourceClient

    ->DocumentLoader::dataReceived

    ->DocumentLoader::commitData

    ->DocumentWriter::addData()

    ->DecodedDataDocumentParser::appendBytes,//其实这个parserHTMLDocumentParser,因为他继承自ScriptableDocumentParserScriptableDocumentParser又继承自DecodedDataDocumentParser.

    ->HTMLDocumentParser::append

    ->startBackgroundParser(),新起一个线程执行backgroundparser,并向该线程发送执行BackgroundHTMLParser::appendtask.把数据也发给那个线程.HtmlParserThread是在他的shared()里创建的,在他的构造函数里,建立一个thread:m_thread(adoptPtr(WebKit::Platform::current()->createThread("HTMLParserThread")))



----------------------------下面是运行backgroundhtml parser的线程------------

BackgroundHTMLParser::append(constString&input)

->BackgroundHTMLParser::pumpTokenizer()

->voidBackgroundHTMLParser::sendTokensToMainThread()

->callOnMainThread(bind(&HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser,m_parser,chunk.release())); //把解析后的chunk发送给rendermainthread. 并让HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser执行。



---------------------------下面是rendermainthread-------------

HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser

->HTMLDocumentParser::pumpPendingSpeculations

processParsedChunkFromBackgroundParser()

->

  • prepareToStopParsing()//当遇到最后一个token时准备stop.

    ->DocumentParser::prepareToStopParsing();

    ->attemptToRunDeferredScriptsAndEnd()

    ->end()

    ->HTMLTreeBuilder::finished()

    ->m_tree->finishedParsing(),m_treeHTMLConstructionSite,也就是

    voidHTMLConstructionSite::finishedParsing()

    ->Document::finishedParsing()

    ->FrameLoader::finishedParsing()

    ->FrameLoader::checkCompleted()

    ->FrameView::handleLoadCompleted()

    ->flushDeferredRepaints()把一些defferredrepaints重新绘制。

  • HTMLDocumentParser::constructTreeFromCompactHTMLToken(constCompactHTMLToken&compactToken)

    ->voidHTMLTreeBuilder::constructTree(AtomicHTMLToken*token)

    ->processToken()

    。。。。后续内容暂且不看。



在下载完一个html后,html引用的图片等资源实在哪里启动下载的?





















ResourceLoaderdelegate_content::ResourceDispatcherHostImpl









实际上,browserio thread接受完数据的流程的callback是这样的:

#0 content::AsyncResourceHandler::OnResponseCompleted(this=0x68b90590, request_id=55,//这个函数会send ResourceMsg_RequestCompleterender.

status=...,security_info=...)

at../../content/browser/loader/async_resource_handler.cc:294

#1 0x61cb1e72 in content::BufferedResourceHandler::OnResponseCompleted(

this=<optimizedout>, request_id=55, status=..., security_info=...)

at../../content/browser/loader/buffered_resource_handler.cc:195

#2 0x61cb3bd8 in content::LayeredResourceHandler::OnResponseCompleted(

this=<optimizedout>, request_id=55, status=..., security_info=...)

at../../content/browser/loader/layered_resource_handler.cc:74

#3 0x61cbc9ce in content::ResourceLoader::ResponseCompleted(this=0x60f78f30)

at../../content/browser/loader/resource_loader.cc:673

#4 0x61cbd548 in content::ResourceLoader::OnReadCompleted(this=0x60f78f30,

unused=0x68ca6790,bytes_read=0) at ../../content/browser/loader/resource_loader.cc:405

#5 0x61cbc316 in content::ResourceLoader::StartReading(this=0x60f78f30,

is_continuation=<optimizedout>) at ../../content/browser/loader/resource_loader.cc:597

#6 0x61cbd534 in content::ResourceLoader::OnReadCompleted(this=0x60f78f30,

unused=0x68ca6790,bytes_read=3580)

at../../content/browser/loader/resource_loader.cc:403

#7 0x6241b23a in net::URLRequest::NotifyReadCompleted (this=0x68ca6790,bytes_read=3580)

at../../net/url_request/url_request.cc:1062

#8 0x624263a4 in net::URLRequestJob::NotifyReadComplete(this=0x67e0e018, bytes_read=1139)

at../../net/url_request/url_request_job.cc:403

#9 0x62423d1e in net::URLRequestHttpJob::OnReadCompleted(this=0x67e0e018,

result=<optimizedout>) at ../../net/url_request/url_request_http_job.cc:938

---Type<return> to continue, or q <return> to quit---

#100x61bca038 in base::internal::RunnableAdapter<void(content::InputEventFilter::*)(IPC::Message const&)>::Run(this=<optimized out>, object=<optimized out>, a1=...)

at../../base/bind_internal.h:190

#110x62421190 in MakeItSo (a1=0x67e0e018, runnable=..., a2=<optimizedout>)

at../../base/bind_internal.h:898

#12base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void(net::URLRequestHttpJob::*)(int)>, void (net::URLRequestHttpJob*,int), void(base::internal::UnretainedWrapper<net::URLRequestHttpJob>)>,void (net::URLRequestHttpJob*,int)>::Run(base::internal::BindStateBase*, int const&)(base=<optimized out>, x2=<optimized out>)

at../../base/bind_internal.h:1224

#130x62392782 in Run (a1=@0x63ef317c: 1139, this=0x63ef3184) at../../base/callback.h:436

#14net::HttpCache::Transaction::DoCallback(this=0x5926bae0, rv=0)

at../../net/http/http_cache_transaction.cc:538

#150x623927f4 in net::HttpCache::Transaction::HandleResult(this=0x5926bae0, rv=1139)

at../../net/http/http_cache_transaction.cc:544

#160x62396322 in net::HttpCache::Transaction::DoLoop (this=0x5926bae0,

result=<optimizedout>) at ../../net/http/http_cache_transaction.cc:771

#170x62396816 in net::HttpCache::Transaction::OnIOComplete(this=0x5926bae0, result=1139)

at../../net/http/http_cache_transaction.cc:2449

#180x616fe016 in Run (object=<optimized out>, this=0x63ef4358,a1=<optimized out>)

at../../base/bind_internal.h:190

#19base::internal::InvokeHelper<true, void,base::internal::RunnableAdapter<void(cc::OutputSurface::*)(cc::CompositorFrameAck const*)>, void(base::WeakPtr<cc::OutputSurface> const&,cc::CompositorFrameAck*const&)>::MakeItSo(base::internal::RunnableAdapter<void(cc::OutputSurfac---Type <return> to continue, or q <return>to quit---

e::*)(cc::CompositorFrameAckconst*)>, base::WeakPtr<cc::OutputSurface> const&,cc::CompositorFrameAck* const&) (runnable=..., weak_ptr=...,a2=@0x63ef437c: 0x473)

at../../base/bind_internal.h:909

#200x6239b53c in Run (a1=@0x63ef437c: 1139, this=0x63ef4384) at../../base/callback.h:436

#21net::HttpNetworkTransaction::DoCallback(this=0x678c8340, rv=0)

at../../net/http/http_network_transaction.cc:541

#220x62398b70 in Run (this=0x63ef44e0, object=<optimized out>,a1=<optimized out>)

at../../base/bind_internal.h:190

#23MakeItSo (a1=<optimized out>, runnable=..., a2=<optimizedout>)

at../../base/bind_internal.h:898

#24base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void(net::HttpNetworkTransaction::*)(int)>, void(net::HttpNetworkTransaction*, int), void(base::internal::UnretainedWrapper<net::HttpNetworkTransaction>)>,void (net::HttpNetworkTransaction*,int)>::Run(base::internal::BindStateBase*, int const&)(base=<optimized out>,

x2=<optimizedout>) at ../../base/bind_internal.h:1224

#250x623b2ac8 in Run (a1=@0x63ef44f4: 1139, this=0x63ef44f8) at../../base/callback.h:436

#26net::HttpStreamParser::OnIOComplete(this=0x67d5a7c0, result=<optimized out>)

at../../net/http/http_stream_parser.cc:355

#270x616fe016 in Run (object=<optimized out>, this=0x63ef4510,a1=<optimized out>)

at../../base/bind_internal.h:190

#28base::internal::InvokeHelper<true, void,base::internal::RunnableAdapter<void(cc::OutputSurface::*)(cc::CompositorFrameAck const*)>, void(base::WeakPtr<cc::OutputSurface> const&,cc::CompositorFrameAck*const&)>::MakeItSo(base::internal::RunnableAdapter<void(cc::OutputSurface::*)(cc::CompositorFrameAck const*)>,base::WeakPtr<cc::OutputSurface> const&,cc::Compositor---Type <return> to continue, or q <return>to quit---

FrameAck*const&) (runnable=..., weak_ptr=..., a2=@0x63ef4534: 0x47a)

at../../base/bind_internal.h:909

#290x623eed3c in Run (a1=@0x63ef4534: 1146, this=0x63ef453c) at../../base/callback.h:436

#30net::TCPClientSocketLibevent::DoReadCallback (this=0x60c7a7a8, rv=0)

at../../net/socket/tcp_client_socket_libevent.cc:639

#310x623eee68 in net::TCPClientSocketLibevent::DidCompleteRead(this=0x60c7a7a8)

at../../net/socket/tcp_client_socket_libevent.cc:702

#320x619178c0 inbase::MessagePumpLibevent::FileDescriptorWatcher::OnFileCanReadWithoutBlocking(this=0x60c7a7f0, fd=142, pump=0x59521e58)

at../../base/message_loop/message_pump_libevent.cc:99

#330x61917952 in base::MessagePumpLibevent::OnLibeventNotification(fd=142,

flags=<optimizedout>, context=<optimized out>)

at../../base/message_loop/message_pump_libevent.cc:356

#340x61bb8d1a in event_process_active (base=<optimized out>)

at../../third_party/libevent/event.c:385

#35event_base_loop(base=<optimized out>, flags=1) at../../third_party/libevent/event.c:525

#360x619170c2 in base::MessagePumpLibevent::Run (this=0x59521e58,delegate=0x63ef4cb8)

at../../base/message_loop/message_pump_libevent.cc:269

#370x61932db2 in base::MessageLoop::RunInternal (this=0x63ef4cb8)

at../../base/message_loop/message_loop.cc:436

#380x6193d718 in base::RunLoop::Run (this=0x63ef4a90) at../../base/run_loop.cc:45

#390x619321c4 in base::MessageLoop::Run (this=<optimized out>)

at../../base/message_loop/message_loop.cc:307

#400x61c36b52 in content::BrowserThreadImpl::IOThreadRun(this=<optimized out>, #41 0x61c371f6 incontent::BrowserThreadImpl::Run (this=0x10001,message_loop=0x63ef4cb8)

at../../content/browser/browser_thread_impl.cc:188

#420x61948e4a in base::Thread::ThreadMain (this=0x59521db8)

at../../base/threading/thread.cc:203

#430x6194614a in base::(anonymous namespace)::ThreadFunc(params=<optimized out>)

at../../base/threading/platform_thread_posix.cc:80

#440x401d2a5c in __thread_entry () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#450x401d2bd8 in pthread_create () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#460x00000000 in ?? ()





--------------------下面是render线程处理一个的requestcomplete的过程------------------

ResourceDispatcher::OnMessageReceived(constIPC::Message& message)

-> DispatchMessage(),处理ResourceMsg_RequestComplete消息:IPC_MESSAGE_HANDLER(ResourceMsg_RequestComplete,OnRequestComplete)

->ResourceDispatcher::OnRequestComplete(),

-> ResourceLoaderBridge:: OnCompletedRequest()

上述肯定最终还会走到ResourceLoader里面:

-> ResourceLoader::didFinishLoadingOnePart()

->m_host->didFinishLoading,这个m_hostResourceFetcher.它继承自ResourceLoaderHost,是在创建ResourceLoader时传进来的。而创建ResourceLoaderResource::Load中创建的,使用的hostResourceFetcher.Source/core/loader/cache/resource.cpp中定义了Resource::load()函数里面创建了ResourceLoader.Resource类有各种子类。比如fontResource,imageResource等。

所以上面的函数是:

resourceFetcher::didFinishLoading()

->FrameLoader::notifier()->dispatchDidFinishLoading(),notifierResourceLoadNotifier

->ResourceLoadNotifier::dispatchDidFinishLoading()

->FrameLoaderClientImpl::dispatchDidFinishLoading()

->调用m_webFrame->clientdidFinishResourceLoad函数。而m_webFramewebFrameImpl。而client是创建WebFrameImpl时传入的。ClientWebSharedWorkerImpl,在voidWebSharedWorkerImpl::initializeLoader(const WebURL&url)里,调用了WebView::->initializeMainFrame(this),意思是说WebSharedWorkerImpl类是WebFrameClient.







注意:DocumentLoader::finishLoading函数是一个切入点,callstack:

#0 WebCore::DocumentLoader::finishedLoading (this=0x5a931c50,finishTime=75756.391204)

at../../third_party/WebKit/Source/core/loader/DocumentLoader.cpp:319

#1 0x62075a4c in WebCore::DocumentLoader::notifyFinished(this=0x5a931c50, resource=<optimized out>)

at../../third_party/WebKit/Source/core/loader/DocumentLoader.cpp:311

#2 0x6209011a in checkNotify (this=0x59330b80)

at../../third_party/WebKit/Source/core/loader/cache/Resource.cpp:200

#3 WebCore::Resource::checkNotify (this=0x59330b80)

at../../third_party/WebKit/Source/core/loader/cache/Resource.cpp:193

#4 0x6208e820 in WebCore::Resource::finishOnePart(this=<optimized out>)

at../../third_party/WebKit/Source/core/loader/cache/Resource.cpp:235

#5 0x6208e956 in WebCore::Resource::finish(this=0x59330b80, finishTime=<optimized out>)

at../../third_party/WebKit/Source/core/loader/cache/Resource.cpp:243

#6 0x6208587c in didFinishLoading (finishTime=75756.391204,this=0x5a932390)

#7 WebCore::ResourceLoader::didFinishLoading(this=0x5a932390, finishTime=<optimized out>)

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:340

#8 0x617ef40a inwebkit_glue::WebURLLoaderImpl::Context::OnCompletedRequest(this=0x59331708,

error_code=<optimizedout>, was_ignored_by_handler=<optimized out>,security_info=..., completion_time=...)

at../../webkit/child/weburlloader_impl.cc:726

#9 0x626f6b84 in content::ResourceDispatcher::OnRequestComplete(this=0x59992710, request_id=<optimized out>,

error_code=0,was_ignored_by_handler=<optimized out>, security_info=...,browser_completion_time=...)

at../../content/child/resource_dispatcher.cc:514

#100x626f6288 in DispatchToMethod<content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, int, bool---Type <return>to continue, or q <return> to quit---

,std::string const&, base::TimeTicks const&), int, int, bool,std::string, base::TimeTicks> (obj=<optimized out>,

method=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,int, int, bool, const std::basic_string<char,std::char_traits<char>, std::allocator<char> > &,const base::TimeTicks &)) 0x626f6b0d<content::ResourceDispatcher::OnRequestComplete(int, int, bool,std::string const&, base::TimeTicks const&)>, arg=...)

at../../base/tuple.h:579

#110x626f62d4 inResourceMsg_RequestComplete::Dispatch<content::ResourceDispatcher,content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, int, bool, std::string const&,base::TimeTicks const&)> (msg=0x5add6558,

obj=0x59992710,func=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,int, int, bool, const std::basic_string<char,std::char_traits<char>, std::allocator<char> > &,const base::TimeTicks &)) 0x626f6b0d<content::ResourceDispatcher::OnRequestComplete(int, int, bool,std::string const&, base::TimeTicks const&)>,sender=<optimized out>)

at../../content/common/resource_messages.h:268

#120x626f7216 in content::ResourceDispatcher::DispatchMessage(this=0x59992710, message=...)

at../../content/child/resource_dispatcher.cc:615

这个msg:IPC_MESSAGE_HANDLER(ResourceMsg_RequestComplete,OnRequestComplete)

#130x626f761c in content::ResourceDispatcher::OnMessageReceived(this=0x59992710, message=...)

at../../content/child/resource_dispatcher.cc:305

#140x626e2bb6 in content::ChildThread::OnMessageReceived(this=0x59992424, msg=...)

at../../content/child/child_thread.cc:314

#150x61a4b1e8 in IPC::ChannelProxy::Context::OnDispatchMessage(this=0x592c61b0, message=...)

at../../ipc/ipc_channel_proxy.cc:264

#160x61a4a05a in Run (a1=..., object=<optimized out>,this=0x64a77898) at ../../base/bind_internal.h:190

#17MakeItSo (a2=..., runnable=..., a1=<optimized out>) at../../base/bind_internal.h:898

---Type<return> to continue, or q <return> to quit---

#18base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(IPC::ChannelProxy::Context::*)(IPC::Message const&)>, void(IPC::ChannelProxy::Context*, IPC::Message const&), void(IPC::ChannelProxy::Context*, IPC::Message)>, void(IPC::ChannelProxy::Context*, IPC::Messageconst&)>::Run(base::internal::BindStateBase*)(base=0x5add6540) at ../../base/bind_internal.h:1253

#190x61ab987e in Run (this=0x64a77a28) at ../../base/callback.h:396

#20base::MessageLoop::RunTask (this=0x64a77cb8, pending_task=...) at../../base/message_loop/message_loop.cc:482

#210x61aba3ee in base::MessageLoop::DeferOrRunPendingTask(this=0x64a77cb8, pending_task=...)

at../../base/message_loop/message_loop.cc:494

#220x61aba720 in DoWork (this=<optimized out>) at../../base/message_loop/message_loop.cc:608

#23base::MessageLoop::DoWork (this=0x64a77cb8) at../../base/message_loop/message_loop.cc:587

#240x61abad58 in base::MessagePumpDefault::Run (this=0x59775ba0,delegate=0x64a77cb8)

at../../base/message_loop/message_pump_default.cc:32

#250x61ab9cba in base::MessageLoop::RunInternal (this=0x64a77cb8) at../../base/message_loop/message_loop.cc:436

#260x61ac4620 in base::RunLoop::Run (this=0x64a77bf8) at../../base/run_loop.cc:45

#270x61ab90cc in base::MessageLoop::Run (this=<optimized out>) at../../base/message_loop/message_loop.cc:307

#280x61acf9ea in base::Thread::ThreadMain (this=0x1) at../../base/threading/thread.cc:203

#290x61acccea in base::(anonymous namespace)::ThreadFunc(params=<optimized out>)

at../../base/threading/platform_thread_posix.cc:80

#300x400fba5c in __thread_entry () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#310x400fbbd8 in pthread_create () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#320x00000000 in ?? ()





#0 WebCore::ResourceLoader::didFinishLoading ()

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:341

#1 0x617ef40a inwebkit_glue::WebURLLoaderImpl::Context::OnCompletedRequest ()

at../../webkit/child/weburlloader_impl.cc:726

#2 0x626f6b84 in content::ResourceDispatcher::OnRequestComplete ()

at../../content/child/resource_dispatcher.cc:514

#3 0x626f6288 in DispatchToMethod<content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, int, bool, std::string const&,base::TimeTicks const&), int, int, bool, std::string,base::TimeTicks> ()

at../../base/tuple.h:579

#4 0x626f62d4 inResourceMsg_RequestComplete::Dispatch<content::ResourceDispatcher,content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, int, bool, std::string const&,base::TimeTicks const&)> (msg=0x5ad70e68,

obj=0x59992710,func=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,int, int, bool, const std::basic_string<char,std::char_traits<char>, std::allocator<char> > &,const base::TimeTicks &)) 0x626f6b0d<content::ResourceDispatcher::OnRequestComplete(int, int, bool,std::string const&, base::TimeTicks const&)>,sender=<optimized out>)

at../../content/common/resource_messages.h:268

#5 0x626f7216 in content::ResourceDispatcher::DispatchMessage()

at../../content/child/resource_dispatcher.cc:615

#6 0x626f761c in content::ResourceDispatcher::OnMessageReceived ()

at../../content/child/resource_dispatcher.cc:305

#7 0x626e2bb6 in content::ChildThread::OnMessageReceived ()

at../../content/child/child_thread.cc:314

#8 0x61a4b1e8 in IPC::ChannelProxy::Context::OnDispatchMessage ()

at../../ipc/ipc_channel_proxy.cc:264

#9 0x61a4a05a in Run (a1=..., object=<optimized out>,this=0x64a77898) at ../../base/bind_internal.h:190

#10MakeItSo (a2=..., runnable=..., a1=<optimized out>) at../../base/bind_internal.h:898

#11base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(IPC::ChannelProxy::Context::*)(IPC::Message const&)>, void(IPC::ChannelProxy::Context*, IPC::Message const&), void(IPC::ChannelProxy::Context*, IPC::Message)>, void(IPC::ChannelProxy::Context*, IPC::Messageconst&)>::Run(base::internal::BindStateBase*)(base=0x5ad70e50) at ../../base/bind_internal.h:1253

#120x61ab987e in Run (this=0x64a77a28) at ../../base/callback.h:396

#13base::MessageLoop::RunTask (this=0x64a77cb8, pending_task=...) at../../base/message_loop/message_loop.cc:482

#140x61aba3ee in base::MessageLoop::DeferOrRunPendingTask(this=0x64a77cb8, pending_task=...)

at../../base/message_loop/message_loop.cc:494

#150x61aba720 in DoWork (this=<optimized out>) at../../base/message_loop/message_loop.cc:608

#16base::MessageLoop::DoWork (this=0x64a77cb8) at../../base/message_loop/message_loop.cc:587

#170x61abad58 in base::MessagePumpDefault::Run (this=0x59775ba0,delegate=0x64a77cb8)

at../../base/message_loop/message_pump_default.cc:32

#180x61ab9cba in base::MessageLoop::RunInternal (this=0x64a77cb8) at../../base/message_loop/message_loop.cc:436

#190x61ac4620 in base::RunLoop::Run (this=0x64a77bf8) at../../base/run_loop.cc:45

---Type<return> to continue, or q <return> to quit---







FrameLoader::completed()的调用callstack:

#0 WebCore::FrameLoader::completed (this=0x5ad6d068)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:802

#1 0x606a63ca in WebCore::FrameLoader::checkCompleted (this=0x5ad6d068)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:612

#2 0x606bf60c in WebCore::ResourceFetcher::didLoadResource(this=0x59a38e90, resource=0x5b0e4a00)

at../../third_party/WebKit/Source/core/loader/cache/ResourceFetcher.cpp:1006

#3 0x606af5f6 in WebCore::ResourceLoader::releaseResources(this=0x59adcc88)

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:91

#4 0x606af8d6 in WebCore::ResourceLoader::cancel(this=0x59adcc88, error=...)

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:211

#5 0x606af9d4 in WebCore::ResourceLoader::cancel (this=<optimizedout>)

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:202

#6 0x606afb30 in WebCore::ResourceLoader::didReceiveResponse (this=0x0,response=...)

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:315

#7 0x5fe19cce inwebkit_glue::WebURLLoaderImpl::Context::OnReceivedResponse(this=0x5b0b8100, info=...)

at../../webkit/child/weburlloader_impl.cc:639

#8 0x60d20d0e in content::ResourceDispatcher::OnReceivedResponse(this=0x593c3638, request_id=<optimized out>,

response_head=...)at ../../content/child/resource_dispatcher.cc:349

#9 0x60d20018 in DispatchToMethod<content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, content::ResourceResponseHeadconst&), int, content::ResourceResponseHead> (arg=..., method=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,int, const content::ResourceResponseHead &)) 0x60d20ca5<content::ResourceDispatcher::OnReceivedResponse(int,content::ResourceResponseHead const&)>,

obj=<optimizedout>) at ../../base/tuple.h:555

---Type<return> to continue, or q <return> to quit---

#10ResourceMsg_ReceivedResponse::Dispatch<content::ResourceDispatcher,content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, content::ResourceResponseHeadconst&)> (msg=0x597d5d50, obj=<optimized out>,

sender=<optimizedout>, func=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,int, const content::ResourceResponseHead &)) 0x60d20ca5<content::ResourceDispatcher::OnReceivedResponse(int,content::ResourceResponseHead const&)>)

at../../content/common/resource_messages.h:208

#110x60d210da in content::ResourceDispatcher::DispatchMessage(this=0x593c3638, message=...)

at../../content/child/resource_dispatcher.cc:608

#120x60d2161c in content::ResourceDispatcher::OnMessageReceived(this=0x593c3638, message=...)

at../../content/child/resource_dispatcher.cc:305

#130x60d0cbb6 in content::ChildThread::OnMessageReceived(this=0x59399214, msg=...)

at../../content/child/child_thread.cc:314

#140x600751e8 in IPC::ChannelProxy::Context::OnDispatchMessage(this=0x592c10d0, message=...)

at../../ipc/ipc_channel_proxy.cc:264

#150x6007405a in Run (a1=..., object=<optimized out>,this=0x65811898) at ../../base/bind_internal.h:190

#16MakeItSo (a2=..., runnable=..., a1=<optimized out>) at../../base/bind_internal.h:898

#17base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(IPC::ChannelProxy::Context::*)(IPC::Message const&)>, void(IPC::ChannelProxy::Context*, IPC::Message const&), void(IPC::ChannelProxy::Context*, IPC::Message)>, void(IPC::ChannelProxy::Context*, IPC::Messageconst&)>::Run(base::internal::BindStateBase*)(base=0x597d5d38) at ../../base/bind_internal.h:1253

#180x600e387e in Run (this=0x65811a28) at ../../base/callback.h:396

#19base::MessageLoop::RunTask (this=0x65811cb8, pending_task=...) at../../base/message_loop/message_loop.cc:482

#200x600e43ee in base::MessageLoop::DeferOrRunPendingTask(this=0x65811cb8, pending_task=...)



FrameLoader里面的m_frame就是Frame,Frame里面的view就是FrameView.FrameLoader::completed()会导致WebCore::FrameView::handleLoadCompleted(),这个函数检查如果document解析完了,会触发绘图。



FrameLoader::handleLoadcompleted()还有一种调用路径:被ResourceMsg_RequestComplete消息触发:

#0 WebCore::FrameView::handleLoadCompleted(this=0x592afe10)

at../../third_party/WebKit/Source/core/page/FrameView.cpp:1765

#1 0x606a634c in WebCore::FrameLoader::checkCompleted(this=0x5b4cec98)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:581

#2 0x606bf60c in WebCore::ResourceFetcher::didLoadResource(this=0x59446370, resource=0x5ac19c40)

at../../third_party/WebKit/Source/core/loader/cache/ResourceFetcher.cpp:1006

#3 0x606af5f6 in WebCore::ResourceLoader::releaseResources(this=0x5b0bbf50)

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:91

#4 0x606af894 in didFinishLoading (finishTime=79130.983825000003,this=0x5b0bbf50)

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:359

#5 WebCore::ResourceLoader::didFinishLoading(this=0x5b0bbf50, finishTime=<optimized out>)

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:340

#6 0x5fe1940a inwebkit_glue::WebURLLoaderImpl::Context::OnCompletedRequest(this=0x5b0b8560,

error_code=<optimizedout>, was_ignored_by_handler=<optimized out>,security_info=..., completion_time=...)

at../../webkit/child/weburlloader_impl.cc:726

#7 0x60d20b84 in content::ResourceDispatcher::OnRequestComplete(this=0x593c3638, request_id=<optimized out>,

error_code=0,was_ignored_by_handler=<optimized out>, security_info=...,browser_completion_time=...)

at../../content/child/resource_dispatcher.cc:514

#8 0x60d20288 in DispatchToMethod<content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, int, bool, std::string const&,base::TimeTicks const&), int, int, bool, std::string,base::TimeTicks> (obj=<optimized out>,

method=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,int, int, bool, const std::basic_string<char,std::char_traits<char>, std::allocator<char> > &,const base::TimeTicks &)) 0x60d20b0d <content::ResourceD---Type<return> to continue, or q <return> to quit---

ispatcher::OnRequestComplete(int,int, bool, std::string const&, base::TimeTicks const&)>,arg=...)

at../../base/tuple.h:579

#9 0x60d202d4 inResourceMsg_RequestComplete::Dispatch<content::ResourceDispatcher,content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, int, bool, std::string const&,base::TimeTicks const&)> (msg=0x5b455238,

obj=0x593c3638,func=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,int, int, bool, const std::basic_string<char,std::char_traits<char>, std::allocator<char> > &,const base::TimeTicks &)) 0x60d20b0d<content::ResourceDispatcher::OnRequestComplete(int, int, bool,std::string const&, base::TimeTicks const&)>,sender=<optimized out>)

at../../content/common/resource_messages.h:268

#100x60d21216 in content::ResourceDispatcher::DispatchMessage(this=0x593c3638, message=...)

at../../content/child/resource_dispatcher.cc:615

#110x60d2161c in content::ResourceDispatcher::OnMessageReceived(this=0x593c3638, message=...)

at../../content/child/resource_dispatcher.cc:305

#120x60d0cbb6 in content::ChildThread::OnMessageReceived(this=0x59399214, msg=...)





FrameLoader::handleLoadCompleted()的另一种调用:看样子是文档解析完毕

Breakpoint2, WebCore::FrameView::handleLoadCompleted (this=0x592afe10)

at../../third_party/WebKit/Source/core/page/FrameView.cpp:1765

1765 return;

(gdb)bt

#0 WebCore::FrameView::handleLoadCompleted (this=0x592afe10)

at../../third_party/WebKit/Source/core/page/FrameView.cpp:1765

#1 0x606a634c in WebCore::FrameLoader::checkCompleted (this=0x5b4cec98)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:581

#2 0x606a667e in WebCore::FrameLoader::finishedParsing(this=0x5b4cec98)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:541

#3 0x6073caae in WebCore::Document::finishedParsing(this=0x59a04784)

at../../third_party/WebKit/Source/core/dom/Document.cpp:4137

#4 0x601d6bd8 in WebCore::HTMLDocumentParser::prepareToStopParsing(this=0x5b513ca0)

at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:196

#5 0x601d7eec inWebCore::HTMLDocumentParser::processParsedChunkFromBackgroundParser(this=0x5b513ca0,

popChunk=...)at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:437

#6 0x601d80c8 in WebCore::HTMLDocumentParser::pumpPendingSpeculations(this=0x5b513ca0)

at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:467

#7 0x601d8472 inWebCore::HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser(this=0x5b513ca0,

chunk=...)at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:317

#8 0x601cfb66 in WTF::FunctionWrapper<void(WebCore::HTMLDocumentParser::*)(WTF::PassOwnPtr<WebCore::HTMLDocumentParser::ParsedChunk>)>::operator()(this=0x58db8dc8, c=..., p1=...)

at../../third_party/WebKit/Source/wtf/Functional.h:210

#9 0x601cfb9c in WTF::BoundFunctionImpl<WTF::FunctionWrapper<void(WebCore::HTMLDocumentParser::*)(WTF::PassOwnPtr<WebCore::HTMLDocumentParser::ParsedChunk>)>,void (WTF::WeakPtr<WebCore::HTMLDocumentParser>,WTF::PassOwnPtr<WebCore::HTMLDocumentParser::ParsedChunk>)>::operator()()(this=<optimized out>)

at../../third_party/WebKit/Source/wtf/Functional.h:420

---Type<return> to continue, or q <return> to quit---

#100x60142fa8 in operator() (this=0x5abd6f18) at../../third_party/WebKit/Source/wtf/Functional.h:577

#11WTF::callFunctionObject (context=0x5abd6f18) at../../third_party/WebKit/Source/wtf/MainThread.cpp:62

#120x5fe169b0 in Run (this=<synthetic pointer>, a1=<optimizedout>) at ../../base/bind_internal.h:171

#13MakeItSo (runnable=..., a1=<optimized out>) at../../base/bind_internal.h:871

#14base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void(*)(void*)>, void (void*), void (void*)>, void(void*)>::Run(base::internal::BindStateBase*) (base=<optimizedout>)

at../../base/bind_internal.h:1169

#150x600e387e in Run (this=0x65811a28) at ../../base/callback.h:396

#16base::MessageLoop::RunTask (this=0x65811cb8, pending_task=...) at../../base/message_loop/message_loop.cc:482

#170x600e43ee in base::MessageLoop::DeferOrRunPendingTask(this=0x65811cb8, pending_task=...)

at../../base/message_loop/message_loop.cc:494

#180x600e4720 in DoWork (this=<optimized out>) at../../base/message_loop/message_loop.cc:608

#19base::MessageLoop::DoWork (this=0x65811cb8) at../../base/message_loop/message_loop.cc:587

#200x600e4d58 in base::MessagePumpDefault::Run (this=0x57bce000,delegate=0x65811cb8)

at../../base/message_loop/message_pump_default.cc:32

#210x600e3cba in base::MessageLoop::RunInternal (this=0x65811cb8) at../../base/message_loop/message_loop.cc:436

#220x600ee620 in base::RunLoop::Run (this=0x65811bf8) at../../base/run_loop.cc:45

#230x600e30cc in base::MessageLoop::Run (this=<optimized out>) at../../base/message_loop/message_loop.cc:307

#240x600f99ea in base::Thread::ThreadMain (this=0x1) at../../base/threading/thread.cc:203

#250x600f6cea in base::(anonymous namespace)::ThreadFunc(params=<optimized out>)

at../../base/threading/platform_thread_posix.cc:80

#260x400fba5c in __thread_entry () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#270x400fbbd8 in pthread_create () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so



还有一种timer触发的FrameLoader::handleLoadCompleted()的调用:

Breakpoint2, WebCore::FrameView::handleLoadCompleted (this=0x592afe10)

at../../third_party/WebKit/Source/core/page/FrameView.cpp:1765

1765 return;

(gdb)bt

#0 WebCore::FrameView::handleLoadCompleted (this=0x592afe10)

at../../third_party/WebKit/Source/core/page/FrameView.cpp:1765

#1 0x606a634c in WebCore::FrameLoader::checkCompleted (this=0x5b4cec98)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:581

#2 0x606bf60c in WebCore::ResourceFetcher::didLoadResource(this=0x59446370, resource=0x0)

at../../third_party/WebKit/Source/core/loader/cache/ResourceFetcher.cpp:1006

#3 0x605c1198 in WebCore::CSSFontSelector::beginLoadTimerFired(this=0x5949d998)

at../../third_party/WebKit/Source/core/css/CSSFontSelector.cpp:602

#4 0x5fdf59e4 in WebCore::Timer<WebCore::SVGElement>::fired(this=<optimized out>)

at../../third_party/WebKit/Source/core/platform/Timer.h:115

#5 0x6051cda8 in WebCore::ThreadTimers::sharedTimerFiredInternal(this=0x597a38c0)

at../../third_party/WebKit/Source/core/platform/ThreadTimers.cpp:134

#6 0x6051ce76 in WebCore::ThreadTimers::sharedTimerFired ()

at../../third_party/WebKit/Source/core/platform/ThreadTimers.cpp:108

#7 0x5fe169a0 in webkit_glue::WebKitPlatformSupportImpl::DoTimeout(this=<optimized out>)

at../../webkit/child/webkitplatformsupport_impl.h:136

#8 0x5fe169d6 in Run (this=0x65811860, object=<optimized out>) at../../base/bind_internal.h:134

#9 MakeItSo (a1=<optimized out>, runnable=...) at../../base/bind_internal.h:871

#10base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void(webkit_glue::WebKitPlatformSupportImpl::*)()>, void(webkit_glue::WebKitPlatformSupportImpl*), void(base::internal::UnretainedWrapper<webkit_glue::WebKitPlatformSupportImpl>)>,void(webkit_glue::WebKitPlatformSupportImpl*)>::Run(base::internal::BindStateBase*)(base=<optimized out>) at ../../base/bind_internal.h:1169

#110x600fc088 in Run (this=0x65811878) at ../../base/callback.h:396

---Type<return> to continue, or q <return> to quit---

#12base::Timer::RunScheduledTask (this=<optimized out>) at../../base/timer/timer.cc:181





FrameLoader::handleLoadCompleted()另一个调用点:当render线程收到ViewMsg_New消息,要创建一个新的renderView时,会初始化Frameloader并调用该函数:

Breakpoint1, WebCore::FrameLoader::completed (this=0x6787c350)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:802

802 else if (sameDocumentNavigationSource ==SameDocumentNavigationReplaceState)

(gdb)bt

#0 WebCore::FrameLoader::completed (this=0x6787c350)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:802

#1 0x606a63ca in WebCore::FrameLoader::checkCompleted (this=0x6787c350)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:612

#2 0x606a52d0 in WebCore::FrameLoader::init(this=0x6787c350)

at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:214

#3 0x600a7208 in init (this=<optimized out>) at../../third_party/WebKit/Source/core/page/Frame.h:204

#4 WebKit::WebFrameImpl::initializeAsMainFrame (this=0x592cc468,page=<optimized out>)

at../../third_party/WebKit/Source/web/WebFrameImpl.cpp:2134

#5 0x600bfeca in WebKit::WebViewImpl::initializeMainFrame(this=0x59b59338, frameClient=<optimized out>)

at../../third_party/WebKit/Source/web/WebViewImpl.cpp:320

#6 0x603b0416 in content::RenderViewImpl::Initialize (this=0x5abdd668,params=0x658111c8)

at../../content/renderer/render_view_impl.cc:924

#7 0x603b06dc in content::RenderViewImpl::Create (opener_id=-2,renderer_prefs=..., webkit_prefs=...,

counter=0x59b3b0f8,routing_id=11, main_frame_routing_id=12, surface_id=6,session_storage_namespace_id=6,

frame_name=...,is_renderer_created=false, swapped_out=false, next_page_id=1,screen_info=...,

accessibility_mode=AccessibilityModeOff,allow_partial_swap=true)

at../../content/renderer/render_view_impl.cc:1102

#8 0x6039c9a8 in content::RenderThreadImpl::OnCreateNewView(this=<optimized out>, params=...)

at../../content/renderer/render_thread_impl.cc:1154

#9 0x6039d282 in DispatchToMethod<content::RenderThreadImpl, void(content::RenderThreadImpl::*)(ViewMsg_New_Params const&),ViewMsg_New_Params> (arg=..., method=

(void(content::RenderThreadImpl::*)(content::RenderThreadImpl * const,const ViewMsg_New_Params &)) 0x6039c935 ---Type <return> tocontinue, or q <return> to quit---

<content::RenderThreadImpl::OnCreateNewView(ViewMsg_New_Paramsconst&)>, obj=0x59399210) at ../../base/tuple.h:548

#10ViewMsg_New::Dispatch<content::RenderThreadImpl,content::RenderThreadImpl, void(content::RenderThreadImpl::*)(ViewMsg_New_Params const&)>(msg=0x5ac85110, obj=0x59399210, sender=<optimized out>, func=

(void(content::RenderThreadImpl::*)(content::RenderThreadImpl * const,const ViewMsg_New_Params &)) 0x6039c935<content::RenderThreadImpl::OnCreateNewView(ViewMsg_New_Paramsconst&)>)

at../../content/common/view_messages.h:808

#110x6039ebc8 in content::RenderThreadImpl::OnControlMessageReceived(this=0x59399210, msg=...)

at../../content/renderer/render_thread_impl.cc:1125

#120x60d0cd54 in OnMessageReceived (msg=..., this=0x59399214) at../../content/child/child_thread.cc:343

#13content::ChildThread::OnMessageReceived (this=0x59399214, msg=...) at../../content/child/child_thread.cc:312

#140x600751e8 in IPC::ChannelProxy::Context::OnDispatchMessage(this=0x592c10d0, message=...)

at../../ipc/ipc_channel_proxy.cc:264

#150x6007405a in Run (a1=..., object=<optimized out>,this=0x65811898) at ../../base/bind_internal.h:190

#16MakeItSo (a2=..., runnable=..., a1=<optimized out>) at../../base/bind_internal.h:898

#17base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(IPC::ChannelProxy::Context::*)(IPC::Message const&)>, void(IPC::ChannelProxy::Context*, IPC::Message const&), void(IPC::ChannelProxy::Context*, IPC::Message)>, void(IPC::ChannelProxy::Context*, IPC::Messageconst&)>::Run(base::internal::BindStateBase*)(base=0x5ac850f8) at ../../base/bind_internal.h:1253

#180x600e387e in Run (this=0x65811a28) at ../../base/callback.h:396

#19base::MessageLoop::RunTask (this=0x65811cb8, pending_task=...) at../../base/message_loop/message_loop.cc:482

#200x600e43ee in base::MessageLoop::DeferOrRunPendingTask(this=0x65811cb8, pending_task=...)

at../../base/message_loop/message_loop.cc:494



打开一个网页时,content::ResourceDispatcher::OnRequestComplete



问题:ResourceMsg_ReceivedResponseResourceMsg_RequestComplete的关系,和先后顺序

前者触发了FrameLoader::completed()后者触发了DocumentLoader::didFinishedLoading()。实际上两者都多次被调用,后者每个资源被下载完后都会调用。





打开一个网页的历程:

ResourceMsg_RequestComplete->WebCore::DocumentLoader::finishedLoading()

ResourceMsg_RequestComplete→ WebCore::FrameLoader::checkCompleted()



打开简单文档历程:

第一步到DocumentLoader::finishedLoading,只是初始化,加载了空文档

#0 WebCore::DocumentLoader::finishedLoading(this=0x5ad9c8d0, finishTime=84586.227721999996) at../../third_party/WebKit/Source/core/loader/DocumentLoader.cpp:319

#1 0x6217fc4c in WebCore::DocumentLoader::maybeLoadEmpty(this=0x5ad9c8d0) at../../third_party/WebKit/Source/core/loader/DocumentLoader.cpp:899

#2 0x6217fd4c in WebCore::DocumentLoader::startLoadingMainResource(this=0x5ad9c8d0) at../../third_party/WebKit/Source/core/loader/DocumentLoader.cpp:913

#3 0x621842a0 in WebCore::FrameLoader::init(this=0x5ad9c1c0) at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:198

#4 0x61b86208 in init (this=<optimized out>) at../../third_party/WebKit/Source/core/page/Frame.h:204

#5 WebKit::WebFrameImpl::initializeAsMainFrame (this=0x5ad9c0c0,page=<optimized out>) at../../third_party/WebKit/Source/web/WebFrameImpl.cpp:2134

#6 0x61b9eeca in WebKit::WebViewImpl::initializeMainFrame(this=0x5ae22420, frameClient=<optimized out>) at../../third_party/WebKit/Source/web/WebViewImpl.cpp:320

#7 0x61e8f416 in content::RenderViewImpl::Initialize (this=0x5ae0a928,params=0x64bdc1c8) at ../../content/renderer/render_view_impl.cc:924

#8 0x61e8f6dc in content::RenderViewImpl::Create(opener_id=-2, renderer_prefs=..., webkit_prefs=...,counter=0x5aaf7f88, routing_id=3, main_frame_routing_id=4,surface_id=2, session_storage_namespace_id=2,

frame_name=...,is_renderer_created=false, swapped_out=false, next_page_id=1,screen_info=..., accessibility_mode=AccessibilityModeOff,allow_partial_swap=true)

at../../content/renderer/render_view_impl.cc:1102

#9 0x61e7b9a8 in content::RenderThreadImpl::OnCreateNewView(this=<optimized out>, params=...) at../../content/renderer/render_thread_impl.cc:1154

#100x61e7c282 in DispatchToMethod<content::RenderThreadImpl, void(content::RenderThreadImpl::*)(ViewMsg_New_Params const&),ViewMsg_New_Params> (arg=..., method=

(void(content::RenderThreadImpl::*)(content::RenderThreadImpl * const,const ViewMsg_New_Params &)) 0x61e7b935<content::RenderThreadImpl::OnCreateNewView(ViewMsg_New_Paramsconst&)>, obj=0x5967a148)

at../../base/tuple.h:548

#11ViewMsg_New::Dispatch<content::RenderThreadImpl,content::RenderThreadImpl, void(content::RenderThreadImpl::*)(ViewMsg_New_Params const&)>(msg=0x59253db0, obj=0x5967a148, sender=<optimized out>, func=

(void(content::RenderThreadImpl::*)(content::RenderThreadImpl * const,const ViewMsg_New_Params &)) 0x61e7b935<content::RenderThreadImpl::OnCreateNewView(ViewMsg_New_Paramsconst&)>)

at../../content/common/view_messages.h:808

#120x61e7dbc8 in content::RenderThreadImpl::OnControlMessageReceived(this=0x5967a148, msg=...) at../../content/renderer/render_thread_impl.cc:1125

#130x627ebd54 in OnMessageReceived (msg=..., this=0x5967a14c) at../../content/child/child_thread.cc:343

#14content::ChildThread::OnMessageReceived (this=0x5967a14c, msg=...) at../../content/child/child_thread.cc:312

#150x61b541e8 in IPC::ChannelProxy::Context::OnDispatchMessage(this=0x59641298, message=...) at ../../ipc/ipc_channel_proxy.cc:264

#160x61b5305a in Run (a1=..., object=<optimized out>,this=0x64bdc898) at ../../base/bind_internal.h:190

#17MakeItSo (a2=..., runnable=..., a1=<optimized out>) at../../base/bind_internal.h:898

#18base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(IPC::ChannelProxy::Context::*)(IPC::Message const&)>, void(IPC::ChannelProxy::Context*, IPC::Message const&), void(IPC::ChannelProxy::Context*, IPC::Message)>, void(IPC::ChannelProxy::Context*, IPC::Messageconst&)>::Run(base::internal::BindStateBase*)(base=0x59253d98) at ../../base/bind_internal.h:1253

#190x61bc287e in Run (this=0x64bdca28) at ../../base/callback.h:396

#20base::MessageLoop::RunTask (this=0x64bdccb8, pending_task=...) at../../base/message_loop/message_loop.cc:482

#210x61bc33ee in base::MessageLoop::DeferOrRunPendingTask(this=0x64bdccb8, pending_task=...) at../../base/message_loop/message_loop.cc:494

#220x61bc3720 in DoWork (this=<optimized out>) at../../base/message_loop/message_loop.cc:608

#23base::MessageLoop::DoWork (this=0x64bdccb8) at../../base/message_loop/message_loop.cc:587

#240x61bc3d58 in base::MessagePumpDefault::Run (this=0x59680af0,delegate=0x64bdccb8) at../../base/message_loop/message_pump_default.cc:32

#250x61bc2cba in base::MessageLoop::RunInternal (this=0x64bdccb8) at../../base/message_loop/message_loop.cc:436

#260x61bcd620 in base::RunLoop::Run (this=0x64bdcbf8) at../../base/run_loop.cc:45

#270x61bc20cc in base::MessageLoop::Run (this=<optimized out>) at../../base/message_loop/message_loop.cc:307

#280x61bd89ea in base::Thread::ThreadMain (this=0x1) at../../base/threading/thread.cc:203

#290x61bd5cea in base::(anonymous namespace)::ThreadFunc(params=<optimized out>) at../../base/threading/platform_thread_posix.cc:80

#300x400fba5c in __thread_entry () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#310x400fbbd8 in pthread_create () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so



第二部:处理ViewMsg_New消息,创建RenderView,并检查是否已经完成加载:其实还没没有加载,这里的操作和第一步基本上都是FrameLoader::init里面的内容。

Breakpoint1, WebCore::FrameLoader::completed (this=0x5ad9c1c0) at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:802

warning:Source file is more recent than executable.

802 else if (sameDocumentNavigationSource ==SameDocumentNavigationReplaceState)

(gdb)bt

#0 WebCore::FrameLoader::completed (this=0x5ad9c1c0) at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:802

#1 0x621853ca in WebCore::FrameLoader::checkCompleted(this=0x5ad9c1c0) at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:612

#2 0x621842d0 in WebCore::FrameLoader::init(this=0x5ad9c1c0) at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:214

#3 0x61b86208 in init (this=<optimized out>) at../../third_party/WebKit/Source/core/page/Frame.h:204

#4 WebKit::WebFrameImpl::initializeAsMainFrame (this=0x5ad9c0c0,page=<optimized out>) at../../third_party/WebKit/Source/web/WebFrameImpl.cpp:2134

#5 0x61b9eeca in WebKit::WebViewImpl::initializeMainFrame(this=0x5ae22420, frameClient=<optimized out>) at../../third_party/WebKit/Source/web/WebViewImpl.cpp:320

#6 0x61e8f416 in content::RenderViewImpl::Initialize (this=0x5ae0a928,params=0x64bdc1c8) at ../../content/renderer/render_view_impl.cc:924

#7 0x61e8f6dc in content::RenderViewImpl::Create(opener_id=-2, renderer_prefs=..., webkit_prefs=...,counter=0x5aaf7f88, routing_id=3, main_frame_routing_id=4,surface_id=2, session_storage_namespace_id=2,

frame_name=...,is_renderer_created=false, swapped_out=false, next_page_id=1,screen_info=..., accessibility_mode=AccessibilityModeOff,allow_partial_swap=true)

at../../content/renderer/render_view_impl.cc:1102

#8 0x61e7b9a8 in content::RenderThreadImpl::OnCreateNewView(this=<optimized out>, params=...) at../../content/renderer/render_thread_impl.cc:1154

#9 0x61e7c282 in DispatchToMethod<content::RenderThreadImpl, void(content::RenderThreadImpl::*)(ViewMsg_New_Params const&),ViewMsg_New_Params> (arg=..., method=

(void(content::RenderThreadImpl::*)(content::RenderThreadImpl * const,const ViewMsg_New_Params &)) 0x61e7b935<content::RenderThreadImpl::OnCreateNewView(ViewMsg_New_Paramsconst&)>, obj=0x5967a148)

at../../base/tuple.h:548

#10ViewMsg_New::Dispatch<content::RenderThreadImpl,content::RenderThreadImpl, void(content::RenderThreadImpl::*)(ViewMsg_New_Params const&)>(msg=0x59253db0, obj=0x5967a148, sender=<optimized out>, func=

(void(content::RenderThreadImpl::*)(content::RenderThreadImpl * const,const ViewMsg_New_Params &)) 0x61e7b935<content::RenderThreadImpl::OnCreateNewView(ViewMsg_New_Paramsconst&)>)

at../../content/common/view_messages.h:808

#110x61e7dbc8 in content::RenderThreadImpl::OnControlMessageReceived(this=0x5967a148, msg=...) at../../content/renderer/render_thread_impl.cc:1125

#120x627ebd54 in OnMessageReceived (msg=..., this=0x5967a14c) at../../content/child/child_thread.cc:343

#13content::ChildThread::OnMessageReceived (this=0x5967a14c, msg=...) at../../content/child/child_thread.cc:312

#140x61b541e8 in IPC::ChannelProxy::Context::OnDispatchMessage(this=0x59641298, message=...) at ../../ipc/ipc_channel_proxy.cc:264

#150x61b5305a in Run (a1=..., object=<optimized out>,this=0x64bdc898) at ../../base/bind_internal.h:190

#16MakeItSo (a2=..., runnable=..., a1=<optimized out>) at../../base/bind_internal.h:898

#17base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(IPC::ChannelProxy::Context::*)(IPC::Message const&)>, void(IPC::ChannelProxy::Context*, IPC::Message const&), void(IPC::ChannelProxy::Context*, IPC::Message)>, void(IPC::ChannelProxy::Context*, IPC::Messageconst&)>::Run(base::internal::BindStateBase*)(base=0x59253d98) at ../../base/bind_internal.h:1253

#180x61bc287e in Run (this=0x64bdca28) at ../../base/callback.h:396

#19base::MessageLoop::RunTask (this=0x64bdccb8, pending_task=...) at../../base/message_loop/message_loop.cc:482

#200x61bc33ee in base::MessageLoop::DeferOrRunPendingTask(this=0x64bdccb8, pending_task=...) at../../base/message_loop/message_loop.cc:494

#210x61bc3720 in DoWork (this=<optimized out>) at../../base/message_loop/message_loop.cc:608

#22base::MessageLoop::DoWork (this=0x64bdccb8) at../../base/message_loop/message_loop.cc:587

#230x61bc3d58 in base::MessagePumpDefault::Run (this=0x59680af0,delegate=0x64bdccb8) at../../base/message_loop/message_pump_default.cc:32

#240x61bc2cba in base::MessageLoop::RunInternal (this=0x64bdccb8) at../../base/message_loop/message_loop.cc:436

#250x61bcd620 in base::RunLoop::Run (this=0x64bdcbf8) at../../base/run_loop.cc:45

#260x61bc20cc in base::MessageLoop::Run (this=<optimized out>) at../../base/message_loop/message_loop.cc:307

#270x61bd89ea in base::Thread::ThreadMain (this=0x1) at../../base/threading/thread.cc:203

#280x61bd5cea in base::(anonymous namespace)::ThreadFunc(params=<optimized out>) at../../base/threading/platform_thread_posix.cc:80

#290x400fba5c in __thread_entry () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#300x400fbbd8 in pthread_create () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so



第三部:文档加载完毕:

Breakpoint2, WebCore::DocumentLoader::finishedLoading (this=0x5ae3a018,finishTime=84798.191741000002) at../../third_party/WebKit/Source/core/loader/DocumentLoader.cpp:319

319 }

(gdb)bt

#0 WebCore::DocumentLoader::finishedLoading(this=0x5ae3a018, finishTime=84798.191741000002) at../../third_party/WebKit/Source/core/loader/DocumentLoader.cpp:319

#1 0x6217ea4c in WebCore::DocumentLoader::notifyFinished(this=0x5ae3a018, resource=<optimized out>) at../../third_party/WebKit/Source/core/loader/DocumentLoader.cpp:311

#2 0x6219911a in checkNotify (this=0x5ad154e8) at../../third_party/WebKit/Source/core/loader/cache/Resource.cpp:200

#3 WebCore::Resource::checkNotify (this=0x5ad154e8) at../../third_party/WebKit/Source/core/loader/cache/Resource.cpp:193

#4 0x62197820 in WebCore::Resource::finishOnePart(this=<optimized out>) at../../third_party/WebKit/Source/core/loader/cache/Resource.cpp:235

#5 0x62197956 in WebCore::Resource::finish (this=0x5ad154e8,finishTime=<optimized out>) at../../third_party/WebKit/Source/core/loader/cache/Resource.cpp:243

#6 0x6218e87c in didFinishLoading (finishTime=84798.191741000002,this=0x5ad15008) at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:352

#7 WebCore::ResourceLoader::didFinishLoading(this=0x5ad15008, finishTime=<optimized out>) at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:340

#8 0x618f840a inwebkit_glue::WebURLLoaderImpl::Context::OnCompletedRequest(this=0x5ad15900, error_code=<optimized out>,was_ignored_by_handler=<optimized out>, security_info=...,completion_time=...)

at../../webkit/child/weburlloader_impl.cc:726

#9 0x627ffb84 in content::ResourceDispatcher::OnRequestComplete(this=0x58c2fdc0, request_id=<optimized out>, error_code=0,was_ignored_by_handler=<optimized out>, security_info=...,browser_completion_time=...)

at../../content/child/resource_dispatcher.cc:514

#100x627ff288 in DispatchToMethod<content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, int, bool, std::string const&,base::TimeTicks const&), int, int, bool, std::string,base::TimeTicks> (

obj=<optimizedout>, method=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,int, int, bool, const std::basic_string<char,std::char_traits<char>, std::allocator<char> > &,const base::TimeTicks &)) 0x627ffb0d<content::ResourceDispatcher::OnRequestComplete(int, int, bool,std::string const&, base::TimeTicks const&)>, arg=...) at../../base/tuple.h:579

#110x627ff2d4 inResourceMsg_RequestComplete::Dispatch<content::ResourceDispatcher,content::ResourceDispatcher, void(content::ResourceDispatcher::*)(int, int, bool, std::string const&,base::TimeTicks const&)>

(msg=0x5ae25238,obj=0x58c2fdc0, func=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,int, int, bool, const std::basic_string<char,std::char_traits<char>, std::allocator<char> > &,const base::TimeTicks &)) 0x627ffb0d<content::ResourceDispatcher::OnRequestComplete(int, int, bool,std::string const&, base::TimeTicks const&)>,sender=<optimized out>) at../../content/common/resource_messages.h:268

#120x62800216 in content::ResourceDispatcher::DispatchMessage(this=0x58c2fdc0, message=...) at../../content/child/resource_dispatcher.cc:615

#130x6280061c in content::ResourceDispatcher::OnMessageReceived(this=0x58c2fdc0, message=...) at../../content/child/resource_dispatcher.cc:305

#140x627ebbb6 in content::ChildThread::OnMessageReceived(this=0x5967a14c, msg=...) at ../../content/child/child_thread.cc:314

#150x61b541e8 in IPC::ChannelProxy::Context::OnDispatchMessage(this=0x59641298, message=...) at ../../ipc/ipc_channel_proxy.cc:264

#160x61b5305a in Run (a1=..., object=<optimized out>,this=0x64bdc898) at ../../base/bind_internal.h:190

#17MakeItSo (a2=..., runnable=..., a1=<optimized out>) at../../base/bind_internal.h:898

#18base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void(IPC::ChannelProxy::Context::*)(IPC::Message const&)>, void(IPC::ChannelProxy::Context*, IPC::Message const&), void(IPC::ChannelProxy::Context*, IPC::Message)>, void(IPC::ChannelProxy::Context*, IPC::Messageconst&)>::Run(base::internal::BindStateBase*)(base=0x5ae25220) at ../../base/bind_internal.h:1253

#190x61bc287e in Run (this=0x64bdca28) at ../../base/callback.h:396

#20base::MessageLoop::RunTask (this=0x64bdccb8, pending_task=...) at../../base/message_loop/message_loop.cc:482

#210x61bc33ee in base::MessageLoop::DeferOrRunPendingTask(this=0x64bdccb8, pending_task=...) at../../base/message_loop/message_loop.cc:494

#220x61bc3720 in DoWork (this=<optimized out>) at../../base/message_loop/message_loop.cc:608

#23base::MessageLoop::DoWork (this=0x64bdccb8) at../../base/message_loop/message_loop.cc:587

#240x61bc3d58 in base::MessagePumpDefault::Run (this=0x59680af0,delegate=0x64bdccb8) at../../base/message_loop/message_pump_default.cc:32

#250x61bc2cba in base::MessageLoop::RunInternal (this=0x64bdccb8) at../../base/message_loop/message_loop.cc:436

#260x61bcd620 in base::RunLoop::Run (this=0x64bdcbf8) at../../base/run_loop.cc:45

#270x61bc20cc in base::MessageLoop::Run (this=<optimized out>) at../../base/message_loop/message_loop.cc:307

#280x61bd89ea in base::Thread::ThreadMain (this=0x1) at../../base/threading/thread.cc:203

#290x61bd5cea in base::(anonymous namespace)::ThreadFunc(params=<optimized out>) at../../base/threading/platform_thread_posix.cc:80

#300x400fba5c in __thread_entry () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#310x400fbbd8 in pthread_create () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so



。。。。中间会有触发文档解析的流程....



第四步:文档解析完毕,通知FrameLoader可以画图了:

Breakpoint1, WebCore::FrameLoader::completed (this=0x5ad9c1c0) at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:802

802 else if (sameDocumentNavigationSource ==SameDocumentNavigationReplaceState)

(gdb)bt

#0 WebCore::FrameLoader::completed (this=0x5ad9c1c0) at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:802

#1 0x621853ca in WebCore::FrameLoader::checkCompleted (this=0x5ad9c1c0)at ../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:612

#2 0x6218567e in WebCore::FrameLoader::finishedParsing(this=0x5ad9c1c0) at../../third_party/WebKit/Source/core/loader/FrameLoader.cpp:541

#3 0x6221baae in WebCore::Document::finishedParsing(this=0x3a724784) at../../third_party/WebKit/Source/core/dom/Document.cpp:4137

#4 0x61cb5bd8 in WebCore::HTMLDocumentParser::prepareToStopParsing(this=0x5219dbc0) at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:196

#5 0x61cb6eec inWebCore::HTMLDocumentParser::processParsedChunkFromBackgroundParser(this=0x5219dbc0, popChunk=...) at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:437

#6 0x61cb70c8 in WebCore::HTMLDocumentParser::pumpPendingSpeculations(this=0x5219dbc0) at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:467

#7 0x61cb7472 inWebCore::HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser(this=0x5219dbc0, chunk=...) at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:317

#8 0x61caeb66 in WTF::FunctionWrapper<void(WebCore::HTMLDocumentParser::*)(WTF::PassOwnPtr<WebCore::HTMLDocumentParser::ParsedChunk>)>::operator()(this=0x5b5cdf18, c=..., p1=...)

at../../third_party/WebKit/Source/wtf/Functional.h:210

#9 0x61caeb9c in WTF::BoundFunctionImpl<WTF::FunctionWrapper<void(WebCore::HTMLDocumentParser::*)(WTF::PassOwnPtr<WebCore::HTMLDocumentParser::ParsedChunk>)>,void (WTF::WeakPtr<WebCore::HTMLDocumentParser>,WTF::PassOwnPtr<WebCore::HTMLDocumentParser::ParsedChunk>)>::operator()()(this=<optimized out>) at../../third_party/WebKit/Source/wtf/Functional.h:420

#100x61c21fa8 in operator() (this=0x5b5cdf30) at../../third_party/WebKit/Source/wtf/Functional.h:577

#11WTF::callFunctionObject (context=0x5b5cdf30) at../../third_party/WebKit/Source/wtf/MainThread.cpp:62

#120x618f59b0 in Run (this=<synthetic pointer>, a1=<optimizedout>) at ../../base/bind_internal.h:171

#13MakeItSo (runnable=..., a1=<optimized out>) at../../base/bind_internal.h:871

#14base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void(*)(void*)>, void (void*), void (void*)>, void(void*)>::Run(base::internal::BindStateBase*) (base=<optimizedout>)

at../../base/bind_internal.h:1169

#150x61bc287e in Run (this=0x64bdca28) at ../../base/callback.h:396

#16base::MessageLoop::RunTask (this=0x64bdccb8, pending_task=...) at../../base/message_loop/message_loop.cc:482

#170x61bc33ee in base::MessageLoop::DeferOrRunPendingTask(this=0x64bdccb8, pending_task=...) at../../base/message_loop/message_loop.cc:494

#180x61bc3720 in DoWork (this=<optimized out>) at../../base/message_loop/message_loop.cc:608

#19base::MessageLoop::DoWork (this=0x64bdccb8) at../../base/message_loop/message_loop.cc:587

#200x61bc3d58 in base::MessagePumpDefault::Run (this=0x59680af0,delegate=0x64bdccb8) at../../base/message_loop/message_pump_default.cc:32

#210x61bc2cba in base::MessageLoop::RunInternal (this=0x64bdccb8) at../../base/message_loop/message_loop.cc:436

#220x61bcd620 in base::RunLoop::Run (this=0x64bdcbf8) at../../base/run_loop.cc:45

#230x61bc20cc in base::MessageLoop::Run (this=<optimized out>) at../../base/message_loop/message_loop.cc:307

#240x61bd89ea in base::Thread::ThreadMain (this=0x1) at../../base/threading/thread.cc:203

#250x61bd5cea in base::(anonymous namespace)::ThreadFunc(params=<optimized out>) at../../base/threading/platform_thread_posix.cc:80

#260x400fba5c in __thread_entry () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#270x400fbbd8 in pthread_create () from/tmp/tshao-adb-gdb-libs/system/lib/libc.so

#280x00000000 in ?? ()





HTML的解析:

voidHTMLDocumentParser::startBackgroundParser()这个函数启动一个background的解析。

BackgroundHTMLParser类解析htmltoken之后会把他们发送会mainthread:

callOnMainThread(bind(&HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser,m_parser,chunk.release()));然后mainthread调用processParsedChunkFromBackgroundParser处理background发过来的解析后的chunk.当发现处理到EOF时,就知道文件处理完了:

if(tokens->last().type()== HTMLToken::EndOfFile){

ASSERT(m_speculations.isEmpty());// There should never be any chunksafter the EOF.

PrepareToStopParsing();//通知frameloader文档解析完了

}



HTMLDocumentParser::startBackgroundParser()是谁调用的?一旦来了数据,就开是启动parser了。当数据源源不断来到后,不断讲述据发送到后台parser预先解析,解析结果发回到主线程处理。,当主线程发现数据处理完后,就通知frameloader

#0 WebCore::HTMLDocumentParser::startBackgroundParser(this=0x5ace4920)

at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:645

#1 0x619ad0a0 in append (inputSource=..., this=0x5ace4920)

at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:684

#2 WebCore::HTMLDocumentParser::append(this=0x5ace4920,inputSource=...)

at../../third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp:677

#3 0x61f09706 in appendBytes (length=<optimized out>,data=<optimized out>, this=0x5ace4920)

at../../third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp:103

#4 WebCore::DecodedDataDocumentParser::appendBytes (this=0x5ace4920,data=<optimized out>, length=<optimized out>)

at../../third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp:88

#5 0x61e78f2e in WebCore::DocumentWriter::addData (this=0x5a702438,

bytes=0x5ae0f000"<html>\r\n<head>\r\n\t<title></title>\r\n\t<styletype=\"text/css\">\r\n\t#red{\r\n\t\twidth:100px;\r\n\t\theight: 100px;\r\n\t\tbackground:red;\r\n\t}\r\n\t</style>\r\n</head>\r\n<body>\r\n<divid=\"red\">i am red</div>\r\n<divid=\"blue\">"..., length=301)

at../../third_party/WebKit/Source/core/loader/DocumentWriter.cpp:104

#6 0x61e7535e in WebCore::DocumentLoader::dataReceived(this=0x5a7442f0,resource=<optimized out>,

data=0x5ae0f000"<html>\r\n<head>\r\n\t<title></title>\r\n\t<styletype=\"text/css\">\r\n\t#red{\r\n\t\twidth:100px;\r\n\t\theight: 100px;\r\n\t\tbackground:red;\r\n\t}\r\n\t</style>\r\n</head>\r\n<body>\r\n<divid=\"red\">i am red</div>\r\n<divid=\"blue\">"..., length=301)

at../../third_party/WebKit/Source/core/loader/DocumentLoader.cpp:657

#7 0x61e8dfb0 in WebCore::RawResource::appendData (this=0x5ac9ebd8,

data=0x5ae0f000"<html>\r\n<head>\r\n\t<title></title>\r\n\t<styletype=\"text/css\">\r\n\t#red{\r\n\t\twidth:100px;\r\n\t\theight: 100px;\r\n\t\tbackground:red;\r\n\t}\r\n\t</style>\r\n</head>\r\n<body>\r\n<divid=\"red\">i a---Type <return> to continue, or q<return> to quit---

mred</div>\r\n<div id=\"blue\">"...,length=301)

at../../third_party/WebKit/Source/core/loader/cache/RawResource.cpp:49

#8 0x61e84fe0 in WebCore::ResourceLoader::didReceiveData(this=0x5ac9ef60,

data=0x5ae0f000"<html>\r\n<head>\r\n\t<title></title>\r\n\t<styletype=\"text/css\">\r\n\t#red{\r\n\t\twidth:100px;\r\n\t\theight: 100px;\r\n\t\tbackground:red;\r\n\t}\r\n\t</style>\r\n</head>\r\n<body>\r\n<divid=\"red\">i am red</div>\r\n<divid=\"blue\">"..., length=301, encodedDataLength=-1)

at../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:337

#9 0x615ef0dc in OnReceivedData (encoded_data_length=<optimizedout>, data_length=301,

data=0x5ae0f000"<html>\r\n<head>\r\n\t<title></title>\r\n\t<styletype=\"text/css\">\r\n\t#red{\r\n\t\twidth:100px;\r\n\t\theight: 100px;\r\n\t\tbackground:red;\r\n\t}\r\n\t</style>\r\n</head>\r\n<body>\r\n<divid=\"red\">i am red</div>\r\n<divid=\"blue\">"..., this=0x5acbaa58) at../../webkit/child/weburlloader_impl.cc:693

#10webkit_glue::WebURLLoaderImpl::Context::OnReceivedData(this=0x5acbaa58,

data=0x5ae0f000"<html>\r\n<head>\r\n\t<title></title>\r\n\t<styletype=\"text/css\">\r\n\t#red{\r\n\t\twidth:100px;\r\n\t\theight: 100px;\r\n\t\tbackground:red;\r\n\t}\r\n\t</style>\r\n</head>\r\n<body>\r\n<divid=\"red\">i am red</div>\r\n<divid=\"blue\">"..., data_length=301,encoded_data_length=<optimized out>)

at../../webkit/child/weburlloader_impl.cc:678

#110x624f7876 in content::ResourceDispatcher::OnReceivedData(this=0x59acbc30, message=..., request_id=0,

data_offset=<optimizedout>, data_length=301, encoded_data_length=-1)

at../../content/child/resource_dispatcher.cc:417

#120x624f6166 inResourceMsg_DataReceived::Dispatch<content::ResourceDispatcher,content::ResourceDispatcher, int, int, int, int> (msg=0x521910b8,obj=0x59acbc30, sender=<optimized out>, func=

(void(content::ResourceDispatcher::*)(content::ResourceDispatcher * const,const IPC::Message &, int, int, int, int)) 0x624f775d<content::ResourceDispatcher::OnReceivedData(IPC::Messageconst&, int, int, int, int)>)

---Type<return> to continue, or q <return> to quit---

at../../content/common/resource_messages.h:253

#130x624f71aa in content::ResourceDispatcher::DispatchMessage(this=0x59acbc30, message=...)

at../../content/child/resource_dispatcher.cc:613

#140x624f761c in content::ResourceDispatcher::OnMessageReceived(this=0x59acbc30, message=...)

at../../content/child/resource_dispatcher.cc:305

#150x624e2bb6 in content::ChildThread::OnMessageReceived(this=0x59acb664, msg=...)

at../../content/child/child_thread.cc:314



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值