Initialize component updater URL feature after feature list initialization

Chromium change:

https://source.chromium.org/chromium/chromium/src/+/adb1c6128d5ac682478cda00c694174a6faf7413

commit adb1c6128d5ac682478cda00c694174a6faf7413
Author: François Doray <fdoray@chromium.org>
Date:   Wed Nov 16 22:57:38 2022 +0000

    Fail immediately on feature state access without a FeatureList.

    Since https://crrev.com/c/4006674, registering a FeatureList in a
    process that previously accessed the state of a feature DCHECKs.
    Because the DCHECK is delayed until FeatureList registration, the
    error log isn't as actionnable as it could be.

    This CL adds FeatureList::FailOnFeatureAccessWithoutFeatureList(),
    which makes feature state access without a FeatureList is registered
    fail instantly. FailOnFeatureAccessWithoutFeatureList() is called from
    ContentMain().

    Extra details:
    - Failing instantly on feature access without a FeatureList can't be
      the default, because this is tolerated in processes that never
      register a FeatureList.
    - We keep track of feature access without a FeatureList even if
      FeatureList::FailOnFeatureAccessWithoutFeatureList() hasn't been
      called, because:
        - FeatureList::FailOnFeatureAccessWithoutFeatureList() may be
          called later.
        - We want to catch early accesses in a myriad of test/utility
          processes that register a FeatureList but don't call
          FeatureList::FailOnFeatureAccessWithoutFeatureList(). Adding
          this call a myriad of processes wouldn't be practical or
          future-proof.

    Bug: 1358639
This commit is contained in:
Emerick Rogul
2023-01-25 07:42:29 +00:00
committed by Claudio DeSouza
parent 15b14b638a
commit 4c54c161df
3 changed files with 14 additions and 8 deletions
+12
View File
@@ -144,3 +144,15 @@ void BraveMainDelegate::PreSandboxStartup() {
brave::InitializeResourceBundle();
}
}
absl::optional<int> BraveMainDelegate::PostEarlyInitialization(
ChromeMainDelegate::InvokedIn invoked_in) {
auto result = ChromeMainDelegate::PostEarlyInitialization(invoked_in);
BraveCommandLineHelper command_line(base::CommandLine::ForCurrentProcess());
std::string update_url = GetUpdateURLHost();
if (!update_url.empty()) {
std::string source = "url-source=" + update_url;
command_line.AppendSwitchASCII(switches::kComponentUpdater, source.c_str());
}
return result;
}
+2 -2
View File
@@ -6,8 +6,6 @@
#ifndef BRAVE_APP_BRAVE_MAIN_DELEGATE_H_
#define BRAVE_APP_BRAVE_MAIN_DELEGATE_H_
#include <string>
#include "build/build_config.h"
#include "chrome/app/chrome_main_delegate.h"
@@ -29,6 +27,8 @@ class BraveMainDelegate : public ChromeMainDelegate {
content::ContentRendererClient* CreateContentRendererClient() override;
content::ContentUtilityClient* CreateContentUtilityClient() override;
void PreSandboxStartup() override;
absl::optional<int> PostEarlyInitialization(
ChromeMainDelegate::InvokedIn invoked_in) override;
};
#endif // BRAVE_APP_BRAVE_MAIN_DELEGATE_H_
@@ -63,12 +63,6 @@ absl::optional<int> ChromeMainDelegate::BasicStartupComplete() {
command_line.AppendSwitch(switches::kDisableDomainReliability);
command_line.AppendSwitch(switches::kEnableDomDistiller);
std::string update_url = GetUpdateURLHost();
if (!update_url.empty()) {
std::string source = "url-source=" + update_url;
command_line.AppendSwitchASCII(switches::kComponentUpdater, source.c_str());
}
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
embedder_support::kOriginTrialPublicKey)) {
command_line.AppendSwitchASCII(embedder_support::kOriginTrialPublicKey,