Skip to content

Commit

Permalink
Replace DISALLOW_COPY_AND_ASSIGN in chromeos/
Browse files Browse the repository at this point in the history
This replaces DISALLOW_COPY_AND_ASSIGN with explicit constructor deletes
where a local script is able to detect its insertion place (~Foo() is
public => insert before this line).

This is incomplete as not all classes have a public ~Foo() declared, so
not all DISALLOW_COPY_AND_ASSIGN occurrences are replaced.

IWYU cleanup is left as a separate pass that is easier when these macros
go away.

Bug: 1010217
Change-Id: I4993fa33cbbb29abf30d51613eae64ac77fce1ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3174591
Auto-Submit: Peter Boström <pbos@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#923967}
  • Loading branch information
pbos authored and Chromium LUCI CQ committed Sep 22, 2021
1 parent fa92379 commit c1cecf2
Show file tree
Hide file tree
Showing 554 changed files with 2,745 additions and 1,413 deletions.
5 changes: 3 additions & 2 deletions chromeos/attestation/attestation_flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class COMPONENT_EXPORT(CHROMEOS_ATTESTATION) AttestationFlow {
AttestationFlow(std::unique_ptr<ServerProxy> server_proxy,
::attestation::KeyType crypto_key_type);

AttestationFlow(const AttestationFlow&) = delete;
AttestationFlow& operator=(const AttestationFlow&) = delete;

virtual ~AttestationFlow();

// Sets the timeout for attestation to be ready.
Expand Down Expand Up @@ -285,8 +288,6 @@ class COMPONENT_EXPORT(CHROMEOS_ATTESTATION) AttestationFlow {
base::TimeDelta retry_delay_;

base::WeakPtrFactory<AttestationFlow> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(AttestationFlow);
};

} // namespace attestation
Expand Down
6 changes: 4 additions & 2 deletions chromeos/attestation/mock_attestation_flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ namespace attestation {
class FakeServerProxy : public ServerProxy {
public:
FakeServerProxy();

FakeServerProxy(const FakeServerProxy&) = delete;
FakeServerProxy& operator=(const FakeServerProxy&) = delete;

~FakeServerProxy() override;

void set_result(bool result) {
Expand Down Expand Up @@ -50,8 +54,6 @@ class FakeServerProxy : public ServerProxy {

std::string enroll_response_;
std::string cert_response_;

DISALLOW_COPY_AND_ASSIGN(FakeServerProxy);
};

class MockServerProxy : public FakeServerProxy {
Expand Down
6 changes: 4 additions & 2 deletions chromeos/components/camera_app_ui/camera_app_helper_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class CameraAppHelperImpl : public ash::TabletModeObserver,
CameraResultCallback camera_result_callback,
SendBroadcastCallback send_broadcast_callback,
aura::Window* window);

CameraAppHelperImpl(const CameraAppHelperImpl&) = delete;
CameraAppHelperImpl& operator=(const CameraAppHelperImpl&) = delete;

~CameraAppHelperImpl() override;
void Bind(mojo::PendingReceiver<mojom::CameraAppHelper> receiver);

Expand Down Expand Up @@ -139,8 +143,6 @@ class CameraAppHelperImpl : public ash::TabletModeObserver,
// Client to connect to document detection service.
std::unique_ptr<chromeos::DocumentScannerServiceClient>
document_scanner_service_;

DISALLOW_COPY_AND_ASSIGN(CameraAppHelperImpl);
};

} // namespace chromeos_camera
Expand Down
6 changes: 4 additions & 2 deletions chromeos/components/camera_app_ui/camera_app_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class CameraAppUI : public ui::MojoWebUIController,
public:
CameraAppUI(content::WebUI* web_ui,
std::unique_ptr<CameraAppUIDelegate> delegate);

CameraAppUI(const CameraAppUI&) = delete;
CameraAppUI& operator=(const CameraAppUI&) = delete;

~CameraAppUI() override;

// Instantiates implementor of the cros::mojom::CameraAppDeviceProvider mojo
Expand Down Expand Up @@ -67,8 +71,6 @@ class CameraAppUI : public ui::MojoWebUIController,
std::unique_ptr<chromeos_camera::CameraAppHelperImpl> helper_;

WEB_UI_CONTROLLER_TYPE_DECL();

DISALLOW_COPY_AND_ASSIGN(CameraAppUI);
};

} // namespace chromeos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class ProximityAuthUI : public ui::MojoWebUIController {
device_sync::DeviceSyncClient* device_sync_client,
secure_channel::SecureChannelClient* secure_channel_client,
MultiDeviceSetupBinder multidevice_setup_binder);

