• chromium源码阅读


    linux下chromium的入口函数在文件:src/chrome/app/chrome_exe_main_aura.cc 中

    int main(int argc, const char** argv) {
      return ChromeMain(argc, argv);
    }

    ChromeMain函数在 src/chrome/app/chrome_main.cc 中

    base::CommandLine::Init(params.argc, params.argv);

    具体函数如下:

    bool CommandLine::Init(int argc, const char* const* argv) {
      if (current_process_commandline_) {
        // If this is intentional, Reset() must be called first. If we are using
        // the shared build mode, we have to share a single object across multiple
        // shared libraries.
        return false;
      }
    
      current_process_commandline_ = new CommandLine(NO_PROGRAM);
    #if defined(OS_WIN)
      current_process_commandline_->ParseFromString(::GetCommandLineW());
    #elif defined(OS_POSIX)
      current_process_commandline_->InitFromArgv(argc, argv);
    #endif
    
      return true;
    }

    接下来进入文件: src/headless/app/headless_shell.cc

    int HeadlessBrowserMain(
        HeadlessBrowser::Options options,
        const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) {
      DCHECK(!on_browser_start_callback.is_null());
    #if DCHECK_IS_ON()
      // The browser can only be initialized once.
      static bool browser_was_initialized;
      DCHECK(!browser_was_initialized);
      browser_was_initialized = true;
    
      // Child processes should not end up here.
      DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
          ::switches::kProcessType));
    #endif
      return RunContentMain(std::move(options),
                            std::move(on_browser_start_callback));
    }

    继续:src/content/app/content_main.cc

    int ContentMain(const ContentMainParams& params) {
      ContentServiceManagerMainDelegate delegate(params);
      service_manager::MainParams main_params(&delegate);
    #if defined(OS_POSIX) && !defined(OS_ANDROID)
      main_params.argc = params.argc;
      main_params.argv = params.argv;
    #endif
      return service_manager::Main(main_params);
    }

    继续往下看:src/services/service_manager/embedder/main.cc   int Main(const MainParams& params) 中

    switch (process_type) {
        case ProcessType::kDefault:
          NOTREACHED();
          break;
    
        case ProcessType::kServiceManager:
          exit_code = RunServiceManager(delegate);
          break;
    
        case ProcessType::kService:
          CommonSubprocessInit();
          exit_code = RunService(delegate);
          break;
    
        case ProcessType::kEmbedder:
          if (ServiceManagerIsRemote())
            CommonSubprocessInit();
          exit_code = delegate->RunEmbedderProcess();
          break;
      }

    继续://src/base/run_loop.cc

    void RunLoop::Run() {
      DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    
      if (!BeforeRun())
        return;
    
      // It is okay to access this RunLoop from another sequence while Run() is
      // active as this RunLoop won't touch its state until after that returns (if
      // the RunLoop's state is accessed while processing Run(), it will be re-bound
      // to the accessing sequence for the remainder of that Run() -- accessing from
      // multiple sequences is still disallowed).
      DETACH_FROM_SEQUENCE(sequence_checker_);
    
      // Use task stopwatch to exclude the loop run time from the current task, if
      // any.
      tracked_objects::TaskStopwatch stopwatch;
      stopwatch.Start();
      delegate_->Run();
      stopwatch.Stop();
    
      // Rebind this RunLoop to the current thread after Run().
      DETACH_FROM_SEQUENCE(sequence_checker_);
      DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    
      AfterRun();
    }
  • 相关阅读:
    ubuntu下安装jupyter notebook问题。ERROR: Package ‘ipython‘ requires a different Python: 3.5.2 not in 」=3.6
    VmWare虚拟机设置ubuntu和windows之间的共享文件夹
    标准测试宏选项
    C库函数、系统函数等调用错误的处理方法
    比atoi()函数更健壮的一类包装函数
    系统函数和C库函数调用的几种错误处理方法
    经典生产者-消费者问题解析
    linux下的并发编程详解
    一文学会GDB操作命令
    Stm32CubeMx lwip+freeRTOS TCP 服务
  • 原文地址:https://www.cnblogs.com/danxi/p/7020375.html
Copyright © 2020-2023  润新知