Skip to content

Commit

Permalink
chore: explicitly initialize every raw_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
ckerr committed Sep 22, 2022
1 parent a881f10 commit b67792b
Show file tree
Hide file tree
Showing 51 changed files with 63 additions and 62 deletions.
2 changes: 1 addition & 1 deletion shell/app/uv_task_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class UvTaskRunner : public base::SingleThreadTaskRunner {
static void OnTimeout(uv_timer_t* timer);
static void OnClose(uv_handle_t* handle);

raw_ptr<uv_loop_t> loop_;
raw_ptr<uv_loop_t> loop_ = nullptr;

std::map<uv_timer_t*, base::OnceClosure> tasks_;
};
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/api/electron_api_download_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ class DownloadItem : public gin::Wrappable<DownloadItem>,

base::FilePath save_path_;
file_dialog::DialogSettings dialog_options_;
raw_ptr<download::DownloadItem> download_item_;
raw_ptr<download::DownloadItem> download_item_ = nullptr;

raw_ptr<v8::Isolate> isolate_;
raw_ptr<v8::Isolate> isolate_ = nullptr;

base::WeakPtrFactory<DownloadItem> weak_factory_{this};
};
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/api/electron_api_native_theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class NativeTheme : public gin::Wrappable<NativeTheme>,
void OnNativeThemeUpdatedOnUI();

private:
raw_ptr<ui::NativeTheme> ui_theme_;
raw_ptr<ui::NativeTheme> web_theme_;
raw_ptr<ui::NativeTheme> ui_theme_ = nullptr;
raw_ptr<ui::NativeTheme> web_theme_ = nullptr;
};

} // namespace electron::api
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_net_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class NetLog : public gin::Wrappable<NetLog> {
void NetLogStarted(int32_t error);

private:
raw_ptr<ElectronBrowserContext> browser_context_;
raw_ptr<ElectronBrowserContext> browser_context_ = nullptr;

mojo::Remote<network::mojom::NetLogExporter> net_log_exporter_;

Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Notification : public gin::Wrappable<Notification>,
std::u16string close_button_text_;
std::u16string toast_xml_;

raw_ptr<electron::NotificationPresenter> presenter_;
raw_ptr<electron::NotificationPresenter> presenter_ = nullptr;

base::WeakPtr<electron::Notification> notification_;
};
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Protocol : public gin::Wrappable<Protocol> {

// Weak pointer; the lifetime of the ProtocolRegistry is guaranteed to be
// longer than the lifetime of this JS interface.
raw_ptr<ProtocolRegistry> protocol_registry_;
raw_ptr<ProtocolRegistry> protocol_registry_ = nullptr;
};

} // namespace api
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Screen : public gin::Wrappable<Screen>,
uint32_t changed_metrics) override;

private:
raw_ptr<display::Screen> screen_;
raw_ptr<display::Screen> screen_ = nullptr;
};

} // namespace electron::api
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_service_worker_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ServiceWorkerContext
~ServiceWorkerContext() override;

private:
raw_ptr<content::ServiceWorkerContext> service_worker_context_;
raw_ptr<content::ServiceWorkerContext> service_worker_context_ = nullptr;

base::WeakPtrFactory<ServiceWorkerContext> weak_ptr_factory_{this};
};
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/api/electron_api_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ class Session : public gin::Wrappable<Session>,
v8::Global<v8::Value> service_worker_context_;
v8::Global<v8::Value> web_request_;

raw_ptr<v8::Isolate> isolate_;
raw_ptr<v8::Isolate> isolate_ = nullptr;

// The client id to enable the network throttler.
base::UnguessableToken network_emulation_token_;

raw_ptr<ElectronBrowserContext> browser_context_;
raw_ptr<ElectronBrowserContext> browser_context_ = nullptr;
};

} // namespace api
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_web_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ class WebContents : public ExclusiveAccessContext,

std::unique_ptr<DevToolsEyeDropper> eye_dropper_;

raw_ptr<ElectronBrowserContext> browser_context_;
raw_ptr<ElectronBrowserContext> browser_context_ = nullptr;

