Commit 52db8740 authored by Oleg Davydov's avatar Oleg Davydov Committed by Commit Bot

Add additional stages into InstallationReporter::Stage

We see in statistics that for some reason force-installed extensions stuck in
CREATED stage. Generally it should never happen, since these extensions
should immediately be moved to PENDING stage (or reported as failed).
Unfortunately, we weren't able to reproduce it locally. To have the
problem more localized we need to split CREATED->PENDING transition into
substages.

Bug: 989526
Change-Id: I4a3f1601dea67c0a75cec1c1ebcf07536ef8704c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1729252Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarPavol Marko <pmarko@chromium.org>
Commit-Queue: Oleg Davydov <burunduk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688452}
parent 10623fd4
...@@ -506,6 +506,17 @@ void ExtensionManagement::OnExtensionPrefChanged() { ...@@ -506,6 +506,17 @@ void ExtensionManagement::OnExtensionPrefChanged() {
} }
void ExtensionManagement::NotifyExtensionManagementPrefChanged() { void ExtensionManagement::NotifyExtensionManagementPrefChanged() {
for (const auto& entry : settings_by_id_) {
if (entry.second->installation_mode == INSTALLATION_FORCED) {
InstallationReporter::ReportInstallationStage(
profile_, entry.first,
InstallationReporter::Stage::NOTIFIED_FROM_MANAGEMENT);
} else {
InstallationReporter::ReportInstallationStage(
profile_, entry.first,
InstallationReporter::Stage::NOTIFIED_FROM_MANAGEMENT_NOT_FORCED);
}
}
for (auto& observer : observer_list_) for (auto& observer : observer_list_)
observer.OnExtensionManagementSettingsChanged(); observer.OnExtensionManagementSettingsChanged();
} }
......
...@@ -8,12 +8,14 @@ ...@@ -8,12 +8,14 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/extensions/external_provider_impl.h" #include "chrome/browser/extensions/external_provider_impl.h"
#include "chrome/browser/extensions/forced_extensions/installation_reporter.h"
namespace extensions { namespace extensions {
ExternalPolicyLoader::ExternalPolicyLoader(ExtensionManagement* settings, ExternalPolicyLoader::ExternalPolicyLoader(Profile* profile,
ExtensionManagement* settings,
InstallationType type) InstallationType type)
: settings_(settings), type_(type) { : profile_(profile), settings_(settings), type_(type) {
settings_->AddObserver(this); settings_->AddObserver(this);
} }
...@@ -39,6 +41,11 @@ void ExternalPolicyLoader::StartLoading() { ...@@ -39,6 +41,11 @@ void ExternalPolicyLoader::StartLoading() {
switch (type_) { switch (type_) {
case FORCED: case FORCED:
prefs = settings_->GetForceInstallList(); prefs = settings_->GetForceInstallList();
for (const auto& it : prefs->DictItems()) {
InstallationReporter::ReportInstallationStage(
profile_, it.first,
InstallationReporter::Stage::SEEN_BY_POLICY_LOADER);
}
break; break;
case RECOMMENDED: case RECOMMENDED:
prefs = settings_->GetRecommendedInstallList(); prefs = settings_->GetRecommendedInstallList();
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "chrome/browser/extensions/extension_management.h" #include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/external_loader.h" #include "chrome/browser/extensions/external_loader.h"
class Profile;
namespace base { namespace base {
class DictionaryValue; class DictionaryValue;
} }
...@@ -32,7 +34,9 @@ class ExternalPolicyLoader : public ExternalLoader, ...@@ -32,7 +34,9 @@ class ExternalPolicyLoader : public ExternalLoader,
RECOMMENDED RECOMMENDED
}; };
ExternalPolicyLoader(ExtensionManagement* settings, InstallationType type); ExternalPolicyLoader(Profile* profile,
ExtensionManagement* settings,
InstallationType type);
// ExtensionManagement::Observer implementation // ExtensionManagement::Observer implementation
void OnExtensionManagementSettingsChanged() override; void OnExtensionManagementSettingsChanged() override;
...@@ -50,6 +54,7 @@ class ExternalPolicyLoader : public ExternalLoader, ...@@ -50,6 +54,7 @@ class ExternalPolicyLoader : public ExternalLoader,
~ExternalPolicyLoader() override; ~ExternalPolicyLoader() override;
Profile* profile_;
ExtensionManagement* settings_; ExtensionManagement* settings_;
InstallationType type_; InstallationType type_;
......
...@@ -57,12 +57,11 @@ class MockExternalPolicyProviderVisitor ...@@ -57,12 +57,11 @@ class MockExternalPolicyProviderVisitor
provider_.reset(new ExternalProviderImpl( provider_.reset(new ExternalProviderImpl(
this, this,
new ExternalPolicyLoader( new ExternalPolicyLoader(
profile_.get(),
ExtensionManagementFactory::GetForBrowserContext(profile_.get()), ExtensionManagementFactory::GetForBrowserContext(profile_.get()),
ExternalPolicyLoader::FORCED), ExternalPolicyLoader::FORCED),
profile_.get(), profile_.get(), Manifest::INVALID_LOCATION,
Manifest::INVALID_LOCATION, Manifest::EXTERNAL_POLICY_DOWNLOAD, Extension::NO_FLAGS));
Manifest::EXTERNAL_POLICY_DOWNLOAD,
Extension::NO_FLAGS));
// Extensions will be removed from this list as they visited, // Extensions will be removed from this list as they visited,
// so it should be emptied by the end. // so it should be emptied by the end.
......
...@@ -145,6 +145,12 @@ void ExternalProviderImpl::SetPrefs( ...@@ -145,6 +145,12 @@ void ExternalProviderImpl::SetPrefs(
// away while |loader_| was working on the FILE thread. // away while |loader_| was working on the FILE thread.
if (!service_) return; if (!service_) return;
for (const auto& it : prefs->DictItems()) {
InstallationReporter::ReportInstallationStage(
profile_, it.first,
InstallationReporter::Stage::SEEN_BY_EXTERNAL_PROVIDER);
}
prefs_ = std::move(prefs); prefs_ = std::move(prefs);
ready_ = true; // Queries for extensions are allowed from this point. ready_ = true; // Queries for extensions are allowed from this point.
...@@ -588,7 +594,7 @@ void ExternalProviderImpl::CreateExternalProviders( ...@@ -588,7 +594,7 @@ void ExternalProviderImpl::CreateExternalProviders(
// path will have type |TYPE_LOGIN_SCREE_EXTENSION| with limited API // path will have type |TYPE_LOGIN_SCREE_EXTENSION| with limited API
// capabilities. // capabilities.
external_loader = new ExternalPolicyLoader( external_loader = new ExternalPolicyLoader(
ExtensionManagementFactory::GetForBrowserContext(profile), profile, ExtensionManagementFactory::GetForBrowserContext(profile),
ExternalPolicyLoader::FORCED); ExternalPolicyLoader::FORCED);
auto signin_profile_provider = std::make_unique<ExternalProviderImpl>( auto signin_profile_provider = std::make_unique<ExternalProviderImpl>(
service, external_loader, profile, crx_location, service, external_loader, profile, crx_location,
...@@ -622,18 +628,18 @@ void ExternalProviderImpl::CreateExternalProviders( ...@@ -622,18 +628,18 @@ void ExternalProviderImpl::CreateExternalProviders(
} }
} else { } else {
external_loader = new ExternalPolicyLoader( external_loader = new ExternalPolicyLoader(
ExtensionManagementFactory::GetForBrowserContext(profile), profile, ExtensionManagementFactory::GetForBrowserContext(profile),
ExternalPolicyLoader::FORCED); ExternalPolicyLoader::FORCED);
external_recommended_loader = new ExternalPolicyLoader( external_recommended_loader = new ExternalPolicyLoader(
ExtensionManagementFactory::GetForBrowserContext(profile), profile, ExtensionManagementFactory::GetForBrowserContext(profile),
ExternalPolicyLoader::RECOMMENDED); ExternalPolicyLoader::RECOMMENDED);
} }
#else #else
external_loader = new ExternalPolicyLoader( external_loader = new ExternalPolicyLoader(
ExtensionManagementFactory::GetForBrowserContext(profile), profile, ExtensionManagementFactory::GetForBrowserContext(profile),
ExternalPolicyLoader::FORCED); ExternalPolicyLoader::FORCED);
external_recommended_loader = new ExternalPolicyLoader( external_recommended_loader = new ExternalPolicyLoader(
ExtensionManagementFactory::GetForBrowserContext(profile), profile, ExtensionManagementFactory::GetForBrowserContext(profile),
ExternalPolicyLoader::RECOMMENDED); ExternalPolicyLoader::RECOMMENDED);
#endif #endif
......
...@@ -31,6 +31,26 @@ class InstallationReporter { ...@@ -31,6 +31,26 @@ class InstallationReporter {
// ExtensionManagement::settings_by_id_. // ExtensionManagement::settings_by_id_.
CREATED = 0, CREATED = 0,
// TODO(crbug.com/989526): stages from NOTIFIED_FROM_MANAGEMENT to
// SEEN_BY_EXTERNAL_PROVIDER are temporary ones for investigation. Remove
// then after investigation will complete and we'll be confident in
// extension handling between CREATED and PENDING.
// ExtensionManagement class is about to pass extension with
// INSTALLATION_FORCED mode to its observers.
NOTIFIED_FROM_MANAGEMENT = 5,
// ExtensionManagement class is about to pass extension with other mode to
// its observers.
NOTIFIED_FROM_MANAGEMENT_NOT_FORCED = 6,
// ExternalPolicyLoader with FORCED type fetches extension from
// ExtensionManagement.
SEEN_BY_POLICY_LOADER = 7,
// ExternalProviderImpl receives extension.
SEEN_BY_EXTERNAL_PROVIDER = 8,
// Extension added to PendingExtensionManager. // Extension added to PendingExtensionManager.
PENDING = 1, PENDING = 1,
...@@ -45,7 +65,7 @@ class InstallationReporter { ...@@ -45,7 +65,7 @@ class InstallationReporter {
// Magic constant used by the histogram macros. // Magic constant used by the histogram macros.
// Always update it to the max value. // Always update it to the max value.
kMaxValue = COMPLETE, kMaxValue = SEEN_BY_EXTERNAL_PROVIDER,
}; };
// Enum used for UMA. Do NOT reorder or remove entries. Don't forget to // Enum used for UMA. Do NOT reorder or remove entries. Don't forget to
......
...@@ -20391,6 +20391,10 @@ Called by update_net_error_codes.py.--> ...@@ -20391,6 +20391,10 @@ Called by update_net_error_codes.py.-->
<int value="2" label="DOWNLOADING"/> <int value="2" label="DOWNLOADING"/>
<int value="3" label="INSTALLING"/> <int value="3" label="INSTALLING"/>
<int value="4" label="COMPLETE"/> <int value="4" label="COMPLETE"/>
<int value="5" label="NOTIFIED_FROM_MANAGEMENT"/>
<int value="6" label="NOTIFIED_FROM_MANAGEMENT_NOT_FORCED"/>
<int value="7" label="SEEN_BY_POLICY_LOADER"/>
<int value="8" label="SEEN_BY_EXTERNAL_PROVIDER"/>
</enum> </enum>
<enum name="ExtensionInstallCause"> <enum name="ExtensionInstallCause">
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