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

@ -158,7 +158,7 @@ namespace gtkui {
AppIndicatorIcon::AppIndicatorIcon(std::string id,
const gfx::ImageSkia& image,
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());
desktop_env_ = base::nix::GetDesktopEnvironment(env.get());

View file

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

View file

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

View file

@ -54,16 +54,16 @@ class AppIndicatorIconMenu {
ui::MenuModel* menu_model_;
// 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
// menu item from |menu_model_| is activated, MenuModel::ActivatedAt() is
// invoked and is assumed to do any necessary processing.
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);
};

View file

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

View file

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

View file

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

View file

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

View file

@ -315,7 +315,7 @@
namespace electron {
TrayIconCocoa::TrayIconCocoa() : weak_factory_(this) {
TrayIconCocoa::TrayIconCocoa() {
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,
views::Widget* parent_widget)
: popup_(popup), parent_widget_(parent_widget), weak_ptr_factory_(this) {
: popup_(popup), parent_widget_(parent_widget) {
CreateChildViews();
SetFocusBehavior(FocusBehavior::ALWAYS);
set_drag_controller(this);

View file

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

View file

@ -81,11 +81,7 @@ InspectableWebContentsView* CreateInspectableContentsView(
InspectableWebContentsViewViews::InspectableWebContentsViewViews(
InspectableWebContents* 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_visible_(false),
devtools_window_delegate_(nullptr),
title_(base::ASCIIToUTF16("Developer Tools")) {
if (!inspectable_web_contents_->IsGuest() &&
inspectable_web_contents_->GetWebContents()->GetNativeView()) {

View file

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

View file

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

View file

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