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

@ -79,6 +79,10 @@ class App : public ElectronBrowserClient::Delegate,
App();
// disable copy
App(const App&) = delete;
App& operator=(const App&) = delete;
private:
~App() override;
@ -261,8 +265,6 @@ class App : public ElectronBrowserClient::Delegate,
bool disable_hw_acceleration_ = false;
bool disable_domain_blocking_for_3DAPIs_ = false;
DISALLOW_COPY_AND_ASSIGN(App);
};
} // namespace api

View file

@ -30,6 +30,10 @@ class AutoUpdater : public gin::Wrappable<AutoUpdater>,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
AutoUpdater(const AutoUpdater&) = delete;
AutoUpdater& operator=(const AutoUpdater&) = delete;
protected:
AutoUpdater();
~AutoUpdater() override;
@ -54,8 +58,6 @@ class AutoUpdater : public gin::Wrappable<AutoUpdater>,
std::string GetFeedURL();
void SetFeedURL(gin::Arguments* args);
void QuitAndInstall();
DISALLOW_COPY_AND_ASSIGN(AutoUpdater);
};
} // namespace api

View file

@ -54,6 +54,10 @@ class BrowserView : public gin::Wrappable<BrowserView>,
int32_t ID() const { return id_; }
// disable copy
BrowserView(const BrowserView&) = delete;
BrowserView& operator=(const BrowserView&) = delete;
protected:
BrowserView(gin::Arguments* args, const gin_helper::Dictionary& options);
~BrowserView() override;
@ -78,8 +82,6 @@ class BrowserView : public gin::Wrappable<BrowserView>,
std::unique_ptr<NativeBrowserView> view_;
int32_t id_;
DISALLOW_COPY_AND_ASSIGN(BrowserView);
};
} // namespace api

View file

@ -37,6 +37,10 @@ class BrowserWindow : public BaseWindow,
return weak_factory_.GetWeakPtr();
}
// disable copy
BrowserWindow(const BrowserWindow&) = delete;
BrowserWindow& operator=(const BrowserWindow&) = delete;
protected:
BrowserWindow(gin::Arguments* args, const gin_helper::Dictionary& options);
~BrowserWindow() override;
@ -123,8 +127,6 @@ class BrowserWindow : public BaseWindow,
base::WeakPtr<api::WebContents> api_web_contents_;
base::WeakPtrFactory<BrowserWindow> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(BrowserWindow);
};
} // namespace api

View file

@ -41,6 +41,10 @@ class Cookies : public gin::Wrappable<Cookies>,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
Cookies(const Cookies&) = delete;
Cookies& operator=(const Cookies&) = delete;
protected:
Cookies(v8::Isolate* isolate, ElectronBrowserContext* browser_context);
~Cookies() override;
@ -62,8 +66,6 @@ class Cookies : public gin::Wrappable<Cookies>,
// Weak reference; ElectronBrowserContext is guaranteed to outlive us.
ElectronBrowserContext* browser_context_;
DISALLOW_COPY_AND_ASSIGN(Cookies);
};
} // namespace api

View file

@ -57,6 +57,10 @@ class DataPipeReader {
~DataPipeReader() = default;
// disable copy
DataPipeReader(const DataPipeReader&) = delete;
DataPipeReader& operator=(const DataPipeReader&) = delete;
private:
// Callback invoked by DataPipeGetter::Read.
void ReadCallback(int32_t status, uint64_t size) {
@ -137,8 +141,6 @@ class DataPipeReader {
uint64_t remaining_size_ = 0;
base::WeakPtrFactory<DataPipeReader> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DataPipeReader);
};
} // namespace

View file

@ -37,14 +37,16 @@ class DataPipeHolder : public gin::Wrappable<DataPipeHolder> {
// The unique ID that can be used to receive the object.
const std::string& id() const { return id_; }
// disable copy
DataPipeHolder(const DataPipeHolder&) = delete;
DataPipeHolder& operator=(const DataPipeHolder&) = delete;
private:
explicit DataPipeHolder(const network::DataElement& element);
~DataPipeHolder() override;
std::string id_;
mojo::Remote<network::mojom::DataPipeGetter> data_pipe_;
DISALLOW_COPY_AND_ASSIGN(DataPipeHolder);
};
} // namespace api

View file

@ -40,6 +40,10 @@ class Debugger : public gin::Wrappable<Debugger>,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
Debugger(const Debugger&) = delete;
Debugger& operator=(const Debugger&) = delete;
protected:
Debugger(v8::Isolate* isolate, content::WebContents* web_contents);
~Debugger() override;
@ -68,8 +72,6 @@ class Debugger : public gin::Wrappable<Debugger>,
PendingRequestMap pending_requests_;
int previous_request_id_ = 0;
DISALLOW_COPY_AND_ASSIGN(Debugger);
};
} // namespace api

