Commit a9a0b0b3 authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

WebApp: Rename passes for subsystems startup.

- Rename Init as Start.
- Rename CreateSubsystems as Init.

As a result, Init is truely the first thing that must be called before using the
instance.

Bug: 920062
Change-Id: I5606250f10c3d249a994f19b71682a8d95e44be0
Reviewed-on: https://chromium-review.googlesource.com/c/1442072Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626911}
parent 9382aadb
......@@ -120,7 +120,7 @@ TEST_F(WebAppPolicyManagerTest, NoForceInstalledAppsPrefValue) {
auto pending_app_manager = std::make_unique<TestPendingAppManager>();
WebAppPolicyManager web_app_policy_manager(profile(),
pending_app_manager.get());
web_app_policy_manager.Init();
web_app_policy_manager.Start();
base::RunLoop().RunUntilIdle();
const auto& apps_to_install = pending_app_manager->install_requests();
......@@ -134,7 +134,7 @@ TEST_F(WebAppPolicyManagerTest, NoForceInstalledApps) {
auto pending_app_manager = std::make_unique<TestPendingAppManager>();
WebAppPolicyManager web_app_policy_manager(profile(),
pending_app_manager.get());
web_app_policy_manager.Init();
web_app_policy_manager.Start();
base::RunLoop().RunUntilIdle();
const auto& apps_to_install = pending_app_manager->install_requests();
......@@ -151,7 +151,7 @@ TEST_F(WebAppPolicyManagerTest, TwoForceInstalledApps) {
auto pending_app_manager = std::make_unique<TestPendingAppManager>();
WebAppPolicyManager web_app_policy_manager(profile(),
pending_app_manager.get());
web_app_policy_manager.Init();
web_app_policy_manager.Start();
base::RunLoop().RunUntilIdle();
const auto& apps_to_install = pending_app_manager->install_requests();
......@@ -171,7 +171,7 @@ TEST_F(WebAppPolicyManagerTest, ForceInstallAppWithNoForcedLaunchContainer) {
auto pending_app_manager = std::make_unique<TestPendingAppManager>();
WebAppPolicyManager web_app_policy_manager(profile(),
pending_app_manager.get());
web_app_policy_manager.Init();
web_app_policy_manager.Start();
base::RunLoop().RunUntilIdle();
const auto& apps_to_install = pending_app_manager->install_requests();
......@@ -191,7 +191,7 @@ TEST_F(WebAppPolicyManagerTest, DynamicRefresh) {
auto pending_app_manager = std::make_unique<TestPendingAppManager>();
WebAppPolicyManager web_app_policy_manager(profile(),
pending_app_manager.get());
web_app_policy_manager.Init();
web_app_policy_manager.Start();
base::RunLoop().RunUntilIdle();
const auto& apps_to_install = pending_app_manager->install_requests();
......@@ -234,7 +234,7 @@ TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInPreviousSession) {
WebAppPolicyManager web_app_policy_manager(profile(),
pending_app_manager.get());
web_app_policy_manager.Init();
web_app_policy_manager.Start();
base::RunLoop().RunUntilIdle();
// We should only try to install the app in the policy.
......@@ -253,7 +253,7 @@ TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInCurrentSession) {
auto pending_app_manager = std::make_unique<TestPendingAppManager>();
WebAppPolicyManager web_app_policy_manager(profile(),
pending_app_manager.get());
web_app_policy_manager.Init();
web_app_policy_manager.Start();
base::RunLoop().RunUntilIdle();
// Add two sites, one that opens in a window and one that opens in a tab.
......
......@@ -149,8 +149,8 @@ SystemWebAppManagerBrowserTest::CreateWebAppProvider(
return nullptr;
auto provider = std::make_unique<TestWebAppProvider>(profile);
// Create all real subsystems:
provider->CreateSubsystems();
// Create all real subsystems but do not start them:
provider->Init();
// But override SystemWebAppManager with TestSystemWebAppManager:
DCHECK(!test_system_web_app_manager_);
......@@ -163,8 +163,8 @@ SystemWebAppManagerBrowserTest::CreateWebAppProvider(
system_apps.emplace_back(GURL("chrome://test-system-app/pwa.html"));
test_system_web_app_manager_->SetSystemApps(std::move(system_apps));
// Initialize all subsystems:
provider->Init();
// Start all subsystems:
provider->Start();
return provider;
}
......
......@@ -99,7 +99,7 @@ TEST_F(SystemWebAppManagerTest, Disabled) {
TestSystemWebAppManager system_web_app_manager(profile(),
pending_app_manager.get());
system_web_app_manager.SetSystemApps(std::move(system_apps));
system_web_app_manager.Init();
system_web_app_manager.Start();
base::RunLoop().RunUntilIdle();
......@@ -122,7 +122,7 @@ TEST_F(SystemWebAppManagerTest, Enabled) {
TestSystemWebAppManager system_web_app_manager(profile(),
pending_app_manager.get());
system_web_app_manager.SetSystemApps(std::move(system_apps));
system_web_app_manager.Init();
system_web_app_manager.Start();
base::RunLoop().RunUntilIdle();
......@@ -148,7 +148,7 @@ TEST_F(SystemWebAppManagerTest, UninstallAppInstalledInPreviousSession) {
TestSystemWebAppManager system_web_app_manager(profile(),
pending_app_manager.get());
system_web_app_manager.SetSystemApps(std::move(system_apps));
system_web_app_manager.Init();
system_web_app_manager.Start();
base::RunLoop().RunUntilIdle();
......
......@@ -29,7 +29,7 @@ WebAppPolicyManager::WebAppPolicyManager(Profile* profile,
WebAppPolicyManager::~WebAppPolicyManager() = default;
void WebAppPolicyManager::Init() {
void WebAppPolicyManager::Start() {
content::BrowserThread::PostAfterStartupTask(
FROM_HERE,
base::CreateSingleThreadTaskRunnerWithTraits(
......
......@@ -33,7 +33,7 @@ class WebAppPolicyManager {
WebAppPolicyManager(Profile* profile, PendingAppManager* pending_app_manager);
~WebAppPolicyManager();
void Init();
void Start();
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
......
......@@ -41,7 +41,7 @@ SystemWebAppManager::SystemWebAppManager(Profile* profile,
SystemWebAppManager::~SystemWebAppManager() = default;
void SystemWebAppManager::Init() {
void SystemWebAppManager::Start() {
content::BrowserThread::PostAfterStartupTask(
FROM_HERE,
base::CreateSingleThreadTaskRunnerWithTraits(
......
......@@ -25,7 +25,7 @@ class SystemWebAppManager {
SystemWebAppManager(Profile* profile, PendingAppManager* pending_app_manager);
virtual ~SystemWebAppManager();
void Init();
void Start();
static bool ShouldEnableForProfile(Profile* profile);
......
......@@ -64,7 +64,7 @@ WebAppProvider::WebAppProvider(Profile* profile) : profile_(profile) {
WebAppProvider::~WebAppProvider() = default;
void WebAppProvider::CreateSubsystems() {
void WebAppProvider::Init() {
audio_focus_id_map_ = std::make_unique<WebAppAudioFocusIdMap>();
if (base::FeatureList::IsEnabled(features::kDesktopPWAsWithoutExtensions))
......@@ -73,7 +73,7 @@ void WebAppProvider::CreateSubsystems() {
CreateBookmarkAppsSubsystems(profile_);
}
void WebAppProvider::Init() {
void WebAppProvider::Start() {
notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
content::Source<Profile>(profile_));
......@@ -81,10 +81,11 @@ void WebAppProvider::Init() {
registrar_->Init(base::BindOnce(&WebAppProvider::OnRegistryReady,
weak_ptr_factory_.GetWeakPtr()));
} else {
web_app_policy_manager_->Init();
system_web_app_manager_->Init();
web_app_policy_manager_->Start();
system_web_app_manager_->Start();
web_app::ScanForExternalWebApps(
// Start ExternalWebApps subsystem:
ScanForExternalWebApps(
profile_, base::BindOnce(&WebAppProvider::OnScanForExternalWebApps,
weak_ptr_factory_.GetWeakPtr()));
......
......@@ -57,10 +57,10 @@ class WebAppProvider : public KeyedService,
explicit WebAppProvider(Profile* profile);
~WebAppProvider() override;
// 1st pass: Just create subsystems.
void CreateSubsystems();
// 2nd pass: Initialize subsystems.
// Create subsystems but do not start them (yet).
void Init();
// Start all subsystems.
void Start();
// Clients can use PendingAppManager to install, uninstall, and update
// Web Apps.
......
......@@ -39,8 +39,8 @@ KeyedService* WebAppProviderFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
WebAppProvider* provider = new WebAppProvider(profile);
provider->CreateSubsystems();
provider->Init();
provider->Start();
return provider;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment