refactor: use C++11 class member variable initialization (#27477)

This commit is contained in:
Milan Burda 2021-01-26 19:16:21 +01:00 committed by GitHub
parent f083380c38
commit ddf3ef0a5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
93 changed files with 130 additions and 163 deletions

View file

@ -127,10 +127,11 @@ class ProcessSingleton {
NotificationCallback notification_callback_; // Handler for notifications. NotificationCallback notification_callback_; // Handler for notifications.
#if defined(OS_WIN) #if defined(OS_WIN)
HWND remote_window_; // The HWND_MESSAGE of another browser. HWND remote_window_ = nullptr; // The HWND_MESSAGE of another browser.
base::win::MessageWindow window_; // The message-only window. base::win::MessageWindow window_; // The message-only window.
bool is_virtualized_; // Stuck inside Microsoft Softricity VM environment. bool is_virtualized_ =
HANDLE lock_file_; false; // Stuck inside Microsoft Softricity VM environment.
HANDLE lock_file_ = INVALID_HANDLE_VALUE;
base::FilePath user_data_dir_; base::FilePath user_data_dir_;
ShouldKillRemoteProcessCallback should_kill_remote_process_callback_; ShouldKillRemoteProcessCallback should_kill_remote_process_callback_;
#elif defined(OS_POSIX) && !defined(OS_ANDROID) #elif defined(OS_POSIX) && !defined(OS_ANDROID)
@ -175,7 +176,7 @@ class ProcessSingleton {
// because it posts messages between threads. // because it posts messages between threads.
class LinuxWatcher; class LinuxWatcher;
scoped_refptr<LinuxWatcher> watcher_; scoped_refptr<LinuxWatcher> watcher_;
int sock_; int sock_ = -1;
bool listen_on_ready_ = false; bool listen_on_ready_ = false;
#endif #endif

View file

@ -333,7 +333,7 @@ bool IsChromeProcess(pid_t pid) {
// A helper class to hold onto a socket. // A helper class to hold onto a socket.
class ScopedSocket { class ScopedSocket {
public: public:
ScopedSocket() : fd_(-1) { Reset(); } ScopedSocket() { Reset(); }
~ScopedSocket() { Close(); } ~ScopedSocket() { Close(); }
int fd() { return fd_; } int fd() { return fd_; }
void Reset() { void Reset() {
@ -347,7 +347,7 @@ class ScopedSocket {
} }
private: private:
int fd_; int fd_ = -1;
}; };
// Returns a random string for uniquifying profile connections. // Returns a random string for uniquifying profile connections.
@ -473,10 +473,7 @@ class ProcessSingleton::LinuxWatcher
SocketReader(ProcessSingleton::LinuxWatcher* parent, SocketReader(ProcessSingleton::LinuxWatcher* parent,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
int fd) int fd)
: parent_(parent), : parent_(parent), ui_task_runner_(ui_task_runner), fd_(fd) {
ui_task_runner_(ui_task_runner),
fd_(fd),
bytes_read_(0) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
// Wait for reads. // Wait for reads.
fd_watch_controller_ = base::FileDescriptorWatcher::WatchReadable( fd_watch_controller_ = base::FileDescriptorWatcher::WatchReadable(
@ -508,20 +505,20 @@ class ProcessSingleton::LinuxWatcher
fd_watch_controller_; fd_watch_controller_;
// The ProcessSingleton::LinuxWatcher that owns us. // The ProcessSingleton::LinuxWatcher that owns us.
ProcessSingleton::LinuxWatcher* const parent_; ProcessSingleton::LinuxWatcher* const parent_ = nullptr;
// A reference to the UI task runner. // A reference to the UI task runner.
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// The file descriptor we're reading. // The file descriptor we're reading.
const int fd_; const int fd_ = -1;
// Store the message in this buffer. // Store the message in this buffer.
char buf_[kMaxMessageLength]; char buf_[kMaxMessageLength];
// Tracks the number of bytes we've read in case we're getting partial // Tracks the number of bytes we've read in case we're getting partial
// reads. // reads.
size_t bytes_read_; size_t bytes_read_ = 0;
base::OneShotTimer timer_; base::OneShotTimer timer_;

View file

@ -172,8 +172,6 @@ ProcessSingleton::ProcessSingleton(
const base::FilePath& user_data_dir, const base::FilePath& user_data_dir,
const NotificationCallback& notification_callback) const NotificationCallback& notification_callback)
: notification_callback_(notification_callback), : notification_callback_(notification_callback),
is_virtualized_(false),
lock_file_(INVALID_HANDLE_VALUE),
user_data_dir_(user_data_dir), user_data_dir_(user_data_dir),
should_kill_remote_process_callback_( should_kill_remote_process_callback_(
base::BindRepeating(&TerminateAppWithError)) { base::BindRepeating(&TerminateAppWithError)) {

View file

@ -38,8 +38,7 @@ void GlobalMenuBarRegistrarX11::OnWindowUnmapped(x11::Window window) {
live_windows_.erase(window); live_windows_.erase(window);
} }
GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11() GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11() {
: registrar_proxy_(nullptr) {
// libdbusmenu uses the gio version of dbus; I tried using the code in dbus/, // libdbusmenu uses the gio version of dbus; I tried using the code in dbus/,
// but it looks like that's isn't sharing the bus name with the gio version, // but it looks like that's isn't sharing the bus name with the gio version,
// even when |connection_type| is set to SHARED. // even when |connection_type| is set to SHARED.

View file

@ -48,7 +48,7 @@ class GlobalMenuBarRegistrarX11 {
GObject*, GObject*,
GParamSpec*); GParamSpec*);
GDBusProxy* registrar_proxy_; GDBusProxy* registrar_proxy_ = nullptr;
// x11::Window which want to be registered, but haven't yet been because // x11::Window which want to be registered, but haven't yet been because
// we're waiting for the proxy to become available. // we're waiting for the proxy to become available.

View file

@ -82,7 +82,7 @@ class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {
friend class base::NoDestructor<ElectronCrashReporterClient>; friend class base::NoDestructor<ElectronCrashReporterClient>;
std::string upload_url_; std::string upload_url_;
bool collect_stats_consent_; bool collect_stats_consent_ = false;
bool rate_limit_ = false; bool rate_limit_ = false;
bool compress_uploads_ = false; bool compress_uploads_ = false;
std::map<std::string, std::string> global_annotations_; std::map<std::string, std::string> global_annotations_;

View file

@ -76,8 +76,7 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
} // namespace } // namespace
BaseWindow::BaseWindow(v8::Isolate* isolate, BaseWindow::BaseWindow(v8::Isolate* isolate,
const gin_helper::Dictionary& options) const gin_helper::Dictionary& options) {
: weak_factory_(this) {
// The parent window. // The parent window.
gin::Handle<BaseWindow> parent; gin::Handle<BaseWindow> parent;
if (options.Get("parent", &parent) && !parent.IsEmpty()) if (options.Get("parent", &parent) && !parent.IsEmpty())

View file

@ -274,7 +274,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
// Reference to JS wrapper to prevent garbage collection. // Reference to JS wrapper to prevent garbage collection.
v8::Global<v8::Value> self_ref_; v8::Global<v8::Value> self_ref_;
base::WeakPtrFactory<BaseWindow> weak_factory_; base::WeakPtrFactory<BaseWindow> weak_factory_{this};
}; };
} // namespace api } // namespace api

View file

@ -32,7 +32,7 @@ namespace api {
BrowserWindow::BrowserWindow(gin::Arguments* args, BrowserWindow::BrowserWindow(gin::Arguments* args,
const gin_helper::Dictionary& options) const gin_helper::Dictionary& options)
: BaseWindow(args->isolate(), options), weak_factory_(this) { : BaseWindow(args->isolate(), options) {
// Use options.webPreferences in WebContents. // Use options.webPreferences in WebContents.
v8::Isolate* isolate = args->isolate(); v8::Isolate* isolate = args->isolate();
gin_helper::Dictionary web_preferences = gin_helper::Dictionary web_preferences =

View file

@ -126,7 +126,7 @@ class BrowserWindow : public BaseWindow,
v8::Global<v8::Value> web_contents_; v8::Global<v8::Value> web_contents_;
base::WeakPtr<api::WebContents> api_web_contents_; base::WeakPtr<api::WebContents> api_web_contents_;
base::WeakPtrFactory<BrowserWindow> weak_factory_; base::WeakPtrFactory<BrowserWindow> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(BrowserWindow); DISALLOW_COPY_AND_ASSIGN(BrowserWindow);
}; };

View file

@ -47,7 +47,7 @@ class MenuMac : public Menu {
// window ID -> open context menu // window ID -> open context menu
std::map<int32_t, scoped_nsobject<ElectronMenuController>> popup_controllers_; std::map<int32_t, scoped_nsobject<ElectronMenuController>> popup_controllers_;
base::WeakPtrFactory<MenuMac> weak_factory_; base::WeakPtrFactory<MenuMac> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(MenuMac); DISALLOW_COPY_AND_ASSIGN(MenuMac);
}; };

View file

@ -30,7 +30,7 @@ namespace electron {
namespace api { namespace api {
MenuMac::MenuMac(gin::Arguments* args) : Menu(args), weak_factory_(this) {} MenuMac::MenuMac(gin::Arguments* args) : Menu(args) {}
MenuMac::~MenuMac() = default; MenuMac::~MenuMac() = default;

View file

@ -17,7 +17,7 @@ namespace electron {
namespace api { namespace api {
MenuViews::MenuViews(gin::Arguments* args) : Menu(args), weak_factory_(this) {} MenuViews::MenuViews(gin::Arguments* args) : Menu(args) {}
MenuViews::~MenuViews() = default; MenuViews::~MenuViews() = default;

View file

@ -36,7 +36,7 @@ class MenuViews : public Menu {
// window ID -> open context menu // window ID -> open context menu
std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_; std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
base::WeakPtrFactory<MenuViews> weak_factory_; base::WeakPtrFactory<MenuViews> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(MenuViews); DISALLOW_COPY_AND_ASSIGN(MenuViews);
}; };

View file

@ -79,7 +79,7 @@ namespace api {
gin::WrapperInfo NetLog::kWrapperInfo = {gin::kEmbedderNativeGin}; gin::WrapperInfo NetLog::kWrapperInfo = {gin::kEmbedderNativeGin};
NetLog::NetLog(v8::Isolate* isolate, ElectronBrowserContext* browser_context) NetLog::NetLog(v8::Isolate* isolate, ElectronBrowserContext* browser_context)
: browser_context_(browser_context), weak_ptr_factory_(this) { : browser_context_(browser_context) {
file_task_runner_ = CreateFileTaskRunner(); file_task_runner_ = CreateFileTaskRunner();
} }

View file

@ -65,7 +65,7 @@ class NetLog : public gin::Wrappable<NetLog> {
scoped_refptr<base::TaskRunner> file_task_runner_; scoped_refptr<base::TaskRunner> file_task_runner_;
base::WeakPtrFactory<NetLog> weak_ptr_factory_; base::WeakPtrFactory<NetLog> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NetLog); DISALLOW_COPY_AND_ASSIGN(NetLog);
}; };

View file

@ -45,8 +45,7 @@ namespace api {
gin::WrapperInfo PowerSaveBlocker::kWrapperInfo = {gin::kEmbedderNativeGin}; gin::WrapperInfo PowerSaveBlocker::kWrapperInfo = {gin::kEmbedderNativeGin};
PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate) PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
: current_lock_type_(device::mojom::WakeLockType::kPreventAppSuspension), : current_lock_type_(device::mojom::WakeLockType::kPreventAppSuspension) {}
is_wake_lock_active_(false) {}
PowerSaveBlocker::~PowerSaveBlocker() = default; PowerSaveBlocker::~PowerSaveBlocker() = default;

View file

@ -44,7 +44,7 @@ class PowerSaveBlocker : public gin::Wrappable<PowerSaveBlocker> {
device::mojom::WakeLockType current_lock_type_; device::mojom::WakeLockType current_lock_type_;
// Whether the wake lock is currently active. // Whether the wake lock is currently active.
bool is_wake_lock_active_; bool is_wake_lock_active_ = false;
// Map from id to the corresponding blocker type for each request. // Map from id to the corresponding blocker type for each request.
using WakeLockTypeMap = std::map<int, device::mojom::WakeLockType>; using WakeLockTypeMap = std::map<int, device::mojom::WakeLockType>;

View file

@ -74,7 +74,7 @@ gin::WrapperInfo ServiceWorkerContext::kWrapperInfo = {gin::kEmbedderNativeGin};
ServiceWorkerContext::ServiceWorkerContext( ServiceWorkerContext::ServiceWorkerContext(
v8::Isolate* isolate, v8::Isolate* isolate,
ElectronBrowserContext* browser_context) ElectronBrowserContext* browser_context)
: browser_context_(browser_context), weak_ptr_factory_(this) { : browser_context_(browser_context) {
service_worker_context_ = service_worker_context_ =
content::BrowserContext::GetDefaultStoragePartition(browser_context_) content::BrowserContext::GetDefaultStoragePartition(browser_context_)
->GetServiceWorkerContext(); ->GetServiceWorkerContext();

View file

@ -52,7 +52,7 @@ class ServiceWorkerContext
content::ServiceWorkerContext* service_worker_context_; content::ServiceWorkerContext* service_worker_context_;
base::WeakPtrFactory<ServiceWorkerContext> weak_ptr_factory_; base::WeakPtrFactory<ServiceWorkerContext> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContext); DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContext);
}; };

View file

@ -156,9 +156,9 @@ class SystemPreferences
std::string current_color_; std::string current_color_;
bool invertered_color_scheme_; bool invertered_color_scheme_ = false;
bool high_contrast_color_scheme_; bool high_contrast_color_scheme_ = false;
std::unique_ptr<gfx::ScopedSysColorChangeListener> color_change_listener_; std::unique_ptr<gfx::ScopedSysColorChangeListener> color_change_listener_;
#endif #endif

View file

@ -617,11 +617,12 @@ WebContents::WebContents(v8::Isolate* isolate,
id_(GetAllWebContents().Add(this)), id_(GetAllWebContents().Add(this)),
devtools_file_system_indexer_(new DevToolsFileSystemIndexer), devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
file_task_runner_( file_task_runner_(
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})), base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()}))
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
print_task_runner_(CreatePrinterHandlerTaskRunner()), ,
print_task_runner_(CreatePrinterHandlerTaskRunner())
#endif #endif
weak_factory_(this) { {
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
// WebContents created by extension host will have valid ViewType set. // WebContents created by extension host will have valid ViewType set.
extensions::ViewType view_type = extensions::GetViewType(web_contents); extensions::ViewType view_type = extensions::GetViewType(web_contents);
@ -653,11 +654,12 @@ WebContents::WebContents(v8::Isolate* isolate,
id_(GetAllWebContents().Add(this)), id_(GetAllWebContents().Add(this)),
devtools_file_system_indexer_(new DevToolsFileSystemIndexer), devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
file_task_runner_( file_task_runner_(
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})), base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()}))
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
print_task_runner_(CreatePrinterHandlerTaskRunner()), ,
print_task_runner_(CreatePrinterHandlerTaskRunner())
#endif #endif
weak_factory_(this) { {
DCHECK(type != Type::kRemote) DCHECK(type != Type::kRemote)
<< "Can't take ownership of a remote WebContents"; << "Can't take ownership of a remote WebContents";
auto session = Session::CreateFrom(isolate, GetBrowserContext()); auto session = Session::CreateFrom(isolate, GetBrowserContext());
@ -671,11 +673,12 @@ WebContents::WebContents(v8::Isolate* isolate,
: id_(GetAllWebContents().Add(this)), : id_(GetAllWebContents().Add(this)),
devtools_file_system_indexer_(new DevToolsFileSystemIndexer), devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
file_task_runner_( file_task_runner_(
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})), base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()}))
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
print_task_runner_(CreatePrinterHandlerTaskRunner()), ,
print_task_runner_(CreatePrinterHandlerTaskRunner())
#endif #endif
weak_factory_(this) { {
// Read options. // Read options.
options.Get("backgroundThrottling", &background_throttling_); options.Get("backgroundThrottling", &background_throttling_);

View file

@ -787,7 +787,7 @@ class WebContents : public gin::Wrappable<WebContents>,
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*> registry_; service_manager::BinderRegistryWithArgs<content::RenderFrameHost*> registry_;
base::WeakPtrFactory<WebContents> weak_factory_; base::WeakPtrFactory<WebContents> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(WebContents); DISALLOW_COPY_AND_ASSIGN(WebContents);
}; };

View file

@ -26,8 +26,7 @@ FrameSubscriber::FrameSubscriber(content::WebContents* web_contents,
bool only_dirty) bool only_dirty)
: content::WebContentsObserver(web_contents), : content::WebContentsObserver(web_contents),
callback_(callback), callback_(callback),
only_dirty_(only_dirty), only_dirty_(only_dirty) {
weak_ptr_factory_(this) {
content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); content::RenderViewHost* rvh = web_contents->GetRenderViewHost();
if (rvh) if (rvh)
AttachToHost(rvh->GetWidget()); AttachToHost(rvh->GetWidget());

View file

@ -67,7 +67,7 @@ class FrameSubscriber : public content::WebContentsObserver,
content::RenderWidgetHost* host_; content::RenderWidgetHost* host_;
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_; std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
base::WeakPtrFactory<FrameSubscriber> weak_ptr_factory_; base::WeakPtrFactory<FrameSubscriber> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber); DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);
}; };

View file

@ -102,12 +102,10 @@ ElectronBrowserContext::browser_context_map() {
ElectronBrowserContext::ElectronBrowserContext(const std::string& partition, ElectronBrowserContext::ElectronBrowserContext(const std::string& partition,
bool in_memory, bool in_memory,
base::DictionaryValue options) base::DictionaryValue options)
: in_memory_pref_store_(nullptr), : storage_policy_(new SpecialStoragePolicy),
storage_policy_(new SpecialStoragePolicy),
protocol_registry_(new ProtocolRegistry), protocol_registry_(new ProtocolRegistry),
in_memory_(in_memory), in_memory_(in_memory),
ssl_config_(network::mojom::SSLConfig::New()), ssl_config_(network::mojom::SSLConfig::New()) {
weak_factory_(this) {
user_agent_ = ElectronBrowserClient::Get()->GetUserAgent(); user_agent_ = ElectronBrowserClient::Get()->GetUserAgent();
// Read options. // Read options.

View file

@ -165,7 +165,7 @@ class ElectronBrowserContext
// Initialize pref registry. // Initialize pref registry.
void InitPrefs(); void InitPrefs();
ValueMapPrefStore* in_memory_pref_store_; ValueMapPrefStore* in_memory_pref_store_ = nullptr;
std::unique_ptr<content::ResourceContext> resource_context_; std::unique_ptr<content::ResourceContext> resource_context_;
std::unique_ptr<CookieChangeNotifier> cookie_change_notifier_; std::unique_ptr<CookieChangeNotifier> cookie_change_notifier_;
@ -197,7 +197,7 @@ class ElectronBrowserContext
network::mojom::SSLConfigPtr ssl_config_; network::mojom::SSLConfigPtr ssl_config_;
mojo::Remote<network::mojom::SSLConfigClient> ssl_config_client_; mojo::Remote<network::mojom::SSLConfigClient> ssl_config_client_;
base::WeakPtrFactory<ElectronBrowserContext> weak_factory_; base::WeakPtrFactory<ElectronBrowserContext> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ElectronBrowserContext); DISALLOW_COPY_AND_ASSIGN(ElectronBrowserContext);
}; };

View file

@ -17,8 +17,7 @@ ElectronBrowserHandlerImpl::ElectronBrowserHandlerImpl(
content::RenderFrameHost* frame_host, content::RenderFrameHost* frame_host,
mojo::PendingReceiver<mojom::ElectronBrowser> receiver) mojo::PendingReceiver<mojom::ElectronBrowser> receiver)
: render_process_id_(frame_host->GetProcess()->GetID()), : render_process_id_(frame_host->GetProcess()->GetID()),
render_frame_id_(frame_host->GetRoutingID()), render_frame_id_(frame_host->GetRoutingID()) {
weak_factory_(this) {
content::WebContents* web_contents = content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(frame_host); content::WebContents::FromRenderFrameHost(frame_host);
DCHECK(web_contents); DCHECK(web_contents);

View file

@ -74,7 +74,7 @@ class ElectronBrowserHandlerImpl : public mojom::ElectronBrowser,
mojo::Receiver<mojom::ElectronBrowser> receiver_{this}; mojo::Receiver<mojom::ElectronBrowser> receiver_{this};
base::WeakPtrFactory<ElectronBrowserHandlerImpl> weak_factory_; base::WeakPtrFactory<ElectronBrowserHandlerImpl> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ElectronBrowserHandlerImpl); DISALLOW_COPY_AND_ASSIGN(ElectronBrowserHandlerImpl);
}; };

View file

@ -52,7 +52,7 @@ base::FilePath CreateDownloadPath(const GURL& url,
ElectronDownloadManagerDelegate::ElectronDownloadManagerDelegate( ElectronDownloadManagerDelegate::ElectronDownloadManagerDelegate(
content::DownloadManager* manager) content::DownloadManager* manager)
: download_manager_(manager), weak_ptr_factory_(this) {} : download_manager_(manager) {}
ElectronDownloadManagerDelegate::~ElectronDownloadManagerDelegate() { ElectronDownloadManagerDelegate::~ElectronDownloadManagerDelegate() {
if (download_manager_) { if (download_manager_) {

View file

@ -53,7 +53,7 @@ class ElectronDownloadManagerDelegate
gin_helper::Dictionary result); gin_helper::Dictionary result);
content::DownloadManager* download_manager_; content::DownloadManager* download_manager_;
base::WeakPtrFactory<ElectronDownloadManagerDelegate> weak_ptr_factory_; base::WeakPtrFactory<ElectronDownloadManagerDelegate> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ElectronDownloadManagerDelegate); DISALLOW_COPY_AND_ASSIGN(ElectronDownloadManagerDelegate);
}; };

View file

@ -69,8 +69,7 @@ std::pair<scoped_refptr<const Extension>, std::string> LoadUnpacked(
ElectronExtensionLoader::ElectronExtensionLoader( ElectronExtensionLoader::ElectronExtensionLoader(
content::BrowserContext* browser_context) content::BrowserContext* browser_context)
: browser_context_(browser_context), : browser_context_(browser_context),
extension_registrar_(browser_context, this), extension_registrar_(browser_context, this) {}
weak_factory_(this) {}
ElectronExtensionLoader::~ElectronExtensionLoader() = default; ElectronExtensionLoader::~ElectronExtensionLoader() = default;

View file

@ -90,7 +90,7 @@ class ElectronExtensionLoader : public ExtensionRegistrar::Delegate {
// LoadExtensionForReload(). // LoadExtensionForReload().
bool did_schedule_reload_ = false; bool did_schedule_reload_ = false;
base::WeakPtrFactory<ElectronExtensionLoader> weak_factory_; base::WeakPtrFactory<ElectronExtensionLoader> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionLoader); DISALLOW_COPY_AND_ASSIGN(ElectronExtensionLoader);
}; };

View file

@ -49,8 +49,7 @@ namespace extensions {
ElectronExtensionSystem::ElectronExtensionSystem( ElectronExtensionSystem::ElectronExtensionSystem(
BrowserContext* browser_context) BrowserContext* browser_context)
: browser_context_(browser_context), : browser_context_(browser_context),
store_factory_(new ValueStoreFactoryImpl(browser_context->GetPath())), store_factory_(new ValueStoreFactoryImpl(browser_context->GetPath())) {}
weak_factory_(this) {}
ElectronExtensionSystem::~ElectronExtensionSystem() = default; ElectronExtensionSystem::~ElectronExtensionSystem() = default;

View file

@ -113,7 +113,7 @@ class ElectronExtensionSystem : public ExtensionSystem {
// Signaled when the extension system has completed its startup tasks. // Signaled when the extension system has completed its startup tasks.
base::OneShotEvent ready_; base::OneShotEvent ready_;
base::WeakPtrFactory<ElectronExtensionSystem> weak_factory_; base::WeakPtrFactory<ElectronExtensionSystem> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionSystem); DISALLOW_COPY_AND_ASSIGN(ElectronExtensionSystem);
}; };

View file

@ -53,7 +53,7 @@ class TransactionObserver {
private: private:
InAppTransactionObserver* observer_; InAppTransactionObserver* observer_;
base::WeakPtrFactory<TransactionObserver> weak_ptr_factory_; base::WeakPtrFactory<TransactionObserver> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(TransactionObserver); DISALLOW_COPY_AND_ASSIGN(TransactionObserver);
}; };

