receive data to parse

本文详细探讨了从Chromium和Apache两个不同角度的数据接收流程,包括数据在WebUrlLoaderClient、ResourceLoader、HTMLTokenizer等组件间的传递,以及在HTMLTreeBuilder中构建DOM树的过程。同时,介绍了设置Accept类型和DTD的步骤,以及从WebView加载URL到网络请求的完整路径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. receive data to parse

a .for chromium stack

WebUrlLoaderClient::didReceiveData

ResourceLoader::didReceiveData

MainResourceLoader::didReceiveData

ResourceLoader::didReceiveData

MainResourceLoader::addData

DocumentLoader::receivedData

DocumentLoader::commitLoad 

FrameLoaderClient::committedLoad (FrameLoaderClientAndroid.cpp)

//also call ResourceLoader::didReceiveResponse

DocumentLoader::commitData(also call DocumentWrite:setEncoding to create the document.)

DocumentWriter::addData

DecodedDataDocumentParser::appendBytes

HTMLDocumentParser::append

HTMLDocumentParser::pumpTokenizerIfPossible

HTMLDocumentParser::pumpTokenizer

HTMLTokenizer::nextToken


//VC's receive sequence

a.ResourceLoader::didReceiveRespons

b.MainResourceLoader::didReceiveResponse

c.ResourceLoader::didReceiveRespons

d.ResourceLoader::didReceiveData

e.MainResourceLoader::didReceiveData


b.for apache

LoadListener::commitLoad

WebCoreResourceLoader::nativeAddData

WebCoreResourceLoader::AddData

ResourceHandleClient::didReceiveData

ResourceLoader::didReceiveData

MainResourceLoader::didReceiveData

ResourceLoader::didReceiveData

MainResourceLoader::addData

DocumentLoader::receivedData

DocumentLoader::commitLoad

FrameLoaderClientAndroid::committedLoad

DocumentLoader::commitData

DocumentWriter::addData

DecodedDataDocumentParser::appendBytes

HTMLDocumentParser::append

HTMLDocumentParser::pumpTokenizerIfPossible

HTMLDocumentParser::pumpTokenizer

HTMLTokenizer::nextToken


HTMLTokenizer::nextToken, generate HTMLTokenizer from document;

HTMLTreeBuilder::constructTreeFromToken, generate dom tree with HTMLTokenizer


PS:

The HTMLTreeBuilder was in HTMLDocumentParser, and 

HTMLDocumentParse has memberships as below:

OwnPtr<HTMLTokenizer> m_tokenizer
OwnPtr<HTMLScriptRunner> m_scriptRunner;
OwnPtr<HTMLTreeBuilder> m_treeBuilder;
OwnPtr<HTMLPreloadScanner> m_preloadScanner;
OwnPtr<HTMLParserScheduler> m_parserScheduler;
HTMLSourceTracker m_sourceTracker;
XSSFilter m_xssFilter;


2 FrameLoaderClient::committedLoad

void FrameLoaderClientAndroid::committedLoad(DocumentLoader* loader,
    const char* data, int length) {
    if (!m_manualLoader)
        loader->commitData(data, length);

    // commit data may have created a manual plugin loader
    if (m_manualLoader) {
        if (!m_hasSentResponseToPlugin) {
            m_manualLoader->didReceiveResponse(loader->response());
            // Failure could cause the main document to have an error causing
            // the manual loader to be reset.
            if (!m_manualLoader)
                return;
            m_hasSentResponseToPlugin = true;
        }
        m_manualLoader->didReceiveData(data, length);
    }
}


3.Document Create

MainResourceLoader::didReceiveData

ResourceLoader::didReceiveData

MainResourceLoader::addData

DocumentLoader::receivedData

DocumentLoader::commitLoad

WebFrameLoaderClient::committedLoad(FrameLoaderClient)

DocumentLoader::commitData (also callDocumentWriter::addData to Parser)

DocumentWriter::setEncoding

FrameLoader::willSetEncoding() 

FrameLoader::receivedFirstData()

DocumentWriter::begin

DocumentWriter::createDocument() //after the document was created, it was set to the frame()


4. Accept type and DTD

4.1where to set the accept type

FrameLoader.cpp
static const char defaultAcceptHeader[] = "application/vnd.wap.xhtml+xml,application/xhtml+xml;profile='http://www.wapforum.org/xhtml',text/html,application/xml;q=0.9,*/*;q=0.8"

4.2change xml DTD type
XMLDocumentParserLibxml2.cpp
"internalSubset"
add "&& extId != "-//WAPFORUM//DTD WML 1.1//ZH"


5. the process from loadurl to network (chromium stack)

a.WebView.java 

loadUrl

b.WebViewCore.java

loadUrl

c.BrowserFrame.java 

loadUrl

nativeLoadUrl

d.WebCoreFrameBridge.cpp

LoadUrl

--pFrame->loader()->load(request, false);

e.FrameLoader

load(const ResourceRequest& request, bool lockHistory)

----FrameLoaderClient->createDocumentLoader()

load(DocumentLoader* newDocumentLoader)

----addExtraFieldsToMainResourceRequest

----loadWithDocumentLoader

callContinueLoadAfterNavigationPolicy()

continueLoadAfterWillSubmitForm()

f. DocumentLoader

startLoadingMainResource

g.MainResourceLoader

load

loadNow.

h.ResourceHandle

create

i.ResourceHandleAndroid.cpp

start

j.ResourceLoaderAndroid

start

k.WebUrlLoader

start

l.WebUrlLoaderClient

start.

......

to chromium stack.

see 

also another imporant classes

ResourceRequest and ResourceResonse



for apache

from WebView.loadUrl() to ResourceLoaderAndroid.start() ,the same as above.

next

1. WebFrame::startLoadingResource

2.BrowserFrame.LoadListener startLoadingResource()//webkit java

3.FrameLoader.executeLoad()//webkit java

4.FrameLoader.handleHTTPLoad()

5.NetWork.requestURL() //webkit java

6.RequestQueue.queueSynchronousRequest()

7.RequestHandle.processRequest() //framework http java

8.Connection.processRequests(); //state send , framework http java

9.Request.sendRequest()

10.AndroidHttpClientConnection.sendRequestEntity();

11.EntitySerializer.serialize()

12.Connection.processRequests();// state read, framework http java

13.Request.readResponse()

14.AndroidHttpClientConnection.receiveResponseEntity();

15.BasicHttpEntity.receiveResponseEntity()

16.EventHandler.endData()

17.LoaderListener.endData() //webkit java

18.LoaderListener.handleMessage()

19.LoaderListener.handleHeaders/commitLoad()

20.LoaderListener.nativeAddData();

21.WebCoreResourceLoader:;AddData(); //webkit cpp

22. see 

"1. receive data to parse" for apache


for Mms



写一个在Ubuntu系统运行的脚本,场景是一个文件夹内有多个java文件,都是.java格式,现在需要把所有的文件名字带ReceiveData的文件拣选出来,里面的内容示例如下public class Bcm_1ReceiveData extends RpcIviDataGrp.JClass_RpcIviGrpCan1_0x391_BCM_1_Door_Light implements ComparableData<Bcm_1ReceiveData> { private final String TAG = "Bcm_1ReceiveData"; /** * 小灯 */ private int mParklightSts = Constants.ResultCode.NOT_INIT; /** * 大灯 */ private int mLowBeamSts = Constants.ResultCode.NOT_INIT; /** * 自动 */ private int mAutoHeadlightSts = Constants.ResultCode.NOT_INIT; /** * 后雾灯 */ private int mRearFogLightSts = Constants.ResultCode.NOT_INIT; public int getmBCM_KeySts() { return mBCM_KeySts; } public void setmBCM_KeySts(int mBCM_KeySts) { this.mBCM_KeySts = mBCM_KeySts; } /** * 车钥匙 */ private int mBCM_KeySts = Constants.ResultCode.NOT_INIT; /** * 光感传感器信号 */ private int mBcmLightSensor = Constants.ResultCode.NOT_INIT; public Bcm_1ReceiveData() { set_myBcmParklightsts_u8(Constants.ResultCode.NOT_INIT); set_myBcmAutoheadlightsts_u8(Constants.ResultCode.NOT_INIT); set_myBcmLowbeamsts_u8(Constants.ResultCode.NOT_INIT); set_myBcmRearfoglightsts_u8(Constants.ResultCode.NOT_INIT); set_myBcmKeysts_u8(Constants.ResultCode.NOT_INIT); set_myBcmLightSensor_u8(Constants.Resu需要将这些文件里面的内容全部按规律改成下面的方式写:public void compareBcm1(JClass_RpcIviGrpCan1_0x391_BCM_1_Door_Light newData, JClass_RpcIviGrpCan1_0x391_BCM_1_Door_Light oldData) { LogUtils.d(TAG, "compareBcm1 "); //车钥匙 int newKeyValue = newData.get_myBcmKeysts_u8(); if (newKeyValue != oldData.get_myBcmKeysts_u8()) { LogUtils.d(TAG, "PropertyKey.BCM.BCM_BCM_KEY_STATUS: " + newKeyValue); mListener.onBcmPropertyChanged(PropertyKey.BCM.CAR_KEY_STATUS, newKeyValue); } //自动 int newAutoLightVal并且遍历完当前文件夹下的所有文件后,将输出内容保存到一个新的.class文件中
最新发布
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值