View file

@ -45,6 +45,10 @@ class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
DesktopCapturer(const DesktopCapturer&) = delete;
DesktopCapturer& operator=(const DesktopCapturer&) = delete;
protected:
explicit DesktopCapturer(v8::Isolate* isolate);
~DesktopCapturer() override;
@ -71,8 +75,6 @@ class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
#endif // defined(OS_WIN)
base::WeakPtrFactory<DesktopCapturer> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DesktopCapturer);
};
} // namespace api

View file

@ -43,6 +43,10 @@ class DownloadItem : public gin::Wrappable<DownloadItem>,
base::FilePath GetSavePath() const;
file_dialog::DialogSettings GetSaveDialogOptions() const;
// disable copy
DownloadItem(const DownloadItem&) = delete;
DownloadItem& operator=(const DownloadItem&) = delete;
private:
DownloadItem(v8::Isolate* isolate, download::DownloadItem* item);
~DownloadItem() override;
@ -81,8 +85,6 @@ class DownloadItem : public gin::Wrappable<DownloadItem>,
v8::Isolate* isolate_;
base::WeakPtrFactory<DownloadItem> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DownloadItem);
};
} // namespace api

View file

@ -29,6 +29,10 @@ class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
GlobalShortcut(const GlobalShortcut&) = delete;
GlobalShortcut& operator=(const GlobalShortcut&) = delete;
protected:
explicit GlobalShortcut(v8::Isolate* isolate);
~GlobalShortcut() override;
@ -50,8 +54,6 @@ class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
void OnKeyPressed(const ui::Accelerator& accelerator) override;
AcceleratorCallbackMap accelerator_callback_map_;
DISALLOW_COPY_AND_ASSIGN(GlobalShortcut);
};
} // namespace api

View file

@ -32,6 +32,10 @@ class InAppPurchase : public gin::Wrappable<InAppPurchase>,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
InAppPurchase(const InAppPurchase&) = delete;
InAppPurchase& operator=(const InAppPurchase&) = delete;
protected:
InAppPurchase();
~InAppPurchase() override;
@ -45,9 +49,6 @@ class InAppPurchase : public gin::Wrappable<InAppPurchase>,
// TransactionObserver:
void OnTransactionsUpdated(
const std::vector<in_app_purchase::Transaction>& transactions) override;
private:
DISALLOW_COPY_AND_ASSIGN(InAppPurchase);
};
} // namespace api

View file

@ -46,6 +46,10 @@ class Menu : public gin::Wrappable<Menu>,
ElectronMenuModel* model() const { return model_.get(); }
// disable copy
Menu(const Menu&) = delete;
Menu& operator=(const Menu&) = delete;
protected:
explicit Menu(gin::Arguments* args);
~Menu() override;
@ -117,8 +121,6 @@ class Menu : public gin::Wrappable<Menu>,
bool IsEnabledAt(int index) const;
bool IsVisibleAt(int index) const;
bool WorksWhenHiddenAt(int index) const;
DISALLOW_COPY_AND_ASSIGN(Menu);
};
} // namespace api

View file

@ -48,8 +48,6 @@ class MenuMac : public Menu {
std::map<int32_t, scoped_nsobject<ElectronMenuController>> popup_controllers_;
base::WeakPtrFactory<MenuMac> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(MenuMac);
};
} // namespace api

View file

@ -37,8 +37,6 @@ class MenuViews : public Menu {
std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
base::WeakPtrFactory<MenuViews> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(MenuViews);
};
} // namespace api

View file

@ -27,6 +27,10 @@ class NativeTheme : public gin::Wrappable<NativeTheme>,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
NativeTheme(const NativeTheme&) = delete;
NativeTheme& operator=(const NativeTheme&) = delete;
protected:
NativeTheme(v8::Isolate* isolate,
ui::NativeTheme* ui_theme,
@ -50,8 +54,6 @@ class NativeTheme : public gin::Wrappable<NativeTheme>,
private:
ui::NativeTheme* ui_theme_;
ui::NativeTheme* web_theme_;
DISALLOW_COPY_AND_ASSIGN(NativeTheme);
};
} // namespace api

View file

@ -7,7 +7,6 @@
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "gin/handle.h"
@ -45,6 +44,10 @@ class NetLog : public gin::Wrappable<NetLog> {
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
NetLog(const NetLog&) = delete;
NetLog& operator=(const NetLog&) = delete;
protected:
explicit NetLog(v8::Isolate* isolate,
ElectronBrowserContext* browser_context);
@ -68,8 +71,6 @@ class NetLog : public gin::Wrappable<NetLog> {
scoped_refptr<base::TaskRunner> file_task_runner_;
base::WeakPtrFactory<NetLog> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NetLog);
};
} // namespace api

