chore: use std::make_unique/base::MakeRefCounted when possible (#29510)
This commit is contained in:
parent
a4decffe9a
commit
79cb5144ae
38 changed files with 106 additions and 101 deletions
|
@ -197,13 +197,13 @@ void GetUploadedReports(
|
|||
#else
|
||||
scoped_refptr<UploadList> CreateCrashUploadList() {
|
||||
#if defined(OS_MAC) || defined(OS_WIN)
|
||||
return new CrashUploadListCrashpad();
|
||||
return base::MakeRefCounted<CrashUploadListCrashpad>();
|
||||
#else
|
||||
base::FilePath crash_dir_path;
|
||||
base::PathService::Get(electron::DIR_CRASH_DUMPS, &crash_dir_path);
|
||||
base::FilePath upload_log_path =
|
||||
crash_dir_path.AppendASCII(CrashUploadList::kReporterLogFilename);
|
||||
return new TextLogUploadList(upload_log_path);
|
||||
return base::MakeRefCounted<TextLogUploadList>(upload_log_path);
|
||||
#endif // defined(OS_MAC) || defined(OS_WIN)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ namespace api {
|
|||
|
||||
gin::WrapperInfo Menu::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||
|
||||
Menu::Menu(gin::Arguments* args) : model_(new ElectronMenuModel(this)) {
|
||||
Menu::Menu(gin::Arguments* args)
|
||||
: model_(std::make_unique<ElectronMenuModel>(this)) {
|
||||
model_->AddObserver(this);
|
||||
|
||||
#if defined(OS_MAC)
|
||||
|
|
|
@ -192,7 +192,8 @@ void SystemPreferences::InitializeWindow() {
|
|||
// Creating this listener before the app is ready causes global shortcuts
|
||||
// to not fire
|
||||
if (Browser::Get()->is_ready())
|
||||
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
|
||||
color_change_listener_ =
|
||||
std::make_unique<gfx::ScopedSysColorChangeListener>(this);
|
||||
else
|
||||
Browser::Get()->AddObserver(this);
|
||||
|
||||
|
@ -259,7 +260,8 @@ void SystemPreferences::OnSysColorChange() {
|
|||
|
||||
void SystemPreferences::OnFinishLaunching(
|
||||
const base::DictionaryValue& launch_info) {
|
||||
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
|
||||
color_change_listener_ =
|
||||
std::make_unique<gfx::ScopedSysColorChangeListener>(this);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
|
|
@ -537,8 +537,7 @@ FileSystem CreateFileSystemStruct(content::WebContents* web_contents,
|
|||
|
||||
std::unique_ptr<base::DictionaryValue> CreateFileSystemValue(
|
||||
const FileSystem& file_system) {
|
||||
std::unique_ptr<base::DictionaryValue> file_system_value(
|
||||
new base::DictionaryValue());
|
||||
auto file_system_value = std::make_unique<base::DictionaryValue>();
|
||||
file_system_value->SetString("type", file_system.type);
|
||||
file_system_value->SetString("fileSystemName", file_system.file_system_name);
|
||||
file_system_value->SetString("rootURL", file_system.root_url);
|
||||
|
@ -618,7 +617,8 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
: content::WebContentsObserver(web_contents),
|
||||
type_(Type::kRemote),
|
||||
id_(GetAllWebContents().Add(this)),
|
||||
devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
|
||||
devtools_file_system_indexer_(
|
||||
base::MakeRefCounted<DevToolsFileSystemIndexer>()),
|
||||
file_task_runner_(
|
||||
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()}))
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
|
@ -635,7 +635,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
|
||||
extensions::ElectronExtensionWebContentsObserver::CreateForWebContents(
|
||||
web_contents);
|
||||
script_executor_.reset(new extensions::ScriptExecutor(web_contents));
|
||||
script_executor_ = std::make_unique<extensions::ScriptExecutor>(web_contents);
|
||||
#endif
|
||||
|
||||
auto session = Session::CreateFrom(isolate, GetBrowserContext());
|
||||
|
@ -674,7 +674,8 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
const gin_helper::Dictionary& options)
|
||||
: id_(GetAllWebContents().Add(this)),
|
||||
devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
|
||||
devtools_file_system_indexer_(
|
||||
base::MakeRefCounted<DevToolsFileSystemIndexer>()),
|
||||
file_task_runner_(
|
||||
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()}))
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
|
@ -838,7 +839,8 @@ void WebContents::InitWithSessionAndOptions(
|
|||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
extensions::ElectronExtensionWebContentsObserver::CreateForWebContents(
|
||||
web_contents());
|
||||
script_executor_.reset(new extensions::ScriptExecutor(web_contents()));
|
||||
script_executor_ =
|
||||
std::make_unique<extensions::ScriptExecutor>(web_contents());
|
||||
#endif
|
||||
|
||||
AutofillDriverFactory::CreateForWebContents(web_contents());
|
||||
|
@ -904,8 +906,8 @@ void WebContents::InitWithWebContents(content::WebContents* web_contents,
|
|||
web_preferences && web_preferences->IsEnabled(options::kOffscreen);
|
||||
|
||||
// Create InspectableWebContents.
|
||||
inspectable_web_contents_.reset(new InspectableWebContents(
|
||||
web_contents, browser_context->prefs(), is_guest));
|
||||
inspectable_web_contents_ = std::make_unique<InspectableWebContents>(
|
||||
web_contents, browser_context->prefs(), is_guest);
|
||||
inspectable_web_contents_->SetDelegate(this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue