• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Chromium Embedded Framework Authors.
2 // Portions copyright 2012 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 
6 #ifndef CEF_LIBCEF_COMMON_CHROME_CHROME_MAIN_RUNNER_DELEGATE_CEF_
7 #define CEF_LIBCEF_COMMON_CHROME_CHROME_MAIN_RUNNER_DELEGATE_CEF_
8 
9 #include <memory>
10 
11 #include "include/cef_app.h"
12 #include "libcef/common/main_runner_delegate.h"
13 #include "libcef/common/main_runner_handler.h"
14 
15 class ChromeMainDelegateCef;
16 class MainThreadStackSamplingProfiler;
17 class ScopedKeepAlive;
18 
19 class ChromeMainRunnerDelegate : public CefMainRunnerDelegate {
20  public:
21   // |runner| will be non-nullptr for the main process only, and will outlive
22   // this object.
23   ChromeMainRunnerDelegate(CefMainRunnerHandler* runner,
24                            CefSettings* settings,
25                            CefRefPtr<CefApp> application);
26 
27   ChromeMainRunnerDelegate(const ChromeMainRunnerDelegate&) = delete;
28   ChromeMainRunnerDelegate& operator=(const ChromeMainRunnerDelegate&) = delete;
29 
30   ~ChromeMainRunnerDelegate() override;
31 
32  protected:
33   // CefMainRunnerDelegate overrides.
34   content::ContentMainDelegate* GetContentMainDelegate() override;
35   void BeforeMainThreadInitialize(const CefMainArgs& args) override;
36   void BeforeMainMessageLoopRun(base::RunLoop* run_loop) override;
37   bool HandleMainMessageLoopQuit() override;
38   void AfterMainThreadShutdown() override;
39   void BeforeExecuteProcess(const CefMainArgs& args) override;
40   void AfterExecuteProcess() override;
41 
42  private:
43   std::unique_ptr<ChromeMainDelegateCef> main_delegate_;
44 
45   std::unique_ptr<MainThreadStackSamplingProfiler> sampling_profiler_;
46   std::unique_ptr<ScopedKeepAlive> keep_alive_;
47 
48   CefMainRunnerHandler* const runner_;
49   CefSettings* const settings_;
50   CefRefPtr<CefApp> application_;
51 };
52 
53 #endif  // CEF_LIBCEF_COMMON_CHROME_CHROME_MAIN_RUNNER_DELEGATE_CEF_
54