View file

@ -56,6 +56,10 @@ class Notification : public gin::Wrappable<Notification>,
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
// disable copy
Notification(const Notification&) = delete;
Notification& operator=(const Notification&) = delete;
protected:
explicit Notification(gin::Arguments* args);
~Notification() override;
@ -111,8 +115,6 @@ class Notification : public gin::Wrappable<Notification>,
electron::NotificationPresenter* presenter_;
base::WeakPtr<electron::Notification> notification_;
DISALLOW_COPY_AND_ASSIGN(Notification);
};
} // namespace api

View file

@ -33,6 +33,10 @@ class PowerMonitor : public gin::Wrappable<PowerMonitor>,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
PowerMonitor(const PowerMonitor&) = delete;
PowerMonitor& operator=(const PowerMonitor&) = delete;
private:
explicit PowerMonitor(v8::Isolate* isolate);
~PowerMonitor() override;
@ -80,8 +84,6 @@ class PowerMonitor : public gin::Wrappable<PowerMonitor>,
#if defined(OS_LINUX)
PowerObserverLinux power_observer_linux_{this};
#endif
DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
};
} // namespace api

View file

@ -27,6 +27,10 @@ class PowerSaveBlocker : public gin::Wrappable<PowerSaveBlocker> {
static gin::WrapperInfo kWrapperInfo;
// disable copy
PowerSaveBlocker(const PowerSaveBlocker&) = delete;
PowerSaveBlocker& operator=(const PowerSaveBlocker&) = delete;
protected:
explicit PowerSaveBlocker(v8::Isolate* isolate);
~PowerSaveBlocker() override;
@ -50,8 +54,6 @@ class PowerSaveBlocker : public gin::Wrappable<PowerSaveBlocker> {
WakeLockTypeMap wake_lock_types_;
mojo::Remote<device::mojom::WakeLock> wake_lock_;
DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
};
} // namespace api

View file

@ -34,6 +34,10 @@ class Screen : public gin::Wrappable<Screen>,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
Screen(const Screen&) = delete;
Screen& operator=(const Screen&) = delete;
protected:
Screen(v8::Isolate* isolate, display::Screen* screen);
~Screen() override;
@ -52,8 +56,6 @@ class Screen : public gin::Wrappable<Screen>,
private:
display::Screen* screen_;
DISALLOW_COPY_AND_ASSIGN(Screen);
};
} // namespace api

View file

@ -43,6 +43,10 @@ class ServiceWorkerContext
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
ServiceWorkerContext(const ServiceWorkerContext&) = delete;
ServiceWorkerContext& operator=(const ServiceWorkerContext&) = delete;
protected:
explicit ServiceWorkerContext(v8::Isolate* isolate,
ElectronBrowserContext* browser_context);
@ -52,8 +56,6 @@ class ServiceWorkerContext
content::ServiceWorkerContext* service_worker_context_;
base::WeakPtrFactory<ServiceWorkerContext> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContext);
};
} // namespace api

View file

@ -155,6 +155,10 @@ class Session : public gin::Wrappable<Session>,
extensions::UnloadedExtensionReason reason) override;
#endif
// disable copy
Session(const Session&) = delete;
Session& operator=(const Session&) = delete;
protected:
Session(v8::Isolate* isolate, ElectronBrowserContext* browser_context);
~Session() override;
@ -187,8 +191,6 @@ class Session : public gin::Wrappable<Session>,
base::UnguessableToken network_emulation_token_;
ElectronBrowserContext* browser_context_;
DISALLOW_COPY_AND_ASSIGN(Session);
};
} // namespace api

View file

@ -121,6 +121,10 @@ class SystemPreferences
bool IsHighContrastColorScheme();
v8::Local<v8::Value> GetAnimationSettings(v8::Isolate* isolate);
// disable copy
SystemPreferences(const SystemPreferences&) = delete;
SystemPreferences& operator=(const SystemPreferences&) = delete;
protected:
SystemPreferences();
~SystemPreferences() override;
@ -162,7 +166,6 @@ class SystemPreferences
std::unique_ptr<gfx::ScopedSysColorChangeListener> color_change_listener_;
#endif
DISALLOW_COPY_AND_ASSIGN(SystemPreferences);
};
} // namespace api

View file

