cef/libcef/common/alloy/alloy_main_runner_delegate.cc
Marshall Greenblatt 84f3ff2afd Rename the current CEF runtime to Alloy (see issue #2969)
As part of introducing the Chrome runtime we now need to distinguish
between the classes that implement the current CEF runtime and the
classes the implement the shared CEF library/runtime structure and
public API. We choose the name Alloy for the current CEF runtime
because it describes a combination of Chrome and other elements.

Shared CEF library/runtime classes will continue to use the Cef
prefix. Classes that implement the Alloy or Chrome runtime will use
the Alloy or Chrome prefixes respectively. Classes that extend an
existing Chrome-prefixed class will add the Cef or Alloy suffix,
thereby following the existing naming pattern of Chrome-derived
classes.

This change applies the new naming pattern to an initial set of
runtime-related classes. Additional classes/files will be renamed
and moved as the Chrome runtime implementation progresses.
2020-06-29 16:17:41 -04:00

69 lines
2.4 KiB
C++

// Copyright 2020 The Chromium Embedded Framework Authors.
// Portions copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/common/alloy/alloy_main_runner_delegate.h"
#include "libcef/browser/alloy/chrome_browser_process_alloy.h"
#include "libcef/common/alloy/alloy_main_delegate.h"
#include "libcef/common/widevine_loader.h"
#include "libcef/renderer/alloy/alloy_content_renderer_client.h"
#include "content/public/browser/render_process_host.h"
#include "ui/base/resource/resource_bundle.h"
AlloyMainRunnerDelegate::AlloyMainRunnerDelegate(CefMainRunnerHandler* runner,
CefSettings* settings,
CefRefPtr<CefApp> application)
: runner_(runner), settings_(settings), application_(application) {}
AlloyMainRunnerDelegate::~AlloyMainRunnerDelegate() = default;
content::ContentMainDelegate*
AlloyMainRunnerDelegate::GetContentMainDelegate() {
if (!main_delegate_) {
main_delegate_ =
std::make_unique<AlloyMainDelegate>(runner_, settings_, application_);
}
return main_delegate_.get();
}
void AlloyMainRunnerDelegate::BeforeMainThreadInitialize(
const CefMainArgs& args) {
g_browser_process = new ChromeBrowserProcessAlloy();
}
void AlloyMainRunnerDelegate::BeforeMainThreadRun() {
static_cast<ChromeBrowserProcessAlloy*>(g_browser_process)->Initialize();
}
void AlloyMainRunnerDelegate::AfterUIThreadInitialize() {
#if BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
CefWidevineLoader::GetInstance()->OnContextInitialized();
#endif
static_cast<ChromeBrowserProcessAlloy*>(g_browser_process)
->OnContextInitialized();
}
void AlloyMainRunnerDelegate::AfterUIThreadShutdown() {
static_cast<ChromeBrowserProcessAlloy*>(g_browser_process)
->CleanupOnUIThread();
ui::ResourceBundle::GetSharedInstance().CleanupOnUIThread();
}
void AlloyMainRunnerDelegate::BeforeMainThreadShutdown() {
if (content::RenderProcessHost::run_renderer_in_process()) {
// Blocks until RenderProcess cleanup is complete.
AlloyContentRendererClient::Get()->RunSingleProcessCleanup();
}
}
void AlloyMainRunnerDelegate::AfterMainThreadShutdown() {
if (g_browser_process) {
delete g_browser_process;
g_browser_process = nullptr;
}
}