#001
?
void FrameLoader::load(const ResourceRequest& request)
#002
?
{
#003
?????
load(request, SubstituteData());
#004
?
}
在這個函數也只是一個中間者,它又調用函數
load
函數的重載函數來實現了。
#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
?
在這個函數里,第一個參數
request
是連接相關的信息,第二個參數
substituteData
是一些狀態數據。然后在第
7
行里設置加載的類型,第
8
行里調用
WebFrameLoaderClient::createDocumentLoader
函數來創建
WebDocumentLoaderImpl
對象,然后再通過
get
函數返回來,這樣就知道
load
函數又調用那個重載函數了,原來它是調用這個函數,如下:
#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
?
}
上面只對
newDocumentLoader
做一些準備工作,并沒有真正地去加載任何東西,接著又調用函數:
void FrameLoader::load(DocumentLoader* loader, FrameLoadType type, PassRefPtr<FormState> formState)
在上面這個函數進行安全策略的處理,然后再經過
N
個函數處理之后,就調用下面的函數:
void FrameLoader::continueLoadAfterWillSubmitForm(PolicyAction)
在這個函數開始使用類
DocumentLoader
來設置下載請求,主要通過函數
bool DocumentLoader::startLoadingMainResource(unsigned long identifier)
來實現的,緊跟后面調用加載函數:
bool MainResourceLoader::load(const ResourceRequest& r, const SubstituteData&
?
substituteData)
在這個函數里又開始分為兩種情況處理,一種是延進加載數據,一種是立即加載數據,下面主要介紹立即加載數據函數:
bool MainResourceLoader::loadNow(ResourceRequest& r)
在類
MainResourceLoader
是主要資源下載的管理類,
loadNow
函數是把資源請求
ResourceRequest
變成一個
IPC
消息又發送給資源下載進程去處理。它的簡略代碼如下:
#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
?
}
在這個函數的第
29
行里,就會通過
ResourceHandle::create
函數創建一個資源消息,并把這個消息發送出去,到底它是怎么樣實現的呢?下一次再來分析它。
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

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