make_scoped_refptr --> WrapRefCounted

This commit is contained in:
Samuel Attard 2017-12-18 11:23:02 +11:00 committed by Aleksei Kuzmin
parent 4666879f94
commit 12066a60f3
11 changed files with 26 additions and 26 deletions

View file

@ -659,7 +659,7 @@ void App::OnLogin(LoginHandler* login_handler,
request_details, request_details,
login_handler->auth_info(), login_handler->auth_info(),
base::Bind(&PassLoginInformation, base::Bind(&PassLoginInformation,
make_scoped_refptr(login_handler))); WrapRefCounted(login_handler)));
} }
// Default behavior is to always cancel the auth. // Default behavior is to always cancel the auth.

View file

@ -250,7 +250,7 @@ Cookies::~Cookies() {}
void Cookies::Get(const base::DictionaryValue& filter, void Cookies::Get(const base::DictionaryValue& filter,
const GetCallback& callback) { const GetCallback& callback) {
std::unique_ptr<base::DictionaryValue> copied(filter.CreateDeepCopy()); std::unique_ptr<base::DictionaryValue> copied(filter.CreateDeepCopy());
auto getter = make_scoped_refptr(request_context_getter_); auto getter = WrapRefCounted(request_context_getter_);
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(GetCookiesOnIO, getter, Passed(&copied), callback)); base::Bind(GetCookiesOnIO, getter, Passed(&copied), callback));
@ -258,7 +258,7 @@ void Cookies::Get(const base::DictionaryValue& filter,
void Cookies::Remove(const GURL& url, const std::string& name, void Cookies::Remove(const GURL& url, const std::string& name,
const base::Closure& callback) { const base::Closure& callback) {
auto getter = make_scoped_refptr(request_context_getter_); auto getter = WrapRefCounted(request_context_getter_);
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(RemoveCookieOnIOThread, getter, url, name, callback)); base::Bind(RemoveCookieOnIOThread, getter, url, name, callback));
@ -267,14 +267,14 @@ void Cookies::Remove(const GURL& url, const std::string& name,
void Cookies::Set(const base::DictionaryValue& details, void Cookies::Set(const base::DictionaryValue& details,
const SetCallback& callback) { const SetCallback& callback) {
std::unique_ptr<base::DictionaryValue> copied(details.CreateDeepCopy()); std::unique_ptr<base::DictionaryValue> copied(details.CreateDeepCopy());
auto getter = make_scoped_refptr(request_context_getter_); auto getter = WrapRefCounted(request_context_getter_);
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(SetCookieOnIO, getter, Passed(&copied), callback)); base::Bind(SetCookieOnIO, getter, Passed(&copied), callback));
} }
void Cookies::FlushStore(const base::Closure& callback) { void Cookies::FlushStore(const base::Closure& callback) {
auto getter = make_scoped_refptr(request_context_getter_); auto getter = WrapRefCounted(request_context_getter_);
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(FlushCookieStoreOnIOThread, getter, callback)); base::Bind(FlushCookieStoreOnIOThread, getter, callback));

View file

@ -498,7 +498,7 @@ template<Session::CacheAction action>
void Session::DoCacheAction(const net::CompletionCallback& callback) { void Session::DoCacheAction(const net::CompletionCallback& callback) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&DoCacheActionInIO, base::Bind(&DoCacheActionInIO,
make_scoped_refptr(browser_context_->GetRequestContext()), WrapRefCounted(browser_context_->GetRequestContext()),
action, action,
callback)); callback));
} }
@ -591,7 +591,7 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&SetCertVerifyProcInIO, base::Bind(&SetCertVerifyProcInIO,
make_scoped_refptr(browser_context_->GetRequestContext()), WrapRefCounted(browser_context_->GetRequestContext()),
proc)); proc));
} }
@ -613,7 +613,7 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&ClearHostResolverCacheInIO, base::Bind(&ClearHostResolverCacheInIO,
make_scoped_refptr(browser_context_->GetRequestContext()), WrapRefCounted(browser_context_->GetRequestContext()),
callback)); callback));
} }
@ -629,14 +629,14 @@ void Session::ClearAuthCache(mate::Arguments* args) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(&ClearAuthCacheInIO, base::Bind(&ClearAuthCacheInIO,
make_scoped_refptr(browser_context_->GetRequestContext()), WrapRefCounted(browser_context_->GetRequestContext()),
options, callback)); options, callback));
} }
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) { void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&AllowNTLMCredentialsForDomainsInIO, base::Bind(&AllowNTLMCredentialsForDomainsInIO,
make_scoped_refptr(browser_context_->GetRequestContext()), WrapRefCounted(browser_context_->GetRequestContext()),
domains)); domains));
} }