@ -52,6 +52,10 @@ class Tray : public gin::Wrappable<Tray>,
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
// disable copy
Tray(const Tray&) = delete;
Tray& operator=(const Tray&) = delete;
private:
Tray(v8::Isolate* isolate,
v8::Local<v8::Value> image,
@ -105,8 +109,6 @@ class Tray : public gin::Wrappable<Tray>,
v8::Global<v8::Value> menu_;
std::unique_ptr<TrayIcon> tray_icon_;
DISALLOW_COPY_AND_ASSIGN(Tray);
};
} // namespace api

View file

@ -30,6 +30,10 @@ class View : public gin_helper::Wrappable<View> {
views::View* view() const { return view_; }
// disable copy
View(const View&) = delete;
View& operator=(const View&) = delete;
protected:
explicit View(views::View* view);
View();
@ -43,8 +47,6 @@ class View : public gin_helper::Wrappable<View> {
bool delete_view_ = true;
views::View* view_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(View);
};
} // namespace api

View file

@ -15,6 +15,7 @@
#include "base/containers/id_map.h"
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/macros.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/current_thread.h"

View file

@ -447,6 +447,10 @@ class WebContents : public ExclusiveAccessContext,
content::PermissionType permissionType,
content::RenderFrameHost* render_frame_host);
// disable copy
WebContents(const WebContents&) = delete;
WebContents& operator=(const WebContents&) = delete;
private:
// Does not manage lifetime of |web_contents|.
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
@ -820,8 +824,6 @@ class WebContents : public ExclusiveAccessContext,
DevicePermissionMap granted_devices_;
base::WeakPtrFactory<WebContents> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(WebContents);
};
} // namespace api

View file

@ -51,8 +51,6 @@ class WebContentsView : public View, public content::WebContentsObserver {
// Keep a reference to v8 wrapper.
v8::Global<v8::Value> web_contents_;
api::WebContents* api_web_contents_;
DISALLOW_COPY_AND_ASSIGN(WebContentsView);
};
} // namespace api

View file

@ -59,6 +59,10 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
content::RenderFrameHost* render_frame_host() const { return render_frame_; }
// disable copy
WebFrameMain(const WebFrameMain&) = delete;
WebFrameMain& operator=(const WebFrameMain&) = delete;
protected:
explicit WebFrameMain(content::RenderFrameHost* render_frame);
~WebFrameMain() override;
@ -124,8 +128,6 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
bool render_frame_disposed_ = false;
base::WeakPtrFactory<WebFrameMain> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(WebFrameMain);
};
} // namespace api

View file

@ -29,6 +29,10 @@ class Event : public gin::Wrappable<Event> {
// `invoke` calls.
bool SendReply(v8::Isolate* isolate, v8::Local<v8::Value> result);
// disable copy
Event(const Event&) = delete;
Event& operator=(const Event&) = delete;
protected:
Event();
~Event() override;
@ -41,8 +45,6 @@ class Event : public gin::Wrappable<Event> {
private:
// Replyer for the synchronous messages.
InvokeCallback callback_;
DISALLOW_COPY_AND_ASSIGN(Event);
};
} // namespace gin_helper

View file

@ -38,6 +38,10 @@ class FrameSubscriber : public content::WebContentsObserver,
bool only_dirty);
~FrameSubscriber() override;
// disable copy
FrameSubscriber(const FrameSubscriber&) = delete;
FrameSubscriber& operator=(const FrameSubscriber&) = delete;
private:
void AttachToHost(content::RenderWidgetHost* host);
void DetachFromHost();
@ -69,8 +73,6 @@ class FrameSubscriber : public content::WebContentsObserver,
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
base::WeakPtrFactory<FrameSubscriber> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);
};
} // namespace api

View file

@ -22,6 +22,11 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
GPUInfoManager();
~GPUInfoManager() override;
// disable copy
GPUInfoManager(const GPUInfoManager&) = delete;
GPUInfoManager& operator=(const GPUInfoManager&) = delete;
bool NeedsCompleteGpuInfoCollection() const;
void FetchCompleteInfo(gin_helper::Promise<base::DictionaryValue> promise);
void FetchBasicInfo(gin_helper::Promise<base::DictionaryValue> promise);
@ -40,8 +45,6 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
std::vector<gin_helper::Promise<base::DictionaryValue>>
complete_info_promise_set_;
content::GpuDataManagerImpl* gpu_data_manager_;
DISALLOW_COPY_AND_ASSIGN(GPUInfoManager);
};
} // namespace electron

View file

@ -30,9 +30,6 @@ class ImageView : public View {
views::ImageView* image_view() const {
return static_cast<views::ImageView*>(view());
}
private:
DISALLOW_COPY_AND_ASSIGN(ImageView);
};
} // namespace api