• 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();
    }
  • 相关阅读:
    名信片定做网站
    [置顶] 数据库开发常识
    <IMG>中UserMap的用法
    阿斯钢iojeg9uhweu9erhpu9hyw49
    慎得慌二u赫然共和任务i个屁
    阿斯钢iojeg9uhw8uhy平
    2014校园招聘笔、面经历总结---华为双选会
    PDCA模型的学习
    阿斯钢 弇7人后偶尔一个味5而已
    【HTML】让<pre>标签文本自动换行
  • 原文地址:https://www.cnblogs.com/danxi/p/7020375.html
Copyright © 2020-2023  润新知