chromium启动流程和消息处理是怎么关联起来

..\chrome\app\chrome_main.cc
该函数是首先进入的主函数
#if defined(OS_WIN)
DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
                                 sandbox::SandboxInterfaceInfo* sandbox_info) {
#elif defined(OS_POSIX)
int ChromeMain(int argc, const char** argv) {
#endif
#if defined(OS_WIN) && defined(ARCH_CPU_X86_64)
  // VS2013 only checks the existence of FMA3 instructions, not the enabled-ness
  // of them at the OS level (this is fixed in VS2015). We force off usage of
  // FMA3 instructions in the CRT to avoid using that path and hitting illegal
  // instructions when running on CPUs that support FMA3, but OSs that don't.
  // See http://crbug.com/436603.
  _set_FMA3_enable(0);
#endif  // WIN && ARCH_CPU_X86_64


  ChromeMainDelegate chrome_main_delegate;
  content::ContentMainParams params(&chrome_main_delegate);


#if defined(OS_WIN)
  // The process should crash when going through abnormal termination.
  base::win::SetShouldCrashOnProcessDetach(true);
  base::win::SetAbortBehaviorForCrashReporting();
  params.instance = instance;
  params.sandbox_info = sandbox_info;


  // SetDumpWithoutCrashingFunction must be passed the DumpProcess function
  // from the EXE and not from the DLL in order for DumpWithoutCrashing to
  // function correctly.
  typedef void (__cdecl *DumpProcessFunction)();
  DumpProcessFunction DumpProcess = reinterpret_cast(
      ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName),
          "DumpProcessWithoutCrash"));
  base::debug::SetDumpWithoutCrashingFunction(DumpProcess);
#else
  params.argc = argc;
  params.argv = argv;
#endif


#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
#if !defined(OS_WIN)
  base::CommandLine::Init(params.argc, params.argv);
#endif
  const base::CommandLine& command_line =
      *base::CommandLine::ForCurrentProcess();
  // TODO(sky): only do this for dev builds and if on canary channel.
  if (command_line.HasSwitch("mash"))
    return MashMain();
#endif


  int rv = content::ContentMain(params);


#if defined(OS_WIN)
  base::win::SetShouldCrashOnProcessDetach(false);
#endif


  return rv;
}

其次通过int rv = content::ContentMain(params);创建并初始化ContentMainRunnerImpl

该类是实现者,负责ContentClient的初始化和必要的对象关联,例如ContentClient内部指针对象

 // The embedder API for participating in browser logic.
  ContentBrowserClient* browser_;
  // The embedder API for participating in gpu logic.
  ContentGpuClient* gpu_;
  // The embedder API for participating in plugin logic.
  ContentPluginClient* plugin_;
  // The embedder API for participating in renderer logic.
  ContentRendererClient* renderer_;
  // The embedder API for participating in utility logic.
  ContentUtilityClient* utility_;

详细初始化位置如下:

在content::ContentMain内部调用

ContentMainRunnerImpl::Initialize()

而在ContentMainRunnerImpl::Initialize()调用

重要的delegate_->BasicStartupComplete 进行Content::SetContentClient初始化,这个函数会初始化一个全局对象。

而后调用ContentClientInitializer::Set(process_type, delegate_);在该函数里面,会初始化上面提及红色字体等内部对象指针。

你可能感兴趣的:(chromium启动流程和消息处理是怎么关联起来)