loader()->load函數里面,那么在這個函數里面到底是怎么樣處理的呢,只有去分析它的代碼,我們才能找到它的答案,現在就來開始看吧,如下:#001voidFrameLoader::load(constResourceRequest&request)#002{#003load(request,SubstituteData());#004}在這個函數也只是一個中間者,它又調用函數loa" />

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

谷歌瀏覽器的源碼分析(24)

系統 2430 0
繼續上一次的分析,這里開始把連接址和其它相關的信息傳送 frame_->loader()->load 函數里面,那么在這個函數里面到底是怎么樣處理的呢,只有去分析它的代碼,我們才能找到它的答案,現在就來開始看吧,如下:

#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.

# 007 ????? m _loadType = FrameLoadTypeStandard;

#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

# 029 ????????? m _handle = ResourceHandle::create(r, this, m_frame.get(), false, true, true);

#030 ?

#031 ????? return false;

#032 ? }

在這個函數的第 29 行里,就會通過 ResourceHandle::create 函數創建一個資源消息,并把這個消息發送出去,到底它是怎么樣實現的呢?下一次再來分析它。

谷歌瀏覽器的源碼分析(24)


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

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

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 怀化市| 抚松县| 青州市| 许昌县| 吉木乃县| 内乡县| 裕民县| 萍乡市| 潮安县| 五华县| 广东省| 鹤庆县| 江津市| 荥经县| 京山县| 普兰店市| 故城县| 清河县| 天水市| 旬阳县| 长顺县| 内黄县| 化德县| 娱乐| 吐鲁番市| 大安市| 惠安县| 临夏市| 樟树市| 宜城市| 和田市| 宁波市| 定安县| 吉木萨尔县| 霸州市| 天台县| 邢台县| 中超| 成都市| 东方市| 汤原县|