Commit 296efeee authored by Ryo Hashimoto's avatar Ryo Hashimoto Committed by Commit Bot

chromeos: Initialize browser D-Bus clients in the same way

Create() returns std::unique_ptr<> instead of a raw pointer.
UpdateEngineClient will be addressed later as it has 3 implementations
(i.e. real, stub, and fake).

BUG=952745
TEST=build

Change-Id: I5153d7c1aefb244c24b7bc335d3678f92729d6ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574996
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652815}
parent 8756d16e
......@@ -81,8 +81,8 @@ ArcObbMounterClient::ArcObbMounterClient() = default;
ArcObbMounterClient::~ArcObbMounterClient() = default;
// static
ArcObbMounterClient* ArcObbMounterClient::Create() {
return new ArcObbMounterClientImpl();
std::unique_ptr<ArcObbMounterClient> ArcObbMounterClient::Create() {
return std::make_unique<ArcObbMounterClientImpl>();
}
} // namespace chromeos
......@@ -7,6 +7,7 @@
#include <stdint.h>
#include <memory>
#include <string>
#include "base/callback_forward.h"
......@@ -28,7 +29,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) ArcObbMounterClient : public DBusClient {
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static ArcObbMounterClient* Create();
static std::unique_ptr<ArcObbMounterClient> Create();
// Mounts the specified OBB at the specified mount path, with the owner GID
// set to the given value.
......
......@@ -78,8 +78,8 @@ ArcOemCryptoClient::ArcOemCryptoClient() = default;
ArcOemCryptoClient::~ArcOemCryptoClient() = default;
// static
ArcOemCryptoClient* ArcOemCryptoClient::Create() {
return new ArcOemCryptoClientImpl();
std::unique_ptr<ArcOemCryptoClient> ArcOemCryptoClient::Create() {
return std::make_unique<ArcOemCryptoClientImpl>();
}
} // namespace chromeos
......@@ -7,6 +7,7 @@
#include <stdint.h>
#include <memory>
#include <string>
#include "base/callback_forward.h"
......@@ -30,7 +31,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) ArcOemCryptoClient : public DBusClient {
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static ArcOemCryptoClient* Create();
static std::unique_ptr<ArcOemCryptoClient> Create();
// Bootstraps the Mojo IPC connection between Chrome and the service daemon.
// This should pass in the child end of a Mojo pipe.
......
......@@ -10,7 +10,6 @@
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "chromeos/dbus/fake_cec_service_client.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_proxy.h"
......@@ -133,13 +132,8 @@ CecServiceClient::CecServiceClient() = default;
CecServiceClient::~CecServiceClient() = default;
// static
std::unique_ptr<CecServiceClient> CecServiceClient::Create(
DBusClientImplementationType type) {
if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
return std::make_unique<CecServiceClientImpl>();
DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type);
return std::make_unique<FakeCecServiceClient>();
std::unique_ptr<CecServiceClient> CecServiceClient::Create() {
return std::make_unique<CecServiceClientImpl>();
}
} // namespace chromeos
......@@ -10,7 +10,6 @@
#include "base/macros.h"
#include "chromeos/dbus/dbus_client.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
#include "chromeos/dbus/dbus_method_call_status.h"
namespace chromeos {
......@@ -50,8 +49,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) CecServiceClient : public DBusClient {
base::OnceCallback<void(const std::vector<PowerState>&)>;
// For normal usage, access the singleton via DBusThreadManager::Get().
static std::unique_ptr<CecServiceClient> Create(
DBusClientImplementationType type);
static std::unique_ptr<CecServiceClient> Create();
// Puts all connected HDMI CEC capable displays into stand-by mode. The effect
// of calling this method is on a best effort basis, no guarantees of displays
......
......@@ -96,7 +96,7 @@ class CecServiceClientTest : public testing::Test {
.WillByDefault(Return(mock_proxy_.get()));
// Create a client with the mock bus.
client_ = CecServiceClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION);
client_ = CecServiceClient::Create();
client_->Init(mock_bus_.get());
// Run the message loop to run the signal connection result callback.
......
......@@ -329,8 +329,8 @@ ConciergeClient::ConciergeClient() = default;
ConciergeClient::~ConciergeClient() = default;
ConciergeClient* ConciergeClient::Create() {
return new ConciergeClientImpl();
std::unique_ptr<ConciergeClient> ConciergeClient::Create() {
return std::make_unique<ConciergeClientImpl>();
}
} // namespace chromeos
......@@ -5,6 +5,8 @@
#ifndef CHROMEOS_DBUS_CONCIERGE_CLIENT_H_
#define CHROMEOS_DBUS_CONCIERGE_CLIENT_H_
#include <memory>
#include "base/component_export.h"
#include "base/files/scoped_file.h"
#include "chromeos/dbus/concierge/service.pb.h"
......@@ -111,7 +113,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) ConciergeClient : public DBusClient {
callback) = 0;
// Creates an instance of ConciergeClient.
static ConciergeClient* Create();
static std::unique_ptr<ConciergeClient> Create();
~ConciergeClient() override;
......
......@@ -25,7 +25,6 @@
#include "base/task_runner_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chromeos/dbus/fake_cros_disks_client.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
......@@ -714,11 +713,8 @@ CrosDisksClient::CrosDisksClient() = default;
CrosDisksClient::~CrosDisksClient() = default;
// static
CrosDisksClient* CrosDisksClient::Create(DBusClientImplementationType type) {
if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
return new CrosDisksClientImpl();
DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type);
return new FakeCrosDisksClient();
std::unique_ptr<CrosDisksClient> CrosDisksClient::Create() {
return std::make_unique<CrosDisksClientImpl>();
}
// static
......
......@@ -7,6 +7,7 @@
#include <stdint.h>
#include <memory>
#include <string>
#include <vector>
......@@ -14,7 +15,6 @@
#include "base/component_export.h"
#include "base/macros.h"
#include "chromeos/dbus/dbus_client.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
#include "chromeos/dbus/dbus_method_call_status.h"
namespace base {
......@@ -372,7 +372,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) CrosDisksClient : public DBusClient {
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static CrosDisksClient* Create(DBusClientImplementationType type);
static std::unique_ptr<CrosDisksClient> Create();
// Returns the path of the mount point for archive files.
static base::FilePath GetArchiveMountPoint();
......
......@@ -22,8 +22,10 @@
#include "chromeos/dbus/fake_arc_midis_client.h"
#include "chromeos/dbus/fake_arc_obb_mounter_client.h"
#include "chromeos/dbus/fake_arc_oemcrypto_client.h"
#include "chromeos/dbus/fake_cec_service_client.h"
#include "chromeos/dbus/fake_cicerone_client.h"
#include "chromeos/dbus/fake_concierge_client.h"
#include "chromeos/dbus/fake_cros_disks_client.h"
#include "chromeos/dbus/fake_debug_daemon_client.h"
#include "chromeos/dbus/fake_diagnosticsd_client.h"
#include "chromeos/dbus/fake_easy_unlock_client.h"
......@@ -70,73 +72,35 @@ DBusClientsBrowser::DBusClientsBrowser(bool use_real_clients) {
arc_appfuse_provider_client_ =
CREATE_DBUS_CLIENT(ArcAppfuseProviderClient, use_real_clients);
arc_midis_client_ = CREATE_DBUS_CLIENT(ArcMidisClient, use_real_clients);
if (use_real_clients)
arc_obb_mounter_client_.reset(ArcObbMounterClient::Create());
else
arc_obb_mounter_client_.reset(new FakeArcObbMounterClient);
if (use_real_clients)
arc_oemcrypto_client_.reset(ArcOemCryptoClient::Create());
else
arc_oemcrypto_client_.reset(new FakeArcOemCryptoClient);
cec_service_client_ = CecServiceClient::Create(client_impl_type);
cros_disks_client_.reset(CrosDisksClient::Create(client_impl_type));
arc_obb_mounter_client_ =
CREATE_DBUS_CLIENT(ArcObbMounterClient, use_real_clients);
arc_oemcrypto_client_ =
CREATE_DBUS_CLIENT(ArcOemCryptoClient, use_real_clients);
cec_service_client_ = CREATE_DBUS_CLIENT(CecServiceClient, use_real_clients);
cros_disks_client_ = CREATE_DBUS_CLIENT(CrosDisksClient, use_real_clients);
cicerone_client_ = CREATE_DBUS_CLIENT(CiceroneClient, use_real_clients);
if (use_real_clients)
concierge_client_.reset(ConciergeClient::Create());
else
concierge_client_.reset(new FakeConciergeClient);
if (use_real_clients)
debug_daemon_client_.reset(DebugDaemonClient::Create());
else
debug_daemon_client_.reset(new FakeDebugDaemonClient);
concierge_client_ = CREATE_DBUS_CLIENT(ConciergeClient, use_real_clients);
debug_daemon_client_ =
CREATE_DBUS_CLIENT(DebugDaemonClient, use_real_clients);
diagnosticsd_client_ =
CREATE_DBUS_CLIENT(DiagnosticsdClient, use_real_clients);
if (use_real_clients)
easy_unlock_client_.reset(EasyUnlockClient::Create());
else
easy_unlock_client_.reset(new FakeEasyUnlockClient);
if (use_real_clients)
image_burner_client_.reset(ImageBurnerClient::Create());
else
image_burner_client_.reset(new FakeImageBurnerClient);
if (use_real_clients)
image_loader_client_.reset(ImageLoaderClient::Create());
else
image_loader_client_.reset(new FakeImageLoaderClient);
if (use_real_clients)
lorgnette_manager_client_.reset(LorgnetteManagerClient::Create());
else
lorgnette_manager_client_.reset(new FakeLorgnetteManagerClient);
easy_unlock_client_ = CREATE_DBUS_CLIENT(EasyUnlockClient, use_real_clients);
image_burner_client_ =
CREATE_DBUS_CLIENT(ImageBurnerClient, use_real_clients);
image_loader_client_ =
CREATE_DBUS_CLIENT(ImageLoaderClient, use_real_clients);
lorgnette_manager_client_ =
CREATE_DBUS_CLIENT(LorgnetteManagerClient, use_real_clients);
oobe_configuration_client_ =
CREATE_DBUS_CLIENT(OobeConfigurationClient, use_real_clients);
runtime_probe_client_ =
CREATE_DBUS_CLIENT(RuntimeProbeClient, use_real_clients);
seneschal_client_ = CREATE_DBUS_CLIENT(SeneschalClient, use_real_clients);
if (use_real_clients)
smb_provider_client_.reset(SmbProviderClient::Create());
else
smb_provider_client_ = std::make_unique<FakeSmbProviderClient>();
smb_provider_client_ =
CREATE_DBUS_CLIENT(SmbProviderClient, use_real_clients);
update_engine_client_.reset(UpdateEngineClient::Create(client_impl_type));
if (use_real_clients)
virtual_file_provider_client_.reset(VirtualFileProviderClient::Create());
else
virtual_file_provider_client_.reset(new FakeVirtualFileProviderClient);
virtual_file_provider_client_ =
CREATE_DBUS_CLIENT(VirtualFileProviderClient, use_real_clients);
}
DBusClientsBrowser::~DBusClientsBrowser() = default;
......
......@@ -853,8 +853,8 @@ DebugDaemonClient::DebugDaemonClient() = default;
DebugDaemonClient::~DebugDaemonClient() = default;
// static
DebugDaemonClient* DebugDaemonClient::Create() {
return new DebugDaemonClientImpl();
std::unique_ptr<DebugDaemonClient> DebugDaemonClient::Create() {
return std::make_unique<DebugDaemonClientImpl>();
}
} // namespace chromeos
......@@ -255,7 +255,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) DebugDaemonClient
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static DebugDaemonClient* Create();
static std::unique_ptr<DebugDaemonClient> Create();
protected:
// Create() should be used instead.
......
......@@ -203,8 +203,8 @@ EasyUnlockClient::EasyUnlockClient() = default;
EasyUnlockClient::~EasyUnlockClient() = default;
// static
EasyUnlockClient* EasyUnlockClient::Create() {
return new EasyUnlockClientImpl();
std::unique_ptr<EasyUnlockClient> EasyUnlockClient::Create() {
return std::make_unique<EasyUnlockClientImpl>();
}
} // namespace chromeos
......@@ -5,6 +5,7 @@
#ifndef CHROMEOS_DBUS_EASY_UNLOCK_CLIENT_H_
#define CHROMEOS_DBUS_EASY_UNLOCK_CLIENT_H_
#include <memory>
#include <string>
#include "base/callback.h"
......@@ -142,7 +143,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) EasyUnlockClient : public DBusClient {
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static EasyUnlockClient* Create();
static std::unique_ptr<EasyUnlockClient> Create();
protected:
// Create() should be used instead.
......
......@@ -143,8 +143,8 @@ ImageBurnerClient::ImageBurnerClient() = default;
ImageBurnerClient::~ImageBurnerClient() = default;
// static
ImageBurnerClient* ImageBurnerClient::Create() {
return new ImageBurnerClientImpl();
std::unique_ptr<ImageBurnerClient> ImageBurnerClient::Create() {
return std::make_unique<ImageBurnerClientImpl>();
}
} // namespace chromeos
......@@ -7,6 +7,7 @@
#include <stdint.h>
#include <memory>
#include <string>
#include "base/callback.h"
......@@ -55,7 +56,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) ImageBurnerClient : public DBusClient {
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static ImageBurnerClient* Create();
static std::unique_ptr<ImageBurnerClient> Create();
protected:
// Create() should be used instead.
......
......@@ -168,8 +168,8 @@ ImageLoaderClient::ImageLoaderClient() = default;
ImageLoaderClient::~ImageLoaderClient() = default;
// static
ImageLoaderClient* ImageLoaderClient::Create() {
return new ImageLoaderClientImpl();
std::unique_ptr<ImageLoaderClient> ImageLoaderClient::Create() {
return std::make_unique<ImageLoaderClientImpl>();
}
} // namespace chromeos
......@@ -5,6 +5,7 @@
#ifndef CHROMEOS_DBUS_IMAGE_LOADER_CLIENT_H_
#define CHROMEOS_DBUS_IMAGE_LOADER_CLIENT_H_
#include <memory>
#include <string>
#include "base/callback.h"
......@@ -56,7 +57,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) ImageLoaderClient : public DBusClient {
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static ImageLoaderClient* Create();
static std::unique_ptr<ImageLoaderClient> Create();
protected:
// Create() should be used instead.
......
......@@ -231,8 +231,8 @@ LorgnetteManagerClient::LorgnetteManagerClient() = default;
LorgnetteManagerClient::~LorgnetteManagerClient() = default;
// static
LorgnetteManagerClient* LorgnetteManagerClient::Create() {
return new LorgnetteManagerClientImpl();
std::unique_ptr<LorgnetteManagerClient> LorgnetteManagerClient::Create() {
return std::make_unique<LorgnetteManagerClientImpl>();
}
} // namespace chromeos
......@@ -6,6 +6,7 @@
#define CHROMEOS_DBUS_LORGNETTE_MANAGER_CLIENT_H_
#include <map>
#include <memory>
#include <string>
#include "base/callback.h"
......@@ -45,7 +46,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) LorgnetteManagerClient
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static LorgnetteManagerClient* Create();
static std::unique_ptr<LorgnetteManagerClient> Create();
protected:
// Create() should be used instead.
......
......@@ -752,8 +752,8 @@ SmbProviderClient::SmbProviderClient() = default;
SmbProviderClient::~SmbProviderClient() = default;
// static
SmbProviderClient* SmbProviderClient::Create() {
return new SmbProviderClientImpl();
std::unique_ptr<SmbProviderClient> SmbProviderClient::Create() {
return std::make_unique<SmbProviderClientImpl>();
}
} // namespace chromeos
......@@ -5,6 +5,7 @@
#ifndef CHROMEOS_DBUS_SMB_PROVIDER_CLIENT_H_
#define CHROMEOS_DBUS_SMB_PROVIDER_CLIENT_H_
#include <memory>
#include <string>
#include "base/callback.h"
......@@ -57,7 +58,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) SmbProviderClient
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static SmbProviderClient* Create();
static std::unique_ptr<SmbProviderClient> Create();
// Calls Mount. It runs OpenDirectory() on |share_path| to check that it is a
// valid share. |workgroup|, |username|, and |password_fd| will be used as
......
......@@ -77,8 +77,8 @@ VirtualFileProviderClient::VirtualFileProviderClient() = default;
VirtualFileProviderClient::~VirtualFileProviderClient() = default;
// static
VirtualFileProviderClient* VirtualFileProviderClient::Create() {
return new VirtualFileProviderClientImpl();
std::unique_ptr<VirtualFileProviderClient> VirtualFileProviderClient::Create() {
return std::make_unique<VirtualFileProviderClientImpl>();
}
} // namespace chromeos
......@@ -7,6 +7,7 @@
#include <stdint.h>
#include <memory>
#include <string>
#include "base/callback_forward.h"
......@@ -33,7 +34,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) VirtualFileProviderClient
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static VirtualFileProviderClient* Create();
static std::unique_ptr<VirtualFileProviderClient> Create();
// Creates a new file descriptor and returns it with a unique ID.
// |size| will be used to perform boundary check when FD is seeked.
......
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