Skip to content

Commit

Permalink
refactor: run clang-tidy (#20231)
Browse files Browse the repository at this point in the history
* refactor: clang-tidy modernize-use-nullptr

* refactor: clang-tidy modernize-use-equals-default

* refactor: clang-tidy modernize-make-unique

* refactor: omit nullptr arg from unique_ptr.reset()

As per comment by @miniak
  • Loading branch information
ckerr committed Sep 16, 2019
1 parent 660e566 commit 2b316f3
Show file tree
Hide file tree
Showing 93 changed files with 261 additions and 223 deletions.
2 changes: 1 addition & 1 deletion chromium_src/chrome/browser/certificate_manager_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ CertificateManagerModel::CertificateManagerModel(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}

CertificateManagerModel::~CertificateManagerModel() {}
CertificateManagerModel::~CertificateManagerModel() = default;

int CertificateManagerModel::ImportFromPKCS12(
PK11SlotInfo* slot_info,
Expand Down
2 changes: 1 addition & 1 deletion chromium_src/chrome/browser/process_singleton_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ int WaitSocketForRead(int fd, const base::TimeDelta& timeout) {
FD_ZERO(&read_fds);
FD_SET(fd, &read_fds);

return HANDLE_EINTR(select(fd + 1, &read_fds, NULL, NULL, &tv));
return HANDLE_EINTR(select(fd + 1, &read_fds, nullptr, nullptr, &tv));
}

// Read a message from a socket fd, with an optional timeout.
Expand Down
2 changes: 1 addition & 1 deletion native_mate/native_mate/converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ bool Converter<std::string>::FromV8(v8::Isolate* isolate,
v8::Local<v8::String> str = v8::Local<v8::String>::Cast(val);
int length = str->Utf8Length(isolate);
out->resize(length);
str->WriteUtf8(isolate, &(*out)[0], length, NULL,
str->WriteUtf8(isolate, &(*out)[0], length, nullptr,
v8::String::NO_NULL_TERMINATION);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions shell/app/atom_content_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ void AppendDelimitedSwitchToVector(const base::StringPiece cmd_switch,

} // namespace

AtomContentClient::AtomContentClient() {}
AtomContentClient::AtomContentClient() = default;

AtomContentClient::~AtomContentClient() {}
AtomContentClient::~AtomContentClient() = default;

base::string16 AtomContentClient::GetLocalizedString(int message_id) {
return l10n_util::GetStringUTF16(message_id);
Expand Down
14 changes: 7 additions & 7 deletions shell/app/atom_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ void LoadResourceBundle(const std::string& locale) {
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
}

AtomMainDelegate::AtomMainDelegate() {}
AtomMainDelegate::AtomMainDelegate() = default;

AtomMainDelegate::~AtomMainDelegate() {}
AtomMainDelegate::~AtomMainDelegate() = default;

bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
auto* command_line = base::CommandLine::ForCurrentProcess();
Expand Down Expand Up @@ -283,12 +283,12 @@ void AtomMainDelegate::PreCreateMainMessageLoop() {
}

content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
browser_client_.reset(new AtomBrowserClient);
browser_client_ = std::make_unique<AtomBrowserClient>();
return browser_client_.get();
}

content::ContentGpuClient* AtomMainDelegate::CreateContentGpuClient() {
gpu_client_.reset(new AtomGpuClient);
gpu_client_ = std::make_unique<AtomGpuClient>();
return gpu_client_.get();
}

Expand All @@ -297,16 +297,16 @@ AtomMainDelegate::CreateContentRendererClient() {
auto* command_line = base::CommandLine::ForCurrentProcess();

if (IsSandboxEnabled(command_line)) {
renderer_client_.reset(new AtomSandboxedRendererClient);
renderer_client_ = std::make_unique<AtomSandboxedRendererClient>();
} else {
renderer_client_.reset(new AtomRendererClient);
renderer_client_ = std::make_unique<AtomRendererClient>();
}

return renderer_client_.get();
}

content::ContentUtilityClient* AtomMainDelegate::CreateContentUtilityClient() {
utility_client_.reset(new AtomContentUtilityClient);
utility_client_ = std::make_unique<AtomContentUtilityClient>();
return utility_client_.get();
}

Expand Down
10 changes: 6 additions & 4 deletions shell/browser/api/atom_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "shell/browser/api/atom_api_app.h"

#include <memory>

#include <string>
#include <vector>

Expand Down Expand Up @@ -941,9 +943,9 @@ std::string App::GetLocaleCountryCode() {
kCFStringEncodingUTF8);
region = temporaryCString;
#else
const char* locale_ptr = setlocale(LC_TIME, NULL);
const char* locale_ptr = setlocale(LC_TIME, nullptr);
if (!locale_ptr)
locale_ptr = setlocale(LC_NUMERIC, NULL);
locale_ptr = setlocale(LC_NUMERIC, nullptr);
if (locale_ptr) {
std::string locale = locale_ptr;
std::string::size_type rpos = locale.find('.');
Expand Down Expand Up @@ -977,8 +979,8 @@ bool App::RequestSingleInstanceLock() {

auto cb = base::BindRepeating(&App::OnSecondInstance, base::Unretained(this));

process_singleton_.reset(new ProcessSingleton(
user_dir, base::BindRepeating(NotificationCallbackWrapper, cb)));
process_singleton_ = std::make_unique<ProcessSingleton>(
user_dir, base::BindRepeating(NotificationCallbackWrapper, cb));

switch (process_singleton_->NotifyOtherProcessOrCreate()) {
case ProcessSingleton::NotifyResult::LOCK_ERROR:
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/atom_api_cookies.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Cookies::Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context)
base::Unretained(this)));
}

Cookies::~Cookies() {}
Cookies::~Cookies() = default;

v8::Local<v8::Promise> Cookies::Get(const base::DictionaryValue& filter) {
util::Promise<net::CookieList> promise(isolate());
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/atom_api_debugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Debugger::Debugger(v8::Isolate* isolate, content::WebContents* web_contents)
Init(isolate);
}

Debugger::~Debugger() {}
Debugger::~Debugger() = default;

void Debugger::AgentHostClosed(DevToolsAgentHost* agent_host) {
DCHECK(agent_host == agent_host_);
Expand Down
10 changes: 5 additions & 5 deletions shell/browser/api/atom_api_desktop_capturer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ DesktopCapturer::DesktopCapturer(v8::Isolate* isolate) {
Init(isolate);
}

DesktopCapturer::~DesktopCapturer() {}
DesktopCapturer::~DesktopCapturer() = default;

void DesktopCapturer::StartHandling(bool capture_window,
bool capture_screen,
Expand Down Expand Up @@ -90,18 +90,18 @@ void DesktopCapturer::StartHandling(bool capture_window,
// Initialize the source list.
// Apply the new thumbnail size and restart capture.
if (capture_window) {
window_capturer_.reset(new NativeDesktopMediaList(
window_capturer_ = std::make_unique<NativeDesktopMediaList>(
content::DesktopMediaID::TYPE_WINDOW,
content::desktop_capture::CreateWindowCapturer()));
content::desktop_capture::CreateWindowCapturer());
window_capturer_->SetThumbnailSize(thumbnail_size);
window_capturer_->AddObserver(this);
window_capturer_->StartUpdating();
}

if (capture_screen) {
screen_capturer_.reset(new NativeDesktopMediaList(
screen_capturer_ = std::make_unique<NativeDesktopMediaList>(
content::DesktopMediaID::TYPE_SCREEN,
content::desktop_capture::CreateScreenCapturer()));
content::desktop_capture::CreateScreenCapturer());
screen_capturer_->SetThumbnailSize(thumbnail_size);
screen_capturer_->AddObserver(this);
screen_capturer_->StartUpdating();
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/atom_api_menu_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void MenuViews::PopupAt(TopLevelWindow* window,
menu_runners_[window_id] =
std::make_unique<MenuRunner>(model(), flags, close_callback);
menu_runners_[window_id]->RunMenuAt(
native_window->widget(), NULL, gfx::Rect(location, gfx::Size()),
native_window->widget(), nullptr, gfx::Rect(location, gfx::Size()),
views::MenuAnchorPosition::kTopLeft, ui::MENU_SOURCE_MOUSE);
}

Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/atom_api_net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Net::Net(v8::Isolate* isolate) {
Init(isolate);
}

Net::~Net() {}
Net::~Net() = default;

// static
v8::Local<v8::Value> Net::Create(v8::Isolate* isolate) {
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/atom_api_power_save_blocker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
: current_lock_type_(device::mojom::WakeLockType::kPreventAppSuspension),
is_wake_lock_active_(false) {}

PowerSaveBlocker::~PowerSaveBlocker() {}
PowerSaveBlocker::~PowerSaveBlocker() = default;

void PowerSaveBlocker::UpdatePowerSaveBlocker() {
if (wake_lock_types_.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/atom_api_url_request_ns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ URLRequestNS::URLRequestNS(mate::Arguments* args) : weak_factory_(this) {
InitWith(args->isolate(), args->GetThis());
}

URLRequestNS::~URLRequestNS() {}
URLRequestNS::~URLRequestNS() = default;

bool URLRequestNS::NotStarted() const {
return request_state_ == 0;
Expand Down
10 changes: 5 additions & 5 deletions shell/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
GURL("chrome-guest://fake-host"));
content::WebContents::CreateParams params(session->browser_context(),
site_instance);
guest_delegate_.reset(
new WebViewGuestDelegate(embedder_->web_contents(), this));
guest_delegate_ =
std::make_unique<WebViewGuestDelegate>(embedder_->web_contents(), this);
params.guest_delegate = guest_delegate_.get();

#if BUILDFLAG(ENABLE_OSR)
Expand Down Expand Up @@ -828,7 +828,7 @@ std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
content::JavaScriptDialogManager* WebContents::GetJavaScriptDialogManager(
content::WebContents* source) {
if (!dialog_manager_)
dialog_manager_.reset(new AtomJavaScriptDialogManager(this));
dialog_manager_ = std::make_unique<AtomJavaScriptDialogManager>(this);

return dialog_manager_.get();
}
Expand Down Expand Up @@ -2038,8 +2038,8 @@ void WebContents::BeginFrameSubscription(mate::Arguments* args) {
return;
}

frame_subscriber_.reset(
new FrameSubscriber(web_contents(), callback, only_dirty));
frame_subscriber_ =
std::make_unique<FrameSubscriber>(web_contents(), callback, only_dirty);
}

void WebContents::EndFrameSubscription() {
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/atom_api_web_contents_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace {
class WebContentsViewRelay
: public content::WebContentsUserData<WebContentsViewRelay> {
public:
~WebContentsViewRelay() override {}
~WebContentsViewRelay() override = default;

private:
explicit WebContentsViewRelay(content::WebContents* contents) {}
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Event::Event(v8::Isolate* isolate) {
Init(isolate);
}

Event::~Event() {}
Event::~Event() = default;

void Event::SetCallback(base::Optional<MessageSyncCallback> callback) {
DCHECK(!callback_);
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/gpu_info_enumerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace electron {
GPUInfoEnumerator::GPUInfoEnumerator()
: value_stack(), current(std::make_unique<base::DictionaryValue>()) {}

GPUInfoEnumerator::~GPUInfoEnumerator() {}
GPUInfoEnumerator::~GPUInfoEnumerator() = default;

void GPUInfoEnumerator::AddInt64(const char* name, int64_t value) {
current->SetInteger(name, value);
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/save_page_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SavePageHandler::SavePageHandler(content::WebContents* web_contents,
util::Promise<void*> promise)
: web_contents_(web_contents), promise_(std::move(promise)) {}

SavePageHandler::~SavePageHandler() {}
SavePageHandler::~SavePageHandler() = default;

void SavePageHandler::OnDownloadCreated(content::DownloadManager* manager,
download::DownloadItem* item) {
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/trackable_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TrackableObjectBase::TrackableObjectBase() : weak_factory_(this) {
GetDestroyClosure());
}

TrackableObjectBase::~TrackableObjectBase() {}
TrackableObjectBase::~TrackableObjectBase() = default;

base::OnceClosure TrackableObjectBase::GetDestroyClosure() {
return base::BindOnce(&TrackableObjectBase::Destroy,
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/atom_autofill_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "shell/browser/atom_autofill_driver.h"

#include <memory>

#include <utility>

#include "content/public/browser/render_widget_host_view.h"
Expand All @@ -16,11 +18,11 @@ AutofillDriver::AutofillDriver(
content::RenderFrameHost* render_frame_host,
mojom::ElectronAutofillDriverAssociatedRequest request)
: render_frame_host_(render_frame_host), binding_(this) {
autofill_popup_.reset(new AutofillPopup());
autofill_popup_ = std::make_unique<AutofillPopup>();
binding_.Bind(std::move(request));
}

AutofillDriver::~AutofillDriver() {}
AutofillDriver::~AutofillDriver() = default;

void AutofillDriver::ShowAutofillPopup(
const gfx::RectF& bounds,
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/atom_autofill_driver_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::unique_ptr<AutofillDriver> CreateDriver(

} // namespace

AutofillDriverFactory::~AutofillDriverFactory() {}
AutofillDriverFactory::~AutofillDriverFactory() = default;

// static
void AutofillDriverFactory::BindAutofillDriver(
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/atom_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ content::PlatformNotificationService*
AtomBrowserClient::GetPlatformNotificationService(
content::BrowserContext* browser_context) {
if (!notification_service_) {
notification_service_.reset(new PlatformNotificationService(this));
notification_service_ = std::make_unique<PlatformNotificationService>(this);
}
return notification_service_.get();
}
Expand Down
17 changes: 10 additions & 7 deletions shell/browser/atom_browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "shell/browser/atom_browser_context.h"

#include <memory>

#include <utility>

#include "base/command_line.h"
Expand Down Expand Up @@ -205,13 +207,13 @@ int AtomBrowserContext::GetMaxCacheSize() const {

content::ResourceContext* AtomBrowserContext::GetResourceContext() {
if (!resource_context_)
resource_context_.reset(new content::ResourceContext);
resource_context_ = std::make_unique<content::ResourceContext>();
return resource_context_.get();
}

std::string AtomBrowserContext::GetMediaDeviceIDSalt() {
if (!media_device_id_salt_.get())
media_device_id_salt_.reset(new MediaDeviceIDSalt(prefs_.get()));
media_device_id_salt_ = std::make_unique<MediaDeviceIDSalt>(prefs_.get());
return media_device_id_salt_->GetSalt();
}

Expand All @@ -228,22 +230,22 @@ content::DownloadManagerDelegate*
AtomBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_.get()) {
auto* download_manager = content::BrowserContext::GetDownloadManager(this);
download_manager_delegate_.reset(
new AtomDownloadManagerDelegate(download_manager));
download_manager_delegate_ =
std::make_unique<AtomDownloadManagerDelegate>(download_manager);
}
return download_manager_delegate_.get();
}

content::BrowserPluginGuestManager* AtomBrowserContext::GetGuestManager() {
if (!guest_manager_)
guest_manager_.reset(new WebViewManager);
guest_manager_ = std::make_unique<WebViewManager>();
return guest_manager_.get();
}

content::PermissionControllerDelegate*
AtomBrowserContext::GetPermissionControllerDelegate() {
if (!permission_manager_.get())
permission_manager_.reset(new AtomPermissionManager);
permission_manager_ = std::make_unique<AtomPermissionManager>();
return permission_manager_.get();
}

Expand All @@ -257,7 +259,8 @@ std::string AtomBrowserContext::GetUserAgent() const {

predictors::PreconnectManager* AtomBrowserContext::GetPreconnectManager() {
if (!preconnect_manager_.get()) {
preconnect_manager_.reset(new predictors::PreconnectManager(nullptr, this));
preconnect_manager_ =
std::make_unique<predictors::PreconnectManager>(nullptr, this);
}
return preconnect_manager_.get();
}
Expand Down

0 comments on commit 2b316f3

Please sign in to comment.