Skip to content

Instantly share code, notes, and snippets.

@paulirish
Last active December 1, 2021 22:40
Show Gist options
  • Save paulirish/45938e75e395ace53c6006f86ff8599c to your computer and use it in GitHub Desktop.
Save paulirish/45938e75e395ace53c6006f86ff8599c to your computer and use it in GitHub Desktop.
diff --git a/chrome/browser/devtools/protocol/page_handler.cc b/chrome/browser/devtools/protocol/page_handler.cc
index e07fd9eec46e..8c147fc0f96c 100644
--- a/chrome/browser/devtools/protocol/page_handler.cc
+++ b/chrome/browser/devtools/protocol/page_handler.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/browser/devtools/protocol/page_handler.h"
+#include "base/debug/stack_trace.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
@@ -104,6 +105,8 @@ void PageHandler::GetInstallabilityErrors(
protocol::Response::ServerError("Unable to fetch errors for target"));
return;
}
+ LOG(ERROR) << "*** about to get install errors";
+ // base::debug::StackTrace().Print();
manager->GetAllErrors(base::BindOnce(&PageHandler::GotInstallabilityErrors,
std::move(callback)));
}
@@ -112,6 +115,8 @@ void PageHandler::GetInstallabilityErrors(
void PageHandler::GotInstallabilityErrors(
std::unique_ptr<GetInstallabilityErrorsCallback> callback,
std::vector<content::InstallabilityError> installability_errors) {
+
+ LOG(ERROR) << "**** received install errors";
auto result_installability_errors =
std::make_unique<protocol::Array<protocol::Page::InstallabilityError>>();
for (const auto& installability_error : installability_errors) {
@@ -125,6 +130,7 @@ void PageHandler::GotInstallabilityErrors(
.SetValue(error_argument.value)
.Build());
}
+ LOG(ERROR) << "**** received install error item: " << installability_error.error_id;
result_installability_errors->emplace_back(
protocol::Page::InstallabilityError::Create()
.SetErrorId(installability_error.error_id)
diff --git a/components/webapps/browser/banners/app_banner_manager.cc b/components/webapps/browser/banners/app_banner_manager.cc
index 96537be0d3d4..b082cdcf4c90 100644
--- a/components/webapps/browser/banners/app_banner_manager.cc
+++ b/components/webapps/browser/banners/app_banner_manager.cc
@@ -169,6 +169,7 @@ void AppBannerManager::RequestAppBanner(const GURL& validated_url) {
validated_url_ = validated_url;
UpdateState(State::FETCHING_MANIFEST);
+ LOG(ERROR) << "AppBannerManager::RequestAppBanner";
manager_->GetData(
ParamsToGetManifest(),
base::BindOnce(&AppBannerManager::OnDidGetManifest, GetWeakPtr()));
@@ -347,19 +348,22 @@ bool AppBannerManager::DidRetryInstallableManagerRequest(
}
void AppBannerManager::OnDidGetManifest(const InstallableData& data) {
- if (DidRetryInstallableManagerRequest(data))
+ bool didRetry = DidRetryInstallableManagerRequest(data);
+ LOG(ERROR) << "**** AppBannerManager::OnDidGetManifest " << didRetry;
+
+ if (didRetry)
return;
UpdateState(State::ACTIVE);
if (!data.NoBlockingErrors()) {
Stop(data.errors[0]);
return;
}
-
DCHECK(!data.manifest_url.is_empty());
DCHECK(!blink::IsEmptyManifest(data.manifest));
manifest_url_ = data.manifest_url;
manifest_ = data.manifest.Clone();
+ LOG(ERROR) << "AppBannerManager::OnDidGetManifest about to PerformInstallableChecks ";
PerformInstallableChecks();
}
@@ -382,6 +386,8 @@ void AppBannerManager::PerformInstallableWebAppCheck() {
if (!CheckIfShouldShowBanner())
return;
+ LOG(ERROR) << "**** AppBannerManager::PerformInstallableWebAppCheck";
+
// Fetch and verify the other required information.
UpdateState(State::PENDING_INSTALLABLE_CHECK);
manager_->GetData(
@@ -392,7 +398,9 @@ void AppBannerManager::PerformInstallableWebAppCheck() {
void AppBannerManager::OnDidPerformInstallableWebAppCheck(
const InstallableData& data) {
- if (DidRetryInstallableManagerRequest(data))
+ bool didRetry = DidRetryInstallableManagerRequest(data);
+ LOG(ERROR) << "**** AppBannerManager::OnDidPerformInstallableWebAppCheck " << didRetry;
+ if (didRetry)
return;
UpdateState(State::ACTIVE);
diff --git a/components/webapps/browser/installable/installable_manager.cc b/components/webapps/browser/installable/installable_manager.cc
index c21ea7e6e424..370b81fb3757 100644
--- a/components/webapps/browser/installable/installable_manager.cc
+++ b/components/webapps/browser/installable/installable_manager.cc
@@ -8,6 +8,9 @@
#include <limits>
#include <utility>
+#include "base/debug/stack_trace.h"
+
+
#include "base/bind.h"
#include "base/callback.h"
#include "base/callback_helpers.h"
@@ -192,6 +195,7 @@ void OnDidCompleteGetAllErrors(
base::OnceCallback<void(std::vector<content::InstallabilityError>
installability_errors)> callback,
const InstallableData& data) {
+ LOG(ERROR) << "**** OnDidCompleteGetAllErrors";
std::vector<content::InstallabilityError> installability_errors;
for (auto error : data.errors) {
content::InstallabilityError installability_error =
@@ -300,13 +304,20 @@ void InstallableManager::GetData(const InstallableParams& params,
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(callback);
+ LOG(ERROR) << "**** getdata. init";
+ // base::debug::StackTrace().Print();
+
// Return immediately if we're already working on a task. The new task will be
// looked at once the current task is finished.
bool was_active = task_queue_.HasCurrent();
task_queue_.Add({params, std::move(callback)});
- if (was_active)
+ if (was_active) {
+ LOG(ERROR) << "**** getdata. but quitting cuz theres something active";
+
return;
+ }
+ LOG(ERROR) << "**** getdata. start fresh";
WorkOnTask();
}
@@ -323,6 +334,7 @@ void InstallableManager::GetAllErrors(
params.valid_primary_icon = true;
params.wait_for_worker = false;
params.is_debug_mode = true;
+ LOG(ERROR) << "**** GetAllErrors";
GetData(params,
base::BindOnce(OnDidCompleteGetAllErrors, std::move(callback)));
}
@@ -557,6 +569,7 @@ void InstallableManager::RunCallback(
valid_manifest_->is_valid,
worker_->has_worker,
};
+ LOG(ERROR) << "runcallback finishing up ";
std::move(task.callback).Run(data);
}
@@ -565,8 +578,14 @@ void InstallableManager::WorkOnTask() {
if (!task_queue_.HasCurrent())
return;
+
const InstallableParams& params = task_queue_.Current().params;
+ if (params.has_worker)
+ LOG(ERROR) << "**** workontask. w/ has_worker";
+ else
+ LOG(ERROR) << "**** workontask. just elig";
+
auto errors = GetErrors(params);
bool check_passed = errors.empty() || (errors.size() == 1 &&
errors[0] == WARN_NOT_OFFLINE_CAPABLE);
@@ -579,36 +598,45 @@ void InstallableManager::WorkOnTask() {
auto task = std::move(task_queue_.Current());
RunCallback(std::move(task), std::move(errors));
+ LOG(ERROR) << "**** workontask IS COMPLETE !!! " << (!check_passed && !params.is_debug_mode) << " . " << IsComplete(params);
return;
}
if (params.check_eligibility && !eligibility_->fetched) {
+ LOG(ERROR) << "**** workontask: CheckEligiblity()";
CheckEligiblity();
} else if (!manifest_->fetched) {
FetchManifest();
} else if (params.valid_manifest && !valid_manifest_->fetched) {
+ LOG(ERROR) << "**** workontask: CheckManifestValid()";
CheckManifestValid(params.check_webapp_manifest_display);
} else if (params.valid_primary_icon && params.prefer_maskable_icon &&
!IsMaskableIconFetched(IconUsage::kPrimary)) {
+ LOG(ERROR) << "**** workontask: CheckAndFetchBestIcon()";
CheckAndFetchBestIcon(GetIdealPrimaryAdaptiveLauncherIconSizeInPx(),
kMinimumPrimaryAdaptiveLauncherIconSizeInPx,
IconPurpose::MASKABLE, IconUsage::kPrimary);
} else if (params.valid_primary_icon &&
!IsIconFetchComplete(IconUsage::kPrimary)) {
+ LOG(ERROR) << "**** workontask: CheckAndFetchBestIcon()";
CheckAndFetchBestIcon(GetIdealPrimaryIconSizeInPx(),
GetMinimumPrimaryIconSizeInPx(), IconPurpose::ANY,
IconUsage::kPrimary);
} else if (params.fetch_screenshots && !is_screenshots_fetch_complete_) {
+ LOG(ERROR) << "**** workontask: CheckAndFetchScreenshots()";
CheckAndFetchScreenshots();
} else if (params.has_worker && !worker_->fetched) {
+ LOG(ERROR) << "**** workontask: CheckServiceWorker()";
CheckServiceWorker();
} else if (params.valid_splash_icon && params.prefer_maskable_icon &&
!IsMaskableIconFetched(IconUsage::kSplash)) {
+ LOG(ERROR) << "**** workontask: CheckAndFetchBestIcon()";
CheckAndFetchBestIcon(GetIdealSplashIconSizeInPx(),
GetMinimumSplashIconSizeInPx(), IconPurpose::MASKABLE,
IconUsage::kSplash);
} else if (params.valid_splash_icon &&
!IsIconFetchComplete(IconUsage::kSplash)) {
+ LOG(ERROR) << "**** workontask: CheckAndFetchBestIcon()";
CheckAndFetchBestIcon(GetIdealSplashIconSizeInPx(),
GetMinimumSplashIconSizeInPx(), IconPurpose::ANY,
IconUsage::kSplash);
@@ -727,6 +755,7 @@ void InstallableManager::CheckServiceWorker() {
if (!service_worker_context_)
return;
+ LOG(ERROR) << "InstallableManager::CheckServiceWorker " << base::TimeTicks::Now();
// Check to see if there is a service worker for the manifest's scope.
service_worker_context_->CheckHasServiceWorker(
manifest().scope,
@@ -738,6 +767,7 @@ void InstallableManager::CheckServiceWorker() {
void InstallableManager::OnDidCheckHasServiceWorker(
base::TimeTicks check_service_worker_start_time,
content::ServiceWorkerCapability capability) {
+ LOG(ERROR) << "InstallableManager::OnDidCheckHasServiceWorker " << base::TimeTicks::Now();
if (!GetWebContents())
return;
@@ -754,11 +784,13 @@ void InstallableManager::OnDidCheckHasServiceWorker(
worker_->error = NO_URL_FOR_SERVICE_WORKER;
worker_->fetched = true;
WorkOnTask();
+ LOG(ERROR) << "InstallableManager::OnDidCheckHasServiceWorker. no worker";
return;
}
// Dispatch a fetch event to `start_url` while simulating an offline
// environment and see if the site supports an offline page.
+ LOG(ERROR) << "InstallableManager::OnDidCheckHasServiceWorker. about to check offline capability";
service_worker_context_->CheckOfflineCapability(
manifest().start_url,
blink::StorageKey(url::Origin::Create(manifest().start_url)),
@@ -780,6 +812,7 @@ void InstallableManager::OnDidCheckHasServiceWorker(
// Wait for ServiceWorkerContextObserver::OnRegistrationCompleted. Set
// the param |wait_for_worker| to false so we only wait once per task.
task.params.wait_for_worker = false;
+ LOG(ERROR) << "InstallableManager::OnDidCheckHasServiceWorker. calling OnWaitingForServiceWorker";
OnWaitingForServiceWorker();
task_queue_.PauseCurrent();
WorkOnTask();
@@ -789,6 +822,7 @@ void InstallableManager::OnDidCheckHasServiceWorker(
worker_->error = NO_MATCHING_SERVICE_WORKER;
break;
}
+ LOG(ERROR) << "InstallableManager::OnDidCheckHasServiceWorker. some break case";
// These are recorded in OnDidCheckOfflineCapability() when
// CheckOfflineCapability is enabled.
@@ -799,6 +833,7 @@ void InstallableManager::OnDidCheckHasServiceWorker(
InstallableMetrics::ConvertFromServiceWorkerCapability(capability));
}
+ LOG(ERROR) << "InstallableManager::OnDidCheckHasServiceWorker. finishing up task";
worker_->fetched = true;
WorkOnTask();
}
@@ -813,6 +848,9 @@ void InstallableManager::OnDidCheckOfflineCapability(
InstallableMetrics::RecordCheckServiceWorkerStatus(
InstallableMetrics::ConvertFromOfflineCapability(capability));
+ LOG(ERROR) << "InstallableManager::OnDidCheckOfflineCapability. ";
+
+
switch (capability) {
case content::OfflineCapability::kSupported:
worker_->has_worker = true;
diff --git a/components/webapps/browser/installable/installable_task_queue.cc b/components/webapps/browser/installable/installable_task_queue.cc
index 2b51dc61b398..fc8eb78cdf48 100644
--- a/components/webapps/browser/installable/installable_task_queue.cc
+++ b/components/webapps/browser/installable/installable_task_queue.cc
@@ -54,6 +54,7 @@ bool InstallableTaskQueue::HasPaused() const {
InstallableTask& InstallableTaskQueue::Current() {
DCHECK(HasCurrent());
+ // LOG(ERROR) << "**** task items left: " << tasks_.size();
return tasks_.front();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment