refactoring: use std::make_unique<T> (#13245)

This commit is contained in:
Milan Burda 2018-06-18 09:32:55 +02:00 committed by Cheng Zhao
parent 4dec5ec5f9
commit 28fd571d0c
29 changed files with 64 additions and 86 deletions

View file

@ -83,7 +83,7 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
#endif // !defined(OS_WIN) #endif // !defined(OS_WIN)
// Only enable logging when --enable-logging is specified. // Only enable logging when --enable-logging is specified.
std::unique_ptr<base::Environment> env(base::Environment::Create()); auto env = base::Environment::Create();
if (!command_line->HasSwitch(::switches::kEnableLogging) && if (!command_line->HasSwitch(::switches::kEnableLogging) &&
!env->HasVar("ELECTRON_ENABLE_LOGGING")) { !env->HasVar("ELECTRON_ENABLE_LOGGING")) {
settings.logging_dest = logging::LOG_NONE; settings.logging_dest = logging::LOG_NONE;
@ -203,7 +203,7 @@ bool AtomMainDelegate::DelaySandboxInitialization(
std::unique_ptr<brightray::ContentClient> std::unique_ptr<brightray::ContentClient>
AtomMainDelegate::CreateContentClient() { AtomMainDelegate::CreateContentClient() {
return std::unique_ptr<brightray::ContentClient>(new AtomContentClient); return std::make_unique<AtomContentClient>();
} }
} // namespace atom } // namespace atom

View file

@ -38,7 +38,7 @@ int NodeMain(int argc, char* argv[]) {
base::ThreadTaskRunnerHandle handle(uv_task_runner); base::ThreadTaskRunnerHandle handle(uv_task_runner);
// Initialize feature list. // Initialize feature list.
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); auto feature_list = std::make_unique<base::FeatureList>();
feature_list->InitializeFromCommandLine("", ""); feature_list->InitializeFromCommandLine("", "");
base::FeatureList::SetInstance(std::move(feature_list)); base::FeatureList::SetInstance(std::move(feature_list));

View file

@ -547,9 +547,9 @@ App::App(v8::Isolate* isolate) {
Browser::Get()->AddObserver(this); Browser::Get()->AddObserver(this);
content::GpuDataManager::GetInstance()->AddObserver(this); content::GpuDataManager::GetInstance()->AddObserver(this);
base::ProcessId pid = base::GetCurrentProcId(); base::ProcessId pid = base::GetCurrentProcId();
std::unique_ptr<atom::ProcessMetric> process_metric(new atom::ProcessMetric( auto process_metric = std::make_unique<atom::ProcessMetric>(
content::PROCESS_TYPE_BROWSER, pid, content::PROCESS_TYPE_BROWSER, pid,
base::ProcessMetrics::CreateCurrentProcessMetrics())); base::ProcessMetrics::CreateCurrentProcessMetrics());
app_metrics_[pid] = std::move(process_metric); app_metrics_[pid] = std::move(process_metric);
Init(isolate); Init(isolate);
} }
@ -811,9 +811,8 @@ void App::ChildProcessLaunched(int process_type, base::ProcessHandle handle) {
std::unique_ptr<base::ProcessMetrics> metrics( std::unique_ptr<base::ProcessMetrics> metrics(
base::ProcessMetrics::CreateProcessMetrics(handle)); base::ProcessMetrics::CreateProcessMetrics(handle));
#endif #endif
std::unique_ptr<atom::ProcessMetric> process_metric( app_metrics_[pid] = std::make_unique<atom::ProcessMetric>(process_type, pid,
new atom::ProcessMetric(process_type, pid, std::move(metrics))); std::move(metrics));
app_metrics_[pid] = std::move(process_metric);
} }
void App::ChildProcessDisconnected(base::ProcessId pid) { void App::ChildProcessDisconnected(base::ProcessId pid) {

View file

@ -336,7 +336,7 @@ v8::Local<v8::Value> BrowserWindow::GetWebContents(v8::Isolate* isolate) {
// Convert draggable regions in raw format to SkRegion format. // Convert draggable regions in raw format to SkRegion format.
std::unique_ptr<SkRegion> BrowserWindow::DraggableRegionsToSkRegion( std::unique_ptr<SkRegion> BrowserWindow::DraggableRegionsToSkRegion(
const std::vector<DraggableRegion>& regions) { const std::vector<DraggableRegion>& regions) {
std::unique_ptr<SkRegion> sk_region(new SkRegion); auto sk_region = std::make_unique<SkRegion>();
for (const DraggableRegion& region : regions) { for (const DraggableRegion& region : regions) {
sk_region->op( sk_region->op(
region.bounds.x(), region.bounds.y(), region.bounds.right(), region.bounds.x(), region.bounds.y(), region.bounds.right(),

View file

@ -42,10 +42,10 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
int width, int width,
int height) { int height) {
std::vector<gfx::Rect> result; std::vector<gfx::Rect> result;
std::unique_ptr<SkRegion> non_draggable(new SkRegion); SkRegion non_draggable;
non_draggable->op(0, 0, width, height, SkRegion::kUnion_Op); non_draggable.op(0, 0, width, height, SkRegion::kUnion_Op);
non_draggable->op(*draggable, SkRegion::kDifference_Op); non_draggable.op(*draggable, SkRegion::kDifference_Op);
for (SkRegion::Iterator it(*non_draggable); !it.done(); it.next()) { for (SkRegion::Iterator it(non_draggable); !it.done(); it.next()) {
result.push_back(gfx::SkIRectToRect(it.rect())); result.push_back(gfx::SkIRectToRect(it.rect()));
} }
return result; return result;

View file

@ -46,8 +46,8 @@ void MenuViews::PopupAt(TopLevelWindow* window,
int32_t window_id = window->weak_map_id(); int32_t window_id = window->weak_map_id();
auto close_callback = base::Bind( auto close_callback = base::Bind(
&MenuViews::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback); &MenuViews::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
menu_runners_[window_id] = std::unique_ptr<MenuRunner>( menu_runners_[window_id] =
new MenuRunner(model(), flags, close_callback)); std::make_unique<MenuRunner>(model(), flags, close_callback);
menu_runners_[window_id]->RunMenuAt( menu_runners_[window_id]->RunMenuAt(
native_window->widget(), NULL, gfx::Rect(location, gfx::Size()), native_window->widget(), NULL, gfx::Rect(location, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE); views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE);

View file

@ -72,12 +72,11 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
} }
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) { if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
std::unique_ptr<device::PowerSaveBlocker> new_blocker( auto new_blocker = std::make_unique<device::PowerSaveBlocker>(
new device::PowerSaveBlocker( new_blocker_type, device::PowerSaveBlocker::kReasonOther,
new_blocker_type, device::PowerSaveBlocker::kReasonOther, ATOM_PRODUCT_NAME,
ATOM_PRODUCT_NAME, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE));
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
power_save_blocker_.swap(new_blocker); power_save_blocker_.swap(new_blocker);
current_blocker_type_ = new_blocker_type; current_blocker_type_ = new_blocker_type;
} }

View file

@ -117,9 +117,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
request_context_getter->job_factory()); request_context_getter->job_factory());
if (job_factory->IsHandledProtocol(scheme)) if (job_factory->IsHandledProtocol(scheme))
return PROTOCOL_REGISTERED; return PROTOCOL_REGISTERED;
std::unique_ptr<CustomProtocolHandler<RequestJob>> protocol_handler( auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>(
new CustomProtocolHandler<RequestJob>( isolate, request_context_getter.get(), handler);
isolate, request_context_getter.get(), handler));
if (job_factory->SetProtocolHandler(scheme, std::move(protocol_handler))) if (job_factory->SetProtocolHandler(scheme, std::move(protocol_handler)))
return PROTOCOL_OK; return PROTOCOL_OK;
else else
@ -166,9 +165,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
// It is possible a protocol is handled but can not be intercepted. // It is possible a protocol is handled but can not be intercepted.
if (!job_factory->HasProtocolHandler(scheme)) if (!job_factory->HasProtocolHandler(scheme))
return PROTOCOL_FAIL; return PROTOCOL_FAIL;
std::unique_ptr<CustomProtocolHandler<RequestJob>> protocol_handler( auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>(
new CustomProtocolHandler<RequestJob>( isolate, request_context_getter.get(), handler);
isolate, request_context_getter.get(), handler));
if (!job_factory->InterceptProtocol(scheme, std::move(protocol_handler))) if (!job_factory->InterceptProtocol(scheme, std::move(protocol_handler)))
return PROTOCOL_INTERCEPTED; return PROTOCOL_INTERCEPTED;
return PROTOCOL_OK; return PROTOCOL_OK;

View file

@ -772,9 +772,7 @@ void WebContents::RequestToLockMouse(content::WebContents* web_contents,
std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser( std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
content::RenderFrameHost* frame, content::RenderFrameHost* frame,
const content::BluetoothChooser::EventHandler& event_handler) { const content::BluetoothChooser::EventHandler& event_handler) {
std::unique_ptr<BluetoothChooser> bluetooth_chooser( return std::make_unique<BluetoothChooser>(this, event_handler);
new BluetoothChooser(this, event_handler));
return std::move(bluetooth_chooser);
} }
content::JavaScriptDialogManager* WebContents::GetJavaScriptDialogManager( content::JavaScriptDialogManager* WebContents::GetJavaScriptDialogManager(

View file

@ -223,8 +223,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
// The corresponding call in macOS is in AtomApplicationDelegate. // The corresponding call in macOS is in AtomApplicationDelegate.
Browser::Get()->WillFinishLaunching(); Browser::Get()->WillFinishLaunching();
std::unique_ptr<base::DictionaryValue> empty_info(new base::DictionaryValue); Browser::Get()->DidFinishLaunching(base::DictionaryValue());
Browser::Get()->DidFinishLaunching(*empty_info);
#endif #endif
// Notify observers that main thread message loop was initialized. // Notify observers that main thread message loop was initialized.

View file

@ -134,12 +134,12 @@ std::unique_ptr<net::ClientCertStore>
AtomResourceDispatcherHostDelegate::CreateClientCertStore( AtomResourceDispatcherHostDelegate::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

@ -62,9 +62,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
atom::NSDictionaryToDictionaryValue(user_notification.userInfo); atom::NSDictionaryToDictionaryValue(user_notification.userInfo);
atom::Browser::Get()->DidFinishLaunching(*launch_info); atom::Browser::Get()->DidFinishLaunching(*launch_info);
} else { } else {
std::unique_ptr<base::DictionaryValue> empty_info( atom::Browser::Get()->DidFinishLaunching(base::DictionaryValue());
new base::DictionaryValue);
atom::Browser::Get()->DidFinishLaunching(*empty_info);
} }
#if BUILDFLAG(USE_ALLOCATOR_SHIM) #if BUILDFLAG(USE_ALLOCATOR_SHIM)

View file

@ -26,7 +26,7 @@ std::unique_ptr<base::ListValue> NSArrayToListValue(NSArray* arr) {
if (!arr) if (!arr)
return nullptr; return nullptr;
std::unique_ptr<base::ListValue> result(new base::ListValue); auto result = std::make_unique<base::ListValue>();
for (id value in arr) { for (id value in arr) {
if ([value isKindOfClass:[NSString class]]) { if ([value isKindOfClass:[NSString class]]) {
result->AppendString(base::SysNSStringToUTF8(value)); result->AppendString(base::SysNSStringToUTF8(value));
@ -79,7 +79,7 @@ std::unique_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
if (!dict) if (!dict)
return nullptr; return nullptr;
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); auto result = std::make_unique<base::DictionaryValue>();
for (id key in dict) { for (id key in dict) {
std::string str_key = base::SysNSStringToUTF8( std::string str_key = base::SysNSStringToUTF8(
[key isKindOfClass:[NSString class]] ? key : [key description]); [key isKindOfClass:[NSString class]] ? key : [key description]);

View file

@ -88,7 +88,7 @@ class CertVerifierRequest : public AtomCertVerifier::Request {
void OnDefaultVerificationDone(int error) { void OnDefaultVerificationDone(int error) {
error_ = error; error_ = error;
std::unique_ptr<VerifyRequestParams> request(new VerifyRequestParams()); auto request = std::make_unique<VerifyRequestParams>();
request->hostname = params_.hostname(); request->hostname = params_.hostname();
request->default_result = net::ErrorToString(error); request->default_result = net::ErrorToString(error);
request->error_code = error; request->error_code = error;
@ -174,8 +174,7 @@ int AtomCertVerifier::Verify(const RequestParams& params,
CertVerifierRequest* request = FindRequest(params); CertVerifierRequest* request = FindRequest(params);
if (!request) { if (!request) {
out_req->reset(); out_req->reset();
std::unique_ptr<CertVerifierRequest> new_request = auto new_request = std::make_unique<CertVerifierRequest>(params, this);
std::make_unique<CertVerifierRequest>(params, this);
new_request->Start(crl_set, net_log); new_request->Start(crl_set, net_log);
request = new_request.get(); request = new_request.get();
*out_req = std::move(new_request); *out_req = std::move(new_request);

View file

@ -105,7 +105,7 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) {
void ToDictionary(base::DictionaryValue* details, void ToDictionary(base::DictionaryValue* details,
const net::HttpRequestHeaders& headers) { const net::HttpRequestHeaders& headers) {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); auto dict = std::make_unique<base::DictionaryValue>();
net::HttpRequestHeaders::Iterator it(headers); net::HttpRequestHeaders::Iterator it(headers);
while (it.GetNext()) while (it.GetNext())
dict->SetKey(it.name(), base::Value(it.value())); dict->SetKey(it.name(), base::Value(it.value()));
@ -117,7 +117,7 @@ void ToDictionary(base::DictionaryValue* details,
if (!headers) if (!headers)
return; return;
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); auto dict = std::make_unique<base::DictionaryValue>();
size_t iter = 0; size_t iter = 0;
std::string key; std::string key;
std::string value; std::string value;
@ -127,7 +127,7 @@ void ToDictionary(base::DictionaryValue* details,
if (dict->GetList(key, &values)) if (dict->GetList(key, &values))
values->AppendString(value); values->AppendString(value);
} else { } else {
std::unique_ptr<base::ListValue> values(new base::ListValue); auto values = std::make_unique<base::ListValue>();
values->AppendString(value); values->AppendString(value);
dict->Set(key, std::move(values)); dict->Set(key, std::move(values));
} }
@ -388,7 +388,7 @@ int AtomNetworkDelegate::HandleResponseEvent(
if (!MatchesFilterCondition(request, info.url_patterns)) if (!MatchesFilterCondition(request, info.url_patterns))
return net::OK; return net::OK;
std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue); auto details = std::make_unique<base::DictionaryValue>();
FillDetailsObject(details.get(), request, args...); FillDetailsObject(details.get(), request, args...);
int render_process_id, render_frame_id; int render_process_id, render_frame_id;
@ -416,7 +416,7 @@ void AtomNetworkDelegate::HandleSimpleEvent(SimpleEvent type,
if (!MatchesFilterCondition(request, info.url_patterns)) if (!MatchesFilterCondition(request, info.url_patterns))
return; return;
std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue); auto details = std::make_unique<base::DictionaryValue>();
FillDetailsObject(details.get(), request, args...); FillDetailsObject(details.get(), request, args...);
int render_process_id, render_frame_id; int render_process_id, render_frame_id;

View file

@ -68,8 +68,7 @@ class JsAsker : public RequestJob {
private: private:
// RequestJob: // RequestJob:
void Start() override { void Start() override {
std::unique_ptr<base::DictionaryValue> request_details( auto request_details = std::make_unique<base::DictionaryValue>();
new base::DictionaryValue);
request_start_time_ = base::TimeTicks::Now(); request_start_time_ = base::TimeTicks::Now();
FillRequestDetails(request_details.get(), RequestJob::request()); FillRequestDetails(request_details.get(), RequestJob::request());
content::BrowserThread::PostTask( content::BrowserThread::PostTask(

View file

@ -187,8 +187,8 @@ void FileChooserDialog::AddFilters(const Filters& filters) {
GtkFileFilter* gtk_filter = gtk_file_filter_new(); GtkFileFilter* gtk_filter = gtk_file_filter_new();
for (size_t j = 0; j < filter.second.size(); ++j) { for (size_t j = 0; j < filter.second.size(); ++j) {
std::unique_ptr<std::string> file_extension( auto file_extension =
new std::string("." + filter.second[j])); std::make_unique<std::string>("." + filter.second[j]);
gtk_file_filter_add_custom( gtk_file_filter_add_custom(
gtk_filter, GTK_FILE_FILTER_FILENAME, gtk_filter, GTK_FILE_FILTER_FILENAME,
reinterpret_cast<GtkFileFilterFunc>(FileFilterCaseInsensitive), reinterpret_cast<GtkFileFilterFunc>(FileFilterCaseInsensitive),

View file

@ -85,13 +85,9 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
// Create array to keep file types and their name. // Create array to keep file types and their name.
for (const Filter& filter : filters) { for (const Filter& filter : filters) {
NSMutableSet* file_type_set = [NSMutableSet set]; NSMutableSet* file_type_set = [NSMutableSet set];
base::ScopedCFTypeRef<CFStringRef> name_cf( [filter_names addObject:@(filter.first.c_str())];
base::SysUTF8ToCFStringRef(filter.first));
[filter_names addObject:base::mac::CFToNSCast(name_cf.get())];
for (const std::string& ext : filter.second) { for (const std::string& ext : filter.second) {
base::ScopedCFTypeRef<CFStringRef> ext_cf( [file_type_set addObject:@(ext.c_str())];
base::SysUTF8ToCFStringRef(ext));
[file_type_set addObject:base::mac::CFToNSCast(ext_cf.get())];
} }
[file_types_list addObject:[file_type_set allObjects]]; [file_types_list addObject:[file_type_set allObjects]];
} }

View file

@ -151,8 +151,8 @@ struct RunState {
}; };
bool CreateDialogThread(RunState* run_state) { bool CreateDialogThread(RunState* run_state) {
std::unique_ptr<base::Thread> thread( auto thread =
new base::Thread(ATOM_PRODUCT_NAME "FileDialogThread")); std::make_unique<base::Thread>(ATOM_PRODUCT_NAME "FileDialogThread");
thread->init_com_with_mta(false); thread->init_com_with_mta(false);
if (!thread->Start()) if (!thread->Start())
return false; return false;

View file

@ -257,8 +257,8 @@ void ShowMessageBox(NativeWindow* parent,
bool checkbox_checked, bool checkbox_checked,
const gfx::ImageSkia& icon, const gfx::ImageSkia& icon,
const MessageBoxCallback& callback) { const MessageBoxCallback& callback) {
std::unique_ptr<base::Thread> thread( auto thread =
new base::Thread(ATOM_PRODUCT_NAME "MessageBoxThread")); std::make_unique<base::Thread>(ATOM_PRODUCT_NAME "MessageBoxThread");
thread->init_com_with_mta(false); thread->init_com_with_mta(false);
if (!thread->Start()) { if (!thread->Start()) {
callback.Run(cancel_id, checkbox_checked); callback.Run(cancel_id, checkbox_checked);

View file

@ -23,7 +23,7 @@ class Archive : public mate::Wrappable<Archive> {
public: public:
static v8::Local<v8::Value> Create(v8::Isolate* isolate, static v8::Local<v8::Value> Create(v8::Isolate* isolate,
const base::FilePath& path) { const base::FilePath& path) {
std::unique_ptr<asar::Archive> archive(new asar::Archive(path)); auto archive = std::make_unique<asar::Archive>(path);
if (!archive->Init()) if (!archive->Init())
return v8::False(isolate); return v8::False(isolate);
return (new Archive(isolate, std::move(archive)))->GetWrapper(); return (new Archive(isolate, std::move(archive)))->GetWrapper();

View file

@ -85,7 +85,7 @@ bool AddImageSkiaRep(gfx::ImageSkia* image,
int width, int width,
int height, int height,
double scale_factor) { double scale_factor) {
std::unique_ptr<SkBitmap> decoded(new SkBitmap()); auto decoded = std::make_unique<SkBitmap>();
// Try PNG first. // Try PNG first.
if (!gfx::PNGCodec::Decode(data, size, decoded.get())) { if (!gfx::PNGCodec::Decode(data, size, decoded.get())) {

View file

@ -157,8 +157,7 @@ v8::Local<v8::Value> AtomBindings::GetHeapStatistics(v8::Isolate* isolate) {
// static // static
v8::Local<v8::Value> AtomBindings::GetProcessMemoryInfo(v8::Isolate* isolate) { v8::Local<v8::Value> AtomBindings::GetProcessMemoryInfo(v8::Isolate* isolate) {
std::unique_ptr<base::ProcessMetrics> metrics( auto metrics = base::ProcessMetrics::CreateCurrentProcessMetrics();
base::ProcessMetrics::CreateCurrentProcessMetrics());
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("workingSetSize", dict.Set("workingSetSize",
@ -224,8 +223,7 @@ v8::Local<v8::Value> AtomBindings::GetCPUUsage(v8::Isolate* isolate) {
// static // static
v8::Local<v8::Value> AtomBindings::GetIOCounters(v8::Isolate* isolate) { v8::Local<v8::Value> AtomBindings::GetIOCounters(v8::Isolate* isolate) {
std::unique_ptr<base::ProcessMetrics> metrics( auto metrics = base::ProcessMetrics::CreateCurrentProcessMetrics();
base::ProcessMetrics::CreateCurrentProcessMetrics());
base::IoCounters io_counters; base::IoCounters io_counters;
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);

View file

@ -291,7 +291,7 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
return true; return true;
} }
std::unique_ptr<ScopedTemporaryFile> temp_file(new ScopedTemporaryFile); auto temp_file = std::make_unique<ScopedTemporaryFile>();
base::FilePath::StringType ext = path.Extension(); base::FilePath::StringType ext = path.Extension();
if (!temp_file->InitFromFile(&file_, ext, info.offset, info.size)) if (!temp_file->InitFromFile(&file_, ext, info.offset, info.size))
return false; return false;

View file

@ -209,10 +209,9 @@ v8::Local<v8::Value> Converter<scoped_refptr<ResourceRequestBody>>::ToV8(
const scoped_refptr<ResourceRequestBody>& val) { const scoped_refptr<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 == ResourceRequestBody::Element::TYPE_BYTES) { if (type == ResourceRequestBody::Element::TYPE_BYTES) {
std::unique_ptr<base::Value> bytes(base::Value::CreateWithCopiedBuffer( std::unique_ptr<base::Value> bytes(base::Value::CreateWithCopiedBuffer(
@ -249,7 +248,7 @@ bool Converter<scoped_refptr<ResourceRequestBody>>::FromV8(
v8::Isolate* isolate, v8::Isolate* isolate,
v8::Local<v8::Value> val, v8::Local<v8::Value> val,
scoped_refptr<ResourceRequestBody>* out) { scoped_refptr<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 content::ResourceRequestBody(); *out = new content::ResourceRequestBody();

View file

@ -158,7 +158,7 @@ v8::Local<v8::Value> Converter<net::HttpResponseHeaders*>::ToV8(
if (response_headers.GetList(key, &values)) if (response_headers.GetList(key, &values))
values->AppendString(value); values->AppendString(value);
} else { } else {
std::unique_ptr<base::ListValue> values(new base::ListValue()); auto values = std::make_unique<base::ListValue>();
values->AppendString(value); values->AppendString(value);
response_headers.Set(key, std::move(values)); response_headers.Set(key, std::move(values));
} }
@ -208,12 +208,11 @@ void FillRequestDetails(base::DictionaryValue* details,
url = request->url().spec(); url = request->url().spec();
details->SetKey("url", base::Value(url)); details->SetKey("url", base::Value(url));
details->SetString("referrer", request->referrer()); details->SetString("referrer", request->referrer());
std::unique_ptr<base::ListValue> list(new base::ListValue); auto list = std::make_unique<base::ListValue>();
GetUploadData(list.get(), request); GetUploadData(list.get(), request);
if (!list->empty()) if (!list->empty())
details->Set("uploadData", std::move(list)); details->Set("uploadData", std::move(list));
std::unique_ptr<base::DictionaryValue> headers_value( auto headers_value = std::make_unique<base::DictionaryValue>();
new base::DictionaryValue);
for (net::HttpRequestHeaders::Iterator it(request->extra_request_headers()); for (net::HttpRequestHeaders::Iterator it(request->extra_request_headers());
it.GetNext();) { it.GetNext();) {
headers_value->SetString(it.name(), it.value()); headers_value->SetString(it.name(), it.value());
@ -229,8 +228,7 @@ void GetUploadData(base::ListValue* upload_data_list,
const std::vector<std::unique_ptr<net::UploadElementReader>>* readers = const std::vector<std::unique_ptr<net::UploadElementReader>>* readers =
upload_data->GetElementReaders(); upload_data->GetElementReaders();
for (const auto& reader : *readers) { for (const auto& reader : *readers) {
std::unique_ptr<base::DictionaryValue> upload_data_dict( auto upload_data_dict = std::make_unique<base::DictionaryValue>();
new base::DictionaryValue);
if (reader->AsBytesReader()) { if (reader->AsBytesReader()) {
const net::UploadBytesElementReader* bytes_reader = const net::UploadBytesElementReader* bytes_reader =
reader->AsBytesReader(); reader->AsBytesReader();

View file

@ -429,7 +429,7 @@ base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,
val->CreationContext() != isolate->GetCurrentContext()) val->CreationContext() != isolate->GetCurrentContext())
scope.reset(new v8::Context::Scope(val->CreationContext())); scope.reset(new v8::Context::Scope(val->CreationContext()));
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); auto result = std::make_unique<base::DictionaryValue>();
v8::Local<v8::Array> property_names(val->GetOwnPropertyNames()); v8::Local<v8::Array> property_names(val->GetOwnPropertyNames());
for (uint32_t i = 0; i < property_names->Length(); ++i) { for (uint32_t i = 0; i < property_names->Length(); ++i) {

View file

@ -195,8 +195,8 @@ void WebFrame::SetSpellCheckProvider(mate::Arguments* args,
return; return;
} }
std::unique_ptr<SpellCheckClient> client(new SpellCheckClient( auto client = std::make_unique<SpellCheckClient>(
language, auto_spell_correct_turned_on, args->isolate(), provider)); language, auto_spell_correct_turned_on, args->isolate(), provider);
// Set spellchecker for all live frames in the same process or // Set spellchecker for all live frames in the same process or
// in the sandbox mode for all live sub frames to this WebFrame. // in the sandbox mode for all live sub frames to this WebFrame.
FrameSpellChecker spell_checker( FrameSpellChecker spell_checker(

View file

@ -136,9 +136,7 @@ void RendererClientBase::RenderThreadStarted() {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool scroll_bounce = command_line->HasSwitch(switches::kScrollBounce); bool scroll_bounce = command_line->HasSwitch(switches::kScrollBounce);
base::ScopedCFTypeRef<CFStringRef> rubber_banding_key( CFPreferencesSetAppValue(CFSTR("NSScrollViewRubberbanding"),
base::SysUTF8ToCFStringRef("NSScrollViewRubberbanding"));
CFPreferencesSetAppValue(rubber_banding_key,
scroll_bounce ? kCFBooleanTrue : kCFBooleanFalse, scroll_bounce ? kCFBooleanTrue : kCFBooleanFalse,
kCFPreferencesCurrentApplication); kCFPreferencesCurrentApplication);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);