在android手机上,从一个url的输入,到数据内容传输到Webkit的过程是挺复杂的。
extern 里面的chromium模块去承担了具体的下载任务. 以前一直对这方面里面的不是很透彻,所以在看这方面code的时候,做了如下笔记.
Tab.java
| public void loadUrl(String url, Map<String, String> headers)
| mMainView.loadUrl(url, headers)
BrowserFrame.java
| public void loadUrl(String url, Map<String, String> extraHeaders)
| nativeLoadUrl(url, extraHeaders)
WebCoreFrameBridge.cpp
| static void LoadUrl(JNIEnv *env, jobject obj, jstring url, jobject headers)
| pFrame->loader()->load(request, false);
FrameLoader.cpp
| void FrameLoader::load(const ResourceRequest& request, bool lockHistory)
| load(request, SubstituteData(), lockHistory);
| void FrameLoader::load(const ResourceRequest& request, const SubstituteData& substituteData, bool lockHistory)
| load(loader.get())
| void FrameLoader::load(DocumentLoader* newDocumentLoader)
| loadWithDocumentLoader(newDocumentLoader, type, 0);
| continueLoadAfterNavigationPolicy(loader->request(), formState, false)
| continueLoadAfterWillSubmitForm()
| m_provisionalDocumentLoader->startLoadingMainResource(identifier)
DocumentLoader.cpp
| bool DocumentLoader::startLoadingMainResource(unsigned long identifier)
| m_mainResourceLoader->load(m_request, m_substituteData)
MainResourceLoader.cpp
| bool MainResourceLoader::load(const ResourceRequest& r, const SubstituteData& substituteData)
| loadNow(request)
| bool MainResourceLoader::loadNow(ResourceRequest& r)
| handleDataLoadSoon(r)
| void MainResourceLoader::handleDataLoadSoon(const ResourceRequest& r)
| handleDataLoadNow(0)
| void MainResourceLoader::handleDataLoadNow(MainResourceLoaderTimer*)
| didReceiveResponse(response)
| callContinueAfterContentPolicy(this, PolicyUse)
| void MainResourceLoader::callContinueAfterContentPolicy(void* argument, PolicyAction policy)
| continueAfterContentPolicy(policy, m_response)
| void MainResourceLoader::continueAfterContentPolicy(PolicyAction contentPolicy, const ResourceResponse& r)
| didReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true)
ResourceLoader.cpp
| void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
| addData(data, length, allAtOnce)
| m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), r, this, false, true)
ResourceHandle.cpp
| PassRefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff)
| newHandle->start(context)
| bool ResourceHandle::start(NetworkingContext* context)
| RefPtr<ResourceLoaderAndroid> loader = ResourceLoaderAndroid::start(this, d->m_firstRequest, context->frameLoaderClient(), isMainResource, false);
ResourceLoaderAndroid.cpp
| PassRefPtr<ResourceLoaderAndroid> ResourceLoaderAndroid::start(ResourceHandle* handle, const ResourceRequest& request, FrameLoaderClient* client, bool isMainResource, bool isSync)
WebUrlLoader::start(client, handle, request, isMainResource, isMainFrame, isSync, webViewCore->webRequestContext())
Note: webRequestContext() --> HTTP environment,such as: language, cache
client is FrameLoaderClient --> some message about system platform.
WebUrlLoader.cpp
| loader->m_loaderClient->start(isMainResource, isMainFrame, isSync, context)
WebUrlLoaderClient.cpp
| bool WebUrlLoaderClient::start(bool isMainResource, bool isMainFrame, bool sync, WebRequestContext* context)
| MessageLoop::PostTask
networkThread is a thread in MessageLoop, and function in iothread.
&& networkThread run WebRequest::start function.
WebRequest.cpp
| void WebRequest::start()
| m_request->Start();
who is m_request? m_request = new net::URLRequest(gurl, this);
net/url_request/url_request.cc
| void URLRequest::Start()
| public void loadUrl(String url, Map<String, String> headers)
| mMainView.loadUrl(url, headers)
BrowserFrame.java
| public void loadUrl(String url, Map<String, String> extraHeaders)
| nativeLoadUrl(url, extraHeaders)
WebCoreFrameBridge.cpp
| static void LoadUrl(JNIEnv *env, jobject obj, jstring url, jobject headers)
| pFrame->loader()->load(request, false);
FrameLoader.cpp
| void FrameLoader::load(const ResourceRequest& request, bool lockHistory)
| load(request, SubstituteData(), lockHistory);
| void FrameLoader::load(const ResourceRequest& request, const SubstituteData& substituteData, bool lockHistory)
| load(loader.get())
| void FrameLoader::load(DocumentLoader* newDocumentLoader)
| loadWithDocumentLoader(newDocumentLoader, type, 0);
| continueLoadAfterNavigationPolicy(loader->request(), formState, false)
| continueLoadAfterWillSubmitForm()
| m_provisionalDocumentLoader->startLoadingMainResource(identifier)
DocumentLoader.cpp
| bool DocumentLoader::startLoadingMainResource(unsigned long identifier)
| m_mainResourceLoader->load(m_request, m_substituteData)
MainResourceLoader.cpp
| bool MainResourceLoader::load(const ResourceRequest& r, const SubstituteData& substituteData)
| loadNow(request)
| bool MainResourceLoader::loadNow(ResourceRequest& r)
| handleDataLoadSoon(r)
| void MainResourceLoader::handleDataLoadSoon(const ResourceRequest& r)
| handleDataLoadNow(0)
| void MainResourceLoader::handleDataLoadNow(MainResourceLoaderTimer*)
| didReceiveResponse(response)
| callContinueAfterContentPolicy(this, PolicyUse)
| void MainResourceLoader::callContinueAfterContentPolicy(void* argument, PolicyAction policy)
| continueAfterContentPolicy(policy, m_response)
| void MainResourceLoader::continueAfterContentPolicy(PolicyAction contentPolicy, const ResourceResponse& r)
| didReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true)
ResourceLoader.cpp
| void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
| addData(data, length, allAtOnce)
| m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), r, this, false, true)
ResourceHandle.cpp
| PassRefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff)
| newHandle->start(context)
| bool ResourceHandle::start(NetworkingContext* context)
| RefPtr<ResourceLoaderAndroid> loader = ResourceLoaderAndroid::start(this, d->m_firstRequest, context->frameLoaderClient(), isMainResource, false);
ResourceLoaderAndroid.cpp
| PassRefPtr<ResourceLoaderAndroid> ResourceLoaderAndroid::start(ResourceHandle* handle, const ResourceRequest& request, FrameLoaderClient* client, bool isMainResource, bool isSync)
WebUrlLoader::start(client, handle, request, isMainResource, isMainFrame, isSync, webViewCore->webRequestContext())
Note: webRequestContext() --> HTTP environment,such as: language, cache
client is FrameLoaderClient --> some message about system platform.
WebUrlLoader.cpp
| loader->m_loaderClient->start(isMainResource, isMainFrame, isSync, context)
WebUrlLoaderClient.cpp
| bool WebUrlLoaderClient::start(bool isMainResource, bool isMainFrame, bool sync, WebRequestContext* context)
| MessageLoop::PostTask
networkThread is a thread in MessageLoop, and function in iothread.
&& networkThread run WebRequest::start function.
WebRequest.cpp
| void WebRequest::start()
| m_request->Start();
who is m_request? m_request = new net::URLRequest(gurl, this);
net/url_request/url_request.cc
| void URLRequest::Start()