// The stored InspectableWebContents object.
// Notice that inspectable_web_contents_ must be placed after
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_web_contents_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class WebContentsView : public View, public content::WebContentsObserver {

// Keep a reference to v8 wrapper.
v8::Global<v8::Value> web_contents_;
raw_ptr<api::WebContents> api_web_contents_;
raw_ptr<api::WebContents> api_web_contents_ = nullptr;
};

} // namespace electron::api
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_web_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class WebRequest : public gin::Wrappable<WebRequest>, public WebRequestAPI {
std::map<uint64_t, net::CompletionOnceCallback> callbacks_;

// Weak-ref, it manages us.
raw_ptr<content::BrowserContext> browser_context_;
raw_ptr<content::BrowserContext> browser_context_ = nullptr;
};

} // namespace electron::api
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/frame_subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class FrameSubscriber : public content::WebContentsObserver,
FrameCaptureCallback callback_;
bool only_dirty_;

raw_ptr<content::RenderWidgetHost> host_;
raw_ptr<content::RenderWidgetHost> host_ = nullptr;
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;

base::WeakPtrFactory<FrameSubscriber> weak_ptr_factory_{this};
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/gpuinfo_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
// This set maintains all the promises that should be fulfilled
// once we have the complete information data
std::vector<gin_helper::Promise<base::Value>> complete_info_promise_set_;
raw_ptr<content::GpuDataManagerImpl> gpu_data_manager_;
raw_ptr<content::GpuDataManagerImpl> gpu_data_manager_ = nullptr;
};

} // namespace electron
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/save_page_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SavePageHandler : public content::DownloadManager::Observer,
// download::DownloadItem::Observer:
void OnDownloadUpdated(download::DownloadItem* item) override;

raw_ptr<content::WebContents> web_contents_; // weak
raw_ptr<content::WebContents> web_contents_ = nullptr; // weak
gin_helper::Promise<void> promise_;
};

Expand Down
2 changes: 1 addition & 1 deletion shell/browser/electron_browser_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class ElectronBrowserContext : public content::BrowserContext {

#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
// Owned by the KeyedService system.
raw_ptr<extensions::ElectronExtensionSystem> extension_system_;
raw_ptr<extensions::ElectronExtensionSystem> extension_system_ = nullptr;
#endif

// Shared URLLoaderFactory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ElectronRuntimeAPIDelegate : public RuntimeAPIDelegate {
bool RestartDevice(std::string* error_message) override;

private:
raw_ptr<content::BrowserContext> browser_context_;
raw_ptr<content::BrowserContext> browser_context_ = nullptr;
};

} // namespace extensions
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/extensions/api/tabs/tabs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TabsUpdateFunction : public ExtensionFunction {
bool UpdateURL(const std::string& url, int tab_id, std::string* error);
ResponseValue GetResult();

raw_ptr<content::WebContents> web_contents_;
raw_ptr<content::WebContents> web_contents_ = nullptr;

private:
ResponseAction Run() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ElectronExtensionMessageFilter : public content::BrowserMessageFilter {
// be accessed on the UI thread! Furthermore since this class is refcounted it
// may outlive |browser_context_|, so make sure to NULL check if in doubt;
// async calls and the like.
raw_ptr<content::BrowserContext> browser_context_;
raw_ptr<content::BrowserContext> browser_context_ = nullptr;
};

} // namespace electron
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/extensions/electron_extension_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ElectronExtensionSystem : public ExtensionSystem {
scoped_refptr<Extension> extension);
void LoadComponentExtensions();

raw_ptr<content::BrowserContext> browser_context_; // Not owned.
raw_ptr<content::BrowserContext> browser_context_ = nullptr; // Not owned.

// Data to be accessed on the IO thread. Must outlive process_manager_.
scoped_refptr<InfoMap> info_map_;
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/hid/hid_chooser_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class HidChooserContext : public KeyedService,
const url::Origin& origin,
const device::mojom::HidDeviceInfo& device);

raw_ptr<ElectronBrowserContext> browser_context_;
raw_ptr<ElectronBrowserContext> browser_context_ = nullptr;