View file

@ -182,7 +182,7 @@ Transaction::Transaction() = default;
Transaction::Transaction(const Transaction&) = default; Transaction::Transaction(const Transaction&) = default;
Transaction::~Transaction() = default; Transaction::~Transaction() = default;
TransactionObserver::TransactionObserver() : weak_ptr_factory_(this) { TransactionObserver::TransactionObserver() {
observer_ = [[InAppTransactionObserver alloc] observer_ = [[InAppTransactionObserver alloc]
initWithCallback:base::BindRepeating( initWithCallback:base::BindRepeating(
&TransactionObserver::OnTransactionsUpdated, &TransactionObserver::OnTransactionsUpdated,

View file

@ -33,8 +33,7 @@ MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
return base::Singleton<MediaCaptureDevicesDispatcher>::get(); return base::Singleton<MediaCaptureDevicesDispatcher>::get();
} }
MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() {
: is_device_enumeration_disabled_(false) {
// MediaCaptureDevicesDispatcher is a singleton. It should be created on // MediaCaptureDevicesDispatcher is a singleton. It should be created on
// UI thread. // UI thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

View file

@ -80,7 +80,7 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
blink::MediaStreamDevices test_video_devices_; blink::MediaStreamDevices test_video_devices_;
// Flag used by unittests to disable device enumeration. // Flag used by unittests to disable device enumeration.
bool is_device_enumeration_disabled_; bool is_device_enumeration_disabled_ = false;
DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher);
}; };

View file

@ -48,7 +48,7 @@ gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
NativeWindow::NativeWindow(const gin_helper::Dictionary& options, NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
NativeWindow* parent) NativeWindow* parent)
: widget_(new views::Widget), parent_(parent), weak_factory_(this) { : widget_(new views::Widget), parent_(parent) {
++next_id_; ++next_id_;
options.Get(options::kFrame, &has_frame_); options.Get(options::kFrame, &has_frame_);

View file

@ -382,7 +382,7 @@ class NativeWindow : public base::SupportsUserData,
// Accessible title. // Accessible title.
base::string16 accessible_title_; base::string16 accessible_title_;
base::WeakPtrFactory<NativeWindow> weak_factory_; base::WeakPtrFactory<NativeWindow> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NativeWindow); DISALLOW_COPY_AND_ASSIGN(NativeWindow);
}; };

View file

@ -21,8 +21,7 @@ NodeStreamLoader::NodeStreamLoader(
: binding_(this, std::move(loader)), : binding_(this, std::move(loader)),
client_(std::move(client)), client_(std::move(client)),
isolate_(isolate), isolate_(isolate),
emitter_(isolate, emitter), emitter_(isolate, emitter) {
weak_factory_(this) {
binding_.set_connection_error_handler( binding_.set_connection_error_handler(
base::BindOnce(&NodeStreamLoader::NotifyComplete, base::BindOnce(&NodeStreamLoader::NotifyComplete,
weak_factory_.GetWeakPtr(), net::ERR_FAILED)); weak_factory_.GetWeakPtr(), net::ERR_FAILED));

View file

@ -95,7 +95,7 @@ class NodeStreamLoader : public network::mojom::URLLoader {
// Store the V8 callbacks to unsubscribe them later. // Store the V8 callbacks to unsubscribe them later.
std::map<std::string, v8::Global<v8::Value>> handlers_; std::map<std::string, v8::Global<v8::Value>> handlers_;
base::WeakPtrFactory<NodeStreamLoader> weak_factory_; base::WeakPtrFactory<NodeStreamLoader> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NodeStreamLoader); DISALLOW_COPY_AND_ASSIGN(NodeStreamLoader);
}; };

View file

@ -19,9 +19,7 @@ URLPipeLoader::URLPipeLoader(
mojo::PendingRemote<network::mojom::URLLoaderClient> client, mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::NetworkTrafficAnnotationTag& annotation, const net::NetworkTrafficAnnotationTag& annotation,
base::DictionaryValue upload_data) base::DictionaryValue upload_data)
: binding_(this, std::move(loader)), : binding_(this, std::move(loader)), client_(std::move(client)) {
client_(std::move(client)),
weak_factory_(this) {
binding_.set_connection_error_handler(base::BindOnce( binding_.set_connection_error_handler(base::BindOnce(
&URLPipeLoader::NotifyComplete, base::Unretained(this), net::ERR_FAILED)); &URLPipeLoader::NotifyComplete, base::Unretained(this), net::ERR_FAILED));

View file

@ -75,7 +75,7 @@ class URLPipeLoader : public network::mojom::URLLoader,
std::unique_ptr<mojo::DataPipeProducer> producer_; std::unique_ptr<mojo::DataPipeProducer> producer_;
std::unique_ptr<network::SimpleURLLoader> loader_; std::unique_ptr<network::SimpleURLLoader> loader_;
base::WeakPtrFactory<URLPipeLoader> weak_factory_; base::WeakPtrFactory<URLPipeLoader> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(URLPipeLoader); DISALLOW_COPY_AND_ASSIGN(URLPipeLoader);
}; };

View file

@ -75,7 +75,7 @@ bool LibnotifyNotification::Initialize() {
LibnotifyNotification::LibnotifyNotification(NotificationDelegate* delegate, LibnotifyNotification::LibnotifyNotification(NotificationDelegate* delegate,
NotificationPresenter* presenter) NotificationPresenter* presenter)
: Notification(delegate, presenter), notification_(nullptr) {} : Notification(delegate, presenter) {}
LibnotifyNotification::~LibnotifyNotification() { LibnotifyNotification::~LibnotifyNotification() {
if (notification_) { if (notification_) {

View file

@ -37,7 +37,7 @@ class LibnotifyNotification : public Notification {
NotifyNotification*, NotifyNotification*,
char*); char*);
NotifyNotification* notification_; NotifyNotification* notification_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(LibnotifyNotification); DISALLOW_COPY_AND_ASSIGN(LibnotifyNotification);
}; };

View file

@ -14,7 +14,7 @@ NotificationOptions::~NotificationOptions() = default;
Notification::Notification(NotificationDelegate* delegate, Notification::Notification(NotificationDelegate* delegate,
NotificationPresenter* presenter) NotificationPresenter* presenter)
: delegate_(delegate), presenter_(presenter), weak_factory_(this) {} : delegate_(delegate), presenter_(presenter) {}
Notification::~Notification() { Notification::~Notification() {
if (delegate()) if (delegate())

View file

@ -82,7 +82,7 @@ class Notification {
NotificationPresenter* presenter_; NotificationPresenter* presenter_;
std::string notification_id_; std::string notification_id_;
base::WeakPtrFactory<Notification> weak_factory_; base::WeakPtrFactory<Notification> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(Notification); DISALLOW_COPY_AND_ASSIGN(Notification);
}; };

View file

@ -182,11 +182,9 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
frame_rate_(frame_rate), frame_rate_(frame_rate),
size_(initial_size), size_(initial_size),
painting_(painting), painting_(painting),
is_showing_(false),
cursor_manager_(new content::CursorManager(this)), cursor_manager_(new content::CursorManager(this)),
mouse_wheel_phase_handler_(this), mouse_wheel_phase_handler_(this),
backing_(new SkBitmap), backing_(new SkBitmap) {
weak_ptr_factory_(this) {
DCHECK(render_widget_host_); DCHECK(render_widget_host_);
DCHECK(!render_widget_host_->GetView()); DCHECK(!render_widget_host_->GetView());

View file

@ -280,7 +280,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
std::unique_ptr<SkBitmap> backing_; std::unique_ptr<SkBitmap> backing_;
base::WeakPtrFactory<OffScreenRenderWidgetHostView> weak_ptr_factory_; base::WeakPtrFactory<OffScreenRenderWidgetHostView> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(OffScreenRenderWidgetHostView); DISALLOW_COPY_AND_ASSIGN(OffScreenRenderWidgetHostView);
}; };

View file

@ -18,8 +18,7 @@ OffScreenVideoConsumer::OffScreenVideoConsumer(
OnPaintCallback callback) OnPaintCallback callback)
: callback_(callback), : callback_(callback),
view_(view), view_(view),
video_capturer_(view->CreateVideoCapturer()), video_capturer_(view->CreateVideoCapturer()) {
weak_ptr_factory_(this) {
video_capturer_->SetResolutionConstraints(view_->SizeInPixels(), video_capturer_->SetResolutionConstraints(view_->SizeInPixels(),
view_->SizeInPixels(), true); view_->SizeInPixels(), true);
video_capturer_->SetAutoThrottlingEnabled(false); video_capturer_->SetAutoThrottlingEnabled(false);

View file

@ -48,7 +48,7 @@ class OffScreenVideoConsumer : public viz::mojom::FrameSinkVideoConsumer {
OffScreenRenderWidgetHostView* view_; OffScreenRenderWidgetHostView* view_;
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_; std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
base::WeakPtrFactory<OffScreenVideoConsumer> weak_ptr_factory_; base::WeakPtrFactory<OffScreenVideoConsumer> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(OffScreenVideoConsumer); DISALLOW_COPY_AND_ASSIGN(OffScreenVideoConsumer);
}; };

View file

@ -14,7 +14,7 @@ namespace electron {
OffScreenWebContentsView::OffScreenWebContentsView( OffScreenWebContentsView::OffScreenWebContentsView(
bool transparent, bool transparent,
const OnPaintCallback& callback) const OnPaintCallback& callback)
: native_window_(nullptr), transparent_(transparent), callback_(callback) { : transparent_(transparent), callback_(callback) {
#if defined(OS_MAC) #if defined(OS_MAC)
PlatformCreate(); PlatformCreate();
#endif #endif

View file

@ -88,7 +88,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
OffScreenRenderWidgetHostView* GetView() const; OffScreenRenderWidgetHostView* GetView() const;
NativeWindow* native_window_; NativeWindow* native_window_ = nullptr;
const bool transparent_; const bool transparent_;
bool painting_ = true; bool painting_ = true;

View file

@ -53,7 +53,7 @@ void StopWorker(int document_cookie) {
PrintPreviewMessageHandler::PrintPreviewMessageHandler( PrintPreviewMessageHandler::PrintPreviewMessageHandler(
content::WebContents* web_contents) content::WebContents* web_contents)
: content::WebContentsObserver(web_contents), weak_ptr_factory_(this) { : content::WebContentsObserver(web_contents) {
DCHECK(web_contents); DCHECK(web_contents);
} }

View file

@ -96,7 +96,7 @@ class PrintPreviewMessageHandler
mojo::AssociatedReceiver<printing::mojom::PrintPreviewUI> receiver_{this}; mojo::AssociatedReceiver<printing::mojom::PrintPreviewUI> receiver_{this};
base::WeakPtrFactory<PrintPreviewMessageHandler> weak_ptr_factory_; base::WeakPtrFactory<PrintPreviewMessageHandler> weak_ptr_factory_{this};
WEB_CONTENTS_USER_DATA_KEY_DECL(); WEB_CONTENTS_USER_DATA_KEY_DECL();

View file

@ -158,7 +158,7 @@ namespace gtkui {
AppIndicatorIcon::AppIndicatorIcon(std::string id, AppIndicatorIcon::AppIndicatorIcon(std::string id,
const gfx::ImageSkia& image, const gfx::ImageSkia& image,
const base::string16& tool_tip) const base::string16& tool_tip)
: id_(id), icon_(nullptr), menu_model_(nullptr), icon_change_count_(0) { : id_(id) {
std::unique_ptr<base::Environment> env(base::Environment::Create()); std::unique_ptr<base::Environment> env(base::Environment::Create());
desktop_env_ = base::nix::GetDesktopEnvironment(env.get()); desktop_env_ = base::nix::GetDesktopEnvironment(env.get());

View file

@ -96,13 +96,13 @@ class AppIndicatorIcon : public views::StatusIconLinux {
base::nix::DesktopEnvironment desktop_env_; base::nix::DesktopEnvironment desktop_env_;
// Gtk status icon wrapper // Gtk status icon wrapper
AppIndicator* icon_; AppIndicator* icon_ = nullptr;
std::unique_ptr<AppIndicatorIconMenu> menu_; std::unique_ptr<AppIndicatorIconMenu> menu_;
ui::MenuModel* menu_model_; ui::MenuModel* menu_model_ = nullptr;
base::FilePath temp_dir_; base::FilePath temp_dir_;
int icon_change_count_; int icon_change_count_ = 0;
base::WeakPtrFactory<AppIndicatorIcon> weak_factory_{this}; base::WeakPtrFactory<AppIndicatorIcon> weak_factory_{this};

View file

@ -16,10 +16,7 @@ namespace electron {
namespace gtkui { namespace gtkui {
AppIndicatorIconMenu::AppIndicatorIconMenu(ui::MenuModel* model) AppIndicatorIconMenu::AppIndicatorIconMenu(ui::MenuModel* model)
: menu_model_(model), : menu_model_(model) {
click_action_replacement_menu_item_added_(false),
gtk_menu_(nullptr),
block_activation_(false) {
{ {
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/378770 ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/378770
gtk_menu_ = gtk_menu_new(); gtk_menu_ = gtk_menu_new();

View file

@ -54,16 +54,16 @@ class AppIndicatorIconMenu {
ui::MenuModel* menu_model_; ui::MenuModel* menu_model_;
// Whether a "click action replacement" menu item has been added to the menu. // Whether a "click action replacement" menu item has been added to the menu.
bool click_action_replacement_menu_item_added_; bool click_action_replacement_menu_item_added_ = false;
// Called when the click action replacement menu item is activated. When a // Called when the click action replacement menu item is activated. When a
// menu item from |menu_model_| is activated, MenuModel::ActivatedAt() is // menu item from |menu_model_| is activated, MenuModel::ActivatedAt() is
// invoked and is assumed to do any necessary processing. // invoked and is assumed to do any necessary processing.
base::Closure click_action_replacement_callback_; base::Closure click_action_replacement_callback_;
GtkWidget* gtk_menu_; GtkWidget* gtk_menu_ = nullptr;
bool block_activation_; bool block_activation_ = false;
DISALLOW_COPY_AND_ASSIGN(AppIndicatorIconMenu); DISALLOW_COPY_AND_ASSIGN(AppIndicatorIconMenu);
}; };

View file

@ -337,14 +337,10 @@ InspectableWebContents::InspectableWebContents(
content::WebContents* web_contents, content::WebContents* web_contents,
PrefService* pref_service, PrefService* pref_service,
bool is_guest) bool is_guest)
: frontend_loaded_(false), : pref_service_(pref_service),
can_dock_(true),
delegate_(nullptr),
pref_service_(pref_service),
web_contents_(web_contents), web_contents_(web_contents),
is_guest_(is_guest), is_guest_(is_guest),
view_(CreateInspectableContentsView(this)), view_(CreateInspectableContentsView(this)) {
weak_factory_(this) {
const base::Value* bounds_dict = pref_service_->Get(kDevToolsBoundsPref); const base::Value* bounds_dict = pref_service_->Get(kDevToolsBoundsPref);
if (bounds_dict->is_dict()) { if (bounds_dict->is_dict()) {
devtools_bounds_ = DictionaryToRect(bounds_dict); devtools_bounds_ = DictionaryToRect(bounds_dict);

View file

@ -201,7 +201,7 @@ class InspectableWebContents
void AddDevToolsExtensionsToClient(); void AddDevToolsExtensionsToClient();
#endif #endif
bool frontend_loaded_; bool frontend_loaded_ = false;
scoped_refptr<content::DevToolsAgentHost> agent_host_; scoped_refptr<content::DevToolsAgentHost> agent_host_;
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_; std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
std::unique_ptr<DevToolsEmbedderMessageDispatcher> std::unique_ptr<DevToolsEmbedderMessageDispatcher>
@ -209,11 +209,11 @@ class InspectableWebContents
DevToolsContentsResizingStrategy contents_resizing_strategy_; DevToolsContentsResizingStrategy contents_resizing_strategy_;
gfx::Rect devtools_bounds_; gfx::Rect devtools_bounds_;
bool can_dock_; bool can_dock_ = true;
std::string dock_state_; std::string dock_state_;
bool activate_ = true; bool activate_ = true;
InspectableWebContentsDelegate* delegate_; // weak references. InspectableWebContentsDelegate* delegate_ = nullptr; // weak references.
PrefService* pref_service_; // weak reference. PrefService* pref_service_; // weak reference.
@ -235,7 +235,7 @@ class InspectableWebContents
using ExtensionsAPIs = std::map<std::string, std::string>; using ExtensionsAPIs = std::map<std::string, std::string>;
ExtensionsAPIs extensions_api_; ExtensionsAPIs extensions_api_;
base::WeakPtrFactory<InspectableWebContents> weak_factory_; base::WeakPtrFactory<InspectableWebContents> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(InspectableWebContents); DISALLOW_COPY_AND_ASSIGN(InspectableWebContents);
}; };

View file

@ -23,7 +23,7 @@ class InspectableWebContentsViewDelegate;
class InspectableWebContentsView { class InspectableWebContentsView {
public: public:
InspectableWebContentsView() : delegate_(nullptr) {} InspectableWebContentsView() {}
virtual ~InspectableWebContentsView() {} virtual ~InspectableWebContentsView() {}
// The delegate manages its own life. // The delegate manages its own life.
@ -54,7 +54,7 @@ class InspectableWebContentsView {
virtual void SetTitle(const base::string16& title) = 0; virtual void SetTitle(const base::string16& title) = 0;
private: private:
InspectableWebContentsViewDelegate* delegate_; // weak references. InspectableWebContentsViewDelegate* delegate_ = nullptr; // weak references.
}; };
} // namespace electron } // namespace electron

View file

@ -43,7 +43,7 @@ class TrayIconCocoa : public TrayIcon {
// Status menu shown when right-clicking the system icon. // Status menu shown when right-clicking the system icon.
base::scoped_nsobject<ElectronMenuController> menu_; base::scoped_nsobject<ElectronMenuController> menu_;
base::WeakPtrFactory<TrayIconCocoa> weak_factory_; base::WeakPtrFactory<TrayIconCocoa> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa); DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa);
}; };

View file

@ -315,7 +315,7 @@
namespace electron { namespace electron {
TrayIconCocoa::TrayIconCocoa() : weak_factory_(this) { TrayIconCocoa::TrayIconCocoa() {
status_item_view_.reset([[StatusItemView alloc] initWithIcon:this]); status_item_view_.reset([[StatusItemView alloc] initWithIcon:this]);
} }

View file

@ -31,7 +31,7 @@ void AutofillPopupChildView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
AutofillPopupView::AutofillPopupView(AutofillPopup* popup, AutofillPopupView::AutofillPopupView(AutofillPopup* popup,
views::Widget* parent_widget) views::Widget* parent_widget)
: popup_(popup), parent_widget_(parent_widget), weak_ptr_factory_(this) { : popup_(popup), parent_widget_(parent_widget) {
CreateChildViews(); CreateChildViews();
SetFocusBehavior(FocusBehavior::ALWAYS); SetFocusBehavior(FocusBehavior::ALWAYS);
set_drag_controller(this); set_drag_controller(this);

View file

@ -147,7 +147,7 @@ class AutofillPopupView : public views::WidgetDelegateView,
// key presses // key presses
content::RenderWidgetHost::KeyPressEventCallback keypress_callback_; content::RenderWidgetHost::KeyPressEventCallback keypress_callback_;
base::WeakPtrFactory<AutofillPopupView> weak_ptr_factory_; base::WeakPtrFactory<AutofillPopupView> weak_ptr_factory_{this};
}; };
} // namespace electron } // namespace electron

View file

@ -81,11 +81,7 @@ InspectableWebContentsView* CreateInspectableContentsView(
InspectableWebContentsViewViews::InspectableWebContentsViewViews( InspectableWebContentsViewViews::InspectableWebContentsViewViews(
InspectableWebContents* inspectable_web_contents) InspectableWebContents* inspectable_web_contents)
: inspectable_web_contents_(inspectable_web_contents), : inspectable_web_contents_(inspectable_web_contents),
devtools_window_web_view_(nullptr),
contents_web_view_(nullptr),
devtools_web_view_(new views::WebView(nullptr)), devtools_web_view_(new views::WebView(nullptr)),
devtools_visible_(false),
devtools_window_delegate_(nullptr),
title_(base::ASCIIToUTF16("Developer Tools")) { title_(base::ASCIIToUTF16("Developer Tools")) {
if (!inspectable_web_contents_->IsGuest() && if (!inspectable_web_contents_->IsGuest() &&
inspectable_web_contents_->GetWebContents()->GetNativeView()) { inspectable_web_contents_->GetWebContents()->GetNativeView()) {

View file

@ -55,13 +55,13 @@ class InspectableWebContentsViewViews : public InspectableWebContentsView,
InspectableWebContents* inspectable_web_contents_; InspectableWebContents* inspectable_web_contents_;
std::unique_ptr<views::Widget> devtools_window_; std::unique_ptr<views::Widget> devtools_window_;
views::WebView* devtools_window_web_view_; views::WebView* devtools_window_web_view_ = nullptr;
views::View* contents_web_view_; views::View* contents_web_view_ = nullptr;
views::WebView* devtools_web_view_; views::WebView* devtools_web_view_ = nullptr;
DevToolsContentsResizingStrategy strategy_; DevToolsContentsResizingStrategy strategy_;
bool devtools_visible_; bool devtools_visible_ = false;
views::WidgetDelegate* devtools_window_delegate_; views::WidgetDelegate* devtools_window_delegate_ = nullptr;
base::string16 title_; base::string16 title_;
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewViews); DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewViews);

View file

@ -18,8 +18,7 @@
namespace electron { namespace electron {
MenuDelegate::MenuDelegate(MenuBar* menu_bar) MenuDelegate::MenuDelegate(MenuBar* menu_bar) : menu_bar_(menu_bar) {}
: menu_bar_(menu_bar), id_(-1), hold_first_switch_(false) {}
MenuDelegate::~MenuDelegate() = default; MenuDelegate::~MenuDelegate() = default;

View file

@ -62,13 +62,13 @@ class MenuDelegate : public views::MenuDelegate {
private: private:
MenuBar* menu_bar_; MenuBar* menu_bar_;
int id_; int id_ = -1;
std::unique_ptr<views::MenuDelegate> adapter_; std::unique_ptr<views::MenuDelegate> adapter_;
std::unique_ptr<views::MenuRunner> menu_runner_; std::unique_ptr<views::MenuRunner> menu_runner_;
// The menu button to switch to. // The menu button to switch to.
views::MenuButton* button_to_open_ = nullptr; views::MenuButton* button_to_open_ = nullptr;
bool hold_first_switch_; bool hold_first_switch_ = false;
base::ObserverList<Observer>::Unchecked observers_; base::ObserverList<Observer>::Unchecked observers_;

View file

@ -105,7 +105,7 @@ file_dialog::Filters GetFileTypesFromAcceptType(
namespace electron { namespace electron {
WebDialogHelper::WebDialogHelper(NativeWindow* window, bool offscreen) WebDialogHelper::WebDialogHelper(NativeWindow* window, bool offscreen)
: window_(window), offscreen_(offscreen), weak_factory_(this) {} : window_(window), offscreen_(offscreen) {}
WebDialogHelper::~WebDialogHelper() = default; WebDialogHelper::~WebDialogHelper() = default;

View file

@ -41,7 +41,7 @@ class WebDialogHelper {
NativeWindow* window_; NativeWindow* window_;
bool offscreen_; bool offscreen_;
base::WeakPtrFactory<WebDialogHelper> weak_factory_; base::WeakPtrFactory<WebDialogHelper> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(WebDialogHelper); DISALLOW_COPY_AND_ASSIGN(WebDialogHelper);
}; };

View file

@ -8,15 +8,15 @@
namespace electron { namespace electron {
ScopedHString::ScopedHString(const wchar_t* source) : str_(nullptr) { ScopedHString::ScopedHString(const wchar_t* source) {
Reset(source); Reset(source);
} }
ScopedHString::ScopedHString(const std::wstring& source) : str_(nullptr) { ScopedHString::ScopedHString(const std::wstring& source) {
Reset(source); Reset(source);
} }
ScopedHString::ScopedHString() : str_(nullptr) {} ScopedHString::ScopedHString() {}
ScopedHString::~ScopedHString() { ScopedHString::~ScopedHString() {
Reset(); Reset();

View file

@ -35,7 +35,7 @@ class ScopedHString {
bool success() const { return str_; } bool success() const { return str_; }
private: private:
HSTRING str_; HSTRING str_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ScopedHString); DISALLOW_COPY_AND_ASSIGN(ScopedHString);
}; };

View file

@ -45,7 +45,7 @@ void ZoomLevelDelegate::RegisterPrefs(PrefRegistrySimple* registry) {
ZoomLevelDelegate::ZoomLevelDelegate(PrefService* pref_service, ZoomLevelDelegate::ZoomLevelDelegate(PrefService* pref_service,
const base::FilePath& partition_path) const base::FilePath& partition_path)
: pref_service_(pref_service), host_zoom_map_(nullptr) { : pref_service_(pref_service) {
DCHECK(pref_service_); DCHECK(pref_service_);
partition_key_ = GetHash(partition_path); partition_key_ = GetHash(partition_path);
} }

View file

@ -52,7 +52,7 @@ class ZoomLevelDelegate : public content::ZoomLevelDelegate {
void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
PrefService* pref_service_; PrefService* pref_service_;
content::HostZoomMap* host_zoom_map_; content::HostZoomMap* host_zoom_map_ = nullptr;
base::CallbackListSubscription zoom_subscription_; base::CallbackListSubscription zoom_subscription_;
std::string partition_key_; std::string partition_key_;

View file

@ -11,7 +11,7 @@ namespace electron {
ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate, ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate,
v8::Local<v8::Object> target) v8::Local<v8::Object> target)
: target_(isolate, target), weak_ptr_factory_(this) { : target_(isolate, target) {
target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter); target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter);
} }

View file

@ -24,7 +24,7 @@ class ObjectLifeMonitor {
v8::Global<v8::Object> target_; v8::Global<v8::Object> target_;
base::WeakPtrFactory<ObjectLifeMonitor> weak_ptr_factory_; base::WeakPtrFactory<ObjectLifeMonitor> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ObjectLifeMonitor); DISALLOW_COPY_AND_ASSIGN(ObjectLifeMonitor);
}; };

View file

@ -31,7 +31,7 @@ class IDUserData : public base::SupportsUserData::Data {
} // namespace } // namespace
TrackableObjectBase::TrackableObjectBase() : weak_factory_(this) { TrackableObjectBase::TrackableObjectBase() {
// TODO(zcbenz): Make TrackedObject work in renderer process. // TODO(zcbenz): Make TrackedObject work in renderer process.
DCHECK(gin_helper::Locker::IsBrowserProcess()) DCHECK(gin_helper::Locker::IsBrowserProcess())
<< "This class only works for browser process"; << "This class only works for browser process";

View file

@ -43,7 +43,7 @@ class TrackableObjectBase {
private: private:
void Destroy(); void Destroy();
base::WeakPtrFactory<TrackableObjectBase> weak_factory_; base::WeakPtrFactory<TrackableObjectBase> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(TrackableObjectBase); DISALLOW_COPY_AND_ASSIGN(TrackableObjectBase);
}; };

View file

@ -302,7 +302,7 @@ base::FilePath GetResourcesPath() {
} // namespace } // namespace
NodeBindings::NodeBindings(BrowserEnvironment browser_env) NodeBindings::NodeBindings(BrowserEnvironment browser_env)
: browser_env_(browser_env), weak_factory_(this) { : browser_env_(browser_env) {
if (browser_env == BrowserEnvironment::kWorker) { if (browser_env == BrowserEnvironment::kWorker) {
uv_loop_init(&worker_loop_); uv_loop_init(&worker_loop_);
uv_loop_ = &worker_loop_; uv_loop_ = &worker_loop_;

View file

@ -159,7 +159,7 @@ class NodeBindings {
// Isolate data used in creating the environment // Isolate data used in creating the environment
node::IsolateData* isolate_data_ = nullptr; node::IsolateData* isolate_data_ = nullptr;
base::WeakPtrFactory<NodeBindings> weak_factory_; base::WeakPtrFactory<NodeBindings> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NodeBindings); DISALLOW_COPY_AND_ASSIGN(NodeBindings);
}; };

View file

@ -73,8 +73,7 @@ class SpellCheckClient::SpellcheckRequest {
SpellCheckClient::SpellCheckClient(const std::string& language, SpellCheckClient::SpellCheckClient(const std::string& language,
v8::Isolate* isolate, v8::Isolate* isolate,
v8::Local<v8::Object> provider) v8::Local<v8::Object> provider)
: pending_request_param_(nullptr), : isolate_(isolate),
isolate_(isolate),
context_(isolate, isolate->GetCurrentContext()), context_(isolate, isolate->GetCurrentContext()),
provider_(isolate, provider) { provider_(isolate, provider) {
DCHECK(!context_.IsEmpty()); DCHECK(!context_.IsEmpty());

View file

@ -104,8 +104,7 @@ ElectronApiServiceImpl::ElectronApiServiceImpl(
content::RenderFrame* render_frame, content::RenderFrame* render_frame,
RendererClientBase* renderer_client) RendererClientBase* renderer_client)
: content::RenderFrameObserver(render_frame), : content::RenderFrameObserver(render_frame),
renderer_client_(renderer_client), renderer_client_(renderer_client) {}
weak_factory_(this) {}
void ElectronApiServiceImpl::BindTo( void ElectronApiServiceImpl::BindTo(
mojo::PendingAssociatedReceiver<mojom::ElectronRenderer> receiver) { mojo::PendingAssociatedReceiver<mojom::ElectronRenderer> receiver) {

View file

@ -57,7 +57,7 @@ class ElectronApiServiceImpl : public mojom::ElectronRenderer,
mojo::AssociatedReceiver<mojom::ElectronRenderer> receiver_{this}; mojo::AssociatedReceiver<mojom::ElectronRenderer> receiver_{this};
RendererClientBase* renderer_client_; RendererClientBase* renderer_client_;
base::WeakPtrFactory<ElectronApiServiceImpl> weak_factory_; base::WeakPtrFactory<ElectronApiServiceImpl> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ElectronApiServiceImpl); DISALLOW_COPY_AND_ASSIGN(ElectronApiServiceImpl);
}; };

View file

@ -51,7 +51,7 @@ void TrimStringVectorForIPC(std::vector<base::string16>* strings) {
AutofillAgent::AutofillAgent(content::RenderFrame* frame, AutofillAgent::AutofillAgent(content::RenderFrame* frame,
blink::AssociatedInterfaceRegistry* registry) blink::AssociatedInterfaceRegistry* registry)
: content::RenderFrameObserver(frame), weak_ptr_factory_(this) { : content::RenderFrameObserver(frame) {
render_frame()->GetWebFrame()->SetAutofillClient(this); render_frame()->GetWebFrame()->SetAutofillClient(this);
registry->AddInterface(base::BindRepeating(&AutofillAgent::BindReceiver, registry->AddInterface(base::BindRepeating(&AutofillAgent::BindReceiver,
base::Unretained(this))); base::Unretained(this)));

View file

@ -84,7 +84,7 @@ class AutofillAgent : public content::RenderFrameObserver,
mojo::AssociatedReceiver<mojom::ElectronAutofillAgent> receiver_{this}; mojo::AssociatedReceiver<mojom::ElectronAutofillAgent> receiver_{this};
base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(AutofillAgent); DISALLOW_COPY_AND_ASSIGN(AutofillAgent);
}; };

View file

@ -22,8 +22,7 @@ static base::LazyInstance<GuestViewContainerMap>::DestructorAtExit
} // namespace } // namespace
GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame) GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame) {}
: weak_ptr_factory_(this) {}
GuestViewContainer::~GuestViewContainer() { GuestViewContainer::~GuestViewContainer() {
if (element_instance_id_ > 0) if (element_instance_id_ > 0)

View file

@ -32,7 +32,7 @@ class GuestViewContainer {
ResizeCallback element_resize_callback_; ResizeCallback element_resize_callback_;
base::WeakPtrFactory<GuestViewContainer> weak_ptr_factory_; base::WeakPtrFactory<GuestViewContainer> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); DISALLOW_COPY_AND_ASSIGN(GuestViewContainer);
}; };

View file

@ -77,8 +77,7 @@ auto RunProxyResolver(
} // namespace } // namespace
ElectronContentUtilityClient::ElectronContentUtilityClient() ElectronContentUtilityClient::ElectronContentUtilityClient() {
: utility_process_running_elevated_(false) {
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && defined(OS_WIN) #if BUILDFLAG(ENABLE_PRINT_PREVIEW) && defined(OS_WIN)
printing_handler_ = std::make_unique<printing::PrintingHandler>(); printing_handler_ = std::make_unique<printing::PrintingHandler>();
#endif #endif

View file

@ -40,7 +40,7 @@ class ElectronContentUtilityClient : public content::ContentUtilityClient {
#endif #endif
// True if the utility process runs with elevated privileges. // True if the utility process runs with elevated privileges.
bool utility_process_running_elevated_; bool utility_process_running_elevated_ = false;
DISALLOW_COPY_AND_ASSIGN(ElectronContentUtilityClient); DISALLOW_COPY_AND_ASSIGN(ElectronContentUtilityClient);
}; };