View file

@ -49,7 +49,7 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info,
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::Bind(&Browser::RequestLogin, base::Bind(&Browser::RequestLogin,
base::Unretained(Browser::Get()), base::Unretained(Browser::Get()),
base::RetainedRef(make_scoped_refptr(this)), base::RetainedRef(WrapRefCounted(this)),
base::Passed(&request_details))); base::Passed(&request_details)));
} }

View file

@ -144,7 +144,7 @@ int URLRequestAsarJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
dest_size, dest_size,
base::Bind(&URLRequestAsarJob::DidRead, base::Bind(&URLRequestAsarJob::DidRead,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
make_scoped_refptr(dest))); WrapRefCounted(dest)));
if (rv >= 0) { if (rv >= 0) {
remaining_bytes_ -= rv; remaining_bytes_ -= rv;
DCHECK_GE(remaining_bytes_, 0); DCHECK_GE(remaining_bytes_, 0);

View file

@ -444,7 +444,7 @@ bool AtomURLRequest::CopyAndPostBuffer(int bytes_read) {
// data is only a wrapper for the asynchronous response_read_buffer_. // data is only a wrapper for the asynchronous response_read_buffer_.
// Make a deep copy of payload and transfer ownership to the UI thread. // Make a deep copy of payload and transfer ownership to the UI thread.
auto buffer_copy = make_scoped_refptr(new net::IOBufferWithSize(bytes_read)); auto buffer_copy = WrapRefCounted(new net::IOBufferWithSize(bytes_read));
memcpy(buffer_copy->data(), response_read_buffer_->data(), bytes_read); memcpy(buffer_copy->data(), response_read_buffer_->data(), bytes_read);
return content::BrowserThread::PostTask( return content::BrowserThread::PostTask(

View file

@ -119,7 +119,7 @@ int URLRequestStreamJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, content::BrowserThread::UI, FROM_HERE,
base::Bind(&URLRequestStreamJob::CopyMoreData, weak_factory_.GetWeakPtr(), base::Bind(&URLRequestStreamJob::CopyMoreData, weak_factory_.GetWeakPtr(),
make_scoped_refptr(dest), dest_size)); WrapRefCounted(dest), dest_size));
return net::ERR_IO_PENDING; return net::ERR_IO_PENDING;
} }

View file

@ -65,7 +65,7 @@ scoped_refptr<BrowserContext> BrowserContext::Get(
const std::string& partition, bool in_memory) { const std::string& partition, bool in_memory) {
PartitionKey key(partition, in_memory); PartitionKey key(partition, in_memory);
if (browser_context_map_[key].get()) if (browser_context_map_[key].get())
return make_scoped_refptr(browser_context_map_[key].get()); return WrapRefCounted(browser_context_map_[key].get());
return nullptr; return nullptr;
} }
@ -108,7 +108,7 @@ void BrowserContext::InitPrefs() {
pref_store->ReadPrefs(); // Synchronous. pref_store->ReadPrefs(); // Synchronous.
prefs_factory.set_user_prefs(pref_store); prefs_factory.set_user_prefs(pref_store);
auto registry = make_scoped_refptr(new PrefRegistrySimple); auto registry = WrapRefCounted(new PrefRegistrySimple);
RegisterInternalPrefs(registry.get()); RegisterInternalPrefs(registry.get());
RegisterPrefs(registry.get()); RegisterPrefs(registry.get());

View file

@ -126,7 +126,7 @@ void PrintJob::StartPrinting() {
// Real work is done in PrintJobWorker::StartPrinting(). // Real work is done in PrintJobWorker::StartPrinting().
worker_->PostTask(FROM_HERE, worker_->PostTask(FROM_HERE,
base::Bind(&HoldRefCallback, make_scoped_refptr(this), base::Bind(&HoldRefCallback, WrapRefCounted(this),
base::Bind(&PrintJobWorker::StartPrinting, base::Bind(&PrintJobWorker::StartPrinting,
base::Unretained(worker_.get()), base::Unretained(worker_.get()),
base::RetainedRef(document_)))); base::RetainedRef(document_))));
@ -349,7 +349,7 @@ void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) {
DCHECK(!is_job_pending_); DCHECK(!is_job_pending_);
// Sync the document with the worker. // Sync the document with the worker.
worker_->PostTask(FROM_HERE, worker_->PostTask(FROM_HERE,
base::Bind(&HoldRefCallback, make_scoped_refptr(this), base::Bind(&HoldRefCallback, WrapRefCounted(this),
base::Bind(&PrintJobWorker::OnDocumentChanged, base::Bind(&PrintJobWorker::OnDocumentChanged,
base::Unretained(worker_.get()), base::Unretained(worker_.get()),
base::RetainedRef(document_)))); base::RetainedRef(document_))));

View file

@ -25,7 +25,7 @@ PrintQueriesQueue::~PrintQueriesQueue() {
void PrintQueriesQueue::QueuePrinterQuery(PrinterQuery* job) { void PrintQueriesQueue::QueuePrinterQuery(PrinterQuery* job) {
base::AutoLock lock(lock_); base::AutoLock lock(lock_);
DCHECK(job); DCHECK(job);
queued_queries_.push_back(make_scoped_refptr(job)); queued_queries_.push_back(WrapRefCounted(job));
DCHECK(job->is_valid()); DCHECK(job->is_valid());
} }
@ -47,7 +47,7 @@ scoped_refptr<PrinterQuery> PrintQueriesQueue::PopPrinterQuery(
scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery( scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery(
int render_process_id, int render_process_id,
int render_frame_id) { int render_frame_id) {
return make_scoped_refptr( return WrapRefCounted(
new PrinterQuery(render_process_id, render_frame_id)); new PrinterQuery(render_process_id, render_frame_id));
} }

View file

@ -242,7 +242,7 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
if (ask_user_for_settings) { if (ask_user_for_settings) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), base::Bind(&HoldRefCallback, WrapRefCounted(owner_),
base::Bind(&PrintJobWorker::GetSettingsWithUI, base::Bind(&PrintJobWorker::GetSettingsWithUI,
base::Unretained(this), base::Unretained(this),
document_page_count, document_page_count,
@ -251,14 +251,14 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
} else if (!device_name.empty()) { } else if (!device_name.empty()) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), base::Bind(&HoldRefCallback, WrapRefCounted(owner_),
base::Bind(&PrintJobWorker::InitWithDeviceName, base::Bind(&PrintJobWorker::InitWithDeviceName,
base::Unretained(this), base::Unretained(this),
device_name))); device_name)));
} else { } else {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), base::Bind(&HoldRefCallback, WrapRefCounted(owner_),
base::Bind(&PrintJobWorker::UseDefaultSettings, base::Bind(&PrintJobWorker::UseDefaultSettings,
base::Unretained(this)))); base::Unretained(this))));
} }
@ -272,7 +272,7 @@ void PrintJobWorker::SetSettings(
BrowserThread::UI, BrowserThread::UI,
FROM_HERE, FROM_HERE,
base::Bind(&HoldRefCallback, base::Bind(&HoldRefCallback,
make_scoped_refptr(owner_), WrapRefCounted(owner_),
base::Bind(&PrintJobWorker::UpdatePrintSettings, base::Bind(&PrintJobWorker::UpdatePrintSettings,
base::Unretained(this), base::Unretained(this),
base::Passed(&new_settings)))); base::Passed(&new_settings))));
@ -299,7 +299,7 @@ void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) {
// PrintJob will create the new PrintedDocument. // PrintJob will create the new PrintedDocument.
owner_->PostTask(FROM_HERE, owner_->PostTask(FROM_HERE,
base::Bind(&PrintJobWorkerOwner::GetSettingsDone, base::Bind(&PrintJobWorkerOwner::GetSettingsDone,
make_scoped_refptr(owner_), WrapRefCounted(owner_),
printing_context_->settings(), printing_context_->settings(),
result)); result));
} }
@ -313,7 +313,7 @@ void PrintJobWorker::GetSettingsWithUI(
// weak_factory_ creates pointers valid only on owner_ thread. // weak_factory_ creates pointers valid only on owner_ thread.
printing_context_->AskUserForSettings( printing_context_->AskUserForSettings(
document_page_count, has_selection, is_scripted, document_page_count, has_selection, is_scripted,
base::Bind(&PostOnOwnerThread, make_scoped_refptr(owner_), base::Bind(&PostOnOwnerThread, WrapRefCounted(owner_),
base::Bind(&PrintJobWorker::GetSettingsDone, base::Bind(&PrintJobWorker::GetSettingsDone,
weak_factory_.GetWeakPtr()))); weak_factory_.GetWeakPtr())));
} }