bool is_initialized_ = false;
base::queue<device::mojom::HidManager::GetDevicesCallback>
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/javascript_environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class JavascriptEnvironment {
private:
v8::Isolate* Initialize(uv_loop_t* event_loop);
// Leaked on exit.
raw_ptr<node::MultiIsolatePlatform> platform_;
raw_ptr<node::MultiIsolatePlatform> platform_ = nullptr;

raw_ptr<v8::Isolate> isolate_;
gin::IsolateHolder isolate_holder_;
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/lib/bluetooth_chooser.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BluetoothChooser : public content::BluetoothChooser {

private:
std::map<std::string, std::u16string> device_map_;
raw_ptr<api::WebContents> api_web_contents_;
raw_ptr<api::WebContents> api_web_contents_ = nullptr;
EventHandler event_handler_;
int num_retries_ = 0;
bool refreshing_ = false;
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/mac/in_app_purchase_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TransactionObserver {
const std::vector<Transaction>& transactions) = 0;

private:
raw_ptr<InAppTransactionObserver> observer_;
raw_ptr<InAppTransactionObserver> observer_ = nullptr;

base::WeakPtrFactory<TransactionObserver> weak_ptr_factory_{this};
};
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/net/network_context_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef ELECTRON_SHELL_BROWSER_NET_NETWORK_CONTEXT_SERVICE_H_
#define ELECTRON_SHELL_BROWSER_NET_NETWORK_CONTEXT_SERVICE_H_

#include "base/memory/raw_ptr.h"
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/net/proxy_config_monitor.h"
#include "components/keyed_service/core/keyed_service.h"
#include "mojo/public/cpp/bindings/remote.h"
Expand Down Expand Up @@ -37,7 +37,7 @@ class NetworkContextService : public KeyedService {
bool in_memory,
const base::FilePath& path);

raw_ptr<ElectronBrowserContext> browser_context_;
raw_ptr<ElectronBrowserContext> browser_context_ = nullptr;
ProxyConfigMonitor proxy_config_monitor_;
};

Expand Down
2 changes: 1 addition & 1 deletion shell/browser/net/node_stream_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class NodeStreamLoader : public network::mojom::URLLoader {
mojo::Receiver<network::mojom::URLLoader> url_loader_;
mojo::Remote<network::mojom::URLLoaderClient> client_;

raw_ptr<v8::Isolate> isolate_;
raw_ptr<v8::Isolate> isolate_ = nullptr;
v8::Global<v8::Object> emitter_;
v8::Global<v8::Value> buffer_;

Expand Down
7 changes: 4 additions & 3 deletions shell/browser/net/proxying_url_loader_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ProxyingURLLoaderFactory
void OnRequestError(const network::URLLoaderCompletionStatus& status);
void HandleBeforeRequestRedirect();

const raw_ptr<ProxyingURLLoaderFactory> factory_;
const raw_ptr<ProxyingURLLoaderFactory> factory_ = nullptr;
network::ResourceRequest request_;
const absl::optional<url::Origin> original_initiator_;
const uint64_t request_id_ = 0;
Expand Down Expand Up @@ -246,7 +246,7 @@ class ProxyingURLLoaderFactory
bool ShouldIgnoreConnectionsLimit(const network::ResourceRequest& request);

// Passed from api::WebRequest.
raw_ptr<WebRequestAPI> web_request_api_;
raw_ptr<WebRequestAPI> web_request_api_ = nullptr;

// This is passed from api::Protocol.
//
Expand All @@ -259,7 +259,8 @@ class ProxyingURLLoaderFactory

const int render_process_id_;
const int frame_routing_id_;
raw_ptr<uint64_t> request_id_generator_; // managed by ElectronBrowserClient
raw_ptr<uint64_t> request_id_generator_ =
nullptr; // managed by ElectronBrowserClient
std::unique_ptr<extensions::ExtensionNavigationUIData> navigation_ui_data_;
absl::optional<int64_t> navigation_id_;
mojo::ReceiverSet<network::mojom::URLLoaderFactory> proxy_receivers_;
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/net/proxying_websocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ProxyingWebSocket : public network::mojom::WebSocketHandshakeClient,
void OnMojoConnectionError();

// Passed from api::WebRequest.
raw_ptr<WebRequestAPI> web_request_api_;
raw_ptr<WebRequestAPI> web_request_api_ = nullptr;

// Saved to feed the api::WebRequest.
network::ResourceRequest request_;
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/net/resolve_proxy_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ResolveProxyHelper
mojo::Receiver<network::mojom::ProxyLookupClient> receiver_{this};

// Weak Ref
raw_ptr<ElectronBrowserContext> browser_context_;
raw_ptr<ElectronBrowserContext> browser_context_ = nullptr;
};

} // namespace electron
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/osr/osr_video_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class OffScreenVideoConsumer : public viz::mojom::FrameSinkVideoConsumer {

OnPaintCallback callback_;

raw_ptr<OffScreenRenderWidgetHostView> view_;
raw_ptr<OffScreenRenderWidgetHostView> view_ = nullptr;
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;

base::WeakPtrFactory<OffScreenVideoConsumer> weak_ptr_factory_{this};
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/osr/osr_view_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class OffscreenViewProxy {
void ResetView() { view_ = nullptr; }

private:
raw_ptr<views::View> view_;
raw_ptr<views::View> view_ = nullptr;

gfx::Rect view_bounds_;
std::unique_ptr<SkBitmap> view_bitmap_;
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/osr/osr_web_contents_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
raw_ptr<content::WebContents> web_contents_ = nullptr;

#if BUILDFLAG(IS_MAC)
raw_ptr<OffScreenView> offScreenView_;
raw_ptr<OffScreenView> offScreenView_ = nullptr;
#endif
};

Expand Down
2 changes: 1 addition & 1 deletion shell/browser/serial/serial_chooser_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SerialChooserContext : public KeyedService,
mojo::Receiver<device::mojom::SerialPortManagerClient> client_receiver_{this};
base::ObserverList<PortObserver> port_observer_list_;

raw_ptr<ElectronBrowserContext> browser_context_;
raw_ptr<ElectronBrowserContext> browser_context_ = nullptr;

base::WeakPtrFactory<SerialChooserContext> weak_factory_{this};
};
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/ui/views/autofill_popup_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ class AutofillPopupView : public views::WidgetDelegateView,
void RemoveObserver();

// Controller for this popup. Weak reference.
raw_ptr<AutofillPopup> popup_;
raw_ptr<AutofillPopup> popup_ = nullptr;

// The widget of the window that triggered this popup. Weak reference.
raw_ptr<views::Widget> parent_widget_;
raw_ptr<views::Widget> parent_widget_ = nullptr;

// The time when the popup was shown.
base::Time show_time_;
Expand Down
6 changes: 3 additions & 3 deletions shell/browser/ui/views/client_frame_view_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ class ClientFrameViewLinux : public FramelessView,

gfx::Size SizeWithDecorations(gfx::Size size) const;

raw_ptr<ui::NativeTheme> theme_;
raw_ptr<ui::NativeTheme> theme_ = nullptr;
ThemeValues theme_values_;

raw_ptr<views::Label> title_;
raw_ptr<views::Label> title_ = nullptr;

std::unique_ptr<ui::NavButtonProvider> nav_button_provider_;
std::array<NavButton, kNavButtonCount> nav_buttons_;
Expand All @@ -127,7 +127,7 @@ class ClientFrameViewLinux : public FramelessView,

bool host_supports_client_frame_shadow_ = false;

raw_ptr<ui::WindowFrameProvider> frame_provider_;
raw_ptr<ui::WindowFrameProvider> frame_provider_ = nullptr;

base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
native_theme_observer_{this};
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/ui/views/menu_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class MenuBar : public views::AccessiblePaneView,
SkColor disabled_color_;
#endif

raw_ptr<NativeWindow> window_;
raw_ptr<RootView> root_view_;
raw_ptr<NativeWindow> window_ = nullptr;
raw_ptr<RootView> root_view_ = nullptr;
raw_ptr<ElectronMenuModel> menu_model_ = nullptr;
bool accelerator_installed_ = false;
};
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/ui/views/menu_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MenuDelegate : public views::MenuDelegate {
views::MenuButton** button) override;

private:
raw_ptr<MenuBar> menu_bar_;
raw_ptr<MenuBar> menu_bar_ = nullptr;
int id_ = -1;
std::unique_ptr<views::MenuDelegate> adapter_;
std::unique_ptr<views::MenuRunner> menu_runner_;
Expand Down
Loading

0 comments on commit b67792b

Please sign in to comment.