Skip to content

Commit

Permalink
refactor: replace deprecated DISALLOW_COPY_AND_ASSIGN (electron#31633)
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak authored and t57ser committed Jan 25, 2022
1 parent 074ff28 commit 364b6a2
Show file tree
Hide file tree
Showing 231 changed files with 918 additions and 576 deletions.
7 changes: 4 additions & 3 deletions chromium_src/chrome/browser/certificate_manager_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <string>

#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "net/cert/nss_cert_database.h"

Expand All @@ -31,6 +30,10 @@ class CertificateManagerModel {
static void Create(content::BrowserContext* browser_context,
CreationCallback callback);

// disable copy
CertificateManagerModel(const CertificateManagerModel&) = delete;
CertificateManagerModel& operator=(const CertificateManagerModel&) = delete;

~CertificateManagerModel();

bool is_user_db_available() const { return is_user_db_available_; }
Expand Down Expand Up @@ -108,8 +111,6 @@ class CertificateManagerModel {
// Whether the certificate database has a public slot associated with the
// profile. If not set, importing certificates is not allowed with this model.
bool is_user_db_available_;

DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel);
};

#endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_
7 changes: 4 additions & 3 deletions shell/app/electron_content_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class ElectronContentClient : public content::ContentClient {
ElectronContentClient();
~ElectronContentClient() override;

// disable copy
ElectronContentClient(const ElectronContentClient&) = delete;
ElectronContentClient& operator=(const ElectronContentClient&) = delete;

protected:
// content::ContentClient:
std::u16string GetLocalizedString(int message_id) override;
Expand All @@ -30,9 +34,6 @@ class ElectronContentClient : public content::ContentClient {
void AddContentDecryptionModules(
std::vector<content::CdmInfo>* cdms,
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) override;

private:
DISALLOW_COPY_AND_ASSIGN(ElectronContentClient);
};

} // namespace electron
Expand Down
8 changes: 5 additions & 3 deletions shell/app/electron_crash_reporter_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <string>

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/no_destructor.h"
#include "build/build_config.h"
#include "components/crash/core/app/crash_reporter_client.h"
Expand All @@ -18,6 +17,11 @@ class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {
public:
static void Create();

// disable copy
ElectronCrashReporterClient(const ElectronCrashReporterClient&) = delete;
ElectronCrashReporterClient& operator=(const ElectronCrashReporterClient&) =
delete;

static ElectronCrashReporterClient* Get();
void SetCollectStatsConsent(bool upload_allowed);
void SetUploadUrl(const std::string& url);
Expand Down Expand Up @@ -85,8 +89,6 @@ class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {

ElectronCrashReporterClient();
~ElectronCrashReporterClient() override;

DISALLOW_COPY_AND_ASSIGN(ElectronCrashReporterClient);
};

#endif // SHELL_APP_ELECTRON_CRASH_REPORTER_CLIENT_H_
1 change: 1 addition & 0 deletions shell/app/electron_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <tchar.h>

#include "base/environment.h"
#include "base/macros.h"
#include "base/process/launch.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/windows_version.h"
Expand Down
6 changes: 4 additions & 2 deletions shell/app/electron_main_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class ElectronMainDelegate : public content::ContentMainDelegate {
ElectronMainDelegate();
~ElectronMainDelegate() override;

// disable copy
ElectronMainDelegate(const ElectronMainDelegate&) = delete;
ElectronMainDelegate& operator=(const ElectronMainDelegate&) = delete;

protected:
// content::ContentMainDelegate:
bool BasicStartupComplete(int* exit_code) override;
Expand Down Expand Up @@ -58,8 +62,6 @@ class ElectronMainDelegate : public content::ContentMainDelegate {
std::unique_ptr<content::ContentRendererClient> renderer_client_;
std::unique_ptr<content::ContentUtilityClient> utility_client_;
std::unique_ptr<tracing::TracingSamplerProfiler> tracing_sampler_profiler_;

DISALLOW_COPY_AND_ASSIGN(ElectronMainDelegate);
};

} // namespace electron
Expand Down
6 changes: 4 additions & 2 deletions shell/app/uv_task_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class UvTaskRunner : public base::SingleThreadTaskRunner {
public:
explicit UvTaskRunner(uv_loop_t* loop);

// disable copy
UvTaskRunner(const UvTaskRunner&) = delete;
UvTaskRunner& operator=(const UvTaskRunner&) = delete;

// base::SingleThreadTaskRunner:
bool PostDelayedTask(const base::Location& from_here,
base::OnceClosure task,
Expand All @@ -39,8 +43,6 @@ class UvTaskRunner : public base::SingleThreadTaskRunner {
uv_loop_t* loop_;

std::map<uv_timer_t*, base::OnceClosure> tasks_;

DISALLOW_COPY_AND_ASSIGN(UvTaskRunner);
};

} // namespace electron
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class App : public ElectronBrowserClient::Delegate,

App();

// disable copy
App(const App&) = delete;
App& operator=(const App&) = delete;

private:
~App() override;

Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_auto_updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_browser_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_browser_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_cookies.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_data_pipe_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -137,8 +141,6 @@ class DataPipeReader {
uint64_t remaining_size_ = 0;

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

DISALLOW_COPY_AND_ASSIGN(DataPipeReader);
};

} // namespace
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_data_pipe_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_desktop_capturer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_download_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_global_shortcut.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions shell/browser/api/electron_api_in_app_purchase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/api/electron_api_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions shell/browser/api/electron_api_menu_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 364b6a2

Please sign in to comment.