refactor: replace deprecated DISALLOW_COPY_AND_ASSIGN (#31633)

This commit is contained in:
Milan Burda 2021-11-03 12:41:45 +01:00 committed by GitHub
parent 2a2a1a834c
commit 65a980c673
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
231 changed files with 918 additions and 576 deletions

View file

@ -42,6 +42,10 @@ class Archive : public gin::Wrappable<Archive> {
const char* GetTypeName() override { return "Archive"; }
// disable copy
Archive(const Archive&) = delete;
Archive& operator=(const Archive&) = delete;
protected:
Archive(v8::Isolate* isolate, std::unique_ptr<asar::Archive> archive)
: archive_(std::move(archive)) {}
@ -123,8 +127,6 @@ class Archive : public gin::Wrappable<Archive> {
private:
std::unique_ptr<asar::Archive> archive_;
DISALLOW_COPY_AND_ASSIGN(Archive);
};
// static

View file

@ -23,6 +23,10 @@ namespace api {
class Clipboard {
public:
// disable copy
Clipboard(const Clipboard&) = delete;
Clipboard& operator=(const Clipboard&) = delete;
static ui::ClipboardBuffer GetClipboardBuffer(gin_helper::Arguments* args);
static std::vector<std::u16string> AvailableFormats(
gin_helper::Arguments* args);
@ -61,9 +65,6 @@ class Clipboard {
static void WriteBuffer(const std::string& format_string,
const v8::Local<v8::Value> buffer,
gin_helper::Arguments* args);
private:
DISALLOW_COPY_AND_ASSIGN(Clipboard);
};
} // namespace api

View file

@ -32,6 +32,10 @@ class KeyWeakMap : public gin_helper::Wrappable<KeyWeakMap<K>> {
.SetMethod("remove", &KeyWeakMap<K>::Remove);
}
// disable copy
KeyWeakMap(const KeyWeakMap&) = delete;
KeyWeakMap& operator=(const KeyWeakMap&) = delete;
protected:
explicit KeyWeakMap(v8::Isolate* isolate) {
gin_helper::Wrappable<KeyWeakMap<K>>::Init(isolate);
@ -53,8 +57,6 @@ class KeyWeakMap : public gin_helper::Wrappable<KeyWeakMap<K>> {
void Remove(const K& key) { key_weak_map_.Remove(key); }
electron::KeyWeakMap<K> key_weak_map_;
DISALLOW_COPY_AND_ASSIGN(KeyWeakMap);
};
} // namespace api

View file

@ -51,6 +51,10 @@ class NativeImage : public gin::Wrappable<NativeImage> {
#endif
~NativeImage() override;
// disable copy
NativeImage(const NativeImage&) = delete;
NativeImage& operator=(const NativeImage&) = delete;
static gin::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate);
static gin::Handle<NativeImage> Create(v8::Isolate* isolate,
const gfx::Image& image);
@ -132,8 +136,6 @@ class NativeImage : public gin::Wrappable<NativeImage> {
gfx::Image image_;
v8::Isolate* isolate_;
DISALLOW_COPY_AND_ASSIGN(NativeImage);
};
} // namespace api

View file

@ -9,7 +9,6 @@
#include <memory>
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/process/process_metrics.h"
#include "shell/common/gin_helper/promise.h"
@ -36,6 +35,10 @@ class ElectronBindings {
explicit ElectronBindings(uv_loop_t* loop);
virtual ~ElectronBindings();
// disable copy
ElectronBindings(const ElectronBindings&) = delete;
ElectronBindings& operator=(const ElectronBindings&) = delete;
// Add process._linkedBinding function, which behaves like process.binding
// but load native code from Electron instead.
void BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process);
@ -77,8 +80,6 @@ class ElectronBindings {
UvHandle<uv_async_t> call_next_tick_async_;
std::list<node::Environment*> pending_next_ticks_;
std::unique_ptr<base::ProcessMetrics> metrics_;
DISALLOW_COPY_AND_ASSIGN(ElectronBindings);
};
} // namespace electron

View file

@ -5,7 +5,6 @@
#ifndef SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_
#define SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "v8/include/v8.h"
@ -16,6 +15,10 @@ class ObjectLifeMonitor {
ObjectLifeMonitor(v8::Isolate* isolate, v8::Local<v8::Object> target);
virtual ~ObjectLifeMonitor();
// disable copy
ObjectLifeMonitor(const ObjectLifeMonitor&) = delete;
ObjectLifeMonitor& operator=(const ObjectLifeMonitor&) = delete;
virtual void RunDestructor() = 0;
private:
@ -25,8 +28,6 @@ class ObjectLifeMonitor {
v8::Global<v8::Object> target_;
base::WeakPtrFactory<ObjectLifeMonitor> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ObjectLifeMonitor);
};
} // namespace electron

View file

@ -12,7 +12,6 @@
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/synchronization/lock.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
@ -63,6 +62,10 @@ class Archive {
explicit Archive(const base::FilePath& path);
virtual ~Archive();
// disable copy
Archive(const Archive&) = delete;
Archive& operator=(const Archive&) = delete;
// Read and parse the header.
bool Init();
@ -108,8 +111,6 @@ class Archive {
std::unordered_map<base::FilePath::StringType,
std::unique_ptr<ScopedTemporaryFile>>
external_files_;
DISALLOW_COPY_AND_ASSIGN(Archive);
};
} // namespace asar

View file

@ -6,7 +6,6 @@
#define SHELL_COMMON_ELECTRON_COMMAND_LINE_H_
#include "base/command_line.h"
#include "base/macros.h"
#include "build/build_config.h"
namespace electron {
@ -14,6 +13,10 @@ namespace electron {
// Singleton to remember the original "argc" and "argv".
class ElectronCommandLine {
public:
// disable copy
ElectronCommandLine(const ElectronCommandLine&) = delete;
ElectronCommandLine& operator=(const ElectronCommandLine&) = delete;
static const base::CommandLine::StringVector& argv() { return argv_; }
static void Init(int argc, base::CommandLine::CharType** argv);
@ -26,8 +29,6 @@ class ElectronCommandLine {
private:
static base::CommandLine::StringVector argv_;
DISALLOW_IMPLICIT_CONSTRUCTORS(ElectronCommandLine);
};
} // namespace electron

View file

@ -7,7 +7,6 @@
#include <string>
#include "base/macros.h"
#include "extensions/common/extensions_api_provider.h"
namespace electron {
@ -17,6 +16,11 @@ class ElectronExtensionsAPIProvider : public extensions::ExtensionsAPIProvider {
ElectronExtensionsAPIProvider();
~ElectronExtensionsAPIProvider() override;
// disable copy
ElectronExtensionsAPIProvider(const ElectronExtensionsAPIProvider&) = delete;
ElectronExtensionsAPIProvider& operator=(
const ElectronExtensionsAPIProvider&) = delete;
// ExtensionsAPIProvider:
void AddAPIFeatures(extensions::FeatureProvider* provider) override;
void AddManifestFeatures(extensions::FeatureProvider* provider) override;
@ -29,9 +33,6 @@ class ElectronExtensionsAPIProvider : public extensions::ExtensionsAPIProvider {
void RegisterPermissions(
extensions::PermissionsInfo* permissions_info) override;
void RegisterManifestHandlers() override;
private:
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionsAPIProvider);
};
} // namespace electron

View file

@ -9,7 +9,6 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
#include "components/version_info/version_info.h"
#include "content/public/common/user_agent.h"
#include "extensions/common/core_extensions_api_provider.h"
@ -33,6 +32,12 @@ class ElectronPermissionMessageProvider
ElectronPermissionMessageProvider() = default;
~ElectronPermissionMessageProvider() override = default;
// disable copy
ElectronPermissionMessageProvider(const ElectronPermissionMessageProvider&) =
delete;
ElectronPermissionMessageProvider& operator=(
const ElectronPermissionMessageProvider&) = delete;
// PermissionMessageProvider implementation.
extensions::PermissionMessages GetPermissionMessages(
const extensions::PermissionIDSet& permissions) const override {
@ -53,9 +58,6 @@ class ElectronPermissionMessageProvider
extensions::Manifest::Type extension_type) const override {
return extensions::PermissionIDSet();
}
private:
DISALLOW_COPY_AND_ASSIGN(ElectronPermissionMessageProvider);
};
base::LazyInstance<ElectronPermissionMessageProvider>::DestructorAtExit

View file

@ -8,7 +8,6 @@
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "extensions/common/extensions_client.h"
#include "url/gurl.h"
@ -30,6 +29,10 @@ class ElectronExtensionsClient : public extensions::ExtensionsClient {
ElectronExtensionsClient();
~ElectronExtensionsClient() override;
// disable copy
ElectronExtensionsClient(const ElectronExtensionsClient&) = delete;
ElectronExtensionsClient& operator=(const ElectronExtensionsClient&) = delete;
// ExtensionsClient overrides:
void Initialize() override;
void InitializeWebStoreUrls(base::CommandLine* command_line) override;
@ -55,8 +58,6 @@ class ElectronExtensionsClient : public extensions::ExtensionsClient {
const GURL webstore_base_url_;
const GURL webstore_update_url_;
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionsClient);
};
} // namespace electron

View file

@ -96,8 +96,6 @@ class RefCountedGlobal
private:
v8::Global<T> handle_;
DISALLOW_COPY_AND_ASSIGN(RefCountedGlobal);
};
SafeV8Function::SafeV8Function(v8::Isolate* isolate, v8::Local<v8::Value> value)

View file

@ -71,6 +71,10 @@ class EventEmitter : public gin_helper::Wrappable<T> {
return EmitWithEvent(name, event, std::forward<Args>(args)...);
}
// disable copy
EventEmitter(const EventEmitter&) = delete;
EventEmitter& operator=(const EventEmitter&) = delete;
protected:
EventEmitter() {}
@ -93,8 +97,6 @@ class EventEmitter : public gin_helper::Wrappable<T> {
}
return false;
}
DISALLOW_COPY_AND_ASSIGN(EventEmitter);
};
} // namespace gin_helper

View file

@ -52,6 +52,10 @@ class CallbackHolderBase {
public:
v8::Local<v8::External> GetHandle(v8::Isolate* isolate);
// disable copy
CallbackHolderBase(const CallbackHolderBase&) = delete;
CallbackHolderBase& operator=(const CallbackHolderBase&) = delete;
protected:
explicit CallbackHolderBase(v8::Isolate* isolate);
virtual ~CallbackHolderBase();
@ -63,8 +67,6 @@ class CallbackHolderBase {
const v8::WeakCallbackInfo<CallbackHolderBase>& data);
v8::Global<v8::External> v8_ref_;
DISALLOW_COPY_AND_ASSIGN(CallbackHolderBase);
};
template <typename Sig>
@ -79,8 +81,6 @@ class CallbackHolder : public CallbackHolderBase {
private:
virtual ~CallbackHolder() = default;
DISALLOW_COPY_AND_ASSIGN(CallbackHolder);
};
template <typename T>

View file

@ -7,7 +7,6 @@
#include <memory>
#include "base/macros.h"
#include "v8/include/v8.h"
namespace gin_helper {
@ -18,6 +17,10 @@ class Locker {
explicit Locker(v8::Isolate* isolate);
~Locker();
// disable copy
Locker(const Locker&) = delete;
Locker& operator=(const Locker&) = delete;
// Returns whether current process is browser process, currently we detect it
// by checking whether current has used V8 Lock, but it might be a bad idea.
static inline bool IsBrowserProcess() { return v8::Locker::IsActive(); }
@ -27,8 +30,6 @@ class Locker {
void operator delete(void*, size_t);
std::unique_ptr<v8::Locker> locker_;
DISALLOW_COPY_AND_ASSIGN(Locker);
};
} // namespace gin_helper

View file

@ -7,7 +7,6 @@
#include <memory>
#include "base/macros.h"
#include "v8/include/v8.h"
namespace gin_helper {
@ -22,10 +21,12 @@ class MicrotasksScope {
v8::MicrotasksScope::kRunMicrotasks);
~MicrotasksScope();
// disable copy
MicrotasksScope(const MicrotasksScope&) = delete;
MicrotasksScope& operator=(const MicrotasksScope&) = delete;
private:
std::unique_ptr<v8::MicrotasksScope> v8_microtasks_scope_;
DISALLOW_COPY_AND_ASSIGN(MicrotasksScope);
};
} // namespace gin_helper

View file

@ -33,6 +33,10 @@ class PromiseBase {
PromiseBase(v8::Isolate* isolate, v8::Local<v8::Promise::Resolver> handle);
~PromiseBase();
// disable copy
PromiseBase(const PromiseBase&) = delete;
PromiseBase& operator=(const PromiseBase&) = delete;
// Support moving.
PromiseBase(PromiseBase&&);
PromiseBase& operator=(PromiseBase&&);
@ -75,8 +79,6 @@ class PromiseBase {
v8::Isolate* isolate_;
v8::Global<v8::Context> context_;
v8::Global<v8::Promise::Resolver> resolver_;
DISALLOW_COPY_AND_ASSIGN(PromiseBase);
};
// Template implementation that returns values.

View file

@ -25,8 +25,6 @@ class IDUserData : public base::SupportsUserData::Data {
private:
int32_t id_;
DISALLOW_COPY_AND_ASSIGN(IDUserData);
};
} // namespace

View file

@ -24,6 +24,10 @@ class TrackableObjectBase : public CleanedUpAtExit {
public:
TrackableObjectBase();
// disable copy
TrackableObjectBase(const TrackableObjectBase&) = delete;
TrackableObjectBase& operator=(const TrackableObjectBase&) = delete;
// The ID in weak map.
int32_t weak_map_id() const { return weak_map_id_; }
@ -45,8 +49,6 @@ class TrackableObjectBase : public CleanedUpAtExit {
void Destroy();
base::WeakPtrFactory<TrackableObjectBase> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(TrackableObjectBase);
};
// All instances of TrackableObject will be kept in a weak map and can be got
@ -125,8 +127,6 @@ class TrackableObject : public TrackableObjectBase, public EventEmitter<T> {
private:
static int32_t next_id_;
static electron::KeyWeakMap<int32_t>* weak_map_; // leaked on purpose
DISALLOW_COPY_AND_ASSIGN(TrackableObject);
};
template <typename T>

View file

@ -67,8 +67,6 @@ class Wrappable : public WrappableBase {
private:
static gin::WrapperInfo kWrapperInfo;
DISALLOW_COPY_AND_ASSIGN(Wrappable);
};
// static

View file

@ -9,7 +9,6 @@
#include <utility>
#include <vector>
#include "base/macros.h"
#include "v8/include/v8.h"
namespace electron {
@ -30,6 +29,10 @@ class KeyWeakMap {
p.second.second.ClearWeak();
}
// disable copy
KeyWeakMap(const KeyWeakMap&) = delete;
KeyWeakMap& operator=(const KeyWeakMap&) = delete;
// Sets the object to WeakMap with the given |key|.
void Set(v8::Isolate* isolate, const K& key, v8::Local<v8::Object> object) {
KeyObject key_object = {key, this};
@ -78,8 +81,6 @@ class KeyWeakMap {
// Map of stored objects.
std::unordered_map<K, std::pair<KeyObject, v8::Global<v8::Object>>> map_;
DISALLOW_COPY_AND_ASSIGN(KeyWeakMap);
};
} // namespace electron

View file

@ -8,7 +8,6 @@
#include <type_traits>
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "uv.h" // NOLINT(build/include_directory)
#include "v8/include/v8.h"
@ -109,6 +108,10 @@ class NodeBindings {
bool in_worker_loop() const { return uv_loop_ == &worker_loop_; }
// disable copy
NodeBindings(const NodeBindings&) = delete;
NodeBindings& operator=(const NodeBindings&) = delete;
protected:
explicit NodeBindings(BrowserEnvironment browser_env);
@ -163,8 +166,6 @@ class NodeBindings {
#endif
base::WeakPtrFactory<NodeBindings> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NodeBindings);
};
} // namespace electron

View file

@ -25,8 +25,6 @@ class NodeBindingsLinux : public NodeBindings {
// Epoll to poll for uv's backend fd.
int epoll_;
DISALLOW_COPY_AND_ASSIGN(NodeBindingsLinux);
};
} // namespace electron

View file

@ -22,8 +22,6 @@ class NodeBindingsMac : public NodeBindings {
static void OnWatcherQueueChanged(uv_loop_t* loop);
void PollEvents() override;
DISALLOW_COPY_AND_ASSIGN(NodeBindingsMac);
};
} // namespace electron

View file

@ -17,8 +17,6 @@ class NodeBindingsWin : public NodeBindings {
private:
void PollEvents() override;
DISALLOW_COPY_AND_ASSIGN(NodeBindingsWin);
};
} // namespace electron

View file

@ -112,6 +112,10 @@ class V8ValueConverter::ScopedUniquenessGuard {
}
}
// disable copy
ScopedUniquenessGuard(const ScopedUniquenessGuard&) = delete;
ScopedUniquenessGuard& operator=(const ScopedUniquenessGuard&) = delete;
bool is_valid() const { return is_valid_; }
private:
@ -119,8 +123,6 @@ class V8ValueConverter::ScopedUniquenessGuard {
V8ValueConverter::FromV8ValueState* state_;
v8::Local<v8::Object> value_;
bool is_valid_;
DISALLOW_COPY_AND_ASSIGN(ScopedUniquenessGuard);
};
V8ValueConverter::V8ValueConverter() = default;

View file

@ -8,7 +8,6 @@
#include <memory>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "v8/include/v8.h"
namespace base {
@ -23,6 +22,10 @@ class V8ValueConverter {
public:
V8ValueConverter();
// disable copy
V8ValueConverter(const V8ValueConverter&) = delete;
V8ValueConverter& operator=(const V8ValueConverter&) = delete;
void SetRegExpAllowed(bool val);
void SetFunctionAllowed(bool val);
void SetStripNullFromObjects(bool val);
@ -68,8 +71,6 @@ class V8ValueConverter {
// If true, undefined and null values are ignored when converting v8 objects
// into Values.
bool strip_null_from_objects_ = false;
DISALLOW_COPY_AND_ASSIGN(V8ValueConverter);
};
} // namespace electron