chore: use std::make_unique/base::MakeRefCounted when possible (#29510)

This commit is contained in:
David Sanders 2021-06-07 19:00:05 -07:00 committed by GitHub
parent a4decffe9a
commit 79cb5144ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 106 additions and 101 deletions

View file

@ -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);
}