Skip to content

Commit

Permalink
Move //chromeos/{=>ash/components}/dbus/fwupd
Browse files Browse the repository at this point in the history
And the moved files are migrated from namespace chromeos to ash.

This CL is part of the Chrome OS source code directory migration:
https://docs.google.com/document/d/1g-98HpzA8XcoGBWUv1gQNr4rbnD5yfvbtYZyPDDbkaE.

Bug: 1164001
Change-Id: If768b6aa115152d2ee1d3a1f1a8243db83d86830
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3780043
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Owners-Override: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Yeunjoo Choi <ychoi@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1028548}
  • Loading branch information
duswnchl authored and Chromium LUCI CQ committed Jul 27, 2022
1 parent 77c3ff7 commit fff0853
Show file tree
Hide file tree
Showing 26 changed files with 114 additions and 119 deletions.
4 changes: 2 additions & 2 deletions WATCHLISTS
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,8 @@
},
'firmware_update': {
'filepath': 'ash/components/fwupd/|' \
'chromeos/dbus/fwupd/|' \
'ash/webui/firmware_update_ui/'
'ash/webui/firmware_update_ui/' \
'chromeos/ash/components/dbus/fwupd/|'
},
'freetype_update': {
'filepath': 'third_party/freetype/README.chromium',
Expand Down
4 changes: 2 additions & 2 deletions ash/components/fwupd/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ component("fwupd") {
"//ash/public/mojom",
"//ash/webui/firmware_update_ui/mojom",
"//base:base",
"//chromeos/dbus/fwupd",
"//chromeos/ash/components/dbus/fwupd",
"//crypto",
"//dbus",
]
Expand All @@ -39,7 +39,7 @@ source_set("unit_tests") {
"//ash/public/mojom",
"//ash/webui/firmware_update_ui/mojom",
"//base/test:test_support",
"//chromeos/dbus/fwupd",
"//chromeos/ash/components/dbus/fwupd",
"//dbus:test_support",
"//services/network:test_support",
"//services/network/public/cpp",
Expand Down
37 changes: 17 additions & 20 deletions ash/components/fwupd/firmware_update_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "chromeos/dbus/fwupd/fwupd_client.h"
#include "chromeos/ash/components/dbus/fwupd/fwupd_client.h"
#include "crypto/sha2.h"
#include "dbus/message.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
Expand Down Expand Up @@ -156,7 +156,7 @@ bool CreateDirIfNotExists(const base::FilePath& path) {
}

firmware_update::mojom::FirmwareUpdatePtr CreateUpdate(
const chromeos::FwupdUpdate& update_details,
const FwupdUpdate& update_details,
const std::string& device_id,
const std::string& device_name) {
auto update = firmware_update::mojom::FirmwareUpdate::New();
Expand Down Expand Up @@ -254,16 +254,16 @@ FirmwareUpdateManager::FirmwareUpdateManager()
: task_runner_(base::ThreadPool::CreateSequencedTaskRunner(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN})) {
DCHECK(chromeos::FwupdClient::Get());
chromeos::FwupdClient::Get()->AddObserver(this);
DCHECK(FwupdClient::Get());
FwupdClient::Get()->AddObserver(this);

DCHECK_EQ(nullptr, g_instance);
g_instance = this;
}

FirmwareUpdateManager::~FirmwareUpdateManager() {
DCHECK_EQ(this, g_instance);
chromeos::FwupdClient::Get()->RemoveObserver(this);
FwupdClient::Get()->RemoveObserver(this);
g_instance = nullptr;
}

Expand Down Expand Up @@ -370,11 +370,11 @@ void FirmwareUpdateManager::RequestAllUpdates() {
}

void FirmwareUpdateManager::RequestDevices() {
chromeos::FwupdClient::Get()->RequestDevices();
FwupdClient::Get()->RequestDevices();
}

void FirmwareUpdateManager::RequestUpdates(const std::string& device_id) {
chromeos::FwupdClient::Get()->RequestUpdates(device_id);
FwupdClient::Get()->RequestUpdates(device_id);
}

// TODO(jimmyxgong): Currently only looks for the local cache for the update
Expand Down Expand Up @@ -538,7 +538,7 @@ void FirmwareUpdateManager::OnUrlDownloadedToFile(

void FirmwareUpdateManager::OnGetFileDescriptor(
const std::string& device_id,
chromeos::FirmwareInstallOptions options,
FirmwareInstallOptions options,
base::OnceCallback<void()> callback,
base::ScopedFD file_descriptor) {
if (!file_descriptor.is_valid()) {
Expand Down Expand Up @@ -568,25 +568,23 @@ void FirmwareUpdateManager::OnGetFileDescriptor(
std::move(options), std::move(callback)));
}

void FirmwareUpdateManager::InstallUpdate(
const std::string& device_id,
chromeos::FirmwareInstallOptions options,
base::OnceCallback<void()> callback,
base::File patch_file) {
void FirmwareUpdateManager::InstallUpdate(const std::string& device_id,
FirmwareInstallOptions options,
base::OnceCallback<void()> callback,
base::File patch_file) {
if (!patch_file.IsValid()) {
inflight_update_.reset();
std::move(callback).Run();
return;
}

chromeos::FwupdClient::Get()->InstallUpdate(
FwupdClient::Get()->InstallUpdate(
device_id, base::ScopedFD(patch_file.TakePlatformFile()), options);

std::move(callback).Run();
}

void FirmwareUpdateManager::OnDeviceListResponse(
chromeos::FwupdDeviceList* devices) {
void FirmwareUpdateManager::OnDeviceListResponse(FwupdDeviceList* devices) {
DCHECK(devices);
DCHECK(!HasPendingUpdates());
// Clear all cached updates prior to fetching the new update list.
Expand Down Expand Up @@ -617,9 +615,8 @@ void FirmwareUpdateManager::ShowNotificationIfRequired() {
}
}

void FirmwareUpdateManager::OnUpdateListResponse(
const std::string& device_id,
chromeos::FwupdUpdateList* updates) {
void FirmwareUpdateManager::OnUpdateListResponse(const std::string& device_id,
FwupdUpdateList* updates) {
DCHECK(updates);
DCHECK(base::Contains(devices_pending_update_, device_id));

Expand Down Expand Up @@ -690,7 +687,7 @@ void FirmwareUpdateManager::BindInterface(
}

void FirmwareUpdateManager::OnPropertiesChangedResponse(
chromeos::FwupdProperties* properties) {
FwupdProperties* properties) {
if (!properties || !update_progress_observer_.is_bound()) {
return;
}
Expand Down
23 changes: 11 additions & 12 deletions ash/components/fwupd/firmware_update_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "base/task/sequenced_task_runner.h"
#include "chromeos/dbus/fwupd/fwupd_client.h"
#include "chromeos/dbus/fwupd/fwupd_device.h"
#include "chromeos/dbus/fwupd/fwupd_properties.h"
#include "chromeos/dbus/fwupd/fwupd_update.h"
#include "chromeos/ash/components/dbus/fwupd/fwupd_client.h"
#include "chromeos/ash/components/dbus/fwupd/fwupd_device.h"
#include "chromeos/ash/components/dbus/fwupd/fwupd_properties.h"
#include "chromeos/ash/components/dbus/fwupd/fwupd_update.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote_set.h"
Expand All @@ -36,7 +36,7 @@ class SimpleURLLoader;
namespace ash {
// FirmwareUpdateManager contains all logic that runs the firmware update SWA.
class COMPONENT_EXPORT(ASH_FIRMWARE_UPDATE_MANAGER) FirmwareUpdateManager
: public chromeos::FwupdClient::Observer,
: public FwupdClient::Observer,
public firmware_update::mojom::UpdateProvider,
public firmware_update::mojom::InstallController {
public:
Expand Down Expand Up @@ -87,17 +87,16 @@ class COMPONENT_EXPORT(ASH_FIRMWARE_UPDATE_MANAGER) FirmwareUpdateManager
// FwupdClient::Observer:
// When the fwupd DBus client gets a response with devices from fwupd,
// it calls this function and passes the response.
void OnDeviceListResponse(chromeos::FwupdDeviceList* devices) override;
void OnDeviceListResponse(FwupdDeviceList* devices) override;

// When the fwupd DBus client gets a response with updates from fwupd,
// it calls this function and passes the response.
void OnUpdateListResponse(const std::string& device_id,
chromeos::FwupdUpdateList* updates) override;
FwupdUpdateList* updates) override;
void OnInstallResponse(bool success) override;
// TODO(jimmyxgong): Implement this function to send property updates via
// mojo.
void OnPropertiesChangedResponse(
chromeos::FwupdProperties* properties) override;
void OnPropertiesChangedResponse(FwupdProperties* properties) override;

// Query all updates for all devices.
void RequestAllUpdates();
Expand Down Expand Up @@ -133,13 +132,13 @@ class COMPONENT_EXPORT(ASH_FIRMWARE_UPDATE_MANAGER) FirmwareUpdateManager

// Callback handler after fetching the file descriptor.
void OnGetFileDescriptor(const std::string& device_id,
chromeos::FirmwareInstallOptions options,
FirmwareInstallOptions options,
base::OnceCallback<void()> callback,
base::ScopedFD file_descriptor);

// Query the fwupd DBus client to install an update for a certain device.
void InstallUpdate(const std::string& device_id,
chromeos::FirmwareInstallOptions options,
FirmwareInstallOptions options,
base::OnceCallback<void()> callback,
base::File patch_file);

Expand Down Expand Up @@ -198,7 +197,7 @@ class COMPONENT_EXPORT(ASH_FIRMWARE_UPDATE_MANAGER) FirmwareUpdateManager

// Map of a device ID to `FwupdDevice` which is waiting for the list
// of updates.
base::flat_map<std::string, chromeos::FwupdDevice> devices_pending_update_;
base::flat_map<std::string, FwupdDevice> devices_pending_update_;

// Set of device IDs with critical updates that we've already shown a
// notification for.
Expand Down
3 changes: 1 addition & 2 deletions ash/components/fwupd/firmware_update_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "chromeos/dbus/fwupd/fwupd_client.h"
#include "chromeos/ash/components/dbus/fwupd/fwupd_client.h"
#include "components/user_manager/user_type.h"
#include "dbus/message.h"
#include "dbus/mock_bus.h"
Expand All @@ -39,7 +39,6 @@
#include "ui/message_center/fake_message_center.h"
#include "ui/message_center/message_center.h"

using chromeos::FwupdClient;
using message_center::MessageCenter;
using message_center::Notification;
using ::testing::_;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,7 @@ source_set("ash") {
"//chromeos/ash/components/dbus/concierge:concierge_proto",
"//chromeos/ash/components/dbus/cros_disks",
"//chromeos/ash/components/dbus/fusebox:proto",
"//chromeos/ash/components/dbus/fwupd",
"//chromeos/ash/components/dbus/gnubby",
"//chromeos/ash/components/dbus/image_burner",
"//chromeos/ash/components/dbus/kerberos:kerberos_proto",
Expand Down Expand Up @@ -1605,7 +1606,6 @@ source_set("ash") {
"//chromeos/dbus/cryptohome:cryptohome_proto",
"//chromeos/dbus/debug_daemon",
"//chromeos/dbus/dlcservice",
"//chromeos/dbus/fwupd",
"//chromeos/dbus/missive",
"//chromeos/dbus/power",
"//chromeos/dbus/power:power_manager_proto",
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/ash/dbus/ash_dbus_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "chromeos/ash/components/dbus/cups_proxy/cups_proxy_client.h"
#include "chromeos/ash/components/dbus/federated/federated_client.h"
#include "chromeos/ash/components/dbus/fusebox/fusebox_reverse_client.h"
#include "chromeos/ash/components/dbus/fwupd/fwupd_client.h"
#include "chromeos/ash/components/dbus/gnubby/gnubby_client.h"
#include "chromeos/ash/components/dbus/hermes/hermes_clients.h"
#include "chromeos/ash/components/dbus/human_presence/human_presence_dbus_client.h"
Expand Down Expand Up @@ -78,7 +79,6 @@
#include "chromeos/dbus/dlcservice/dlcservice_client.h"
#include "chromeos/dbus/dlp/dlp_client.h"
#include "chromeos/dbus/easy_unlock/easy_unlock_client.h"
#include "chromeos/dbus/fwupd/fwupd_client.h"
#include "chromeos/dbus/init/initialize_dbus_client.h"
#include "chromeos/dbus/machine_learning/machine_learning_client.h"
#include "chromeos/dbus/missive/missive_client.h"
Expand Down Expand Up @@ -164,7 +164,7 @@ void InitializeDBus() {
InitializeDBusClient<EasyUnlockClient>(bus);
InitializeDBusClient<FederatedClient>(bus);
InitializeDBusClient<FuseBoxReverseClient>(bus);
InitializeDBusClient<chromeos::FwupdClient>(bus);
InitializeDBusClient<FwupdClient>(bus);
InitializeDBusClient<GnubbyClient>(bus);
hermes_clients::Initialize(bus);
#if BUILDFLAG(ENABLE_HIBERNATE)
Expand Down Expand Up @@ -298,7 +298,7 @@ void ShutdownDBus() {
#endif
hermes_clients::Shutdown();
GnubbyClient::Shutdown();
chromeos::FwupdClient::Shutdown();
FwupdClient::Shutdown();
FuseBoxReverseClient::Shutdown();
FederatedClient::Shutdown();
EasyUnlockClient::Shutdown();
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ash/pcie_peripheral/ash_usb_detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chromeos/dbus/fwupd/fwupd_client.h"
#include "chromeos/ash/components/dbus/fwupd/fwupd_client.h"
#include "content/public/browser/device_service.h"

namespace ash {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ source_set("chromeos") {
"//chromeos/ash/components/dbus/federated",
"//chromeos/ash/components/dbus/fusebox",
"//chromeos/ash/components/dbus/fusebox:proto",
"//chromeos/ash/components/dbus/fwupd",
"//chromeos/ash/components/dbus/gnubby",
"//chromeos/ash/components/dbus/hermes",
"//chromeos/ash/components/dbus/human_presence",
Expand Down Expand Up @@ -345,7 +346,6 @@ source_set("chromeos") {
"//chromeos/dbus/dlp",
"//chromeos/dbus/dlp:dlp_proto",
"//chromeos/dbus/easy_unlock",
"//chromeos/dbus/fwupd",
"//chromeos/dbus/machine_learning",
"//chromeos/dbus/missive",
"//chromeos/dbus/permission_broker",
Expand Down
1 change: 1 addition & 0 deletions chromeos/ash/components/dbus/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ source_set("unit_tests") {
"//chromeos/ash/components/dbus/biod:test_support",
"//chromeos/ash/components/dbus/cec_service:unit_tests",
"//chromeos/ash/components/dbus/cros_disks:unit_tests",
"//chromeos/ash/components/dbus/fwupd:test_support",
"//chromeos/ash/components/dbus/gnubby:unit_tests",
"//chromeos/ash/components/dbus/hermes:test_support",
"//chromeos/ash/components/dbus/hiberman",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos")
import("//build/config/chromeos/ui_mode.gni")

assert(is_chromeos_ash, "Non-ChromeOS builds cannot depend on //chromeos/ash")

component("fwupd") {
output_name = "chromeos_dbus_fwupd"
defines = [ "IS_CHROMEOS_DBUS_FWUPD_IMPL" ]
output_name = "ash_dbus_fwupd"
defines = [ "IS_ASH_DBUS_FWUPD_IMPL" ]

deps = [
"//ash/constants",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_DBUS_FWUPD_DBUS_CONSTANTS_H_
#define CHROMEOS_DBUS_FWUPD_DBUS_CONSTANTS_H_
#ifndef CHROMEOS_ASH_COMPONENTS_DBUS_FWUPD_DBUS_CONSTANTS_H_
#define CHROMEOS_ASH_COMPONENTS_DBUS_FWUPD_DBUS_CONSTANTS_H_

namespace chromeos {
namespace ash {

const char kFwupdServiceName[] = "org.freedesktop.fwupd";
const char kFwupdServicePath[] = "/";
Expand All @@ -15,6 +15,6 @@ const char kFwupdGetUpgradesMethodName[] = "GetUpgrades";
const char kFwupdGetDevicesMethodName[] = "GetDevices";
const char kFwupdInstallMethodName[] = "Install";

} // namespace chromeos
} // namespace ash

#endif // CHROMEOS_DBUS_FWUPD_DBUS_CONSTANTS_H_
#endif // CHROMEOS_ASH_COMPONENTS_DBUS_FWUPD_DBUS_CONSTANTS_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chromeos/dbus/fwupd/fake_fwupd_client.h"
#include "chromeos/ash/components/dbus/fwupd/fake_fwupd_client.h"

#include "chromeos/dbus/fwupd/fwupd_device.h"
#include "chromeos/ash/components/dbus/fwupd/fwupd_device.h"

#include <string>

Expand All @@ -14,7 +14,7 @@ const char kFakeDeviceIdForTesting[] = "0123";

} // namespace

namespace chromeos {
namespace ash {

FakeFwupdClient::FakeFwupdClient() = default;
FakeFwupdClient::~FakeFwupdClient() = default;
Expand Down Expand Up @@ -52,4 +52,4 @@ void FakeFwupdClient::InstallUpdate(const std::string& device_id,
observer.OnInstallResponse(install_success_);
}

} // namespace chromeos
} // namespace ash

0 comments on commit fff0853

Please sign in to comment.