From a9eb0cbec0787f98acbe63ab87d83071b7cb4c2d Mon Sep 17 00:00:00 2001 From: Aleksei Kuzmin Date: Thu, 24 Aug 2017 01:42:59 +0300 Subject: [PATCH] Ban raw pointers to ref-counted types on base::Bind https://chromium-review.googlesource.com/c/chromium/src/+/549537 --- atom/browser/api/atom_api_session.cc | 3 ++- atom/browser/net/atom_url_request.cc | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 0d1f6a71782b..0a124c446623 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -623,7 +623,8 @@ void Session::SetUserAgent(const std::string& user_agent, std::string accept_lang = l10n_util::GetApplicationLocale(""); args->GetNext(&accept_lang); - auto getter = browser_context_->GetRequestContext(); + scoped_refptr getter( + browser_context_->GetRequestContext()); getter->GetNetworkTaskRunner()->PostTask( FROM_HERE, base::Bind(&SetUserAgentInIO, getter, accept_lang, user_agent)); diff --git a/atom/browser/net/atom_url_request.cc b/atom/browser/net/atom_url_request.cc index 9400f361f11a..e75aba913732 100644 --- a/atom/browser/net/atom_url_request.cc +++ b/atom/browser/net/atom_url_request.cc @@ -69,7 +69,8 @@ scoped_refptr AtomURLRequest::Create( if (!browser_context || url.empty() || !delegate) { return nullptr; } - auto request_context_getter = browser_context->url_request_context_getter(); + scoped_refptr request_context_getter( + browser_context->url_request_context_getter()); DCHECK(request_context_getter); if (!request_context_getter) { return nullptr; @@ -439,7 +440,7 @@ bool AtomURLRequest::CopyAndPostBuffer(int bytes_read) { // data is only a wrapper for the asynchronous response_read_buffer_. // Make a deep copy of payload and transfer ownership to the UI thread. - auto buffer_copy = new net::IOBufferWithSize(bytes_read); + auto buffer_copy = make_scoped_refptr(new net::IOBufferWithSize(bytes_read)); memcpy(buffer_copy->data(), response_read_buffer_->data(), bytes_read); return content::BrowserThread::PostTask(