2012年3月23日 星期五

[WebKit] Page Loading Flow

This is a simple note about the function flow of standard opening a web. 
After I give a text of url on browser and summit it. Safari will dispatch a message to webkit.

Received Message From Web Page
void Connection::dispatchMessages()  // This is a infinite loop for listening message from browser
void Connection::dispatchMessage(IncomingMessage& message)
void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
void WebPage::didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)

URL Load
void WebPage::loadURLRequest(const ResourceRequest& request, const SandboxExtension::Handle& sandboxExtensionHandle)

Frame Load
void FrameLoader::load(const ResourceRequest& request, bool lockHistory)
void FrameLoader::load(const ResourceRequest& request, const SubstituteData& substituteData, bool lockHistory)
void FrameLoader::load(DocumentLoader* newDocumentLoader)
void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType type, PassRefPtr<FormState> prpFormState)

Policy Check
void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, DocumentLoader* loader,  PassRefPtr<FormState> formState, NavigationPolicyDecisionFunction function, void* argument)
void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> formState)
void PolicyChecker::continueAfterNavigationPolicy(PolicyAction policy)
After Policy Check
void FrameLoader::callContinueLoadAfterNavigationPolicy(void* argument,
    const ResourceRequest& request, PassRefPtr<FormState> formState, bool shouldContinue)
void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, PassRefPtr<FormState> formState, bool shouldContinue) 
Resource Load
void FrameLoader::continueLoadAfterWillSubmitForm()
bool DocumentLoader::startLoadingMainResource(unsigned long identifier)
bool MainResourceLoader::load(const ResourceRequest& r, const SubstituteData& substituteData)
bool MainResourceLoader::loadNow(ResourceRequest& r)
PassRefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff)
bool ResourceHandle::start(NetworkingContext* context)  // It is depends on your platform and it get into ResourceHandleCFNet::start in my case.
>> return to head of call stack


The dll of ResourceHandleCFNet will connect to resource file to get html data.
After data is retrieved from network, the networking component will call back and come up with html data.

Data Receive 
static void ResourceHandleCFNet::didReceiveData(CFURLConnectionRef conn, CFDataRef data, CFIndex originalLength, const void* clientInfo)
void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
void MainResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
void MainResourceLoader::addData(const char* data, int length, bool allAtOnce)
void ResourceLoader::addData(const char* data, int length, bool allAtOnce)
void DocumentLoader::receivedData(const char* data, int length)
void DocumentLoader::commitLoad(const char* data, int length)
void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
void DocumentLoader::commitData(const char* bytes, size_t length)
void DocumentWriter::addData(const char* bytes, size_t length)

>> return to head of call stack


Finish Loading
static void ResourceHandleCFNet::didFinishLoading(CFURLConnectionRef conn, const void* clientInfo)
void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime)
void MainResourceLoader::didFinishLoading(double finishTime)
void FrameLoader::finishedLoading()
void DocumentLoader::finishedLoading()
void FrameLoader::finishedLoadingDocument(DocumentLoader* loader)
void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
void DocumentWriter::end()
void FrameLoader::didEndDocument()
void DocumentWriter::endIfNotLoadingMainResource()


So far, It had finished URL connect and data received, next step would be data parsing.

沒有留言:

張貼留言