ProximityAuthUI(const ProximityAuthUI&) = delete;
ProximityAuthUI& operator=(const ProximityAuthUI&) = delete;

~ProximityAuthUI() override;

// Instantiates implementor of the mojom::MultiDeviceSetup mojo interface
Expand All @@ -47,8 +51,6 @@ class ProximityAuthUI : public ui::MojoWebUIController {
const MultiDeviceSetupBinder multidevice_setup_binder_;

WEB_UI_CONTROLLER_TYPE_DECL();

DISALLOW_COPY_AND_ASSIGN(ProximityAuthUI);
};

} // namespace multidevice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class ProximityAuthWebUIHandler
ProximityAuthWebUIHandler(
device_sync::DeviceSyncClient* device_sync_client,
secure_channel::SecureChannelClient* secure_channel_client);

ProximityAuthWebUIHandler(const ProximityAuthWebUIHandler&) = delete;
ProximityAuthWebUIHandler& operator=(const ProximityAuthWebUIHandler&) =
delete;

~ProximityAuthWebUIHandler() override;

// content::WebUIMessageHandler:
Expand Down Expand Up @@ -129,8 +134,6 @@ class ProximityAuthWebUIHandler
bool get_local_state_update_waiting_for_debug_info_ = false;

base::WeakPtrFactory<ProximityAuthWebUIHandler> weak_ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(ProximityAuthWebUIHandler);
};

} // namespace multidevice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class RemoteDeviceCache;
class ExpiringRemoteDeviceCache {
public:
ExpiringRemoteDeviceCache();

ExpiringRemoteDeviceCache(const ExpiringRemoteDeviceCache&) = delete;
ExpiringRemoteDeviceCache& operator=(const ExpiringRemoteDeviceCache&) =
delete;

virtual ~ExpiringRemoteDeviceCache();

void SetRemoteDevicesAndInvalidateOldEntries(
Expand Down Expand Up @@ -64,8 +69,6 @@ class ExpiringRemoteDeviceCache {

base::flat_set<std::string> legacy_device_ids_from_last_set_call_;
base::flat_set<std::string> instance_ids_from_last_set_call_;

DISALLOW_COPY_AND_ASSIGN(ExpiringRemoteDeviceCache);
};

} // namespace multidevice
Expand Down
15 changes: 11 additions & 4 deletions chromeos/components/multidevice/fake_secure_message_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ namespace multidevice {
class FakeSecureMessageDelegate : public SecureMessageDelegate {
public:
FakeSecureMessageDelegate();

FakeSecureMessageDelegate(const FakeSecureMessageDelegate&) = delete;
FakeSecureMessageDelegate& operator=(const FakeSecureMessageDelegate&) =
delete;

~FakeSecureMessageDelegate() override;

// SecureMessageDelegate:
Expand Down Expand Up @@ -48,14 +53,18 @@ class FakeSecureMessageDelegate : public SecureMessageDelegate {

private:
std::string next_public_key_;

DISALLOW_COPY_AND_ASSIGN(FakeSecureMessageDelegate);
};

class FakeSecureMessageDelegateFactory
: public multidevice::SecureMessageDelegateImpl::Factory {
public:
FakeSecureMessageDelegateFactory() = default;

FakeSecureMessageDelegateFactory(const FakeSecureMessageDelegateFactory&) =
delete;
FakeSecureMessageDelegateFactory& operator=(
const FakeSecureMessageDelegateFactory&) = delete;

~FakeSecureMessageDelegateFactory() override = default;

multidevice::FakeSecureMessageDelegate* instance() { return instance_; }
Expand All @@ -65,8 +74,6 @@ class FakeSecureMessageDelegateFactory
std::unique_ptr<multidevice::SecureMessageDelegate> CreateInstance() override;

multidevice::FakeSecureMessageDelegate* instance_ = nullptr;

DISALLOW_COPY_AND_ASSIGN(FakeSecureMessageDelegateFactory);
};

} // namespace multidevice
Expand Down
6 changes: 4 additions & 2 deletions chromeos/components/multidevice/logging/log_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class LogBuffer {
};

LogBuffer();

LogBuffer(const LogBuffer&) = delete;
LogBuffer& operator=(const LogBuffer&) = delete;

~LogBuffer();

// Returns the global instance.
Expand Down Expand Up @@ -76,8 +80,6 @@ class LogBuffer {

// List of observers.
base::ObserverList<Observer>::Unchecked observers_;

DISALLOW_COPY_AND_ASSIGN(LogBuffer);
};

} // namespace multidevice
Expand Down
6 changes: 4 additions & 2 deletions chromeos/components/multidevice/logging/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class ScopedDisableLoggingForTesting {
class ScopedLogMessage {
public:
ScopedLogMessage(const char* file, int line, logging::LogSeverity severity);

ScopedLogMessage(const ScopedLogMessage&) = delete;
ScopedLogMessage& operator=(const ScopedLogMessage&) = delete;

~ScopedLogMessage();

std::ostream& stream() { return stream_; }
Expand All @@ -53,8 +57,6 @@ class ScopedLogMessage {
int line_;
logging::LogSeverity severity_;
std::ostringstream stream_;

DISALLOW_COPY_AND_ASSIGN(ScopedLogMessage);
};

} // namespace multidevice
Expand Down
7 changes: 4 additions & 3 deletions chromeos/components/proximity_auth/fake_lock_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ namespace proximity_auth {
class FakeLockHandler : public ScreenlockBridge::LockHandler {
public:
FakeLockHandler();

FakeLockHandler(const FakeLockHandler&) = delete;
FakeLockHandler& operator=(const FakeLockHandler&) = delete;

~FakeLockHandler() override;

// LockHandler:
Expand All @@ -32,9 +36,6 @@ class FakeLockHandler : public ScreenlockBridge::LockHandler {
void AttemptEasySignin(const AccountId& account_id,
const std::string& secret,
const std::string& key_label) override;

private:
DISALLOW_COPY_AND_ASSIGN(FakeLockHandler);
};

} // namespace proximity_auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class FakeRemoteDeviceLifeCycle : public RemoteDeviceLifeCycle {
explicit FakeRemoteDeviceLifeCycle(
chromeos::multidevice::RemoteDeviceRef remote_device,
absl::optional<chromeos::multidevice::RemoteDeviceRef> local_device);

FakeRemoteDeviceLifeCycle(const FakeRemoteDeviceLifeCycle&) = delete;
FakeRemoteDeviceLifeCycle& operator=(const FakeRemoteDeviceLifeCycle&) =
delete;

~FakeRemoteDeviceLifeCycle() override;

// RemoteDeviceLifeCycle:
Expand Down Expand Up @@ -55,8 +60,6 @@ class FakeRemoteDeviceLifeCycle : public RemoteDeviceLifeCycle {
State state_;
chromeos::secure_channel::ClientChannel* channel_;
Messenger* messenger_;

DISALLOW_COPY_AND_ASSIGN(FakeRemoteDeviceLifeCycle);
};

} // namespace proximity_auth
Expand Down
6 changes: 4 additions & 2 deletions chromeos/components/proximity_auth/messenger_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class MessengerImpl : public Messenger,
// The messenger begins observing messages as soon as it is constructed.
explicit MessengerImpl(
std::unique_ptr<chromeos::secure_channel::ClientChannel> channel);

MessengerImpl(const MessengerImpl&) = delete;
MessengerImpl& operator=(const MessengerImpl&) = delete;

~MessengerImpl() override;

// Messenger:
Expand Down Expand Up @@ -102,8 +106,6 @@ class MessengerImpl : public Messenger,
std::unique_ptr<PendingMessage> pending_message_;

base::WeakPtrFactory<MessengerImpl> weak_ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(MessengerImpl);
};

} // namespace proximity_auth
Expand Down
13 changes: 8 additions & 5 deletions chromeos/components/proximity_auth/messenger_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class MockMessengerObserver : public MessengerObserver {
explicit MockMessengerObserver(Messenger* messenger) : messenger_(messenger) {
messenger_->AddObserver(this);
}

MockMessengerObserver(const MockMessengerObserver&) = delete;
MockMessengerObserver& operator=(const MockMessengerObserver&) = delete;

virtual ~MockMessengerObserver() { messenger_->RemoveObserver(this); }

MOCK_METHOD1(OnUnlockEventSent, void(bool success));
Expand All @@ -54,19 +58,18 @@ class MockMessengerObserver : public MessengerObserver {
private:
// The messenger that |this| instance observes.
Messenger* const messenger_;

DISALLOW_COPY_AND_ASSIGN(MockMessengerObserver);
};

class TestMessenger : public MessengerImpl {
public:
TestMessenger(
std::unique_ptr<chromeos::secure_channel::ClientChannel> channel)
: MessengerImpl(std::move(channel)) {}
~TestMessenger() override {}

private:
DISALLOW_COPY_AND_ASSIGN(TestMessenger);
TestMessenger(const TestMessenger&) = delete;
TestMessenger& operator=(const TestMessenger&) = delete;

~TestMessenger() override {}
};

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ namespace proximity_auth {
class MockProximityAuthClient : public ProximityAuthClient {
public:
MockProximityAuthClient();

MockProximityAuthClient(const MockProximityAuthClient&) = delete;
MockProximityAuthClient& operator=(const MockProximityAuthClient&) = delete;

~MockProximityAuthClient() override;

// ProximityAuthClient:
Expand All @@ -32,9 +36,6 @@ class MockProximityAuthClient : public ProximityAuthClient {
base::OnceCallback<void(const std::string& challenge)> callback));
MOCK_CONST_METHOD0(GetAuthenticatedUsername, std::string(void));
MOCK_METHOD0(GetPrefManager, ProximityAuthPrefManager*(void));

private:
DISALLOW_COPY_AND_ASSIGN(MockProximityAuthClient);
};

} // namespace proximity_auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ namespace proximity_auth {
class ProximityAuthLocalStatePrefManager : public ProximityAuthPrefManager {
public:
explicit ProximityAuthLocalStatePrefManager(PrefService* local_state);

ProximityAuthLocalStatePrefManager(
const ProximityAuthLocalStatePrefManager&) = delete;
ProximityAuthLocalStatePrefManager& operator=(
const ProximityAuthLocalStatePrefManager&) = delete;

~ProximityAuthLocalStatePrefManager() override;

// Registers the prefs used by this class to the given |pref_service|.
Expand Down Expand Up @@ -64,8 +70,6 @@ class ProximityAuthLocalStatePrefManager : public ProximityAuthPrefManager {

// The account id of the active user for which to fetch the prefs.
AccountId active_user_;

DISALLOW_COPY_AND_ASSIGN(ProximityAuthLocalStatePrefManager);
};

} // namespace proximity_auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ namespace proximity_auth {
class ProximityAuthPrefManager {
public:
ProximityAuthPrefManager() {}

ProximityAuthPrefManager(const ProximityAuthPrefManager&) = delete;
ProximityAuthPrefManager& operator=(const ProximityAuthPrefManager&) = delete;

virtual ~ProximityAuthPrefManager() {}

// Returns true if EasyUnlock is allowed. Note: there is no corresponding
Expand Down Expand Up @@ -60,9 +64,6 @@ class ProximityAuthPrefManager {
// message on the login screen has been shown.
virtual void SetHasShownLoginDisabledMessage(bool has_shown) = 0;
virtual bool HasShownLoginDisabledMessage() const = 0;

private:
DISALLOW_COPY_AND_ASSIGN(ProximityAuthPrefManager);
};

} // namespace proximity_auth
Expand Down
Loading

0 comments on commit c1cecf2

Please sign in to comment.