Skip to content

Commit

Permalink
Convert implicit scoped_refptr constructor calls to explicit ones, pa…
Browse files Browse the repository at this point in the history
…rt 2

This CL was created automatically by this clang rewriter: http://codereview.appspot.com/2826041
I then did quite a bit of manual editing to fix style issues.

BUG=28083
TEST=None

Review URL: http://codereview.chromium.org/4291001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64798 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thakis@chromium.org committed Nov 2, 2010
1 parent d9b888c commit 00cd9c4
Show file tree
Hide file tree
Showing 52 changed files with 276 additions and 213 deletions.
5 changes: 3 additions & 2 deletions chrome/browser/automation/testing_automation_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,9 @@ void TestingAutomationProvider::DeleteCookie(const GURL& url,
NavigationController* tab = tab_tracker_->GetResource(handle);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
new DeleteCookieTask(url, cookie_name,
tab->profile()->GetRequestContext()));
new DeleteCookieTask(
url, cookie_name,
make_scoped_refptr(tab->profile()->GetRequestContext())));
*success = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/extension_cookies_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ bool RemoveCookieFunction::RunImpl() {
// should happen after this.
bool rv = BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
new RemoveCookieTask(url, name, store_context));
new RemoveCookieTask(url, name, make_scoped_refptr(store_context)));
DCHECK(rv);

