From 2337237d5833e46a1dbd2dbcb91f017d228ddcb4 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Tue, 22 May 2018 00:18:38 +0200 Subject: [PATCH] Refactoring: use C++11 class member variable initialization --- atom/browser/api/atom_api_browser_view.cc | 3 +- atom/browser/api/atom_api_browser_view.h | 2 +- atom/browser/api/atom_api_debugger.cc | 2 +- atom/browser/api/atom_api_debugger.h | 2 +- atom/browser/api/atom_api_menu.cc | 2 +- atom/browser/api/atom_api_menu.h | 2 +- atom/browser/api/atom_api_web_contents.cc | 17 ++--------- atom/browser/api/atom_api_web_contents.h | 12 ++++---- atom/browser/api/event.cc | 2 +- atom/browser/api/event.h | 4 +-- atom/browser/api/trackable_object.cc | 7 ++--- atom/browser/api/trackable_object.h | 2 +- atom/browser/atom_browser_client.cc | 2 +- atom/browser/atom_browser_client.h | 2 +- atom/browser/atom_browser_main_parts.cc | 1 - atom/browser/atom_browser_main_parts.h | 2 +- atom/browser/browser.cc | 10 ++----- atom/browser/browser.h | 8 ++--- atom/browser/common_web_contents_delegate.cc | 6 +--- atom/browser/common_web_contents_delegate.h | 8 ++--- atom/browser/lib/bluetooth_chooser.cc | 4 +-- atom/browser/lib/bluetooth_chooser.h | 2 +- atom/browser/login_handler.cc | 6 +--- atom/browser/login_handler.h | 8 ++--- atom/browser/native_window.cc | 14 +-------- atom/browser/native_window.h | 22 +++++++------- atom/browser/native_window_mac.h | 24 +++++++-------- atom/browser/native_window_mac.mm | 12 +------- atom/browser/native_window_views.cc | 14 +-------- atom/browser/native_window_views.h | 21 +++++++------- atom/browser/net/asar/url_request_asar_job.cc | 13 +-------- atom/browser/net/asar/url_request_asar_job.h | 18 +++++------- atom/browser/net/atom_cert_verifier.cc | 9 ++---- atom/browser/net/atom_url_request.cc | 1 - atom/browser/net/atom_url_request.h | 2 +- atom/browser/net/url_request_fetch_job.cc | 9 ++---- atom/browser/net/url_request_fetch_job.h | 4 +-- atom/browser/net/url_request_stream_job.cc | 5 ---- atom/browser/net/url_request_stream_job.h | 6 ++-- atom/browser/osr/osr_output_device.cc | 2 +- atom/browser/osr/osr_output_device.h | 2 +- .../osr/osr_render_widget_host_view.cc | 19 ++---------- .../browser/osr/osr_render_widget_host_view.h | 29 ++++++++++--------- atom/browser/osr/osr_view_proxy.cc | 3 +- atom/browser/osr/osr_view_proxy.h | 2 +- atom/browser/osr/osr_web_contents_view.cc | 6 +--- atom/browser/osr/osr_web_contents_view.h | 6 ++-- atom/browser/render_process_preferences.cc | 2 +- atom/browser/render_process_preferences.h | 4 +-- atom/browser/ui/message_box_gtk.cc | 5 ++-- atom/browser/ui/tray_icon_cocoa.h | 2 +- atom/browser/ui/tray_icon_cocoa.mm | 8 +++-- atom/browser/ui/views/autofill_popup_view.cc | 7 +---- atom/browser/ui/views/frameless_view.cc | 2 +- atom/browser/ui/views/frameless_view.h | 4 +-- atom/browser/ui/views/global_menu_bar_x11.cc | 3 +- atom/browser/ui/views/global_menu_bar_x11.h | 2 +- atom/browser/ui/views/menu_bar.cc | 2 +- atom/browser/ui/views/menu_bar.h | 4 +-- atom/browser/ui/views/submenu_button.cc | 7 ----- atom/browser/ui/views/submenu_button.h | 14 ++++----- atom/browser/ui/webui/pdf_viewer_handler.cc | 2 +- atom/browser/ui/webui/pdf_viewer_handler.h | 2 +- atom/browser/ui/win/notify_icon.cc | 6 +--- atom/browser/ui/win/notify_icon.h | 2 +- atom/browser/ui/win/notify_icon_host.cc | 3 +- atom/browser/ui/win/notify_icon_host.h | 10 +++---- atom/browser/ui/win/taskbar_host.cc | 2 +- atom/browser/ui/win/taskbar_host.h | 2 +- atom/browser/ui/x/window_state_watcher.cc | 5 +--- atom/browser/ui/x/window_state_watcher.h | 4 +-- atom/browser/web_contents_zoom_controller.cc | 7 +---- atom/browser/web_contents_zoom_controller.h | 13 ++++----- atom/browser/web_view_guest_delegate.cc | 8 +---- atom/browser/web_view_guest_delegate.h | 12 ++++---- atom/common/asar/archive.cc | 4 +-- atom/common/asar/archive.h | 4 +-- .../crash_reporter/crash_reporter_linux.cc | 3 +- .../crash_reporter/crash_reporter_linux.h | 6 ++-- .../crash_reporter/crash_reporter_win.cc | 3 +- .../crash_reporter/crash_reporter_win.h | 4 +-- .../linux/crash_dump_handler.cc | 6 ++-- .../crash_reporter/win/crash_service.cc | 8 +---- .../common/crash_reporter/win/crash_service.h | 12 ++++---- .../v8_value_converter.cc | 6 +--- .../v8_value_converter.h | 8 ++--- atom/common/node_bindings.cc | 5 +--- atom/common/node_bindings.h | 4 +-- atom/renderer/atom_autofill_agent.cc | 5 +--- atom/renderer/atom_autofill_agent.h | 4 +-- atom/renderer/atom_render_frame_observer.cc | 3 +- atom/renderer/atom_render_frame_observer.h | 2 +- atom/renderer/atom_renderer_client.cc | 3 +- atom/renderer/atom_renderer_client.h | 2 +- 94 files changed, 218 insertions(+), 377 deletions(-) diff --git a/atom/browser/api/atom_api_browser_view.cc b/atom/browser/api/atom_api_browser_view.cc index 9c90426b969..bd83208694c 100644 --- a/atom/browser/api/atom_api_browser_view.cc +++ b/atom/browser/api/atom_api_browser_view.cc @@ -51,8 +51,7 @@ namespace api { BrowserView::BrowserView(v8::Isolate* isolate, v8::Local wrapper, - const mate::Dictionary& options) - : api_web_contents_(nullptr) { + const mate::Dictionary& options) { Init(isolate, wrapper, options); } diff --git a/atom/browser/api/atom_api_browser_view.h b/atom/browser/api/atom_api_browser_view.h index f6f45c5dbbd..da99c5175b8 100644 --- a/atom/browser/api/atom_api_browser_view.h +++ b/atom/browser/api/atom_api_browser_view.h @@ -59,7 +59,7 @@ class BrowserView : public mate::TrackableObject { v8::Local GetWebContents(); v8::Global web_contents_; - class WebContents* api_web_contents_; + class WebContents* api_web_contents_ = nullptr; std::unique_ptr view_; diff --git a/atom/browser/api/atom_api_debugger.cc b/atom/browser/api/atom_api_debugger.cc index 6307b37f9ef..ff7eb3eee23 100644 --- a/atom/browser/api/atom_api_debugger.cc +++ b/atom/browser/api/atom_api_debugger.cc @@ -26,7 +26,7 @@ namespace atom { namespace api { Debugger::Debugger(v8::Isolate* isolate, content::WebContents* web_contents) - : web_contents_(web_contents), previous_request_id_(0) { + : web_contents_(web_contents) { Init(isolate); } diff --git a/atom/browser/api/atom_api_debugger.h b/atom/browser/api/atom_api_debugger.h index 7441fac7974..810d00572ef 100644 --- a/atom/browser/api/atom_api_debugger.h +++ b/atom/browser/api/atom_api_debugger.h @@ -63,7 +63,7 @@ class Debugger : public mate::TrackableObject, scoped_refptr agent_host_; PendingRequestMap pending_requests_; - int previous_request_id_; + int previous_request_id_ = 0; DISALLOW_COPY_AND_ASSIGN(Debugger); }; diff --git a/atom/browser/api/atom_api_menu.cc b/atom/browser/api/atom_api_menu.cc index b259c2f23a0..1c4f4fcf41e 100644 --- a/atom/browser/api/atom_api_menu.cc +++ b/atom/browser/api/atom_api_menu.cc @@ -20,7 +20,7 @@ namespace atom { namespace api { Menu::Menu(v8::Isolate* isolate, v8::Local wrapper) - : model_(new AtomMenuModel(this)), parent_(nullptr) { + : model_(new AtomMenuModel(this)) { InitWith(isolate, wrapper); model_->AddObserver(this); } diff --git a/atom/browser/api/atom_api_menu.h b/atom/browser/api/atom_api_menu.h index 53c7927689a..26f2b679b6b 100644 --- a/atom/browser/api/atom_api_menu.h +++ b/atom/browser/api/atom_api_menu.h @@ -62,7 +62,7 @@ class Menu : public mate::TrackableObject, virtual void ClosePopupAt(int32_t window_id) = 0; std::unique_ptr model_; - Menu* parent_; + Menu* parent_ = nullptr; // Observable: void OnMenuWillClose() override; diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index c79f18d7f1c..7a578e153cb 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -336,13 +336,7 @@ struct WebContents::FrameDispatchHelper { WebContents::WebContents(v8::Isolate* isolate, content::WebContents* web_contents, Type type) - : content::WebContentsObserver(web_contents), - embedder_(nullptr), - zoom_controller_(nullptr), - type_(type), - request_id_(0), - background_throttling_(true), - enable_devtools_(true) { + : content::WebContentsObserver(web_contents), type_(type) { const mate::Dictionary options = mate::Dictionary::CreateEmpty(isolate); if (type == REMOTE) { web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent()); @@ -356,13 +350,8 @@ WebContents::WebContents(v8::Isolate* isolate, } } -WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options) - : embedder_(nullptr), - zoom_controller_(nullptr), - type_(BROWSER_WINDOW), - request_id_(0), - background_throttling_(true), - enable_devtools_(true) { +WebContents::WebContents(v8::Isolate* isolate, + const mate::Dictionary& options) { // Read options. options.Get("backgroundThrottling", &background_throttling_); diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 84c4e3eccba..af214562f5a 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -437,22 +437,22 @@ class WebContents : public mate::TrackableObject, std::unique_ptr guest_delegate_; // The host webcontents that may contain this webcontents. - WebContents* embedder_; + WebContents* embedder_ = nullptr; // The zoom controller for this webContents. - WebContentsZoomController* zoom_controller_; + WebContentsZoomController* zoom_controller_ = nullptr; // The type of current WebContents. - Type type_; + Type type_ = BROWSER_WINDOW; // Request id used for findInPage request. - uint32_t request_id_; + uint32_t request_id_ = 0; // Whether background throttling is disabled. - bool background_throttling_; + bool background_throttling_ = true; // Whether to enable devtools. - bool enable_devtools_; + bool enable_devtools_ = true; // Observers of this WebContents. base::ObserverList observers_; diff --git a/atom/browser/api/event.cc b/atom/browser/api/event.cc index d5e390f0598..c5465716892 100644 --- a/atom/browser/api/event.cc +++ b/atom/browser/api/event.cc @@ -12,7 +12,7 @@ namespace mate { -Event::Event(v8::Isolate* isolate) : sender_(nullptr), message_(nullptr) { +Event::Event(v8::Isolate* isolate) { Init(isolate); } diff --git a/atom/browser/api/event.h b/atom/browser/api/event.h index 10b14c190ab..d4fee5ae237 100644 --- a/atom/browser/api/event.h +++ b/atom/browser/api/event.h @@ -44,8 +44,8 @@ class Event : public Wrappable, public content::WebContentsObserver { private: // Replyer for the synchronous messages. - content::RenderFrameHost* sender_; - IPC::Message* message_; + content::RenderFrameHost* sender_ = nullptr; + IPC::Message* message_ = nullptr; DISALLOW_COPY_AND_ASSIGN(Event); }; diff --git a/atom/browser/api/trackable_object.cc b/atom/browser/api/trackable_object.cc index 7e22aa0c1da..7955ddefcab 100644 --- a/atom/browser/api/trackable_object.cc +++ b/atom/browser/api/trackable_object.cc @@ -28,8 +28,7 @@ class IDUserData : public base::SupportsUserData::Data { } // namespace -TrackableObjectBase::TrackableObjectBase() - : weak_map_id_(0), weak_factory_(this) { +TrackableObjectBase::TrackableObjectBase() : weak_factory_(this) { atom::AtomBrowserMainParts::Get()->RegisterDestructionCallback( GetDestroyClosure()); } @@ -54,8 +53,8 @@ void TrackableObjectBase::AttachAsUserData(base::SupportsUserData* wrapped) { int32_t TrackableObjectBase::GetIDFromWrappedClass( base::SupportsUserData* wrapped) { if (wrapped) { - auto* id = static_cast( - wrapped->GetUserData(kTrackedObjectKey)); + auto* id = + static_cast(wrapped->GetUserData(kTrackedObjectKey)); if (id) return *id; } diff --git a/atom/browser/api/trackable_object.h b/atom/browser/api/trackable_object.h index 2851902a3dd..f0fd86d344c 100644 --- a/atom/browser/api/trackable_object.h +++ b/atom/browser/api/trackable_object.h @@ -39,7 +39,7 @@ class TrackableObjectBase { // Returns a closure that can destroy the native class. base::OnceClosure GetDestroyClosure(); - int32_t weak_map_id_; + int32_t weak_map_id_ = 0; private: void Destroy(); diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index d653c6deb61..32c8d3dd802 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -88,7 +88,7 @@ void AtomBrowserClient::SetCustomServiceWorkerSchemes( g_custom_service_worker_schemes = base::JoinString(schemes, ","); } -AtomBrowserClient::AtomBrowserClient() : delegate_(nullptr) {} +AtomBrowserClient::AtomBrowserClient() {} AtomBrowserClient::~AtomBrowserClient() {} diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index abb592cc90c..c7bbc883754 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -147,7 +147,7 @@ class AtomBrowserClient : public brightray::BrowserClient, std::unique_ptr resource_dispatcher_host_delegate_; - Delegate* delegate_; + Delegate* delegate_ = nullptr; DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient); }; diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 6c071a318b5..6b19e7e0d15 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -76,7 +76,6 @@ AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr; AtomBrowserMainParts::AtomBrowserMainParts() : fake_browser_process_(new BrowserProcess), - exit_code_(nullptr), browser_(new Browser), node_bindings_(NodeBindings::Create(NodeBindings::BROWSER)), atom_bindings_(new AtomBindings(uv_default_loop())), diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index 129ad2d8687..3e09ab28e5b 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -94,7 +94,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { scoped_refptr bridge_task_runner_; // Pointer to exit code. - int* exit_code_; + int* exit_code_ = nullptr; std::unique_ptr browser_; std::unique_ptr js_env_; diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 56ebc638d38..2897b115725 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -23,14 +23,10 @@ namespace atom { Browser::LoginItemSettings::LoginItemSettings() = default; Browser::LoginItemSettings::~LoginItemSettings() = default; -Browser::LoginItemSettings::LoginItemSettings( - const LoginItemSettings& other) = default; +Browser::LoginItemSettings::LoginItemSettings(const LoginItemSettings& other) = + default; -Browser::Browser() - : is_quiting_(false), - is_exiting_(false), - is_ready_(false), - is_shutdown_(false) { +Browser::Browser() { WindowList::AddObserver(this); } diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 87774c5bd91..246f8a8645d 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -254,7 +254,7 @@ class Browser : public WindowListObserver { // Send the before-quit message and start closing windows. bool HandleBeforeQuit(); - bool is_quiting_; + bool is_quiting_ = false; private: // WindowListObserver implementations: @@ -265,13 +265,13 @@ class Browser : public WindowListObserver { base::ObserverList observers_; // Whether `app.exit()` has been called - bool is_exiting_; + bool is_exiting_ = false; // Whether "ready" event has been emitted. - bool is_ready_; + bool is_ready_ = false; // The browser is being shutdown. - bool is_shutdown_; + bool is_shutdown_ = false; int badge_count_ = 0; diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 62d55b8fd0f..1912f49003d 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -141,11 +141,7 @@ bool IsDevToolsFileSystemAdded(content::WebContents* web_contents, } // namespace CommonWebContentsDelegate::CommonWebContentsDelegate() - : offscreen_(false), - ignore_menu_shortcuts_(false), - html_fullscreen_(false), - native_fullscreen_(false), - devtools_file_system_indexer_(new DevToolsFileSystemIndexer) {} + : devtools_file_system_indexer_(new DevToolsFileSystemIndexer) {} CommonWebContentsDelegate::~CommonWebContentsDelegate() {} diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index 597fc799c79..a977e1667dc 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -155,14 +155,14 @@ class CommonWebContentsDelegate // The window that this WebContents belongs to. base::WeakPtr owner_window_; - bool offscreen_; - bool ignore_menu_shortcuts_; + bool offscreen_ = false; + bool ignore_menu_shortcuts_ = false; // Whether window is fullscreened by HTML5 api. - bool html_fullscreen_; + bool html_fullscreen_ = false; // Whether window is fullscreened by window api. - bool native_fullscreen_; + bool native_fullscreen_ = false; // UI related helper classes. #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) diff --git a/atom/browser/lib/bluetooth_chooser.cc b/atom/browser/lib/bluetooth_chooser.cc index 5a20a57884b..cbc7b1f28dc 100644 --- a/atom/browser/lib/bluetooth_chooser.cc +++ b/atom/browser/lib/bluetooth_chooser.cc @@ -42,9 +42,7 @@ void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler, BluetoothChooser::BluetoothChooser(api::WebContents* contents, const EventHandler& event_handler) - : api_web_contents_(contents), - event_handler_(event_handler), - num_retries_(0) {} + : api_web_contents_(contents), event_handler_(event_handler) {} BluetoothChooser::~BluetoothChooser() {} diff --git a/atom/browser/lib/bluetooth_chooser.h b/atom/browser/lib/bluetooth_chooser.h index fe628ca6aab..ad23751056f 100644 --- a/atom/browser/lib/bluetooth_chooser.h +++ b/atom/browser/lib/bluetooth_chooser.h @@ -39,7 +39,7 @@ class BluetoothChooser : public content::BluetoothChooser { std::vector device_list_; api::WebContents* api_web_contents_; EventHandler event_handler_; - int num_retries_; + int num_retries_ = 0; DISALLOW_COPY_AND_ASSIGN(BluetoothChooser); }; diff --git a/atom/browser/login_handler.cc b/atom/browser/login_handler.cc index 2c1f0125925..d870c58b092 100644 --- a/atom/browser/login_handler.cc +++ b/atom/browser/login_handler.cc @@ -32,11 +32,7 @@ void ResetLoginHandlerForRequest(net::URLRequest* request) { LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info, net::URLRequest* request) - : handled_auth_(false), - auth_info_(auth_info), - request_(request), - render_process_host_id_(0), - render_frame_id_(0) { + : auth_info_(auth_info), request_(request) { content::ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame( &render_process_host_id_, &render_frame_id_); diff --git a/atom/browser/login_handler.h b/atom/browser/login_handler.h index f4cbccd7c2c..16cded48625 100644 --- a/atom/browser/login_handler.h +++ b/atom/browser/login_handler.h @@ -53,7 +53,7 @@ class LoginHandler : public content::ResourceDispatcherHostLoginDelegate { bool TestAndSetAuthHandled(); // True if we've handled auth (Login or CancelAuth has been called). - bool handled_auth_; + bool handled_auth_ = false; mutable base::Lock handled_auth_lock_; // Who/where/what asked for the authentication. @@ -61,11 +61,11 @@ class LoginHandler : public content::ResourceDispatcherHostLoginDelegate { // The request that wants login data. // This should only be accessed on the IO loop. - net::URLRequest* request_; + net::URLRequest* request_ = nullptr; // Cached from the net::URLRequest, in case it goes NULL on us. - int render_process_host_id_; - int render_frame_id_; + int render_process_host_id_ = 0; + int render_frame_id_ = 0; DISALLOW_COPY_AND_ASSIGN(LoginHandler); }; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 71e4d3164a5..4048e2a32b2 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -47,19 +47,7 @@ gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) { NativeWindow::NativeWindow(const mate::Dictionary& options, NativeWindow* parent) - : widget_(new views::Widget), - content_view_(nullptr), - has_frame_(true), - transparent_(false), - enable_larger_than_screen_(false), - is_closed_(false), - sheet_offset_x_(0.0), - sheet_offset_y_(0.0), - aspect_ratio_(0.0), - parent_(parent), - is_modal_(false), - browser_view_(nullptr), - weak_factory_(this) { + : widget_(new views::Widget), parent_(parent), weak_factory_(this) { options.Get(options::kFrame, &has_frame_); options.Get(options::kTransparent, &transparent_); options.Get(options::kEnableLargerThanScreen, &enable_larger_than_screen_); diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 123f375fe15..759d7cb2021 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -287,41 +287,41 @@ class NativeWindow : public base::SupportsUserData, std::unique_ptr widget_; // The content view, weak ref. - views::View* content_view_; + views::View* content_view_ = nullptr; // Whether window has standard frame. - bool has_frame_; + bool has_frame_ = true; // Whether window is transparent. - bool transparent_; + bool transparent_ = false; // Minimum and maximum size, stored as content size. extensions::SizeConstraints size_constraints_; // Whether window can be resized larger than screen. - bool enable_larger_than_screen_; + bool enable_larger_than_screen_ = false; // The windows has been closed. - bool is_closed_; + bool is_closed_ = false; // Used to display sheets at the appropriate horizontal and vertical offsets // on macOS. - double sheet_offset_x_; - double sheet_offset_y_; + double sheet_offset_x_ = 0.0; + double sheet_offset_y_ = 0.0; // Used to maintain the aspect ratio of a view which is inside of the // content view. - double aspect_ratio_; + double aspect_ratio_ = 0.0; gfx::Size aspect_ratio_extraSize_; // The parent window, it is guaranteed to be valid during this window's life. - NativeWindow* parent_; + NativeWindow* parent_ = nullptr; // Is this a modal window. - bool is_modal_; + bool is_modal_ = false; // The browser view layer. - NativeBrowserView* browser_view_; + NativeBrowserView* browser_view_ = nullptr; // Observers of this window. base::ObserverList observers_; diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index fcf40f5b318..dd343c6e2a2 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -173,30 +173,30 @@ class NativeWindowMac : public NativeWindow { // The view that fills the client area. std::unique_ptr root_view_; - bool is_kiosk_; - bool was_fullscreen_; - bool zoom_to_page_width_; - bool fullscreen_window_title_; - bool resizable_; + bool is_kiosk_ = false; + bool was_fullscreen_ = false; + bool zoom_to_page_width_ = false; + bool fullscreen_window_title_ = false; + bool resizable_ = true; - NSInteger attention_request_id_; // identifier from requestUserAttention + NSInteger attention_request_id_ = 0; // identifier from requestUserAttention // The presentation options before entering kiosk mode. NSApplicationPresentationOptions kiosk_options_; // The "titleBarStyle" option. - TitleBarStyle title_bar_style_; + TitleBarStyle title_bar_style_ = NORMAL; // Simple (pre-Lion) Fullscreen Settings - bool always_simple_fullscreen_; - bool is_simple_fullscreen_; - bool was_maximizable_; - bool was_movable_; + bool always_simple_fullscreen_ = false; + bool is_simple_fullscreen_ = false; + bool was_maximizable_ = false; + bool was_movable_ = false; NSRect original_frame_; NSUInteger simple_fullscreen_mask_; base::scoped_nsobject background_color_before_vibrancy_; - bool transparency_before_vibrancy_; + bool transparency_before_vibrancy_ = false; // The presentation options before entering simple fullscreen mode. NSApplicationPresentationOptions simple_fullscreen_options_; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 0797b410938..86c506d423f 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -255,17 +255,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { NativeWindowMac::NativeWindowMac(const mate::Dictionary& options, NativeWindow* parent) - : NativeWindow(options, parent), - root_view_(new RootViewMac(this)), - is_kiosk_(false), - was_fullscreen_(false), - zoom_to_page_width_(false), - fullscreen_window_title_(false), - resizable_(true), - attention_request_id_(0), - title_bar_style_(NORMAL), - always_simple_fullscreen_(false), - is_simple_fullscreen_(false) { + : NativeWindow(options, parent), root_view_(new RootViewMac(this)) { int width = 800, height = 600; options.Get(options::kWidth, &width); options.Get(options::kHeight, &height); diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 30850d09617..0c07d370237 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -102,19 +102,7 @@ NativeWindowViews::NativeWindowViews(const mate::Dictionary& options, NativeWindow* parent) : NativeWindow(options, parent), root_view_(new RootView(this)), - focused_view_(nullptr), -#if defined(OS_WIN) - checked_for_a11y_support_(false), - thick_frame_(true), -#endif - keyboard_event_handler_(new views::UnhandledKeyboardEventHandler), - disable_count_(0), - use_content_size_(false), - movable_(true), - resizable_(true), - maximizable_(true), - minimizable_(true), - fullscreenable_(true) { + keyboard_event_handler_(new views::UnhandledKeyboardEventHandler) { options.Get(options::kTitle, &title_); bool menu_bar_autohide; diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 0bfe19ced25..0ebed3cb129 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -196,7 +196,8 @@ class NativeWindowViews : public NativeWindow, std::unique_ptr root_view_; - views::View* focused_view_; // The view should be focused by default. + // The view should be focused by default. + views::View* focused_view_ = nullptr; // The "resizable" flag on Linux is implemented by setting size constraints, // we need to make sure size constraints are restored when window becomes @@ -241,10 +242,10 @@ class NativeWindowViews : public NativeWindow, TaskbarHost taskbar_host_; // Memoized version of a11y check - bool checked_for_a11y_support_; + bool checked_for_a11y_support_ = false; // Whether to show the WS_THICKFRAME style. - bool thick_frame_; + bool thick_frame_ = true; // The bounds of window before maximize/fullscreen. gfx::Rect restore_bounds_; @@ -269,14 +270,14 @@ class NativeWindowViews : public NativeWindow, std::unique_ptr draggable_region_; // used in custom drag. // How many times the Disable has been called. - int disable_count_; + int disable_count_ = 0; - bool use_content_size_; - bool movable_; - bool resizable_; - bool maximizable_; - bool minimizable_; - bool fullscreenable_; + bool use_content_size_ = false; + bool movable_ = true; + bool resizable_ = true; + bool maximizable_ = true; + bool minimizable_ = true; + bool fullscreenable_ = true; std::string title_; gfx::Size widget_size_; double opacity_ = 1.0; diff --git a/atom/browser/net/asar/url_request_asar_job.cc b/atom/browser/net/asar/url_request_asar_job.cc index 42c69ead301..1b7dd74a05f 100644 --- a/atom/browser/net/asar/url_request_asar_job.cc +++ b/atom/browser/net/asar/url_request_asar_job.cc @@ -32,20 +32,9 @@ namespace asar { -URLRequestAsarJob::FileMetaInfo::FileMetaInfo() - : file_size(0), - mime_type_result(false), - file_exists(false), - is_directory(false) {} - URLRequestAsarJob::URLRequestAsarJob(net::URLRequest* request, net::NetworkDelegate* network_delegate) - : net::URLRequestJob(request, network_delegate), - type_(TYPE_ERROR), - remaining_bytes_(0), - seek_offset_(0), - range_parse_result_(net::OK), - weak_ptr_factory_(this) {} + : net::URLRequestJob(request, network_delegate), weak_ptr_factory_(this) {} URLRequestAsarJob::~URLRequestAsarJob() {} diff --git a/atom/browser/net/asar/url_request_asar_job.h b/atom/browser/net/asar/url_request_asar_job.h index 5a8c301283f..09fc8375c57 100644 --- a/atom/browser/net/asar/url_request_asar_job.h +++ b/atom/browser/net/asar/url_request_asar_job.h @@ -74,19 +74,17 @@ class URLRequestAsarJob : public net::URLRequestJob { // URLRequestFileJob and also passed between threads because disk access is // necessary to obtain it. struct FileMetaInfo { - FileMetaInfo(); - // Size of the file. - int64_t file_size; + int64_t file_size = 0; // Mime type associated with the file. std::string mime_type; // Result returned from GetMimeTypeFromFile(), i.e. flag showing whether // obtaining of the mime type was successful. - bool mime_type_result; + bool mime_type_result = false; // Flag showing whether the file exists. - bool file_exists; + bool file_exists = false; // Flag showing whether the file name actually refers to a directory. - bool is_directory; + bool is_directory = false; // Path to the file. base::FilePath file_path; }; @@ -109,7 +107,7 @@ class URLRequestAsarJob : public net::URLRequestJob { // Callback after data is asynchronously read from the file into |buf|. void DidRead(scoped_refptr buf, int result); - JobType type_; + JobType type_ = TYPE_ERROR; std::shared_ptr archive_; base::FilePath file_path_; @@ -120,10 +118,10 @@ class URLRequestAsarJob : public net::URLRequestJob { scoped_refptr file_task_runner_; net::HttpByteRange byte_range_; - int64_t remaining_bytes_; - int64_t seek_offset_; + int64_t remaining_bytes_ = 0; + int64_t seek_offset_ = 0; - net::Error range_parse_result_; + net::Error range_parse_result_ = net::OK; base::WeakPtrFactory weak_ptr_factory_; diff --git a/atom/browser/net/atom_cert_verifier.cc b/atom/browser/net/atom_cert_verifier.cc index 2b27b8b8abe..25dd6a2792e 100644 --- a/atom/browser/net/atom_cert_verifier.cc +++ b/atom/browser/net/atom_cert_verifier.cc @@ -48,9 +48,6 @@ class CertVerifierRequest : public AtomCertVerifier::Request { AtomCertVerifier* cert_verifier) : params_(params), cert_verifier_(cert_verifier), - error_(net::ERR_IO_PENDING), - custom_response_(net::ERR_IO_PENDING), - first_response_(true), weak_ptr_factory_(this) {} ~CertVerifierRequest() override { @@ -142,9 +139,9 @@ class CertVerifierRequest : public AtomCertVerifier::Request { const AtomCertVerifier::RequestParams params_; AtomCertVerifier* cert_verifier_; - int error_; - int custom_response_; - bool first_response_; + int error_ = net::ERR_IO_PENDING; + int custom_response_ = net::ERR_IO_PENDING; + bool first_response_ = true; ResponseList response_list_; net::CertVerifyResult result_; std::unique_ptr default_verifier_request_; diff --git a/atom/browser/net/atom_url_request.cc b/atom/browser/net/atom_url_request.cc index 36d9b6df6d6..253b7558aa4 100644 --- a/atom/browser/net/atom_url_request.cc +++ b/atom/browser/net/atom_url_request.cc @@ -48,7 +48,6 @@ class UploadOwnedIOBufferElementReader : public net::UploadBytesElementReader { AtomURLRequest::AtomURLRequest(api::URLRequest* delegate) : delegate_(delegate), - is_chunked_upload_(false), response_read_buffer_(new net::IOBuffer(kBufferSize)) {} AtomURLRequest::~AtomURLRequest() { diff --git a/atom/browser/net/atom_url_request.h b/atom/browser/net/atom_url_request.h index 654798d8aac..19aaef091fe 100644 --- a/atom/browser/net/atom_url_request.h +++ b/atom/browser/net/atom_url_request.h @@ -103,7 +103,7 @@ class AtomURLRequest : public base::RefCountedThreadSafe, std::unique_ptr request_; scoped_refptr request_context_getter_; - bool is_chunked_upload_; + bool is_chunked_upload_ = false; std::string redirect_policy_; std::unique_ptr chunked_stream_; std::unique_ptr chunked_stream_writer_; diff --git a/atom/browser/net/url_request_fetch_job.cc b/atom/browser/net/url_request_fetch_job.cc index 7c858352642..5d3be1e455c 100644 --- a/atom/browser/net/url_request_fetch_job.cc +++ b/atom/browser/net/url_request_fetch_job.cc @@ -46,8 +46,7 @@ net::URLFetcher::RequestType GetRequestType(const std::string& raw) { // Pipe the response writer back to URLRequestFetchJob. class ResponsePiper : public net::URLFetcherResponseWriter { public: - explicit ResponsePiper(URLRequestFetchJob* job) - : first_write_(true), job_(job) {} + explicit ResponsePiper(URLRequestFetchJob* job) : job_(job) {} // net::URLFetcherResponseWriter: int Initialize(const net::CompletionCallback& callback) override { @@ -69,7 +68,7 @@ class ResponsePiper : public net::URLFetcherResponseWriter { } private: - bool first_write_; + bool first_write_ = true; URLRequestFetchJob* job_; DISALLOW_COPY_AND_ASSIGN(ResponsePiper); @@ -79,9 +78,7 @@ class ResponsePiper : public net::URLFetcherResponseWriter { URLRequestFetchJob::URLRequestFetchJob(net::URLRequest* request, net::NetworkDelegate* network_delegate) - : JsAsker(request, network_delegate), - pending_buffer_size_(0), - write_num_bytes_(0) {} + : JsAsker(request, network_delegate) {} URLRequestFetchJob::~URLRequestFetchJob() = default; diff --git a/atom/browser/net/url_request_fetch_job.h b/atom/browser/net/url_request_fetch_job.h index 2498c54882a..d952074b209 100644 --- a/atom/browser/net/url_request_fetch_job.h +++ b/atom/browser/net/url_request_fetch_job.h @@ -57,11 +57,11 @@ class URLRequestFetchJob : public JsAsker, // Saved arguments passed to ReadRawData. scoped_refptr pending_buffer_; - int pending_buffer_size_; + int pending_buffer_size_ = 0; // Saved arguments passed to DataAvailable. scoped_refptr write_buffer_; - int write_num_bytes_; + int write_num_bytes_ = 0; net::CompletionCallback write_callback_; DISALLOW_COPY_AND_ASSIGN(URLRequestFetchJob); diff --git a/atom/browser/net/url_request_stream_job.cc b/atom/browser/net/url_request_stream_job.cc index bb944a393ac..f52e2822df8 100644 --- a/atom/browser/net/url_request_stream_job.cc +++ b/atom/browser/net/url_request_stream_job.cc @@ -21,11 +21,6 @@ namespace atom { URLRequestStreamJob::URLRequestStreamJob(net::URLRequest* request, net::NetworkDelegate* network_delegate) : JsAsker(request, network_delegate), - ended_(false), - errored_(false), - pending_io_buf_(nullptr), - pending_io_buf_size_(0), - response_headers_(nullptr), weak_factory_(this) {} URLRequestStreamJob::~URLRequestStreamJob() = default; diff --git a/atom/browser/net/url_request_stream_job.h b/atom/browser/net/url_request_stream_job.h index 4043b09aea3..742ded7f1b9 100644 --- a/atom/browser/net/url_request_stream_job.h +++ b/atom/browser/net/url_request_stream_job.h @@ -52,10 +52,10 @@ class URLRequestStreamJob : public JsAsker { void CopyMoreDataDone(scoped_refptr io_buf, int read_count); std::deque buffer_; - bool ended_; - bool errored_; + bool ended_ = false; + bool errored_ = false; scoped_refptr pending_io_buf_; - int pending_io_buf_size_; + int pending_io_buf_size_ = 0; scoped_refptr response_headers_; mate::EventSubscriber::SafePtr subscriber_; base::WeakPtrFactory weak_factory_; diff --git a/atom/browser/osr/osr_output_device.cc b/atom/browser/osr/osr_output_device.cc index d169a567254..e5c1e7fd95f 100644 --- a/atom/browser/osr/osr_output_device.cc +++ b/atom/browser/osr/osr_output_device.cc @@ -13,7 +13,7 @@ namespace atom { OffScreenOutputDevice::OffScreenOutputDevice(bool transparent, const OnPaintCallback& callback) - : transparent_(transparent), callback_(callback), active_(false) { + : transparent_(transparent), callback_(callback) { DCHECK(!callback_.is_null()); } diff --git a/atom/browser/osr/osr_output_device.h b/atom/browser/osr/osr_output_device.h index dcdf74182fc..4c62414fd0c 100644 --- a/atom/browser/osr/osr_output_device.h +++ b/atom/browser/osr/osr_output_device.h @@ -31,7 +31,7 @@ class OffScreenOutputDevice : public viz::SoftwareOutputDevice { const bool transparent_; OnPaintCallback callback_; - bool active_; + bool active_ = false; std::unique_ptr canvas_; std::unique_ptr bitmap_; diff --git a/atom/browser/osr/osr_render_widget_host_view.cc b/atom/browser/osr/osr_render_widget_host_view.cc index 8983670377f..b2b2cec7468 100644 --- a/atom/browser/osr/osr_render_widget_host_view.cc +++ b/atom/browser/osr/osr_render_widget_host_view.cc @@ -117,8 +117,6 @@ class AtomCopyFrameGenerator { AtomCopyFrameGenerator(OffScreenRenderWidgetHostView* view, int frame_rate_threshold_us) : view_(view), - frame_retry_count_(0), - next_frame_time_(base::TimeTicks::Now()), frame_duration_( base::TimeDelta::FromMicroseconds(frame_rate_threshold_us)), weak_ptr_factory_(this) { @@ -204,8 +202,8 @@ class AtomCopyFrameGenerator { base::Time last_time_; - int frame_retry_count_; - base::TimeTicks next_frame_time_; + int frame_retry_count_ = 0; + base::TimeTicks next_frame_time_ = base::TimeTicks::Now(); base::TimeDelta frame_duration_; base::WeakPtrFactory weak_ptr_factory_; @@ -257,27 +255,14 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( NativeWindow* native_window) : render_widget_host_(content::RenderWidgetHostImpl::From(host)), parent_host_view_(parent_host_view), - popup_host_view_(nullptr), - child_host_view_(nullptr), native_window_(native_window), - software_output_device_(nullptr), transparent_(transparent), callback_(callback), - parent_callback_(nullptr), frame_rate_(frame_rate), - frame_rate_threshold_us_(0), - last_time_(base::Time::Now()), scale_factor_(kDefaultScaleFactor), size_(native_window->GetSize()), painting_(painting), is_showing_(!render_widget_host_->is_hidden()), - is_destroyed_(false), - popup_position_(gfx::Rect()), - hold_resize_(false), - pending_resize_(false), - paint_callback_running_(false), - renderer_compositor_frame_sink_(nullptr), - background_color_(SkColor()), weak_ptr_factory_(this) { DCHECK(render_widget_host_); bool is_guest_view_hack = parent_host_view_ != nullptr; diff --git a/atom/browser/osr/osr_render_widget_host_view.h b/atom/browser/osr/osr_render_widget_host_view.h index 451f58b1eaf..bba0c25c2a3 100644 --- a/atom/browser/osr/osr_render_widget_host_view.h +++ b/atom/browser/osr/osr_render_widget_host_view.h @@ -285,38 +285,38 @@ class OffScreenRenderWidgetHostView // Weak ptrs. content::RenderWidgetHostImpl* render_widget_host_; - OffScreenRenderWidgetHostView* parent_host_view_; - OffScreenRenderWidgetHostView* popup_host_view_; + OffScreenRenderWidgetHostView* parent_host_view_ = nullptr; + OffScreenRenderWidgetHostView* popup_host_view_ = nullptr; std::unique_ptr popup_bitmap_; - OffScreenRenderWidgetHostView* child_host_view_; + OffScreenRenderWidgetHostView* child_host_view_ = nullptr; std::set guest_host_views_; std::set proxy_views_; NativeWindow* native_window_; - OffScreenOutputDevice* software_output_device_; + OffScreenOutputDevice* software_output_device_ = nullptr; const bool transparent_; OnPaintCallback callback_; OnPaintCallback parent_callback_; - int frame_rate_; - int frame_rate_threshold_us_; + int frame_rate_ = 0; + int frame_rate_threshold_us_ = 0; - base::Time last_time_; + base::Time last_time_ = base::Time::Now(); float scale_factor_; gfx::Vector2dF last_scroll_offset_; gfx::Size size_; bool painting_; - bool is_showing_; - bool is_destroyed_; + bool is_showing_ = false; + bool is_destroyed_ = false; gfx::Rect popup_position_; - bool hold_resize_; - bool pending_resize_; + bool hold_resize_ = false; + bool pending_resize_ = false; - bool paint_callback_running_; + bool paint_callback_running_ = false; viz::LocalSurfaceId local_surface_id_; viz::LocalSurfaceIdAllocator local_surface_id_allocator_; @@ -344,9 +344,10 @@ class OffScreenRenderWidgetHostView std::string selected_text_; #endif - viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_; + viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_ = + nullptr; - SkColor background_color_; + SkColor background_color_ = SkColor(); base::WeakPtrFactory weak_ptr_factory_; diff --git a/atom/browser/osr/osr_view_proxy.cc b/atom/browser/osr/osr_view_proxy.cc index 21f64e481b4..485e6193f7f 100644 --- a/atom/browser/osr/osr_view_proxy.cc +++ b/atom/browser/osr/osr_view_proxy.cc @@ -6,8 +6,7 @@ namespace atom { -OffscreenViewProxy::OffscreenViewProxy(views::View* view) - : view_(view), observer_(nullptr) { +OffscreenViewProxy::OffscreenViewProxy(views::View* view) : view_(view) { view_bitmap_.reset(new SkBitmap); } diff --git a/atom/browser/osr/osr_view_proxy.h b/atom/browser/osr/osr_view_proxy.h index 47f001ef5ce..02c491ed609 100644 --- a/atom/browser/osr/osr_view_proxy.h +++ b/atom/browser/osr/osr_view_proxy.h @@ -46,7 +46,7 @@ class OffscreenViewProxy { gfx::Rect view_bounds_; std::unique_ptr view_bitmap_; - OffscreenViewProxyObserver* observer_; + OffscreenViewProxyObserver* observer_ = nullptr; }; } // namespace atom diff --git a/atom/browser/osr/osr_web_contents_view.cc b/atom/browser/osr/osr_web_contents_view.cc index 02ba64f514e..f02ecb3cb06 100644 --- a/atom/browser/osr/osr_web_contents_view.cc +++ b/atom/browser/osr/osr_web_contents_view.cc @@ -15,11 +15,7 @@ namespace atom { OffScreenWebContentsView::OffScreenWebContentsView( bool transparent, const OnPaintCallback& callback) - : transparent_(transparent), - painting_(true), - frame_rate_(60), - callback_(callback), - web_contents_(nullptr) { + : transparent_(transparent), callback_(callback) { #if defined(OS_MACOSX) PlatformCreate(); #endif diff --git a/atom/browser/osr/osr_web_contents_view.h b/atom/browser/osr/osr_web_contents_view.h index fd9caacde09..5801c82cad5 100644 --- a/atom/browser/osr/osr_web_contents_view.h +++ b/atom/browser/osr/osr_web_contents_view.h @@ -83,12 +83,12 @@ class OffScreenWebContentsView : public content::WebContentsView, OffScreenRenderWidgetHostView* GetView() const; const bool transparent_; - bool painting_; - int frame_rate_; + bool painting_ = true; + int frame_rate_ = 60; OnPaintCallback callback_; // Weak refs. - content::WebContents* web_contents_; + content::WebContents* web_contents_ = nullptr; #if defined(OS_MACOSX) OffScreenView* offScreenView_; diff --git a/atom/browser/render_process_preferences.cc b/atom/browser/render_process_preferences.cc index 934417fe274..1d111817766 100644 --- a/atom/browser/render_process_preferences.cc +++ b/atom/browser/render_process_preferences.cc @@ -12,7 +12,7 @@ namespace atom { RenderProcessPreferences::RenderProcessPreferences(const Predicate& predicate) - : predicate_(predicate), next_id_(0), cache_needs_update_(true) { + : predicate_(predicate) { registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, content::NotificationService::AllBrowserContextsAndSources()); } diff --git a/atom/browser/render_process_preferences.h b/atom/browser/render_process_preferences.h index c84a30f8450..61e40324c62 100644 --- a/atom/browser/render_process_preferences.h +++ b/atom/browser/render_process_preferences.h @@ -45,12 +45,12 @@ class RenderProcessPreferences : public content::NotificationObserver { Predicate predicate_; - int next_id_; + int next_id_ = 0; std::unordered_map> entries_; // We need to convert the |entries_| to ListValue for multiple times, this // caches is only updated when we are sending messages. - bool cache_needs_update_; + bool cache_needs_update_ = true; base::ListValue cached_entries_; DISALLOW_COPY_AND_ASSIGN(RenderProcessPreferences); diff --git a/atom/browser/ui/message_box_gtk.cc b/atom/browser/ui/message_box_gtk.cc index 89fcf45e7e1..1a5e4587de9 100644 --- a/atom/browser/ui/message_box_gtk.cc +++ b/atom/browser/ui/message_box_gtk.cc @@ -42,7 +42,6 @@ class GtkMessageBox : public NativeWindowObserver { const std::string& checkbox_label, bool checkbox_checked) : cancel_id_(cancel_id), - checkbox_checked_(false), parent_(static_cast(parent_window)) { // Create dialog. dialog_ = @@ -160,9 +159,9 @@ class GtkMessageBox : public NativeWindowObserver { atom::UnresponsiveSuppressor unresponsive_suppressor_; // The id to return when the dialog is closed without pressing buttons. - int cancel_id_; + int cancel_id_ = 0; - bool checkbox_checked_; + bool checkbox_checked_ = false; NativeWindow* parent_; GtkWidget* dialog_; diff --git a/atom/browser/ui/tray_icon_cocoa.h b/atom/browser/ui/tray_icon_cocoa.h index 0208b189801..34ace850a79 100644 --- a/atom/browser/ui/tray_icon_cocoa.h +++ b/atom/browser/ui/tray_icon_cocoa.h @@ -46,7 +46,7 @@ class TrayIconCocoa : public TrayIcon, public AtomMenuModel::Observer { base::scoped_nsobject menu_; // Used for unregistering observer. - AtomMenuModel* menu_model_; // weak ref. + AtomMenuModel* menu_model_ = nullptr; // weak ref. DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa); }; diff --git a/atom/browser/ui/tray_icon_cocoa.mm b/atom/browser/ui/tray_icon_cocoa.mm index f5ad0624dff..6d0919aaadb 100644 --- a/atom/browser/ui/tray_icon_cocoa.mm +++ b/atom/browser/ui/tray_icon_cocoa.mm @@ -291,7 +291,8 @@ const CGFloat kVerticalTitleMargin = 2; // If we are ignoring double click events, we should ignore the `clickCount` // value and immediately emit a click event. - BOOL shouldBeHandledAsASingleClick = (event.clickCount == 1) || ignoreDoubleClickEvents_; + BOOL shouldBeHandledAsASingleClick = + (event.clickCount == 1) || ignoreDoubleClickEvents_; if (shouldBeHandledAsASingleClick) trayIcon_->NotifyClicked( gfx::ScreenRectFromNSRect(event.window.frame), @@ -299,7 +300,8 @@ const CGFloat kVerticalTitleMargin = 2; ui::EventFlagsFromModifiers([event modifierFlags])); // Double click event. - BOOL shouldBeHandledAsADoubleClick = (event.clickCount == 2) && !ignoreDoubleClickEvents_; + BOOL shouldBeHandledAsADoubleClick = + (event.clickCount == 2) && !ignoreDoubleClickEvents_; if (shouldBeHandledAsADoubleClick) trayIcon_->NotifyDoubleClicked( gfx::ScreenRectFromNSRect(event.window.frame), @@ -417,7 +419,7 @@ const CGFloat kVerticalTitleMargin = 2; namespace atom { -TrayIconCocoa::TrayIconCocoa() : menu_model_(nullptr) {} +TrayIconCocoa::TrayIconCocoa() {} TrayIconCocoa::~TrayIconCocoa() { [status_item_view_ removeItem]; diff --git a/atom/browser/ui/views/autofill_popup_view.cc b/atom/browser/ui/views/autofill_popup_view.cc index 5ecc3b42c21..cbb11bba855 100644 --- a/atom/browser/ui/views/autofill_popup_view.cc +++ b/atom/browser/ui/views/autofill_popup_view.cc @@ -25,12 +25,7 @@ void AutofillPopupChildView::GetAccessibleNodeData(ui::AXNodeData* node_data) { AutofillPopupView::AutofillPopupView(AutofillPopup* popup, views::Widget* parent_widget) - : popup_(popup), - parent_widget_(parent_widget), -#if defined(ENABLE_OSR) - view_proxy_(nullptr), -#endif - weak_ptr_factory_(this) { + : popup_(popup), parent_widget_(parent_widget), weak_ptr_factory_(this) { CreateChildViews(); SetFocusBehavior(FocusBehavior::ALWAYS); set_drag_controller(this); diff --git a/atom/browser/ui/views/frameless_view.cc b/atom/browser/ui/views/frameless_view.cc index 7425c8093de..8959ee13612 100644 --- a/atom/browser/ui/views/frameless_view.cc +++ b/atom/browser/ui/views/frameless_view.cc @@ -22,7 +22,7 @@ const int kResizeAreaCornerSize = 16; // static const char FramelessView::kViewClassName[] = "FramelessView"; -FramelessView::FramelessView() : window_(NULL), frame_(NULL) {} +FramelessView::FramelessView() {} FramelessView::~FramelessView() {} diff --git a/atom/browser/ui/views/frameless_view.h b/atom/browser/ui/views/frameless_view.h index 28d70e94c5e..a9d1e4b5490 100644 --- a/atom/browser/ui/views/frameless_view.h +++ b/atom/browser/ui/views/frameless_view.h @@ -45,8 +45,8 @@ class FramelessView : public views::NonClientFrameView { const char* GetClassName() const override; // Not owned. - NativeWindowViews* window_; - views::Widget* frame_; + NativeWindowViews* window_ = nullptr; + views::Widget* frame_ = nullptr; private: DISALLOW_COPY_AND_ASSIGN(FramelessView); diff --git a/atom/browser/ui/views/global_menu_bar_x11.cc b/atom/browser/ui/views/global_menu_bar_x11.cc index 4358601b591..155714c73f9 100644 --- a/atom/browser/ui/views/global_menu_bar_x11.cc +++ b/atom/browser/ui/views/global_menu_bar_x11.cc @@ -181,8 +181,7 @@ std::string GetMenuModelStatus(AtomMenuModel* model) { GlobalMenuBarX11::GlobalMenuBarX11(NativeWindowViews* window) : window_(window), - xid_(window_->GetNativeWindow()->GetHost()->GetAcceleratedWidget()), - server_(NULL) { + xid_(window_->GetNativeWindow()->GetHost()->GetAcceleratedWidget()) { EnsureMethodsLoaded(); if (server_new) InitServer(xid_); diff --git a/atom/browser/ui/views/global_menu_bar_x11.h b/atom/browser/ui/views/global_menu_bar_x11.h index 808be6e638d..dde466c94e8 100644 --- a/atom/browser/ui/views/global_menu_bar_x11.h +++ b/atom/browser/ui/views/global_menu_bar_x11.h @@ -71,7 +71,7 @@ class GlobalMenuBarX11 { NativeWindowViews* window_; gfx::AcceleratedWidget xid_; - DbusmenuServer* server_; + DbusmenuServer* server_ = nullptr; DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarX11); }; diff --git a/atom/browser/ui/views/menu_bar.cc b/atom/browser/ui/views/menu_bar.cc index 41867ac8d79..9821ccc537b 100644 --- a/atom/browser/ui/views/menu_bar.cc +++ b/atom/browser/ui/views/menu_bar.cc @@ -26,7 +26,7 @@ const SkColor kDefaultColor = SkColorSetARGB(255, 233, 233, 233); const char MenuBar::kViewClassName[] = "ElectronMenuBar"; MenuBar::MenuBar(views::View* window) - : background_color_(kDefaultColor), window_(window), menu_model_(NULL) { + : background_color_(kDefaultColor), window_(window) { RefreshColorCache(); UpdateViewColors(); SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal)); diff --git a/atom/browser/ui/views/menu_bar.h b/atom/browser/ui/views/menu_bar.h index 7ddaca3e5a7..2b10ba3e3bf 100644 --- a/atom/browser/ui/views/menu_bar.h +++ b/atom/browser/ui/views/menu_bar.h @@ -72,8 +72,8 @@ class MenuBar : public views::View, SkColor disabled_color_; #endif - views::View* window_; - AtomMenuModel* menu_model_; + views::View* window_ = nullptr; + AtomMenuModel* menu_model_ = nullptr; View* FindAccelChild(base::char16 key); diff --git a/atom/browser/ui/views/submenu_button.cc b/atom/browser/ui/views/submenu_button.cc index 28aa95bcd17..1124d3d0147 100644 --- a/atom/browser/ui/views/submenu_button.cc +++ b/atom/browser/ui/views/submenu_button.cc @@ -22,13 +22,6 @@ SubmenuButton::SubmenuButton(const base::string16& title, : views::MenuButton(gfx::RemoveAcceleratorChar(title, '&', NULL, NULL), menu_button_listener, false), - accelerator_(0), - show_underline_(false), - underline_start_(0), - underline_end_(0), - text_width_(0), - text_height_(0), - underline_color_(SK_ColorBLACK), background_color_(background_color) { #if defined(OS_LINUX) // Dont' use native style border. diff --git a/atom/browser/ui/views/submenu_button.h b/atom/browser/ui/views/submenu_button.h index 44fbda1f98f..d8b7785da13 100644 --- a/atom/browser/ui/views/submenu_button.h +++ b/atom/browser/ui/views/submenu_button.h @@ -39,15 +39,15 @@ class SubmenuButton : public views::MenuButton { int index, int* pos) const; - base::char16 accelerator_; + base::char16 accelerator_ = 0; - bool show_underline_; + bool show_underline_ = false; - int underline_start_; - int underline_end_; - int text_width_; - int text_height_; - SkColor underline_color_; + int underline_start_ = 0; + int underline_end_ = 0; + int text_width_ = 0; + int text_height_ = 0; + SkColor underline_color_ = SK_ColorBLACK; SkColor background_color_; DISALLOW_COPY_AND_ASSIGN(SubmenuButton); diff --git a/atom/browser/ui/webui/pdf_viewer_handler.cc b/atom/browser/ui/webui/pdf_viewer_handler.cc index bc106a92c43..4b63c3dc711 100644 --- a/atom/browser/ui/webui/pdf_viewer_handler.cc +++ b/atom/browser/ui/webui/pdf_viewer_handler.cc @@ -56,7 +56,7 @@ void PopulateStreamInfo(base::DictionaryValue* stream_info, } // namespace PdfViewerHandler::PdfViewerHandler(const std::string& src) - : stream_(nullptr), original_url_(src) {} + : original_url_(src) {} PdfViewerHandler::~PdfViewerHandler() { RemoveObserver(); diff --git a/atom/browser/ui/webui/pdf_viewer_handler.h b/atom/browser/ui/webui/pdf_viewer_handler.h index 81c7d98d780..8f6c333449b 100644 --- a/atom/browser/ui/webui/pdf_viewer_handler.h +++ b/atom/browser/ui/webui/pdf_viewer_handler.h @@ -53,7 +53,7 @@ class PdfViewerHandler : public content::WebUIMessageHandler, void AddObserver(); void RemoveObserver(); std::unique_ptr initialize_callback_id_; - content::StreamInfo* stream_; + content::StreamInfo* stream_ = nullptr; std::string original_url_; DISALLOW_COPY_AND_ASSIGN(PdfViewerHandler); diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index afd62f2f019..9b01de8a49f 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -19,11 +19,7 @@ namespace atom { NotifyIcon::NotifyIcon(NotifyIconHost* host, UINT id, HWND window, UINT message) - : host_(host), - icon_id_(id), - window_(window), - message_id_(message), - menu_model_(NULL) { + : host_(host), icon_id_(id), window_(window), message_id_(message) { NOTIFYICONDATA icon_data; InitIconData(&icon_data); icon_data.uFlags |= NIF_MESSAGE; diff --git a/atom/browser/ui/win/notify_icon.h b/atom/browser/ui/win/notify_icon.h index d0053ae70cb..aed548ecb61 100644 --- a/atom/browser/ui/win/notify_icon.h +++ b/atom/browser/ui/win/notify_icon.h @@ -79,7 +79,7 @@ class NotifyIcon : public TrayIcon { base::win::ScopedHICON icon_; // The context menu. - AtomMenuModel* menu_model_; + AtomMenuModel* menu_model_ = nullptr; // Context menu associated with this icon (if any). std::unique_ptr menu_runner_; diff --git a/atom/browser/ui/win/notify_icon_host.cc b/atom/browser/ui/win/notify_icon_host.cc index d056062d0ec..435ec050be4 100644 --- a/atom/browser/ui/win/notify_icon_host.cc +++ b/atom/browser/ui/win/notify_icon_host.cc @@ -47,8 +47,7 @@ int GetKeyboardModifers() { } // namespace -NotifyIconHost::NotifyIconHost() - : next_icon_id_(1), atom_(0), instance_(NULL), window_(NULL) { +NotifyIconHost::NotifyIconHost() { // Register our window class WNDCLASSEX window_class; base::win::InitializeWindowClass( diff --git a/atom/browser/ui/win/notify_icon_host.h b/atom/browser/ui/win/notify_icon_host.h index 76419a057fa..6e4dd4e5522 100644 --- a/atom/browser/ui/win/notify_icon_host.h +++ b/atom/browser/ui/win/notify_icon_host.h @@ -40,23 +40,23 @@ class NotifyIconHost { UINT NextIconId(); // The unique icon ID we will assign to the next icon. - UINT next_icon_id_; + UINT next_icon_id_ = 1; // List containing all active NotifyIcons. NotifyIcons notify_icons_; // The window class of |window_|. - ATOM atom_; + ATOM atom_ = 0; // The handle of the module that contains the window procedure of |window_|. - HMODULE instance_; + HMODULE instance_ = nullptr; // The window used for processing events. - HWND window_; + HWND window_ = nullptr; // The message ID of the "TaskbarCreated" message, sent to us when we need to // reset our status icons. - UINT taskbar_created_message_; + UINT taskbar_created_message_ = 0; DISALLOW_COPY_AND_ASSIGN(NotifyIconHost); }; diff --git a/atom/browser/ui/win/taskbar_host.cc b/atom/browser/ui/win/taskbar_host.cc index 24d038a059c..e023fdc8c83 100644 --- a/atom/browser/ui/win/taskbar_host.cc +++ b/atom/browser/ui/win/taskbar_host.cc @@ -50,7 +50,7 @@ bool GetThumbarButtonFlags(const std::vector& flags, } // namespace -TaskbarHost::TaskbarHost() : thumbar_buttons_added_(false) {} +TaskbarHost::TaskbarHost() {} TaskbarHost::~TaskbarHost() {} diff --git a/atom/browser/ui/win/taskbar_host.h b/atom/browser/ui/win/taskbar_host.h index e6b5a3e46f8..eeed3ca10e7 100644 --- a/atom/browser/ui/win/taskbar_host.h +++ b/atom/browser/ui/win/taskbar_host.h @@ -69,7 +69,7 @@ class TaskbarHost { base::win::ScopedComPtr taskbar_; // Whether we have already added the buttons to thumbar. - bool thumbar_buttons_added_; + bool thumbar_buttons_added_ = false; DISALLOW_COPY_AND_ASSIGN(TaskbarHost); }; diff --git a/atom/browser/ui/x/window_state_watcher.cc b/atom/browser/ui/x/window_state_watcher.cc index 4aec37cd6ab..fa9dddac36e 100644 --- a/atom/browser/ui/x/window_state_watcher.cc +++ b/atom/browser/ui/x/window_state_watcher.cc @@ -12,10 +12,7 @@ namespace atom { WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window) - : window_(window), - widget_(window->GetAcceleratedWidget()), - was_minimized_(false), - was_maximized_(false) { + : window_(window), widget_(window->GetAcceleratedWidget()) { ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); } diff --git a/atom/browser/ui/x/window_state_watcher.h b/atom/browser/ui/x/window_state_watcher.h index a0b0c850582..7d65b08d8bb 100644 --- a/atom/browser/ui/x/window_state_watcher.h +++ b/atom/browser/ui/x/window_state_watcher.h @@ -27,8 +27,8 @@ class WindowStateWatcher : public ui::PlatformEventObserver { NativeWindowViews* window_; gfx::AcceleratedWidget widget_; - bool was_minimized_; - bool was_maximized_; + bool was_minimized_ = false; + bool was_maximized_ = false; DISALLOW_COPY_AND_ASSIGN(WindowStateWatcher); }; diff --git a/atom/browser/web_contents_zoom_controller.cc b/atom/browser/web_contents_zoom_controller.cc index afb5b78bfaf..489321810cf 100644 --- a/atom/browser/web_contents_zoom_controller.cc +++ b/atom/browser/web_contents_zoom_controller.cc @@ -21,12 +21,7 @@ namespace atom { WebContentsZoomController::WebContentsZoomController( content::WebContents* web_contents) - : content::WebContentsObserver(web_contents), - zoom_mode_(ZOOM_MODE_DEFAULT), - zoom_level_(1.0), - old_process_id_(-1), - old_view_id_(-1), - embedder_zoom_controller_(nullptr) { + : content::WebContentsObserver(web_contents) { default_zoom_factor_ = content::kEpsilon; host_zoom_map_ = content::HostZoomMap::GetForWebContents(web_contents); } diff --git a/atom/browser/web_contents_zoom_controller.h b/atom/browser/web_contents_zoom_controller.h index 220d5c45bfa..478326f1b82 100644 --- a/atom/browser/web_contents_zoom_controller.h +++ b/atom/browser/web_contents_zoom_controller.h @@ -93,19 +93,18 @@ class WebContentsZoomController void SetZoomFactorOnNavigationIfNeeded(const GURL& url); // The current zoom mode. - ZoomMode zoom_mode_; + ZoomMode zoom_mode_ = ZOOM_MODE_DEFAULT; // Current zoom level. - double zoom_level_; + double zoom_level_ = 1.0; // kZoomFactor. - double default_zoom_factor_; - double temporary_zoom_level_; + double default_zoom_factor_ = 0; - int old_process_id_; - int old_view_id_; + int old_process_id_ = -1; + int old_view_id_ = -1; - WebContentsZoomController* embedder_zoom_controller_; + WebContentsZoomController* embedder_zoom_controller_ = nullptr; base::ObserverList observers_; diff --git a/atom/browser/web_view_guest_delegate.cc b/atom/browser/web_view_guest_delegate.cc index 8894c92fa32..f1d144bc5a0 100644 --- a/atom/browser/web_view_guest_delegate.cc +++ b/atom/browser/web_view_guest_delegate.cc @@ -26,13 +26,7 @@ const int kDefaultHeight = 300; SetSizeParams::SetSizeParams() = default; SetSizeParams::~SetSizeParams() = default; -WebViewGuestDelegate::WebViewGuestDelegate() - : embedder_zoom_controller_(nullptr), - guest_host_(nullptr), - auto_size_enabled_(false), - is_full_page_plugin_(false), - attached_(false), - api_web_contents_(nullptr) {} +WebViewGuestDelegate::WebViewGuestDelegate() {} WebViewGuestDelegate::~WebViewGuestDelegate() {} diff --git a/atom/browser/web_view_guest_delegate.h b/atom/browser/web_view_guest_delegate.h index e9850076b07..2384b0e6dd4 100644 --- a/atom/browser/web_view_guest_delegate.h +++ b/atom/browser/web_view_guest_delegate.h @@ -95,7 +95,7 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, // The zoom controller of the embedder that is used // to subscribe for zoom changes. - WebContentsZoomController* embedder_zoom_controller_; + WebContentsZoomController* embedder_zoom_controller_ = nullptr; // The size of the container element. gfx::Size element_size_; @@ -105,10 +105,10 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, gfx::Size guest_size_; // A pointer to the guest_host. - content::GuestHost* guest_host_; + content::GuestHost* guest_host_ = nullptr; // Indicates whether autosize mode is enabled or not. - bool auto_size_enabled_; + bool auto_size_enabled_ = false; // The maximum size constraints of the container element in autosize mode. gfx::Size max_auto_size_; @@ -120,12 +120,12 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, gfx::Size normal_size_; // Whether the guest view is inside a plugin document. - bool is_full_page_plugin_; + bool is_full_page_plugin_ = false; // Whether attached. - bool attached_; + bool attached_ = false; - api::WebContents* api_web_contents_; + api::WebContents* api_web_contents_ = nullptr; DISALLOW_COPY_AND_ASSIGN(WebViewGuestDelegate); }; diff --git a/atom/common/asar/archive.cc b/atom/common/asar/archive.cc index 4d5465b9c5f..ef8f0e33adb 100644 --- a/atom/common/asar/archive.cc +++ b/atom/common/asar/archive.cc @@ -117,15 +117,13 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, } // namespace Archive::Archive(const base::FilePath& path) - : path_(path), file_(base::File::FILE_OK), header_size_(0) { + : path_(path), file_(base::File::FILE_OK) { base::ThreadRestrictions::ScopedAllowIO allow_io; file_.Initialize(path_, base::File::FLAG_OPEN | base::File::FLAG_READ); #if defined(OS_WIN) fd_ = _open_osfhandle(reinterpret_cast(file_.GetPlatformFile()), 0); #elif defined(OS_POSIX) fd_ = file_.GetPlatformFile(); -#else - fd_ = -1; #endif } diff --git a/atom/common/asar/archive.h b/atom/common/asar/archive.h index a7b11c8702a..5715578ca16 100644 --- a/atom/common/asar/archive.h +++ b/atom/common/asar/archive.h @@ -70,8 +70,8 @@ class Archive { private: base::FilePath path_; base::File file_; - int fd_; - uint32_t header_size_; + int fd_ = -1; + uint32_t header_size_ = 0; std::unique_ptr header_; // Cached external temporary files. diff --git a/atom/common/crash_reporter/crash_reporter_linux.cc b/atom/common/crash_reporter/crash_reporter_linux.cc index 398613335e5..7928c64fb8d 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.cc +++ b/atom/common/crash_reporter/crash_reporter_linux.cc @@ -35,8 +35,7 @@ static const off_t kMaxMinidumpFileSize = 1258291; } // namespace -CrashReporterLinux::CrashReporterLinux() - : process_start_time_(0), pid_(getpid()), upload_to_server_(true) { +CrashReporterLinux::CrashReporterLinux() : pid_(getpid()) { // Set the base process start time value. struct timeval tv; if (!gettimeofday(&tv, NULL)) { diff --git a/atom/common/crash_reporter/crash_reporter_linux.h b/atom/common/crash_reporter/crash_reporter_linux.h index cd3e82a8051..ce9d85fa4b8 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.h +++ b/atom/common/crash_reporter/crash_reporter_linux.h @@ -54,10 +54,10 @@ class CrashReporterLinux : public CrashReporter { std::unique_ptr breakpad_; std::unique_ptr crash_keys_; - uint64_t process_start_time_; - pid_t pid_; + uint64_t process_start_time_ = 0; + pid_t pid_ = 0; std::string upload_url_; - bool upload_to_server_; + bool upload_to_server_ = true; DISALLOW_COPY_AND_ASSIGN(CrashReporterLinux); }; diff --git a/atom/common/crash_reporter/crash_reporter_win.cc b/atom/common/crash_reporter/crash_reporter_win.cc index a5510f6430b..c574da71c9d 100644 --- a/atom/common/crash_reporter/crash_reporter_win.cc +++ b/atom/common/crash_reporter/crash_reporter_win.cc @@ -137,8 +137,7 @@ void UnregisterNonABICompliantCodeRange(void* start) { } // namespace -CrashReporterWin::CrashReporterWin() - : skip_system_crash_handler_(false), code_range_registered_(false) {} +CrashReporterWin::CrashReporterWin() {} CrashReporterWin::~CrashReporterWin() {} diff --git a/atom/common/crash_reporter/crash_reporter_win.h b/atom/common/crash_reporter/crash_reporter_win.h index 3b3af71d5cf..f7f1c6b2845 100644 --- a/atom/common/crash_reporter/crash_reporter_win.h +++ b/atom/common/crash_reporter/crash_reporter_win.h @@ -64,8 +64,8 @@ class CrashReporterWin : public CrashReporter { std::vector custom_info_entries_; google_breakpad::CustomClientInfo custom_info_; - bool skip_system_crash_handler_; - bool code_range_registered_; + bool skip_system_crash_handler_ = false; + bool code_range_registered_ = false; std::unique_ptr breakpad_; DISALLOW_COPY_AND_ASSIGN(CrashReporterWin); diff --git a/atom/common/crash_reporter/linux/crash_dump_handler.cc b/atom/common/crash_reporter/linux/crash_dump_handler.cc index dea98d142dd..ccc8d0d538e 100644 --- a/atom/common/crash_reporter/linux/crash_dump_handler.cc +++ b/atom/common/crash_reporter/linux/crash_dump_handler.cc @@ -152,10 +152,10 @@ class MimeWriter { void AddItemWithoutTrailingSpaces(const void* base, size_t size); struct kernel_iovec iov_[kIovCapacity]; - int iov_index_; + int iov_index_ = 0; // Output file descriptor. - int fd_; + int fd_ = -1; const char* const mime_boundary_; @@ -164,7 +164,7 @@ class MimeWriter { }; MimeWriter::MimeWriter(int fd, const char* const mime_boundary) - : iov_index_(0), fd_(fd), mime_boundary_(mime_boundary) {} + : fd_(fd), mime_boundary_(mime_boundary) {} MimeWriter::~MimeWriter() {} diff --git a/atom/common/crash_reporter/win/crash_service.cc b/atom/common/crash_reporter/win/crash_service.cc index 5e0d07e63c1..a1a6ab6d790 100644 --- a/atom/common/crash_reporter/win/crash_service.cc +++ b/atom/common/crash_reporter/win/crash_service.cc @@ -188,13 +188,7 @@ const char CrashService::kDumpsDir[] = "dumps-dir"; const char CrashService::kPipeName[] = "pipe-name"; const char CrashService::kReporterURL[] = "reporter-url"; -CrashService::CrashService() - : sender_(NULL), - dumper_(NULL), - requests_handled_(0), - requests_sent_(0), - clients_connected_(0), - clients_terminated_(0) {} +CrashService::CrashService() {} CrashService::~CrashService() { base::AutoLock lock(sending_); diff --git a/atom/common/crash_reporter/win/crash_service.h b/atom/common/crash_reporter/win/crash_service.h index 160a0c4ce5f..8b7b51037a3 100644 --- a/atom/common/crash_reporter/win/crash_service.h +++ b/atom/common/crash_reporter/win/crash_service.h @@ -102,8 +102,8 @@ class CrashService { // LocalFree. PSECURITY_DESCRIPTOR GetSecurityDescriptorForLowIntegrity(); - google_breakpad::CrashGenerationServer* dumper_; - google_breakpad::CrashReportSender* sender_; + google_breakpad::CrashGenerationServer* dumper_ = nullptr; + google_breakpad::CrashReportSender* sender_ = nullptr; // the extra tag sent to the server with each dump. std::wstring reporter_tag_; @@ -112,10 +112,10 @@ class CrashService { std::wstring reporter_url_; // clients serviced statistics: - int requests_handled_; - int requests_sent_; - volatile LONG clients_connected_; - volatile LONG clients_terminated_; + int requests_handled_ = 0; + int requests_sent_ = 0; + volatile LONG clients_connected_ = 0; + volatile LONG clients_terminated_ = 0; base::Lock sending_; DISALLOW_COPY_AND_ASSIGN(CrashService); diff --git a/atom/common/native_mate_converters/v8_value_converter.cc b/atom/common/native_mate_converters/v8_value_converter.cc index 2e0d594069c..6788a35e530 100644 --- a/atom/common/native_mate_converters/v8_value_converter.cc +++ b/atom/common/native_mate_converters/v8_value_converter.cc @@ -122,11 +122,7 @@ class V8ValueConverter::ScopedUniquenessGuard { DISALLOW_COPY_AND_ASSIGN(ScopedUniquenessGuard); }; -V8ValueConverter::V8ValueConverter() - : reg_exp_allowed_(false), - function_allowed_(false), - disable_node_(false), - strip_null_from_objects_(false) {} +V8ValueConverter::V8ValueConverter() {} void V8ValueConverter::SetRegExpAllowed(bool val) { reg_exp_allowed_ = val; diff --git a/atom/common/native_mate_converters/v8_value_converter.h b/atom/common/native_mate_converters/v8_value_converter.h index 8a65317246a..364420d219d 100644 --- a/atom/common/native_mate_converters/v8_value_converter.h +++ b/atom/common/native_mate_converters/v8_value_converter.h @@ -58,21 +58,21 @@ class V8ValueConverter { v8::Isolate* isolate) const; // If true, we will convert RegExp JavaScript objects to string. - bool reg_exp_allowed_; + bool reg_exp_allowed_ = false; // If true, we will convert Function JavaScript objects to dictionaries. - bool function_allowed_; + bool function_allowed_ = false; // If true, will not use node::Buffer::Copy to deserialize byte arrays. // node::Buffer::Copy depends on a working node.js environment, and this is // not desirable in sandboxed renderers. That means Buffer instances sent from // browser process will be deserialized as browserify-based Buffer(which are // wrappers around Uint8Array). - bool disable_node_; + bool disable_node_ = false; // If true, undefined and null values are ignored when converting v8 objects // into Values. - bool strip_null_from_objects_; + bool strip_null_from_objects_ = false; DISALLOW_COPY_AND_ASSIGN(V8ValueConverter); }; diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index bdcf5f34e37..d50327934c8 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -135,10 +135,7 @@ base::FilePath GetResourcesPath(bool is_browser) { } // namespace NodeBindings::NodeBindings(BrowserEnvironment browser_env) - : browser_env_(browser_env), - embed_closed_(false), - uv_env_(nullptr), - weak_factory_(this) { + : browser_env_(browser_env), weak_factory_(this) { if (browser_env == WORKER) { uv_loop_init(&worker_loop_); uv_loop_ = &worker_loop_; diff --git a/atom/common/node_bindings.h b/atom/common/node_bindings.h index 0647d30cfae..46c78cbe02b 100644 --- a/atom/common/node_bindings.h +++ b/atom/common/node_bindings.h @@ -87,7 +87,7 @@ class NodeBindings { static void EmbedThreadRunner(void* arg); // Whether the libuv loop has ended. - bool embed_closed_; + bool embed_closed_ = false; // Loop used when constructed in WORKER mode uv_loop_t worker_loop_; @@ -102,7 +102,7 @@ class NodeBindings { uv_sem_t embed_sem_; // Environment that to wrap the uv loop. - node::Environment* uv_env_; + node::Environment* uv_env_ = nullptr; base::WeakPtrFactory weak_factory_; diff --git a/atom/renderer/atom_autofill_agent.cc b/atom/renderer/atom_autofill_agent.cc index af41e9e6059..5a8d712a82a 100644 --- a/atom/renderer/atom_autofill_agent.cc +++ b/atom/renderer/atom_autofill_agent.cc @@ -50,10 +50,7 @@ void TrimStringVectorForIPC(std::vector* strings) { } // namespace AutofillAgent::AutofillAgent(content::RenderFrame* frame) - : content::RenderFrameObserver(frame), - focused_node_was_last_clicked_(false), - was_focused_before_now_(false), - weak_ptr_factory_(this) { + : content::RenderFrameObserver(frame), weak_ptr_factory_(this) { render_frame()->GetWebFrame()->SetAutofillClient(this); } diff --git a/atom/renderer/atom_autofill_agent.h b/atom/renderer/atom_autofill_agent.h index 8994d8dfc97..3dbacb21d3c 100644 --- a/atom/renderer/atom_autofill_agent.h +++ b/atom/renderer/atom_autofill_agent.h @@ -62,12 +62,12 @@ class AutofillAgent : public content::RenderFrameObserver, void DoFocusChangeComplete(); // True when the last click was on the focused node. - bool focused_node_was_last_clicked_; + bool focused_node_was_last_clicked_ = false; // This is set to false when the focus changes, then set back to true soon // afterwards. This helps track whether an event happened after a node was // already focused, or if it caused the focus to change. - bool was_focused_before_now_; + bool was_focused_before_now_ = false; base::WeakPtrFactory weak_ptr_factory_; diff --git a/atom/renderer/atom_render_frame_observer.cc b/atom/renderer/atom_render_frame_observer.cc index d80ff1e398a..ea2355fd968 100644 --- a/atom/renderer/atom_render_frame_observer.cc +++ b/atom/renderer/atom_render_frame_observer.cc @@ -72,8 +72,7 @@ AtomRenderFrameObserver::AtomRenderFrameObserver( RendererClientBase* renderer_client) : content::RenderFrameObserver(frame), render_frame_(frame), - renderer_client_(renderer_client), - document_created_(false) { + renderer_client_(renderer_client) { // Initialise resource for directory listing. net::NetModule::SetResourceProvider(NetResourceProvider); } diff --git a/atom/renderer/atom_render_frame_observer.h b/atom/renderer/atom_render_frame_observer.h index d4f3d0c7d5c..e774741c019 100644 --- a/atom/renderer/atom_render_frame_observer.h +++ b/atom/renderer/atom_render_frame_observer.h @@ -56,7 +56,7 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver { content::RenderFrame* render_frame_; RendererClientBase* renderer_client_; - bool document_created_; + bool document_created_ = false; DISALLOW_COPY_AND_ASSIGN(AtomRenderFrameObserver); }; diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 9a1245182be..5ae1adb1ef3 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -37,8 +37,7 @@ bool IsDevToolsExtension(content::RenderFrame* render_frame) { } // namespace AtomRendererClient::AtomRendererClient() - : node_integration_initialized_(false), - node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)), + : node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)), atom_bindings_(new AtomBindings(uv_default_loop())) {} AtomRendererClient::~AtomRendererClient() { diff --git a/atom/renderer/atom_renderer_client.h b/atom/renderer/atom_renderer_client.h index a1442b72eb7..3e81cd4c647 100644 --- a/atom/renderer/atom_renderer_client.h +++ b/atom/renderer/atom_renderer_client.h @@ -60,7 +60,7 @@ class AtomRendererClient : public RendererClientBase { node::Environment* GetEnvironment(content::RenderFrame* frame) const; // Whether the node integration has been initialized. - bool node_integration_initialized_; + bool node_integration_initialized_ = false; std::unique_ptr node_bindings_; std::unique_ptr atom_bindings_;