Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert brave_component_updater to component target type. #27304

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions browser/brave_browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ void BraveBrowserProcessImpl::PostDestroyThreads() {
brave_component_updater::BraveComponent::Delegate*
BraveBrowserProcessImpl::brave_component_updater_delegate() {
if (!brave_component_updater_delegate_) {
brave_component_updater_delegate_ =
std::make_unique<brave::BraveComponentUpdaterDelegate>(
component_updater(), local_state(), GetApplicationLocale());
brave_component_updater_delegate_ = std::make_unique<
brave_component_updater::BraveComponentUpdaterDelegate>(
component_updater(), local_state(), GetApplicationLocale());
}
return brave_component_updater_delegate_.get();
}
Expand Down
2 changes: 1 addition & 1 deletion browser/extensions/brave_component_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void BraveComponentLoader::ReinstallAsNonComponent(
void BraveComponentLoader::AddExtension(const std::string& extension_id,
const std::string& name,
const std::string& public_key) {
brave::RegisterComponent(
brave_component_updater::RegisterComponent(
g_browser_process->component_updater(), name, public_key,
base::BindOnce(&BraveComponentLoader::OnComponentRegistered,
base::Unretained(this), extension_id),
Expand Down
4 changes: 3 additions & 1 deletion components/brave_component_updater/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import("//extensions/buildflags/buildflags.gni")

static_library("browser") {
component("browser") {
defines = [ "IS_BRAVE_COMPONENT_UPDATER_IMPL" ]

sources = [
"brave_component.cc",
"brave_component.h",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <string>

#include "base/component_export.h"
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
Expand All @@ -31,7 +32,7 @@ namespace brave_component_updater {
class LocalDataFilesService;

// DEPRECATED: Use ComponentInstallerPolicy instead.
class BraveComponent {
class COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER) BraveComponent {
public:
using ReadyCallback = base::RepeatingCallback<void(const base::FilePath&,
const std::string& manifest)>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include "components/update_client/update_client_errors.h"
#include "crypto/sha2.h"

using brave_component_updater::BraveComponent;

namespace {
using Result = update_client::CrxInstaller::Result;
using InstallError = update_client::InstallError;
Expand Down Expand Up @@ -64,7 +62,7 @@ std::string GetManifestString(base::Value::Dict* manifest,

} // namespace

namespace brave {
namespace brave_component_updater {

BraveComponentInstallerPolicy::BraveComponentInstallerPolicy(
const std::string& name,
Expand Down Expand Up @@ -154,4 +152,4 @@ void RegisterComponent(component_updater::ComponentUpdateService* cus,
installer->Register(cus, std::move(registered_callback));
}

} // namespace brave
} // namespace brave_component_updater
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@
#include <string>
#include <vector>

#include "base/component_export.h"
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/values.h"
#include "brave/components/brave_component_updater/browser/brave_component.h"
#include "components/component_updater/component_installer.h"
#include "components/update_client/update_client.h"

using brave_component_updater::BraveComponent;
namespace brave_component_updater {

namespace brave {

class BraveComponentInstallerPolicy
class COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER) BraveComponentInstallerPolicy
: public component_updater::ComponentInstallerPolicy {
public:
explicit BraveComponentInstallerPolicy(
Expand Down Expand Up @@ -59,12 +58,13 @@ class BraveComponentInstallerPolicy
BraveComponent::ReadyCallback ready_callback_;
};

COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER)
void RegisterComponent(component_updater::ComponentUpdateService* cus,
const std::string& name,
const std::string& base64_public_key,
base::OnceClosure registered_callback,
BraveComponent::ReadyCallback ready_callback);

} // namespace brave
} // namespace brave_component_updater

#endif // BRAVE_COMPONENTS_BRAVE_COMPONENT_UPDATER_BROWSER_BRAVE_COMPONENT_INSTALLER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using brave_component_updater::BraveComponent;
using brave_component_updater::BraveOnDemandUpdater;
using component_updater::ComponentUpdateService;

namespace brave {
namespace brave_component_updater {

BraveComponentUpdaterDelegate::BraveComponentUpdaterDelegate(
ComponentUpdateService* component_updater,
Expand All @@ -40,10 +40,9 @@ void BraveComponentUpdaterDelegate::Register(
const std::string& component_base64_public_key,
base::OnceClosure registered_callback,
BraveComponent::ReadyCallback ready_callback) {
brave::RegisterComponent(base::to_address(component_updater_), component_name,
component_base64_public_key,
std::move(registered_callback),
std::move(ready_callback));
RegisterComponent(base::to_address(component_updater_), component_name,
component_base64_public_key, std::move(registered_callback),
std::move(ready_callback));
}

bool BraveComponentUpdaterDelegate::Unregister(
Expand Down Expand Up @@ -78,4 +77,4 @@ PrefService* BraveComponentUpdaterDelegate::local_state() {
return base::to_address(local_state_);
}

} // namespace brave
} // namespace brave_component_updater
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

#include <string>

#include "base/component_export.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ref.h"
#include "brave/components/brave_component_updater/browser/brave_component.h"

using brave_component_updater::BraveComponent;

namespace base {
class SequencedTaskRunner;
}
Expand All @@ -24,9 +23,10 @@ class ComponentUpdateService;

class PrefService;

namespace brave {
namespace brave_component_updater {

class BraveComponentUpdaterDelegate : public BraveComponent::Delegate {
class COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER) BraveComponentUpdaterDelegate
: public BraveComponent::Delegate {
public:
BraveComponentUpdaterDelegate(
component_updater::ComponentUpdateService* updater,
Expand All @@ -42,7 +42,8 @@ class BraveComponentUpdaterDelegate : public BraveComponent::Delegate {
void Register(const std::string& component_name,
const std::string& component_base64_public_key,
base::OnceClosure registered_callback,
BraveComponent::ReadyCallback ready_callback) override;
brave_component_updater::BraveComponent::ReadyCallback
ready_callback) override;
bool Unregister(const std::string& component_id) override;
void EnsureInstalled(const std::string& component_id) override;

Expand All @@ -61,6 +62,6 @@ class BraveComponentUpdaterDelegate : public BraveComponent::Delegate {
scoped_refptr<base::SequencedTaskRunner> task_runner_;
};

} // namespace brave
} // namespace brave_component_updater

#endif // BRAVE_COMPONENTS_BRAVE_COMPONENT_UPDATER_BROWSER_BRAVE_COMPONENT_UPDATER_DELEGATE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>
#include <vector>

#include "base/component_export.h"
#include "base/functional/callback_helpers.h"
#include "components/component_updater/component_updater_service.h"

Expand All @@ -19,7 +20,7 @@ class NoDestructor;

namespace brave_component_updater {

class BraveOnDemandUpdater {
class COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER) BraveOnDemandUpdater {
public:
static BraveOnDemandUpdater* GetInstance();

Expand Down
3 changes: 3 additions & 0 deletions components/brave_component_updater/browser/dat_file_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
#include <utility>
#include <vector>

#include "base/component_export.h"
#include "base/files/file_path.h"

namespace brave_component_updater {

using DATFileDataBuffer = std::vector<unsigned char>;

COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER)
std::string GetDATFileAsString(const base::FilePath& file_path);

COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER)
DATFileDataBuffer ReadDATFileData(const base::FilePath& dat_file_path);

} // namespace brave_component_updater
Expand Down
2 changes: 2 additions & 0 deletions components/brave_component_updater/browser/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#ifndef BRAVE_COMPONENTS_BRAVE_COMPONENT_UPDATER_BROWSER_FEATURES_H_
#define BRAVE_COMPONENTS_BRAVE_COMPONENT_UPDATER_BROWSER_FEATURES_H_

#include "base/component_export.h"
#include "base/feature_list.h"

namespace brave_component_updater {

COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER)
BASE_DECLARE_FEATURE(kUseDevUpdaterUrl);

} // namespace brave_component_updater
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <string>

#include "base/component_export.h"
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/scoped_observation.h"
Expand Down Expand Up @@ -43,7 +44,7 @@ namespace brave_component_updater {
// The abstract base class for observers of the local data files service,
// which is the component that arbitrates access to various DAT files
// like tracking protection.
class LocalDataFilesObserver {
class COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER) LocalDataFilesObserver {
public:
virtual ~LocalDataFilesObserver();
virtual void OnComponentReady(const std::string& component_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <memory>
#include <string>

#include "base/component_export.h"
#include "base/files/file_path.h"
#include "base/observer_list.h"
#include "brave/components/brave_component_updater/browser/brave_component.h"
Expand All @@ -32,7 +33,8 @@ inline constexpr char kLocalDataFilesComponentBase64PublicKey[] =

// The component in charge of delegating access to different DAT files
// such as tracking protection.
class LocalDataFilesService : public BraveComponent {
class COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER) LocalDataFilesService
: public BraveComponent {
public:
explicit LocalDataFilesService(BraveComponent::Delegate* delegate);
LocalDataFilesService(const LocalDataFilesService&) = delete;
Expand Down Expand Up @@ -61,6 +63,7 @@ class LocalDataFilesService : public BraveComponent {
};

// Creates the LocalDataFilesService
COMPONENT_EXPORT(BRAVE_COMPONENT_UPDATER)
std::unique_ptr<LocalDataFilesService>
LocalDataFilesServiceFactory(BraveComponent::Delegate* delegate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@
brave_component_updater::BraveComponent::Delegate*
BraveApplicationContextImpl::brave_component_updater_delegate() {
if (!brave_component_updater_delegate_) {
brave_component_updater_delegate_ =
std::make_unique<brave::BraveComponentUpdaterDelegate>(
GetComponentUpdateService(), GetLocalState(),
GetApplicationLocale());
brave_component_updater_delegate_ = std::make_unique<
brave_component_updater::BraveComponentUpdaterDelegate>(
GetComponentUpdateService(), GetLocalState(), GetApplicationLocale());
}

return brave_component_updater_delegate_.get();
Expand Down
Loading