Commit 5f4d4f03 authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

Remove DISALLOW_COPY_AND_ASSIGN from base/*

Also fix cpp lint warnings. No functional changes.

Bug: 1010217
Change-Id: I60c13a4f4667522c7661b3ab91b948e71a06e657
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432204
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811059}
parent 6a6360f4
......@@ -8,7 +8,6 @@
#include "base/base_export.h"
#include "base/check_op.h"
#include "base/containers/linked_list.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list_types.h"
......@@ -20,6 +19,8 @@ class BASE_EXPORT UncheckedObserverAdapter {
public:
explicit UncheckedObserverAdapter(const void* observer)
: ptr_(const_cast<void*>(observer)) {}
UncheckedObserverAdapter(const UncheckedObserverAdapter&) = delete;
UncheckedObserverAdapter& operator=(const UncheckedObserverAdapter&) = delete;
UncheckedObserverAdapter(UncheckedObserverAdapter&& other) = default;
UncheckedObserverAdapter& operator=(UncheckedObserverAdapter&& other) =
default;
......@@ -39,8 +40,6 @@ class BASE_EXPORT UncheckedObserverAdapter {
private:
void* ptr_;
DISALLOW_COPY_AND_ASSIGN(UncheckedObserverAdapter);
};
// Adapter for CheckedObserver types so that they can use the same syntax as a
......@@ -56,6 +55,8 @@ class BASE_EXPORT CheckedObserverAdapter {
// types.
CheckedObserverAdapter(CheckedObserverAdapter&& other);
CheckedObserverAdapter& operator=(CheckedObserverAdapter&& other);
CheckedObserverAdapter(const CheckedObserverAdapter&) = delete;
CheckedObserverAdapter& operator=(const CheckedObserverAdapter&) = delete;
~CheckedObserverAdapter();
void MarkForRemoval() {
......@@ -92,8 +93,6 @@ class BASE_EXPORT CheckedObserverAdapter {
private:
WeakPtr<CheckedObserver> weak_ptr_;
DISALLOW_COPY_AND_ASSIGN(CheckedObserverAdapter);
};
// Wraps a pointer in a stack-allocated, base::LinkNode. The node is
......@@ -106,6 +105,8 @@ class WeakLinkNode : public base::LinkNode<WeakLinkNode<ObserverList>> {
public:
WeakLinkNode() = default;
explicit WeakLinkNode(ObserverList* list) { SetList(list); }
WeakLinkNode(const WeakLinkNode&) = delete;
WeakLinkNode& operator=(const WeakLinkNode&) = delete;
~WeakLinkNode() { Invalidate(); }
......@@ -138,8 +139,6 @@ class WeakLinkNode : public base::LinkNode<WeakLinkNode<ObserverList>> {
private:
ObserverList* list_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(WeakLinkNode);
};
} // namespace internal
......
......@@ -7,7 +7,6 @@
#include <memory>
#include "base/check_op.h"
#include "base/observer_list.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -34,12 +33,11 @@ perf_test::PerfResultReporter SetUpReporter(const std::string& story_name) {
class ObserverInterface {
public:
ObserverInterface() {}
virtual ~ObserverInterface() {}
ObserverInterface() = default;
ObserverInterface(const ObserverInterface&) = delete;
ObserverInterface& operator=(const ObserverInterface&) = delete;
virtual ~ObserverInterface() = default;
virtual void Observe() const { ++g_observer_list_perf_test_counter; }
private:
DISALLOW_COPY_AND_ASSIGN(ObserverInterface);
};
class UnsafeObserver : public ObserverInterface {};
......@@ -64,10 +62,9 @@ class ObserverListPerfTest : public ::testing::Test {
public:
using ObserverListType = typename Pick<ObserverType>::ObserverListType;
ObserverListPerfTest() {}
private:
DISALLOW_COPY_AND_ASSIGN(ObserverListPerfTest);
ObserverListPerfTest() = default;
ObserverListPerfTest(const ObserverListPerfTest&) = delete;
ObserverListPerfTest& operator=(const ObserverListPerfTest&) = delete;
};
typedef ::testing::Types<UnsafeObserver, TestCheckedObserver> ObserverTypes;
......
......@@ -7,13 +7,13 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include "base/base_export.h"
#include "base/bind.h"
#include "base/check_op.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/sequenced_task_runner.h"
......@@ -55,6 +55,9 @@ class BASE_EXPORT ObserverListThreadSafeBase
: public RefCountedThreadSafe<ObserverListThreadSafeBase> {
public:
ObserverListThreadSafeBase() = default;
ObserverListThreadSafeBase(const ObserverListThreadSafeBase&) = delete;
ObserverListThreadSafeBase& operator=(const ObserverListThreadSafeBase&) =
delete;
protected:
template <typename ObserverType, typename Method>
......@@ -84,8 +87,6 @@ class BASE_EXPORT ObserverListThreadSafeBase
private:
friend class RefCountedThreadSafe<ObserverListThreadSafeBase>;
DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafeBase);
};
} // namespace internal
......@@ -96,6 +97,8 @@ class ObserverListThreadSafe : public internal::ObserverListThreadSafeBase {
ObserverListThreadSafe() = default;
explicit ObserverListThreadSafe(ObserverListPolicy policy)
: policy_(policy) {}
ObserverListThreadSafe(const ObserverListThreadSafe&) = delete;
ObserverListThreadSafe& operator=(const ObserverListThreadSafe&) = delete;
// Adds |observer| to the list. |observer| must not already be in the list.
void AddObserver(ObserverType* observer) {
......@@ -260,8 +263,6 @@ class ObserverListThreadSafe : public internal::ObserverListThreadSafeBase {
// be notified.
std::unordered_map<ObserverType*, scoped_refptr<SequencedTaskRunner>>
observers_ GUARDED_BY(lock_);
DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe);
};
} // namespace base
......
......@@ -304,6 +304,9 @@ class SequenceVerificationObserver : public Foo {
explicit SequenceVerificationObserver(
scoped_refptr<SequencedTaskRunner> task_runner)
: task_runner_(std::move(task_runner)) {}
SequenceVerificationObserver(const SequenceVerificationObserver&) = delete;
SequenceVerificationObserver& operator=(const SequenceVerificationObserver&) =
delete;
~SequenceVerificationObserver() override = default;
void Observe(int x) override {
......@@ -315,8 +318,6 @@ class SequenceVerificationObserver : public Foo {
private:
const scoped_refptr<SequencedTaskRunner> task_runner_;
bool called_on_valid_sequence_ = false;
DISALLOW_COPY_AND_ASSIGN(SequenceVerificationObserver);
};
} // namespace
......@@ -378,6 +379,10 @@ class RemoveWhileNotificationIsRunningObserver : public Foo {
WaitableEvent::InitialState::NOT_SIGNALED),
barrier_(WaitableEvent::ResetPolicy::AUTOMATIC,
WaitableEvent::InitialState::NOT_SIGNALED) {}
RemoveWhileNotificationIsRunningObserver(
const RemoveWhileNotificationIsRunningObserver&) = delete;
RemoveWhileNotificationIsRunningObserver& operator=(
const RemoveWhileNotificationIsRunningObserver&) = delete;
~RemoveWhileNotificationIsRunningObserver() override = default;
void Observe(int x) override {
......@@ -392,8 +397,6 @@ class RemoveWhileNotificationIsRunningObserver : public Foo {
private:
WaitableEvent notification_running_;
WaitableEvent barrier_;
DISALLOW_COPY_AND_ASSIGN(RemoveWhileNotificationIsRunningObserver);
};
} // namespace
......
......@@ -6,7 +6,6 @@
#define BASE_OBSERVER_LIST_TYPES_H_
#include "base/base_export.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
namespace base {
......@@ -27,6 +26,8 @@ class CheckedObserverAdapter;
class BASE_EXPORT CheckedObserver {
public:
CheckedObserver();
CheckedObserver(const CheckedObserver&) = delete;
CheckedObserver& operator=(const CheckedObserver&) = delete;
protected:
virtual ~CheckedObserver();
......@@ -40,8 +41,6 @@ class BASE_EXPORT CheckedObserver {
// Must be mutable to allow ObserverList<const Foo>.
mutable WeakPtrFactory<CheckedObserver> factory_{this};
DISALLOW_COPY_AND_ASSIGN(CheckedObserver);
};
} // namespace base
......
......@@ -4,6 +4,8 @@
#include "base/observer_list.h"
#include <memory>
#include "base/strings/string_piece.h"
#include "base/test/gtest_util.h"
#include "base/threading/simple_thread.h"
......@@ -143,7 +145,9 @@ class ObserverListCreator : public DelegateSimpleThread::Delegate {
class ObserverListTestBase {
public:
ObserverListTestBase() {}
ObserverListTestBase() = default;
ObserverListTestBase(const ObserverListTestBase&) = delete;
ObserverListTestBase& operator=(const ObserverListTestBase&) = delete;
template <class T>
const decltype(T::list_.get()) list(const T& iter) {
......@@ -163,9 +167,6 @@ class ObserverListTestBase {
EXPECT_DCHECK_DEATH(return iter->GetCurrent());
return nullptr;
}
private:
DISALLOW_COPY_AND_ASSIGN(ObserverListTestBase);
};
// Templatized test fixture that can pick between CheckedBase and UncheckedBase.
......@@ -179,10 +180,9 @@ class ObserverListTest : public ObserverListTestBase, public ::testing::Test {
using iterator = typename ObserverList<ObserverType>::iterator;
using const_iterator = typename ObserverList<ObserverType>::const_iterator;
ObserverListTest() {}
private:
DISALLOW_COPY_AND_ASSIGN(ObserverListTest);
ObserverListTest() = default;
ObserverListTest(const ObserverListTest&) = delete;
ObserverListTest& operator=(const ObserverListTest&) = delete;
};
using ObserverTypes = ::testing::Types<CheckedBase, UncheckedBase>;
......@@ -200,10 +200,10 @@ TYPED_TEST_SUITE(ObserverListTest, ObserverTypes);
using Disrupter = DisrupterT<ObserverListFoo>; \
using const_iterator = typename TestFixture::const_iterator; \
using iterator = typename TestFixture::iterator; \
(void)(Disrupter*)(0); \
(void)(Adder*)(0); \
(void)(const_iterator*)(0); \
(void)(iterator*)(0)
(void)reinterpret_cast<Disrupter*>(0); \
(void)reinterpret_cast<Adder*>(0); \
(void)reinterpret_cast<const_iterator*>(0); \
(void)reinterpret_cast<iterator*>(0)
TYPED_TEST(ObserverListTest, BasicTest) {
DECLARE_TYPES;
......@@ -950,26 +950,26 @@ TYPED_TEST(ObserverListTest, ReentrantObserverList) {
class TestCheckedObserver : public CheckedObserver {
public:
explicit TestCheckedObserver(int* count) : count_(count) {}
TestCheckedObserver(const TestCheckedObserver&) = delete;
TestCheckedObserver& operator=(const TestCheckedObserver&) = delete;
void Observe() { ++(*count_); }
private:
int* count_;
DISALLOW_COPY_AND_ASSIGN(TestCheckedObserver);
};
// A second, identical observer, used to test multiple inheritance.
class TestCheckedObserver2 : public CheckedObserver {
public:
explicit TestCheckedObserver2(int* count) : count_(count) {}
TestCheckedObserver2(const TestCheckedObserver2&) = delete;
TestCheckedObserver2& operator=(const TestCheckedObserver2&) = delete;
void Observe() { ++(*count_); }
private:
int* count_;
DISALLOW_COPY_AND_ASSIGN(TestCheckedObserver2);
};
using CheckedObserverListTest = ::testing::Test;
......
......@@ -24,6 +24,8 @@ class RefCountedClass : public base::RefCounted<RefCountedClass> {
: did_delete_instance_(did_delete_instance) {
DCHECK(!*did_delete_instance_);
}
RefCountedClass(const RefCountedClass&) = delete;
RefCountedClass& operator=(const RefCountedClass&) = delete;
void PerformTask() { did_perform_task_ = true; }
bool did_perform_task() const { return did_perform_task_; }
......@@ -36,8 +38,6 @@ class RefCountedClass : public base::RefCounted<RefCountedClass> {
bool* const did_delete_instance_; // Not owned.
bool did_perform_task_ = false;
DISALLOW_COPY_AND_ASSIGN(RefCountedClass);
};
TEST(OneShotEventTest, RecordsSignal) {
......
......@@ -12,7 +12,6 @@
#include "base/base_export.h"
#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/containers/span.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
......@@ -136,12 +135,12 @@ class BASE_EXPORT Pickle {
class BASE_EXPORT Attachment : public RefCountedThreadSafe<Attachment> {
public:
Attachment();
Attachment(const Attachment&) = delete;
Attachment& operator=(const Attachment&) = delete;
protected:
friend class RefCountedThreadSafe<Attachment>;
virtual ~Attachment();
DISALLOW_COPY_AND_ASSIGN(Attachment);
};
// Initialize a Pickle object using the default header size.
......
......@@ -5,6 +5,7 @@
#ifndef BASE_RUN_LOOP_H_
#define BASE_RUN_LOOP_H_
#include <stack>
#include <utility>
#include <vector>
......@@ -12,7 +13,6 @@
#include "base/callback.h"
#include "base/containers/stack.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
......@@ -74,7 +74,9 @@ class BASE_EXPORT RunLoop {
kNestableTasksAllowed,
};
RunLoop(Type type = Type::kDefault);
explicit RunLoop(Type type = Type::kDefault);
RunLoop(const RunLoop&) = delete;
RunLoop& operator=(const RunLoop&) = delete;
~RunLoop();
// Run the current RunLoop::Delegate. This blocks until Quit is called
......@@ -176,6 +178,8 @@ class BASE_EXPORT RunLoop {
class BASE_EXPORT Delegate {
public:
Delegate();
Delegate(const Delegate&) = delete;
Delegate& operator=(const Delegate&) = delete;
virtual ~Delegate();
// Used by RunLoop to inform its Delegate to Run/Quit. Implementations are
......@@ -231,8 +235,6 @@ class BASE_EXPORT RunLoop {
// Thread-affine per its use of TLS.
THREAD_CHECKER(bound_thread_checker_);
DISALLOW_COPY_AND_ASSIGN(Delegate);
};
// Registers |delegate| on the current thread. Must be called once and only
......@@ -261,6 +263,10 @@ class BASE_EXPORT RunLoop {
class BASE_EXPORT ScopedDisallowRunningForTesting {
public:
ScopedDisallowRunningForTesting();
ScopedDisallowRunningForTesting(const ScopedDisallowRunningForTesting&) =
delete;
ScopedDisallowRunningForTesting& operator=(
const ScopedDisallowRunningForTesting&) = delete;
~ScopedDisallowRunningForTesting();
private:
......@@ -268,8 +274,6 @@ class BASE_EXPORT RunLoop {
Delegate* current_delegate_;
const bool previous_run_allowance_;
#endif // DCHECK_IS_ON()
DISALLOW_COPY_AND_ASSIGN(ScopedDisallowRunningForTesting);
};
// Support for //base/test/scoped_run_loop_timeout.h.
......@@ -344,8 +348,6 @@ class BASE_EXPORT RunLoop {
// WeakPtrFactory for QuitClosure safety.
WeakPtrFactory<RunLoop> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(RunLoop);
};
} // namespace base
......
......@@ -5,13 +5,13 @@
#include "base/run_loop.h"
#include <functional>
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/containers/queue.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
......@@ -62,6 +62,9 @@ void RunNestedLoopTask(int* counter) {
class SimpleSingleThreadTaskRunner : public SingleThreadTaskRunner {
public:
SimpleSingleThreadTaskRunner() = default;
SimpleSingleThreadTaskRunner(const SimpleSingleThreadTaskRunner&) = delete;
SimpleSingleThreadTaskRunner& operator=(const SimpleSingleThreadTaskRunner&) =
delete;
bool PostDelayedTask(const Location& from_here,
OnceClosure task,
......@@ -108,8 +111,6 @@ class SimpleSingleThreadTaskRunner : public SingleThreadTaskRunner {
// ThreadCheckerImpl to be able to reliably provide that signal even in
// non-dcheck builds.
ThreadCheckerImpl origin_thread_checker_;
DISALLOW_COPY_AND_ASSIGN(SimpleSingleThreadTaskRunner);
};
// The basis of all TestDelegates, allows safely injecting a OnceClosure to be
......@@ -209,7 +210,7 @@ enum class RunLoopTestType {
// so it can be instantiated on the stack in the RunLoopTest fixture.
class RunLoopTestEnvironment {
public:
RunLoopTestEnvironment(RunLoopTestType type) {
explicit RunLoopTestEnvironment(RunLoopTestType type) {
switch (type) {
case RunLoopTestType::kRealEnvironment: {
task_environment_ = std::make_unique<test::TaskEnvironment>();
......@@ -231,14 +232,15 @@ class RunLoopTestEnvironment {
};
class RunLoopTest : public testing::TestWithParam<RunLoopTestType> {
public:
RunLoopTest(const RunLoopTest&) = delete;
RunLoopTest& operator=(const RunLoopTest&) = delete;
protected:
RunLoopTest() : test_environment_(GetParam()) {}
RunLoopTestEnvironment test_environment_;
RunLoop run_loop_;
private:
DISALLOW_COPY_AND_ASSIGN(RunLoopTest);
};
} // namespace
......@@ -470,22 +472,21 @@ namespace {
class MockNestingObserver : public RunLoop::NestingObserver {
public:
MockNestingObserver() = default;
MockNestingObserver(const MockNestingObserver&) = delete;
MockNestingObserver& operator=(const MockNestingObserver&) = delete;
// RunLoop::NestingObserver:
MOCK_METHOD0(OnBeginNestedRunLoop, void());
MOCK_METHOD0(OnExitNestedRunLoop, void());
private:
DISALLOW_COPY_AND_ASSIGN(MockNestingObserver);
};
class MockTask {
public:
MockTask() = default;
MOCK_METHOD0(Task, void());
MockTask(const MockTask&) = delete;
MockTask& operator=(const MockTask&) = delete;
private:
DISALLOW_COPY_AND_ASSIGN(MockTask);
MOCK_METHOD0(Task, void());
};
} // namespace
......
......@@ -8,6 +8,8 @@
#include <errno.h>
#include "base/base_export.h"
// TODO(crbug.com/1010217) Remove once no #includers are getting base/macros.h
// by including this header.
#include "base/macros.h"
#include "build/build_config.h"
......@@ -23,12 +25,12 @@ namespace base {
class BASE_EXPORT ScopedClearLastErrorBase {
public:
ScopedClearLastErrorBase() : last_errno_(errno) { errno = 0; }
ScopedClearLastErrorBase(const ScopedClearLastErrorBase&) = delete;
ScopedClearLastErrorBase& operator=(const ScopedClearLastErrorBase&) = delete;
~ScopedClearLastErrorBase() { errno = last_errno_; }
private:
const int last_errno_;
DISALLOW_COPY_AND_ASSIGN(ScopedClearLastErrorBase);
};
#if defined(OS_WIN)
......@@ -37,12 +39,12 @@ class BASE_EXPORT ScopedClearLastErrorBase {
class BASE_EXPORT ScopedClearLastError : public ScopedClearLastErrorBase {
public:
ScopedClearLastError();
ScopedClearLastError(const ScopedClearLastError&) = delete;
ScopedClearLastError& operator=(const ScopedClearLastError&) = delete;
~ScopedClearLastError();
private:
const unsigned long last_system_error_;
DISALLOW_COPY_AND_ASSIGN(ScopedClearLastError);
};
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
......
......@@ -9,9 +9,11 @@
#include <ostream>
#include <algorithm>
#include <utility>
#include "base/check.h"
#include "base/compiler_specific.h"
// TODO(crbug.com/1010217) Remove once no #includers are getting base/macros.h
// by including this header.
#include "base/macros.h"
namespace base {
......@@ -119,6 +121,8 @@ class ScopedGeneric {
: data_(rvalue.release(), rvalue.get_traits()) {
TrackAcquire(data_.generic);
}
ScopedGeneric(const ScopedGeneric&) = delete;
ScopedGeneric& operator=(const ScopedGeneric&) = delete;
virtual ~ScopedGeneric() {
CHECK(!receiving_) << "ScopedGeneric destroyed with active receiver";
......@@ -215,15 +219,8 @@ class ScopedGeneric {
"Receiver";
scoped_generic_->receiving_ = true;
}
~Receiver() {
if (scoped_generic_) {
CHECK(scoped_generic_->receiving_);
scoped_generic_->reset(value_);
scoped_generic_->receiving_ = false;
}
}
Receiver(const Receiver&) = delete;
Receiver& operator=(const Receiver&) = delete;
Receiver(Receiver&& move) {
CHECK(!used_) << "moving into already-used Receiver";
CHECK(!move.used_) << "moving from already-used Receiver";
......@@ -237,7 +234,13 @@ class ScopedGeneric {
scoped_generic_ = move.scoped_generic_;
move.scoped_generic_ = nullptr;
}
~Receiver() {
if (scoped_generic_) {
CHECK(scoped_generic_->receiving_);
scoped_generic_->reset(value_);
scoped_generic_->receiving_ = false;
}
}
// We hand out a pointer to a field in Receiver instead of directly to
// ScopedGeneric's internal storage in order to make it so that users can't
// accidentally silently break ScopedGeneric's invariants. This way, an
......@@ -253,8 +256,6 @@ class ScopedGeneric {
T value_ = Traits::InvalidValue();
ScopedGeneric* scoped_generic_;
bool used_ = false;
DISALLOW_COPY_AND_ASSIGN(Receiver);
};
const element_type& get() const { return data_.generic; }
......@@ -324,8 +325,6 @@ class ScopedGeneric {
Data data_;
bool receiving_ = false;
DISALLOW_COPY_AND_ASSIGN(ScopedGeneric);
};
template<class T, class Traits>
......
......@@ -6,7 +6,6 @@
#define BASE_SCOPED_NATIVE_LIBRARY_H_
#include "base/base_export.h"
#include "base/macros.h"
#include "base/native_library.h"
#include "base/scoped_generic.h"
......@@ -33,8 +32,6 @@ class BASE_EXPORT ScopedNativeLibrary
// Initializes with a NULL library.
ScopedNativeLibrary();
~ScopedNativeLibrary() override;
// Takes ownership of the given library handle.
explicit ScopedNativeLibrary(NativeLibrary library);
......@@ -49,14 +46,17 @@ class BASE_EXPORT ScopedNativeLibrary
ScopedNativeLibrary& operator=(ScopedNativeLibrary&& scoped_library) =
default;
ScopedNativeLibrary(const ScopedNativeLibrary&) = delete;
ScopedNativeLibrary& operator=(const ScopedNativeLibrary&) = delete;
~ScopedNativeLibrary() override;
void* GetFunctionPointer(const char* function_name) const;
const NativeLibraryLoadError* GetError() const;
private:
NativeLibraryLoadError error_;
DISALLOW_COPY_AND_ASSIGN(ScopedNativeLibrary);
};
} // namespace base
......
......@@ -11,7 +11,6 @@
#include <vector>
#include "base/check.h"
#include "base/macros.h"
#include "base/stl_util.h"
// ScopedObserver is used to keep track of the set of sources an object has
......@@ -43,7 +42,8 @@ template <class Source,
class ScopedObserver {
public:
explicit ScopedObserver(Observer* observer) : observer_(observer) {}
ScopedObserver(const ScopedObserver&) = delete;
ScopedObserver& operator=(const ScopedObserver&) = delete;
~ScopedObserver() {
RemoveAll();
}
......@@ -80,8 +80,6 @@ class ScopedObserver {
Observer* observer_;
std::vector<Source*> sources_;
DISALLOW_COPY_AND_ASSIGN(ScopedObserver);
};
#endif // BASE_SCOPED_OBSERVER_H_
......@@ -6,7 +6,6 @@
#define BASE_SEQUENCE_CHECKER_H_
#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/sequence_checker_impl.h"
#include "base/strings/string_piece.h"
#include "build/build_config.h"
......@@ -100,12 +99,11 @@ class LOCKABLE SequenceCheckerDoNothing {
SequenceCheckerDoNothing(SequenceCheckerDoNothing&& other) = default;
SequenceCheckerDoNothing& operator=(SequenceCheckerDoNothing&& other) =
default;
SequenceCheckerDoNothing(const SequenceCheckerDoNothing&) = delete;
SequenceCheckerDoNothing& operator=(const SequenceCheckerDoNothing&) = delete;
bool CalledOnValidSequence() const WARN_UNUSED_RESULT { return true; }
void DetachFromSequence() {}
private:
DISALLOW_COPY_AND_ASSIGN(SequenceCheckerDoNothing);
};
#if DCHECK_IS_ON()
......
......@@ -4,6 +4,8 @@
#include "base/sequence_checker_impl.h"
#include <utility>
#include "base/check.h"
#include "base/memory/ptr_util.h"
#include "base/sequence_token.h"
......
......@@ -8,8 +8,6 @@
#include <memory>
#include "base/base_export.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/synchronization/lock.h"
#include "base/thread_annotations.h"
......@@ -26,7 +24,6 @@ namespace base {
class LOCKABLE BASE_EXPORT SequenceCheckerImpl {
public:
SequenceCheckerImpl();
~SequenceCheckerImpl();
// Allow move construct/assign. This must be called on |other|'s associated
// sequence and assignment can only be made into a SequenceCheckerImpl which
......@@ -36,6 +33,9 @@ class LOCKABLE BASE_EXPORT SequenceCheckerImpl {
// will be bound to the current sequence and |other| will be detached.
SequenceCheckerImpl(SequenceCheckerImpl&& other);
SequenceCheckerImpl& operator=(SequenceCheckerImpl&& other);
SequenceCheckerImpl(const SequenceCheckerImpl&) = delete;
SequenceCheckerImpl& operator=(const SequenceCheckerImpl&) = delete;
~SequenceCheckerImpl();
// Returns true if called in sequence with previous calls to this method and
// the constructor.
......@@ -54,8 +54,6 @@ class LOCKABLE BASE_EXPORT SequenceCheckerImpl {
mutable Lock lock_;
mutable std::unique_ptr<Core> core_ GUARDED_BY(lock_);
DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl);
};
} // namespace base
......
......@@ -8,11 +8,11 @@
#include <memory>
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/sequence_token.h"
#include "base/single_thread_task_runner.h"
#include "base/task/post_task.h"
......@@ -36,14 +36,14 @@ class RunCallbackThread : public SimpleThread {
Start();
Join();
}
RunCallbackThread(const RunCallbackThread&) = delete;
RunCallbackThread& operator=(const RunCallbackThread&) = delete;
private:
// SimpleThread:
void Run() override { std::move(callback_).Run(); }
OnceClosure callback_;
DISALLOW_COPY_AND_ASSIGN(RunCallbackThread);
};
void ExpectCalledOnValidSequence(SequenceCheckerImpl* sequence_checker) {
......@@ -259,12 +259,12 @@ TEST(SequenceCheckerMacroTest, Macros) {
class SequenceCheckerOwner {
public:
SequenceCheckerOwner() = default;
SequenceCheckerOwner(const SequenceCheckerOwner&) = delete;
SequenceCheckerOwner& operator=(const SequenceCheckerOwner&) = delete;
~SequenceCheckerOwner() { EXPECT_TRUE(checker_.CalledOnValidSequence()); }
private:
SequenceCheckerImpl checker_;
DISALLOW_COPY_AND_ASSIGN(SequenceCheckerOwner);
};
// Verifies SequenceCheckerImpl::CalledOnValidSequence() returns true if called
......
......@@ -6,7 +6,6 @@
#define BASE_SEQUENCE_TOKEN_H_
#include "base/base_export.h"
#include "base/macros.h"
namespace base {
......@@ -100,14 +99,17 @@ class BASE_EXPORT ScopedSetSequenceTokenForCurrentThread {
// TaskToken::GetForCurrentThread() will return a TaskToken which is not equal
// to any TaskToken returned in the scope of another
// ScopedSetSequenceTokenForCurrentThread.
ScopedSetSequenceTokenForCurrentThread(const SequenceToken& sequence_token);
explicit ScopedSetSequenceTokenForCurrentThread(
const SequenceToken& sequence_token);
ScopedSetSequenceTokenForCurrentThread(
const ScopedSetSequenceTokenForCurrentThread&) = delete;
ScopedSetSequenceTokenForCurrentThread& operator=(
const ScopedSetSequenceTokenForCurrentThread&) = delete;
~ScopedSetSequenceTokenForCurrentThread();
private:
const SequenceToken sequence_token_;
const TaskToken task_token_;
DISALLOW_COPY_AND_ASSIGN(ScopedSetSequenceTokenForCurrentThread);
};
} // namespace base
......
......@@ -23,6 +23,8 @@ class FlagOnDelete {
scoped_refptr<SequencedTaskRunner> expected_deletion_sequence)
: deleted_(deleted),
expected_deletion_sequence_(std::move(expected_deletion_sequence)) {}
FlagOnDelete(const FlagOnDelete&) = delete;
FlagOnDelete& operator=(const FlagOnDelete&) = delete;
private:
friend class DeleteHelper<FlagOnDelete>;
......@@ -38,11 +40,13 @@ class FlagOnDelete {
bool* deleted_;
const scoped_refptr<SequencedTaskRunner> expected_deletion_sequence_;
DISALLOW_COPY_AND_ASSIGN(FlagOnDelete);
};
class SequencedTaskRunnerTest : public testing::Test {
public:
SequencedTaskRunnerTest(const SequencedTaskRunnerTest&) = delete;
SequencedTaskRunnerTest& operator=(const SequencedTaskRunnerTest&) = delete;
protected:
SequencedTaskRunnerTest() : foreign_thread_("foreign") {}
......@@ -57,8 +61,6 @@ class SequencedTaskRunnerTest : public testing::Test {
private:
test::TaskEnvironment task_environment_;
DISALLOW_COPY_AND_ASSIGN(SequencedTaskRunnerTest);
};
using SequenceBoundUniquePtr =
......
......@@ -9,7 +9,6 @@
#include <memory>
#include "base/base_export.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/sequence_checker.h"
......@@ -22,6 +21,8 @@ class BASE_EXPORT SupportsUserData {
SupportsUserData();
SupportsUserData(SupportsUserData&&);
SupportsUserData& operator=(SupportsUserData&&);
SupportsUserData(const SupportsUserData&) = delete;
SupportsUserData& operator=(const SupportsUserData&) = delete;
// Derive from this class and add your own data members to associate extra
// information with this object. Alternatively, add this as a public base
......@@ -67,8 +68,6 @@ class BASE_EXPORT SupportsUserData {
DataMap user_data_;
// Guards usage of |user_data_|
SequenceChecker sequence_checker_;
DISALLOW_COPY_AND_ASSIGN(SupportsUserData);
};
// Adapter class that releases a refcounted object when the
......@@ -83,14 +82,14 @@ class UserDataAdapter : public SupportsUserData::Data {
}
explicit UserDataAdapter(T* object) : object_(object) {}
UserDataAdapter(const UserDataAdapter&) = delete;
UserDataAdapter& operator=(const UserDataAdapter&) = delete;
~UserDataAdapter() override = default;
T* release() { return object_.release(); }
private:
scoped_refptr<T> const object_;
DISALLOW_COPY_AND_ASSIGN(UserDataAdapter);
};
} // namespace base
......
......@@ -12,9 +12,7 @@
#include <stddef.h>
#include "base/base_export.h"
#include "base/compiler_specific.h"
#include "base/files/platform_file.h"
#include "base/macros.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
#include "build/build_config.h"
......@@ -41,6 +39,8 @@ class BASE_EXPORT SyncSocket {
// Creates a SyncSocket from a Handle.
explicit SyncSocket(Handle handle);
explicit SyncSocket(ScopedHandle handle);
SyncSocket(const SyncSocket&) = delete;
SyncSocket& operator=(const SyncSocket&) = delete;
virtual ~SyncSocket();
// Initializes and connects a pair of sockets.
......@@ -89,9 +89,6 @@ class BASE_EXPORT SyncSocket {
protected:
ScopedHandle handle_;
private:
DISALLOW_COPY_AND_ASSIGN(SyncSocket);
};
// Derives from SyncSocket and adds support for shutting down the socket from
......@@ -102,6 +99,8 @@ class BASE_EXPORT CancelableSyncSocket : public SyncSocket {
CancelableSyncSocket();
explicit CancelableSyncSocket(Handle handle);
explicit CancelableSyncSocket(ScopedHandle handle);
CancelableSyncSocket(const CancelableSyncSocket&) = delete;
CancelableSyncSocket& operator=(const CancelableSyncSocket&) = delete;
~CancelableSyncSocket() override = default;
// Initializes a pair of cancelable sockets. See documentation for
......@@ -139,7 +138,6 @@ class BASE_EXPORT CancelableSyncSocket : public SyncSocket {
WaitableEvent shutdown_event_;
WaitableEvent file_operation_;
#endif
DISALLOW_COPY_AND_ASSIGN(CancelableSyncSocket);
};
} // namespace base
......
......@@ -4,7 +4,6 @@
#include "base/sync_socket.h"
#include "base/macros.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
#include "base/threading/simple_thread.h"
......@@ -30,6 +29,8 @@ class HangingReceiveThread : public DelegateSimpleThread::Delegate {
thread_.Start();
}
HangingReceiveThread(const HangingReceiveThread&) = delete;
HangingReceiveThread& operator=(const HangingReceiveThread&) = delete;
~HangingReceiveThread() override = default;
void Run() override {
......@@ -61,8 +62,6 @@ class HangingReceiveThread : public DelegateSimpleThread::Delegate {
bool with_timeout_;
WaitableEvent started_event_;
WaitableEvent done_event_;
DISALLOW_COPY_AND_ASSIGN(HangingReceiveThread);
};
// Tests sending data between two SyncSockets. Uses ASSERT() and thus will exit
......
......@@ -38,15 +38,14 @@ void BASE_EXPORT ResetEventSourceForTesting();
class BASE_EXPORT EventLogMessage {
public:
EventLogMessage(const char* file, int line, LogSeverity severity);
EventLogMessage(const EventLogMessage&) = delete;
EventLogMessage& operator=(const EventLogMessage&) = delete;
~EventLogMessage();
std::ostream& stream() { return log_message_.stream(); }
private:
LogMessage log_message_;
DISALLOW_COPY_AND_ASSIGN(EventLogMessage);
};
} // namespace logging
......
......@@ -13,6 +13,9 @@ namespace base {
// A SequencedTaskRunner whose posted tasks' priorities can be updated.
class BASE_EXPORT UpdateableSequencedTaskRunner : public SequencedTaskRunner {
public:
UpdateableSequencedTaskRunner(const UpdateableSequencedTaskRunner&) = delete;
UpdateableSequencedTaskRunner& operator=(
const UpdateableSequencedTaskRunner&) = delete;
// Updates the priority for tasks posted through this TaskRunner to
// |priority|.
virtual void UpdatePriority(TaskPriority priority) = 0;
......@@ -20,8 +23,6 @@ class BASE_EXPORT UpdateableSequencedTaskRunner : public SequencedTaskRunner {
protected:
UpdateableSequencedTaskRunner() = default;
~UpdateableSequencedTaskRunner() override = default;
DISALLOW_COPY_AND_ASSIGN(UpdateableSequencedTaskRunner);
};
} // namespace base
......
......@@ -36,7 +36,6 @@
#include "base/containers/checked_range.h"
#include "base/containers/flat_map.h"
#include "base/containers/span.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
#include "base/value_iterators.h"
......@@ -151,6 +150,8 @@ class BASE_EXPORT Value {
explicit Value(ListStorage&& in_list) noexcept;
Value& operator=(Value&& that) noexcept;
Value(const Value&) = delete;
Value& operator=(const Value&) = delete;
~Value();
......@@ -571,8 +572,6 @@ class BASE_EXPORT Value {
DictStorage,
ListStorage>
data_;
DISALLOW_COPY_AND_ASSIGN(Value);
};
// DictionaryValue provides a key-value dictionary with (optional) "path"
......
......@@ -9,7 +9,6 @@
#include <vector>
#include "base/base_export.h"
#include "base/macros.h"
#include "base/strings/string_piece.h"
namespace logging {
......@@ -40,6 +39,8 @@ class BASE_EXPORT VlogInfo {
VlogInfo(const std::string& v_switch,
const std::string& vmodule_switch,
int* min_log_level);
VlogInfo(const VlogInfo&) = delete;
VlogInfo& operator=(const VlogInfo&) = delete;
~VlogInfo();
// Returns the vlog level for a given file (usually taken from
......@@ -55,8 +56,6 @@ class BASE_EXPORT VlogInfo {
struct VmodulePattern;
std::vector<VmodulePattern> vmodule_levels_;
int* min_log_level_;
DISALLOW_COPY_AND_ASSIGN(VlogInfo);
};
// Returns true if the string passed in matches the vlog pattern. The
......
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