#001
?
void FrameLoader::load(const ResourceRequest& request)
#002
?
{
#003
?????
load(request, SubstituteData());
#004
?
}
在這個(gè)函數(shù)也只是一個(gè)中間者,它又調(diào)用函數(shù)
load
函數(shù)的重載函數(shù)來(lái)實(shí)現(xiàn)了。
#001
?
void FrameLoader::load(const ResourceRequest& request, const SubstituteData& substituteData)
#002
?
{
#003
?????
if (m_inStopAllLoaders)
#004
??
???????
return;
#005
?????????
#006
?????
// FIXME: is this the right place to reset loadType? Perhaps this should be done after loading is finished or aborted.
#
#008
?????
load(m_client->createDocumentLoader(request, substituteData).get());
#009
?
}
#010
?
在這個(gè)函數(shù)里,第一個(gè)參數(shù)
request
是連接相關(guān)的信息,第二個(gè)參數(shù)
substituteData
是一些狀態(tài)數(shù)據(jù)。然后在第
7
行里設(shè)置加載的類型,第
8
行里調(diào)用
WebFrameLoaderClient::createDocumentLoader
函數(shù)來(lái)創(chuàng)建
WebDocumentLoaderImpl
對(duì)象,然后再通過
get
函數(shù)返回來(lái),這樣就知道
load
函數(shù)又調(diào)用那個(gè)重載函數(shù)了,原來(lái)它是調(diào)用這個(gè)函數(shù),如下:
#001
?
void FrameLoader::load(DocumentLoader* newDocumentLoader)
#002
?
{
#003
?????
ResourceRequest& r = newDocumentLoader->request();
#004
?????
addExtraFieldsToRequest(r, true, false);
#005
?????
FrameLoadType type;
#006
?
#007
?????
if (shouldTreatURLAsSameAsCurrent(newDocumentLoader->originalRequest().url())) {
#008
?????????
r.setCachePolicy(ReloadIgnoringCacheData);
#009
?????????
type = FrameLoadTypeSame;
#010
?????
} else
#011
?????????
type = FrameLoadTypeStandard;
#012
?
#013
?????
// Do not use original encoding override since it is not loaded by user
#014
?????
// selecting encoding.
#015
?????
if (m_documentLoader)
#016
?????????
newDocumentLoader->setOverrideEncoding(String());
#017
?????
#018
?????
// When we loading alternate content for an unreachable URL that we're
#019
?????
// visiting in the b/f list, we treat it as a reload so the b/f list
#020
?????
// is appropriately maintained.
#021
?????
if (shouldReloadToHandleUnreachableURL(newDocumentLoader)) {
#022
?????????
ASSERT(type == FrameLoadTypeStandard);
#023
????????
?
type = FrameLoadTypeReload;
#024
?????
}
#025
?
#026
?????
load(newDocumentLoader, type, 0);
#027
?
}
上面只對(duì)
newDocumentLoader
做一些準(zhǔn)備工作,并沒有真正地去加載任何東西,接著又調(diào)用函數(shù):
void FrameLoader::load(DocumentLoader* loader, FrameLoadType type, PassRefPtr<FormState> formState)
在上面這個(gè)函數(shù)進(jìn)行安全策略的處理,然后再經(jīng)過
N
個(gè)函數(shù)處理之后,就調(diào)用下面的函數(shù):
void FrameLoader::continueLoadAfterWillSubmitForm(PolicyAction)
在這個(gè)函數(shù)開始使用類
DocumentLoader
來(lái)設(shè)置下載請(qǐng)求,主要通過函數(shù)
bool DocumentLoader::startLoadingMainResource(unsigned long identifier)
來(lái)實(shí)現(xiàn)的,緊跟后面調(diào)用加載函數(shù):
bool MainResourceLoader::load(const ResourceRequest& r, const SubstituteData&
?
substituteData)
在這個(gè)函數(shù)里又開始分為兩種情況處理,一種是延進(jìn)加載數(shù)據(jù),一種是立即加載數(shù)據(jù),下面主要介紹立即加載數(shù)據(jù)函數(shù):
bool MainResourceLoader::loadNow(ResourceRequest& r)
在類
MainResourceLoader
是主要資源下載的管理類,
loadNow
函數(shù)是把資源請(qǐng)求
ResourceRequest
變成一個(gè)
IPC
消息又發(fā)送給資源下載進(jìn)程去處理。它的簡(jiǎn)略代碼如下:
#001
?
bool MainResourceLoader::loadNow(ResourceRequest& r)
#002
?
{
......
#011
?????
willSendRequest(r, ResourceResponse());
#012
?
......
#015
?????
if (!frameLoader())
#016
?
????????
return false;
#017
?????
......
#023
?
#024
?????
if (m_substituteData.isValid())
#025
?????????
handleDataLoadSoon(r);
#026
?????
else if (shouldLoadEmpty || frameLoader()->representationExistsForURLScheme(url.protocol()))
#027
?????????
handleEmptyLoad(url, !shouldLoadEmpty);
#028
?????
else
#
#030
?
#031
?????
return false;
#032
?
}
在這個(gè)函數(shù)的第
29
行里,就會(huì)通過
ResourceHandle::create
函數(shù)創(chuàng)建一個(gè)資源消息,并把這個(gè)消息發(fā)送出去,到底它是怎么樣實(shí)現(xiàn)的呢?下一次再來(lái)分析它。
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