return true;
Expand Down
11 changes: 6 additions & 5 deletions chrome/browser/extensions/extension_toolbar_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void ExtensionToolbarModel::MoveBrowserAction(const Extension* extension,
bool inserted = false;
for (ExtensionList::iterator iter = begin(); iter != end(); ++iter, ++i) {
if (i == index) {
toolitems_.insert(iter, extension);
toolitems_.insert(iter, make_scoped_refptr(extension));
inserted = true;
break;
}
Expand All @@ -68,7 +68,7 @@ void ExtensionToolbarModel::MoveBrowserAction(const Extension* extension,
DCHECK_EQ(index, static_cast<int>(toolitems_.size()));
index = toolitems_.size();

toolitems_.push_back(extension);
toolitems_.push_back(make_scoped_refptr(extension));
}

FOR_EACH_OBSERVER(Observer, observers_, BrowserActionMoved(extension, index));
Expand Down Expand Up @@ -111,11 +111,12 @@ void ExtensionToolbarModel::AddExtension(const Extension* extension) {

if (extension->id() == last_extension_removed_ &&
last_extension_removed_index_ < toolitems_.size()) {
toolitems_.insert(begin() + last_extension_removed_index_, extension);
toolitems_.insert(begin() + last_extension_removed_index_,
make_scoped_refptr(extension));
FOR_EACH_OBSERVER(Observer, observers_,
BrowserActionAdded(extension, last_extension_removed_index_));
} else {
toolitems_.push_back(extension);
toolitems_.push_back(make_scoped_refptr(extension));
FOR_EACH_OBSERVER(Observer, observers_,
BrowserActionAdded(extension, toolitems_.size() - 1));
}
Expand Down Expand Up @@ -172,7 +173,7 @@ void ExtensionToolbarModel::InitializeExtensionList() {
int index = std::distance(pref_order.begin(), pos);
sorted[index] = extension;
} else {
unsorted.push_back(extension);
unsorted.push_back(make_scoped_refptr(extension));
}
}

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/extensions/extensions_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ void ExtensionsService::EnableExtension(const std::string& extension_id) {
extension_prefs_->SetExtensionState(extension, Extension::ENABLED);

// Move it over to the enabled list.
extensions_.push_back(extension);
extensions_.push_back(make_scoped_refptr(extension));
ExtensionList::iterator iter = std::find(disabled_extensions_.begin(),
disabled_extensions_.end(),
extension);
Expand All @@ -916,7 +916,7 @@ void ExtensionsService::DisableExtension(const std::string& extension_id) {
extension_prefs_->SetExtensionState(extension, Extension::DISABLED);

// Move it over to the disabled list.
disabled_extensions_.push_back(extension);
disabled_extensions_.push_back(make_scoped_refptr(extension));
ExtensionList::iterator iter = std::find(extensions_.begin(),
extensions_.end(),
extension);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/extensions_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class ExtensionsServiceTest
switch (type.value) {
case NotificationType::EXTENSION_LOADED: {
const Extension* extension = Details<const Extension>(details).ptr();
loaded_.push_back(extension);
loaded_.push_back(make_scoped_refptr(extension));
// The tests rely on the errors being in a certain order, which can vary
// depending on how filesystem iteration works.
std::stable_sort(loaded_.begin(), loaded_.end(), ExtensionsOrder());
Expand Down
12 changes: 5 additions & 7 deletions chrome/browser/memory_purger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class PurgeMemoryIOHelper
: safe_browsing_service_(safe_browsing_service) {
}

void AddRequestContextGetter(URLRequestContextGetter* request_context_getter);
void AddRequestContextGetter(
scoped_refptr<URLRequestContextGetter> request_context_getter);

void PurgeMemoryOnIOThread();

Expand All @@ -52,11 +53,8 @@ class PurgeMemoryIOHelper
};

void PurgeMemoryIOHelper::AddRequestContextGetter(
URLRequestContextGetter* request_context_getter) {
if (!request_context_getters_.count(request_context_getter)) {
request_context_getters_.insert(
RequestContextGetter(request_context_getter));
}
scoped_refptr<URLRequestContextGetter> request_context_getter) {
request_context_getters_.insert(request_context_getter);
}

void PurgeMemoryIOHelper::PurgeMemoryOnIOThread() {
Expand Down Expand Up @@ -104,7 +102,7 @@ void MemoryPurger::PurgeBrowser() {
i != profile_manager->end(); ++i) {
Profile* profile = *i;
purge_memory_io_helper->AddRequestContextGetter(
profile->GetRequestContext());
make_scoped_refptr(profile->GetRequestContext()));

// NOTE: Some objects below may be duplicates across profiles. We could
// conceivably put all these in sets and then iterate over the sets.
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/printing/print_job_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void PrintJobManager::StopJobs(bool wait_for_finish) {
void PrintJobManager::QueuePrinterQuery(PrinterQuery* job) {
AutoLock lock(lock_);
DCHECK(job);
queued_queries_.push_back(job);
queued_queries_.push_back(make_scoped_refptr(job));
DCHECK(job->is_valid());
}

Expand Down Expand Up @@ -116,7 +116,7 @@ void PrintJobManager::OnPrintJobEvent(
current_jobs_.end(),
print_job));
// Causes a AddRef().
current_jobs_.push_back(print_job);
current_jobs_.push_back(make_scoped_refptr(print_job));
break;
}
case JobEventDetails::JOB_DONE: {
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/sync/engine/apply_updates_command_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class ApplyUpdatesCommandTest : public SyncerCommandTest {
virtual void SetUp() {
workers()->clear();
mutable_routing_info()->clear();
workers()->push_back(new ModelSafeWorker()); // GROUP_PASSIVE worker.
// GROUP_PASSIVE worker.
workers()->push_back(make_scoped_refptr(new ModelSafeWorker()));
(*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_PASSIVE;
(*mutable_routing_info())[syncable::PASSWORDS] = GROUP_PASSIVE;
(*mutable_routing_info())[syncable::NIGORI] = GROUP_PASSIVE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ class ProcessCommitResponseCommandTestWithParam
workers()->clear();
mutable_routing_info()->clear();

workers()->push_back(new ModelSafeWorker()); // GROUP_PASSIVE worker.
workers()->push_back(new MockUIModelWorker()); // GROUP_UI worker.
// GROUP_PASSIVE worker.
workers()->push_back(make_scoped_refptr(new ModelSafeWorker()));
// GROUP_UI worker.
workers()->push_back(make_scoped_refptr(new MockUIModelWorker()));
(*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI;
(*mutable_routing_info())[syncable::PREFERENCES] = GROUP_UI;
(*mutable_routing_info())[syncable::AUTOFILL] = GROUP_PASSIVE;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/sync/engine/verify_updates_command_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class VerifyUpdatesCommandTest : public SyncerCommandTest {
virtual void SetUp() {
workers()->clear();
mutable_routing_info()->clear();
workers()->push_back(new MockDBModelWorker());
workers()->push_back(new MockUIModelWorker());
workers()->push_back(make_scoped_refptr(new MockDBModelWorker()));
workers()->push_back(make_scoped_refptr(new MockUIModelWorker()));
(*mutable_routing_info())[syncable::PREFERENCES] = GROUP_UI;
(*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI;
(*mutable_routing_info())[syncable::AUTOFILL] = GROUP_DB;
Expand Down
7 changes: 4 additions & 3 deletions chrome/renderer/render_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2607,7 +2607,8 @@ WebMediaPlayer* RenderView::createMediaPlayer(
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
if (!cmd_line->HasSwitch(switches::kDisableAudio)) {
// Add the chrome specific audio renderer.
collection.push_back(new AudioRendererImpl(audio_message_filter()));
collection.push_back(make_scoped_refptr(
new AudioRendererImpl(audio_message_filter())));
}

if (cmd_line->HasSwitch(switches::kEnableAcceleratedDecoding) &&
Expand All @@ -2618,8 +2619,8 @@ WebMediaPlayer* RenderView::createMediaPlayer(
bool ret = frame->view()->graphicsContext3D()->makeContextCurrent();
CHECK(ret) << "Failed to switch context";

collection.push_back(new IpcVideoDecoder(
MessageLoop::current(), ggl::GetCurrentContext()));
collection.push_back(make_scoped_refptr(new IpcVideoDecoder(
MessageLoop::current(), ggl::GetCurrentContext())));
}

WebApplicationCacheHostImpl* appcache_host =
Expand Down
8 changes: 4 additions & 4 deletions chrome/test/automation/dom_element_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ bool DOMElementProxy::FindElements(const By& by,
return false;
}
for (size_t i = 0; i < element_handles.size(); i++) {
elements->push_back(executor_->GetObjectProxy<DOMElementProxy>(
element_handles[i]));
elements->push_back(make_scoped_refptr(
executor_->GetObjectProxy<DOMElementProxy>(element_handles[i])));
}
return true;
}
Expand All @@ -134,8 +134,8 @@ bool DOMElementProxy::WaitForVisibleElementCount(
}
if (static_cast<int>(element_handles.size()) == count) {
for (size_t i = 0; i < element_handles.size(); i++) {
elements->push_back(executor_->GetObjectProxy<DOMElementProxy>(
element_handles[i]));
elements->push_back(make_scoped_refptr(
executor_->GetObjectProxy<DOMElementProxy>(element_handles[i])));
}
}
return static_cast<int>(element_handles.size()) == count;
Expand Down
4 changes: 2 additions & 2 deletions ipc/ipc_channel_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ChannelProxy::Context::Context(Channel::Listener* listener,
peer_pid_(0),
channel_connected_called_(false) {
if (filter)
filters_.push_back(filter);
filters_.push_back(make_scoped_refptr(filter));
}

void ChannelProxy::Context::CreateChannel(const std::string& id,
Expand Down Expand Up @@ -190,7 +190,7 @@ void ChannelProxy::Context::OnSendMessage(Message* message) {

// Called on the IPC::Channel thread
void ChannelProxy::Context::OnAddFilter(MessageFilter* filter) {
filters_.push_back(filter);
filters_.push_back(make_scoped_refptr(filter));

// If the channel has already been created, then we need to send this message
// so that the filter gets access to the Channel.
Expand Down
2 changes: 1 addition & 1 deletion media/base/pipeline_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ void PipelineImpl::PrepareFilter(scoped_refptr<MediaFilter> filter) {
DCHECK(filter_types_.find(filter->filter_type()) == filter_types_.end())
<< "Filter type " << filter->filter_type() << " already exists";
filter->set_host(this);
filters_.push_back(filter.get());
filters_.push_back(make_scoped_refptr(filter.get()));
filter_types_[filter->filter_type()] = filter.get();
}

Expand Down
4 changes: 2 additions & 2 deletions media/filters/ffmpeg_demuxer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source,
= new FFmpegDemuxerStream(this, stream);

DCHECK(demuxer_stream);
streams_.push_back(demuxer_stream);
packet_streams_.push_back(demuxer_stream);
streams_.push_back(make_scoped_refptr(demuxer_stream));
packet_streams_.push_back(make_scoped_refptr(demuxer_stream));
max_duration = std::max(max_duration, demuxer_stream->duration());
} else {
packet_streams_.push_back(NULL);
Expand Down
16 changes: 10 additions & 6 deletions net/base/host_resolver_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,19 @@ class HostResolverImpl::Job
had_non_speculative_request_(false),
net_log_(BoundNetLog::Make(net_log,
NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB)) {
net_log_.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
new JobCreationParameters(key.hostname,
source_net_log.source()));
net_log_.BeginEvent(
NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
make_scoped_refptr(
new JobCreationParameters(key.hostname, source_net_log.source())));
}

// Attaches a request to this job. The job takes ownership of |req| and will
// take care to delete it.
void AddRequest(Request* req) {
req->request_net_log().BeginEvent(
NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH,
new NetLogSourceParameter("source_dependency", net_log_.source()));
make_scoped_refptr(new NetLogSourceParameter(
"source_dependency", net_log_.source())));

req->set_job(this);
requests_.push_back(req);
Expand Down Expand Up @@ -1238,11 +1240,13 @@ void HostResolverImpl::OnStartRequest(const BoundNetLog& source_net_log,
const RequestInfo& info) {
source_net_log.BeginEvent(
NetLog::TYPE_HOST_RESOLVER_IMPL,
new NetLogSourceParameter("source_dependency", request_net_log.source()));
make_scoped_refptr(new NetLogSourceParameter(
"source_dependency", request_net_log.source())));

request_net_log.BeginEvent(
NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST,
new RequestInfoParameters(info, source_net_log.source()));
make_scoped_refptr(new RequestInfoParameters(
info, source_net_log.source())));

// Notify the observers of the start.
if (!observers_.empty()) {
Expand Down
6 changes: 3 additions & 3 deletions net/disk_cache/file_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void InFlightIO::PostRead(disk_cache::File *file, void* buf, size_t buf_len,
size_t offset, disk_cache::FileIOCallback *callback) {
scoped_refptr<BackgroundIO> operation(
new BackgroundIO(file, buf, buf_len, offset, callback, this));
io_list_.insert(operation.get());
io_list_.insert(operation);
file->AddRef(); // Balanced on InvokeCallback()

if (!callback_thread_)
Expand All @@ -200,7 +200,7 @@ void InFlightIO::PostWrite(disk_cache::File* file, const void* buf,
disk_cache::FileIOCallback* callback) {
scoped_refptr<BackgroundIO> operation(
new BackgroundIO(file, buf, buf_len, offset, callback, this));
io_list_.insert(operation.get());
io_list_.insert(operation);
file->AddRef(); // Balanced on InvokeCallback()

if (!callback_thread_)
Expand Down Expand Up @@ -241,7 +241,7 @@ void InFlightIO::InvokeCallback(BackgroundIO* operation, bool cancel_task) {

// Release the references acquired in PostRead / PostWrite.
operation->file()->Release();
io_list_.erase(operation);
io_list_.erase(make_scoped_refptr(operation));
callback->OnFileIOComplete(bytes);
}

Expand Down
2 changes: 1 addition & 1 deletion net/disk_cache/in_flight_backend_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void InFlightBackendIO::QueueOperationToList(BackendIO* operation,
if (list->empty())
return PostOperation(operation);

list->push_back(operation);
list->push_back(make_scoped_refptr(operation));
}

} // namespace
4 changes: 2 additions & 2 deletions net/disk_cache/in_flight_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ void InFlightIO::InvokeCallback(BackgroundIO* operation, bool cancel_task) {
// Make sure that we remove the operation from the list before invoking the
// callback (so that a subsequent cancel does not invoke the callback again).
DCHECK(io_list_.find(operation) != io_list_.end());
io_list_.erase(operation);
io_list_.erase(make_scoped_refptr(operation));
OnOperationComplete(operation, cancel_task);
}

// Runs on the primary thread.
void InFlightIO::OnOperationPosted(BackgroundIO* operation) {
DCHECK(callback_thread_->BelongsToCurrentThread());
io_list_.insert(operation);
io_list_.insert(make_scoped_refptr(operation));
}

} // namespace disk_cache
6 changes: 3 additions & 3 deletions net/http/http_network_transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ int HttpNetworkTransaction::DoSendRequest() {
if (net_log_.IsLoggingAllEvents()) {
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS,
new NetLogHttpRequestParameter(request_->url.spec(),
request_->extra_headers));
make_scoped_refptr(new NetLogHttpRequestParameter(
request_->url.spec(), request_->extra_headers)));
}

headers_valid_ = false;
Expand Down Expand Up @@ -732,7 +732,7 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) {
if (net_log_.IsLoggingAllEvents()) {
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS,
new NetLogHttpResponseParameter(response_.headers));
make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers)));
}

if (response_.headers->GetParsedHttpVersion() < HttpVersion(1, 0)) {
Expand Down
6 changes: 3 additions & 3 deletions net/http/http_proxy_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ int HttpProxyClientSocket::DoSendRequest() {
if (net_log_.IsLoggingAllEvents()) {
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
new NetLogHttpRequestParameter(
request_line, request_headers));
make_scoped_refptr(new NetLogHttpRequestParameter(
request_line, request_headers)));
}
request_headers_ = request_line + request_headers.ToString();
}
Expand Down Expand Up @@ -381,7 +381,7 @@ int HttpProxyClientSocket::DoReadHeadersComplete(int result) {
if (net_log_.IsLoggingAllEvents()) {
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
new NetLogHttpResponseParameter(response_.headers));
make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers)));
}

switch (response_.headers->response_code()) {
Expand Down
Loading

0 comments on commit 00cd9c4

Please sign in to comment.