Chrome启动代码流程:(v2.0版,Windows平台)
应用程序启动过程:
1. WinMain函数为入口点,定义在文件\chrome\app\chrome_exe_main.cc文件中(位于chrome_exe工程项目中)
2. WinMain从注册表中找到当前版本的子目录,然后装载chrome.dll文件。如果没找到,则直接从当前exe目录查找dll文件,并装载。
3. 直接从chrome.dll中找到函数ChromeMain,然后调用它。ChromeMain函数定义在\chrome\app\chrome_dll_main.cc文件中,位于chrome_dll工程项目中。
HINSTANCE dll_handle = ::LoadLibraryEx (dll_name, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
// Initialize the crash reporter.
InitCrashReporter( client_util::GetDLLPath (dll_name, dll_path));
bool exit_now = true ;
if ( ShowRestartDialogIfCrashed(&exit_now )) {
// We have restarted because of a previous crash. The user might
// decide that he does not want to continue.
if ( exit_now)
return ResultCodes ::NORMAL_EXIT;
}
if ( NULL != dll_handle ) {
client_util:: DLL_MAIN entry = reinterpret_cast< client_util::DLL_MAIN >(
:: GetProcAddress(dll_handle , "ChromeMain"));
if ( NULL != entry )
return (entry )(instance, & sandbox_info, command_line );
}
4. ChromeMain函数做一些通用组件的初始化工作,之后则根据命令行中的参数选项,要么调用RenderMain,要么调用BrowserMain函数,或者调用WorkMain或者PluginMain函数: