use std::make_unique<T>

This commit is contained in:
Milan Burda 2018-06-19 10:15:54 +02:00
parent f0e2da7089
commit d5d5386017
2 changed files with 9 additions and 10 deletions

View file

@ -484,12 +484,12 @@ void AtomBrowserClient::SiteInstanceDeleting(
std::unique_ptr<net::ClientCertStore> AtomBrowserClient::CreateClientCertStore( std::unique_ptr<net::ClientCertStore> AtomBrowserClient::CreateClientCertStore(
content::ResourceContext* resource_context) { content::ResourceContext* resource_context) {
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS( return std::make_unique<net::ClientCertStoreNSS>(
net::ClientCertStoreNSS::PasswordDelegateFactory())); net::ClientCertStoreNSS::PasswordDelegateFactory());
#elif defined(OS_WIN) #elif defined(OS_WIN)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin()); return std::make_unique<net::ClientCertStoreWin>();
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac()); return std::make_unique<net::ClientCertStoreMac>();
#elif defined(USE_OPENSSL) #elif defined(USE_OPENSSL)
return std::unique_ptr<net::ClientCertStore>(); return std::unique_ptr<net::ClientCertStore>();
#endif #endif

View file

@ -20,14 +20,13 @@ Converter<scoped_refptr<network::ResourceRequestBody>>::ToV8(
const scoped_refptr<network::ResourceRequestBody>& val) { const scoped_refptr<network::ResourceRequestBody>& val) {
if (!val) if (!val)
return v8::Null(isolate); return v8::Null(isolate);
std::unique_ptr<base::ListValue> list(new base::ListValue); auto list = std::make_unique<base::ListValue>();
for (const auto& element : *(val->elements())) { for (const auto& element : *(val->elements())) {
std::unique_ptr<base::DictionaryValue> post_data_dict( auto post_data_dict = std::make_unique<base::DictionaryValue>();
new base::DictionaryValue);
auto type = element.type(); auto type = element.type();
if (type == network::DataElement::TYPE_BYTES) { if (type == network::DataElement::TYPE_BYTES) {
std::unique_ptr<base::Value> bytes(base::Value::CreateWithCopiedBuffer( auto bytes = base::Value::CreateWithCopiedBuffer(
element.bytes(), static_cast<size_t>(element.length()))); element.bytes(), static_cast<size_t>(element.length()));
post_data_dict->SetString("type", "rawData"); post_data_dict->SetString("type", "rawData");
post_data_dict->Set("bytes", std::move(bytes)); post_data_dict->Set("bytes", std::move(bytes));
} else if (type == network::DataElement::TYPE_FILE) { } else if (type == network::DataElement::TYPE_FILE) {
@ -52,7 +51,7 @@ bool Converter<scoped_refptr<network::ResourceRequestBody>>::FromV8(
v8::Isolate* isolate, v8::Isolate* isolate,
v8::Local<v8::Value> val, v8::Local<v8::Value> val,
scoped_refptr<network::ResourceRequestBody>* out) { scoped_refptr<network::ResourceRequestBody>* out) {
std::unique_ptr<base::ListValue> list(new base::ListValue); auto list = std::make_unique<base::ListValue>();
if (!ConvertFromV8(isolate, val, list.get())) if (!ConvertFromV8(isolate, val, list.get()))
return false; return false;
*out = new network::ResourceRequestBody(); *out = new network::ResourceRequestBody();