diff options
author | vmpstr <vmpstr@chromium.org> | 2016-03-21 13:28:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-21 20:30:28 +0000 |
commit | a34d11324e0767acd94d8754e3a117e072492cf4 (patch) | |
tree | ac723766c79172c76341b45aab9c1914169b4466 | |
parent | 8a2f463d3726f944f5ec279664b25118fd3ccf3c (diff) | |
download | chromium_src-a34d11324e0767acd94d8754e3a117e072492cf4.zip chromium_src-a34d11324e0767acd94d8754e3a117e072492cf4.tar.gz chromium_src-a34d11324e0767acd94d8754e3a117e072492cf4.tar.bz2 |
Add RetainedRef uses where needed.
This patch adds RetainedRef uses where they are required. These
changes will be required when we remove automatic unwrapping of
scoped_refptrs in Bind.
Please see the bug for more context.
R=tzik@chromium.org, thakis@chromium.org, danakj@chromium.org
BUG=589048
Review URL: https://codereview.chromium.org/1815363002
Cr-Commit-Position: refs/heads/master@{#382371}
114 files changed, 627 insertions, 762 deletions
diff --git a/base/deferred_sequenced_task_runner_unittest.cc b/base/deferred_sequenced_task_runner_unittest.cc index 883a3dd..1ddc354 100644 --- a/base/deferred_sequenced_task_runner_unittest.cc +++ b/base/deferred_sequenced_task_runner_unittest.cc @@ -156,10 +156,9 @@ TEST_F(DeferredSequencedTaskRunnerTest, ObjectDestructionOrder) { scoped_refptr<ExecuteTaskOnDestructor> short_lived_object = new ExecuteTaskOnDestructor(this, 2 * i); runner_->PostTask( - FROM_HERE, - base::Bind(&DeferredSequencedTaskRunnerTest::DoNothing, - base::Unretained(this), - short_lived_object)); + FROM_HERE, base::Bind(&DeferredSequencedTaskRunnerTest::DoNothing, + base::Unretained(this), + base::RetainedRef(short_lived_object))); } // |short_lived_object| with id |2 * i| should be destroyed before the // task |2 * i + 1| is executed. diff --git a/base/synchronization/waitable_event_watcher_posix.cc b/base/synchronization/waitable_event_watcher_posix.cc index aa425f2..7cf8688 100644 --- a/base/synchronization/waitable_event_watcher_posix.cc +++ b/base/synchronization/waitable_event_watcher_posix.cc @@ -145,8 +145,8 @@ bool WaitableEventWatcher::StartWatching( cancel_flag_ = new Flag; callback_ = callback; - internal_callback_ = - base::Bind(&AsyncCallbackHelper, cancel_flag_, callback_, event); + internal_callback_ = base::Bind( + &AsyncCallbackHelper, base::RetainedRef(cancel_flag_), callback_, event); WaitableEvent::WaitableEventKernel* kernel = event->kernel_.get(); AutoLock locked(kernel->lock_); diff --git a/base/task/cancelable_task_tracker.cc b/base/task/cancelable_task_tracker.cc index a756f4e..881249b 100644 --- a/base/task/cancelable_task_tracker.cc +++ b/base/task/cancelable_task_tracker.cc @@ -131,9 +131,10 @@ CancelableTaskTracker::TaskId CancelableTaskTracker::NewTrackedTaskId( // Will always run |untrack_and_delete_flag| on current MessageLoop. base::ScopedClosureRunner* untrack_and_delete_flag_runner = - new base::ScopedClosureRunner(Bind(&RunOrPostToTaskRunner, - base::ThreadTaskRunnerHandle::Get(), - untrack_and_delete_flag)); + new base::ScopedClosureRunner( + Bind(&RunOrPostToTaskRunner, + RetainedRef(base::ThreadTaskRunnerHandle::Get()), + untrack_and_delete_flag)); *is_canceled_cb = Bind(&IsCanceled, flag, base::Owned(untrack_and_delete_flag_runner)); diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc index 6550790..65471c7 100644 --- a/base/test/launcher/test_launcher.cc +++ b/base/test/launcher/test_launcher.cc @@ -563,11 +563,12 @@ void TestLauncher::LaunchChildGTestProcess( bool redirect_stdio = (parallel_jobs_ > 1) || BotModeEnabled(); worker_pool_owner_->pool()->PostWorkerTask( - FROM_HERE, Bind(&DoLaunchChildTestProcess, new_command_line, timeout, - options, redirect_stdio, ThreadTaskRunnerHandle::Get(), - Bind(&TestLauncher::OnLaunchTestProcessFinished, - Unretained(this), completed_callback), - launched_callback)); + FROM_HERE, + Bind(&DoLaunchChildTestProcess, new_command_line, timeout, options, + redirect_stdio, RetainedRef(ThreadTaskRunnerHandle::Get()), + Bind(&TestLauncher::OnLaunchTestProcessFinished, Unretained(this), + completed_callback), + launched_callback)); } void TestLauncher::OnTestFinished(const TestResult& result) { diff --git a/base/test/sequenced_task_runner_test_template.h b/base/test/sequenced_task_runner_test_template.h index ac5f3c6..a510030 100644 --- a/base/test/sequenced_task_runner_test_template.h +++ b/base/test/sequenced_task_runner_test_template.h @@ -211,7 +211,7 @@ TYPED_TEST_P(SequencedTaskRunnerTest, NonNestablePostFromNonNestableTask) { Closure task = Bind( &internal::SequencedTaskTracker::PostNonNestableTasks, this->task_tracker_, - task_runner, + RetainedRef(task_runner), kChildrenPerParent); this->task_tracker_->PostWrappedNonNestableTask(task_runner.get(), task); } diff --git a/base/test/task_runner_test_template.h b/base/test/task_runner_test_template.h index c0d3a12..ed04865 100644 --- a/base/test/task_runner_test_template.h +++ b/base/test/task_runner_test_template.h @@ -201,9 +201,13 @@ TYPED_TEST_P(TaskRunnerAffinityTest, RunsTasksOnCurrentThread) { // the non-task-runner thread. for (int i = 0; i < 20; ++i) { const Closure& ith_task_runner_task = this->task_tracker_->WrapTask( - Bind(&test::ExpectRunsTasksOnCurrentThread, true, task_runner), i); + Bind(&test::ExpectRunsTasksOnCurrentThread, true, + base::RetainedRef(task_runner)), + i); const Closure& ith_non_task_runner_task = this->task_tracker_->WrapTask( - Bind(&test::ExpectRunsTasksOnCurrentThread, false, task_runner), i); + Bind(&test::ExpectRunsTasksOnCurrentThread, false, + base::RetainedRef(task_runner)), + i); for (int j = 0; j < i + 1; ++j) { task_runner->PostTask(FROM_HERE, ith_task_runner_task); thread.task_runner()->PostTask(FROM_HERE, ith_non_task_runner_task); diff --git a/base/threading/sequenced_worker_pool_unittest.cc b/base/threading/sequenced_worker_pool_unittest.cc index 2855b9f..a0be607 100644 --- a/base/threading/sequenced_worker_pool_unittest.cc +++ b/base/threading/sequenced_worker_pool_unittest.cc @@ -566,9 +566,8 @@ TEST_F(SequencedWorkerPoolTest, AllowsAfterShutdown) { const int kNumQueuedTasks = static_cast<int>(kNumWorkerThreads); for (int i = 0; i < kNumQueuedTasks; ++i) { EXPECT_TRUE(pool()->PostWorkerTaskWithShutdownBehavior( - FROM_HERE, - base::Bind(&TestTracker::PostAdditionalTasks, tracker(), i, pool(), - false), + FROM_HERE, base::Bind(&TestTracker::PostAdditionalTasks, tracker(), i, + base::RetainedRef(pool()), false), SequencedWorkerPool::BLOCK_SHUTDOWN)); } @@ -808,15 +807,19 @@ TEST_F(SequencedWorkerPoolTest, IsRunningOnCurrentThread) { unsequenced_token)); pool()->PostSequencedWorkerTask( - token1, FROM_HERE, base::Bind(&IsRunningOnCurrentThreadTask, token1, - token2, pool(), unused_pool_owner.pool())); + token1, FROM_HERE, + base::Bind(&IsRunningOnCurrentThreadTask, token1, token2, + base::RetainedRef(pool()), + base::RetainedRef(unused_pool_owner.pool()))); pool()->PostSequencedWorkerTask( token2, FROM_HERE, base::Bind(&IsRunningOnCurrentThreadTask, token2, unsequenced_token, - pool(), unused_pool_owner.pool())); + base::RetainedRef(pool()), + base::RetainedRef(unused_pool_owner.pool()))); pool()->PostWorkerTask( FROM_HERE, base::Bind(&IsRunningOnCurrentThreadTask, unsequenced_token, - token1, pool(), unused_pool_owner.pool())); + token1, base::RetainedRef(pool()), + base::RetainedRef(unused_pool_owner.pool()))); } // Checks that tasks are destroyed in the right context during shutdown. If a @@ -873,9 +876,8 @@ TEST_F(SequencedWorkerPoolTest, FlushForTesting) { base::Bind(&TestTracker::FastTask, tracker(), 0)); } pool()->PostWorkerTask( - FROM_HERE, - base::Bind(&TestTracker::PostAdditionalTasks, tracker(), 0, pool(), - true)); + FROM_HERE, base::Bind(&TestTracker::PostAdditionalTasks, tracker(), 0, + base::RetainedRef(pool()), true)); // We expect all except the delayed task to have been run. We verify all // closures have been deleted by looking at the refcount of the @@ -949,10 +951,10 @@ void VerifyCurrentSequencedTaskRunnerForUnsequencedTask( // VerifyCurrentSequencedTaskRunner() above for why the check is implemented // this way. const bool expected_equal = true; - task_runner->PostTask( - FROM_HERE, - Bind(&VerifySequencedTaskRunnerRunsOnCurrentThread, - std::move(expected_task_runner), expected_equal, callback)); + task_runner->PostTask(FROM_HERE, + Bind(&VerifySequencedTaskRunnerRunsOnCurrentThread, + RetainedRef(std::move(expected_task_runner)), + expected_equal, callback)); } TEST_F(SequencedWorkerPoolTest, GetSequencedTaskRunnerForCurrentThread) { @@ -986,7 +988,7 @@ TEST_F(SequencedWorkerPoolTest, GetSequencedTaskRunnerForCurrentThread) { pool()->PostWorkerTask( FROM_HERE, Bind(&VerifyCurrentSequencedTaskRunnerForUnsequencedTask, - pool(), signal)); + RetainedRef(pool()), signal)); event.Wait(); } diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc index 0749c86..25aa931 100644 --- a/chrome/browser/browsing_data/browsing_data_remover.cc +++ b/chrome/browser/browsing_data/browsing_data_remover.cc @@ -230,8 +230,9 @@ void ClearChannelIDsOnIOThread( net::ChannelIDService* channel_id_service = rq_context->GetURLRequestContext()->channel_id_service(); channel_id_service->GetChannelIDStore()->DeleteAllCreatedBetween( - delete_begin, delete_end, base::Bind(&OnClearedChannelIDsOnIOThread, - std::move(rq_context), callback)); + delete_begin, delete_end, + base::Bind(&OnClearedChannelIDsOnIOThread, + base::RetainedRef(std::move(rq_context)), callback)); } } // namespace @@ -617,7 +618,7 @@ void BrowsingDataRemover::RemoveImpl(const TimeRange& time_range, BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&ClearCookiesOnIOThread, delete_begin_, delete_end_, - std::move(sb_context), + base::RetainedRef(std::move(sb_context)), UIThreadTrampoline( base::Bind(&BrowsingDataRemover::OnClearedCookies, weak_ptr_factory_.GetWeakPtr())))); diff --git a/chrome/browser/captive_portal/captive_portal_browsertest.cc b/chrome/browser/captive_portal/captive_portal_browsertest.cc index 65c3e70..18e860f 100644 --- a/chrome/browser/captive_portal/captive_portal_browsertest.cc +++ b/chrome/browser/captive_portal/captive_portal_browsertest.cc @@ -2796,7 +2796,7 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, HstsLogin) { content::BrowserThread::PostTask( content::BrowserThread::IO, FROM_HERE, base::Bind(&AddHstsHost, - make_scoped_refptr(browser()->profile()->GetRequestContext()), + base::RetainedRef(browser()->profile()->GetRequestContext()), http_timeout_url.host())); SlowLoadBehindCaptivePortal(browser(), true, http_timeout_url, 1, 1); diff --git a/chrome/browser/chrome_net_benchmarking_message_filter.cc b/chrome/browser/chrome_net_benchmarking_message_filter.cc index fa7064f..9dbe3d1 100644 --- a/chrome/browser/chrome_net_benchmarking_message_filter.cc +++ b/chrome/browser/chrome_net_benchmarking_message_filter.cc @@ -72,7 +72,7 @@ void ChromeNetBenchmarkingMessageFilter::OnClearCache(IPC::Message* reply_msg) { http_transaction_factory()->GetCache()->GetCurrentBackend(); if (backend) { net::CompletionCallback callback = - base::Bind(&ClearCacheCallback, make_scoped_refptr(this), reply_msg); + base::Bind(&ClearCacheCallback, base::RetainedRef(this), reply_msg); rv = backend->DoomAllEntries(callback); if (rv == net::ERR_IO_PENDING) { // The callback will send the reply. diff --git a/chrome/browser/errorpage_browsertest.cc b/chrome/browser/errorpage_browsertest.cc index aed026a..676f642 100644 --- a/chrome/browser/errorpage_browsertest.cc +++ b/chrome/browser/errorpage_browsertest.cc @@ -947,7 +947,8 @@ IN_PROC_BROWSER_TEST_F(ErrorPageTest, StaleCacheStatus) { browser()->profile()->GetRequestContext(); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&InterceptNetworkTransactions, url_request_context_getter, + base::Bind(&InterceptNetworkTransactions, + base::RetainedRef(url_request_context_getter), net::ERR_FAILED)); // With no navigation corrections to load, there's only one navigation. @@ -1228,7 +1229,8 @@ IN_PROC_BROWSER_TEST_F(ErrorPageNavigationCorrectionsFailTest, browser()->profile()->GetRequestContext(); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&InterceptNetworkTransactions, url_request_context_getter, + base::Bind(&InterceptNetworkTransactions, + base::RetainedRef(url_request_context_getter), net::ERR_CONNECTION_FAILED)); ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( diff --git a/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc b/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc index 099f869..555e7fa 100644 --- a/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc +++ b/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc @@ -37,9 +37,8 @@ void WaitForStateStore(Profile* profile, const std::string& extension_id) { scoped_refptr<content::MessageLoopRunner> runner = new content::MessageLoopRunner; ExtensionSystem::Get(profile)->state_store()->GetExtensionValue( - extension_id, - kBrowserActionStorageKey, - base::Bind(&QuitMessageLoop, runner)); + extension_id, kBrowserActionStorageKey, + base::Bind(&QuitMessageLoop, base::RetainedRef(runner))); runner->Run(); } diff --git a/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc b/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc index 545a55d..caeedfe 100644 --- a/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc +++ b/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc @@ -275,12 +275,9 @@ ChromeManagementAPIDelegate::GenerateAppForLinkFunctionDelegate( favicon_service->GetFaviconImageForPageURL( launch_url, - base::Bind( - &ChromeAppForLinkDelegate::OnFaviconForApp, - base::Unretained(delegate), - scoped_refptr<extensions::ManagementGenerateAppForLinkFunction>( - function), - context, title, launch_url), + base::Bind(&ChromeAppForLinkDelegate::OnFaviconForApp, + base::Unretained(delegate), base::RetainedRef(function), + context, title, launch_url), &delegate->cancelable_task_tracker_); return scoped_ptr<extensions::AppForLinkDelegate>(delegate); diff --git a/chrome/browser/extensions/app_data_migrator.cc b/chrome/browser/extensions/app_data_migrator.cc index c2734c1..8d13908 100644 --- a/chrome/browser/extensions/app_data_migrator.cc +++ b/chrome/browser/extensions/app_data_migrator.cc @@ -97,8 +97,8 @@ void MigrateFileSystem(WeakPtr<extensions::AppDataMigrator> migrator, // invoke the original callback passed into DoMigrationAndReply. old_fs_context->default_file_task_runner()->PostTaskAndReply( FROM_HERE, - base::Bind(&MigrateOnFileSystemThread, make_scoped_refptr(old_fs_context), - make_scoped_refptr(fs_context), make_scoped_refptr(extension)), + base::Bind(&MigrateOnFileSystemThread, base::RetainedRef(old_fs_context), + base::RetainedRef(fs_context), base::RetainedRef(extension)), reply); } @@ -118,15 +118,15 @@ void MigrateLegacyPartition(WeakPtr<extensions::AppDataMigrator> migrator, // the migration flow after the IndexedDB migration. base::Closure migrate_fs = base::Bind(&MigrateFileSystem, migrator, old_partition, current_partition, - make_scoped_refptr(extension), reply); + base::RetainedRef(extension), reply); // Perform the IndexedDB migration on the old context's sequenced task // runner. After completion, it should call MigrateFileSystem. old_indexed_db_context->TaskRunner()->PostTaskAndReply( - FROM_HERE, base::Bind(&MigrateOnIndexedDBThread, - make_scoped_refptr(old_indexed_db_context), - make_scoped_refptr(indexed_db_context), - make_scoped_refptr(extension)), + FROM_HERE, + base::Bind( + &MigrateOnIndexedDBThread, base::RetainedRef(old_indexed_db_context), + base::RetainedRef(indexed_db_context), base::RetainedRef(extension)), migrate_fs); } diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 7d12152..018b5d6 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -1858,9 +1858,8 @@ void ExtensionService::AddNewOrUpdatedExtension( const Extension* old = GetInstalledExtension(extension->id()); if (extensions::AppDataMigrator::NeedsMigration(old, extension)) { app_data_migrator_->DoMigrationAndReply( - old, extension, - base::Bind(&ExtensionService::FinishInstallation, AsWeakPtr(), - make_scoped_refptr(extension))); + old, extension, base::Bind(&ExtensionService::FinishInstallation, + AsWeakPtr(), base::RetainedRef(extension))); return; } diff --git a/chrome/browser/extensions/extension_system_impl.cc b/chrome/browser/extensions/extension_system_impl.cc index 61b12fe..47c8295 100644 --- a/chrome/browser/extensions/extension_system_impl.cc +++ b/chrome/browser/extensions/extension_system_impl.cc @@ -407,7 +407,7 @@ void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( BrowserThread::PostTaskAndReply( BrowserThread::IO, FROM_HERE, base::Bind(&InfoMap::AddExtension, info_map(), - make_scoped_refptr(extension), install_time, incognito_enabled, + base::RetainedRef(extension), install_time, incognito_enabled, notifications_disabled), callback); } diff --git a/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc b/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc index 50cf314..d5af052 100644 --- a/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc +++ b/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc @@ -223,11 +223,9 @@ void OnSnapshotFileCreatedRunTask( } delegate->CreateSnapshotFile( url.path(), // device file path - snapshot_file_path, - base::Bind(&OnDidCreateSnapshotFile, - callback, - make_scoped_refptr(context->task_runner()), - validate_media_files), + snapshot_file_path, base::Bind(&OnDidCreateSnapshotFile, callback, + base::RetainedRef(context->task_runner()), + validate_media_files), base::Bind(&OnCreateSnapshotFileError, callback)); } @@ -319,7 +317,7 @@ void DeviceMediaAsyncFileUtil::CreateOrOpen( CreateSnapshotFile( std::move(context), url, base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen, - make_scoped_refptr(context->task_runner()), file_flags, + base::RetainedRef(context->task_runner()), file_flags, callback)); } @@ -366,14 +364,12 @@ void DeviceMediaAsyncFileUtil::GetFileInfo( OnGetFileInfoError(callback, base::File::FILE_ERROR_NOT_FOUND); return; } - delegate->GetFileInfo( - url.path(), - base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo, - weak_ptr_factory_.GetWeakPtr(), - make_scoped_refptr(context->task_runner()), - url.path(), - callback), - base::Bind(&OnGetFileInfoError, callback)); + delegate->GetFileInfo(url.path(), + base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo, + weak_ptr_factory_.GetWeakPtr(), + base::RetainedRef(context->task_runner()), + url.path(), callback), + base::Bind(&OnGetFileInfoError, callback)); } void DeviceMediaAsyncFileUtil::ReadDirectory( @@ -391,8 +387,7 @@ void DeviceMediaAsyncFileUtil::ReadDirectory( url.path(), base::Bind(&DeviceMediaAsyncFileUtil::OnDidReadDirectory, weak_ptr_factory_.GetWeakPtr(), - make_scoped_refptr(context->task_runner()), - callback), + base::RetainedRef(context->task_runner()), callback), base::Bind(&OnReadDirectoryError, callback)); } diff --git a/chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.cc b/chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.cc index 8b728a9..eeba117 100644 --- a/chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.cc +++ b/chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.cc @@ -103,17 +103,12 @@ int MTPFileStreamReader::Read(net::IOBuffer* buf, int buf_len, header_buf_len = net::kMaxBytesToSniff; } - ReadBytes(url_, - header_buf.get(), - 0, - header_buf_len, - base::Bind(&MTPFileStreamReader::FinishValidateMediaHeader, - weak_factory_.GetWeakPtr(), - header_buf, - make_scoped_refptr(buf), - buf_len, - callback), - callback); + ReadBytes( + url_, header_buf.get(), 0, header_buf_len, + base::Bind(&MTPFileStreamReader::FinishValidateMediaHeader, + weak_factory_.GetWeakPtr(), base::RetainedRef(header_buf), + base::RetainedRef(buf), buf_len, callback), + callback); return net::ERR_IO_PENDING; } diff --git a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc index f0efdb6..ee3a1d3 100644 --- a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc +++ b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc @@ -135,7 +135,7 @@ void NativeMediaFileUtil::CreateOrOpen( CreateSnapshotFile( std::move(context), url, base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen, - task_runner, file_flags, callback)); + base::RetainedRef(task_runner), file_flags, callback)); } void NativeMediaFileUtil::EnsureFileExists( diff --git a/chrome/browser/media_galleries/fileapi/readahead_file_stream_reader.cc b/chrome/browser/media_galleries/fileapi/readahead_file_stream_reader.cc index 556e71b..7f6843a 100644 --- a/chrome/browser/media_galleries/fileapi/readahead_file_stream_reader.cc +++ b/chrome/browser/media_galleries/fileapi/readahead_file_stream_reader.cc @@ -105,11 +105,9 @@ void ReadaheadFileStreamReader::ReadFromSourceIfNeeded() { scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kBufferSize)); int result = source_->Read( - buf.get(), - kBufferSize, + buf.get(), kBufferSize, base::Bind(&ReadaheadFileStreamReader::OnFinishReadFromSource, - weak_factory_.GetWeakPtr(), - buf)); + weak_factory_.GetWeakPtr(), base::RetainedRef(buf))); if (result != net::ERR_IO_PENDING) OnFinishReadFromSource(buf.get(), result); diff --git a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc index b4f1a99..63d0bc8 100644 --- a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc +++ b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc @@ -627,15 +627,10 @@ void MTPDeviceDelegateImplLinux::ReadBytes( const ErrorCallback& error_callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK(!device_file_path.empty()); - base::Closure closure = - base::Bind(&MTPDeviceDelegateImplLinux::ReadBytesInternal, - weak_ptr_factory_.GetWeakPtr(), - device_file_path, - buf, - offset, - buf_len, - success_callback, - error_callback); + base::Closure closure = base::Bind( + &MTPDeviceDelegateImplLinux::ReadBytesInternal, + weak_ptr_factory_.GetWeakPtr(), device_file_path, base::RetainedRef(buf), + offset, buf_len, success_callback, error_callback); EnsureInitAndRunTask(PendingTaskInfo(device_file_path, content::BrowserThread::IO, FROM_HERE, diff --git a/chrome/browser/net/preconnect.cc b/chrome/browser/net/preconnect.cc index eb06625..1e920af 100644 --- a/chrome/browser/net/preconnect.cc +++ b/chrome/browser/net/preconnect.cc @@ -33,7 +33,7 @@ void PreconnectOnUIThread( BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&PreconnectOnIOThread, url, first_party_for_cookies, - motivation, count, make_scoped_refptr(getter), true)); + motivation, count, base::RetainedRef(getter), true)); return; } diff --git a/chrome/browser/net/sdch_browsertest.cc b/chrome/browser/net/sdch_browsertest.cc index 224c400..0b7d408 100644 --- a/chrome/browser/net/sdch_browsertest.cc +++ b/chrome/browser/net/sdch_browsertest.cc @@ -420,7 +420,7 @@ class SdchBrowserTest : public InProcessBrowserTest, content::BrowserThread::PostTaskAndReply( content::BrowserThread::IO, FROM_HERE, base::Bind(&SdchBrowserTest::NukeSdchDictionariesOnIOThread, - url_request_context_getter_), + base::RetainedRef(url_request_context_getter_)), run_loop.QuitClosure()); run_loop.Run(); } @@ -449,11 +449,10 @@ class SdchBrowserTest : public InProcessBrowserTest, second_browser_->window()->Show(); content::BrowserThread::PostTask( - content::BrowserThread::IO, - FROM_HERE, + content::BrowserThread::IO, FROM_HERE, base::Bind(&SdchBrowserTest::SubscribeToSdchNotifications, base::Unretained(this), - make_scoped_refptr( + base::RetainedRef( second_browser_->profile()->GetRequestContext()))); return true; @@ -466,11 +465,10 @@ class SdchBrowserTest : public InProcessBrowserTest, return false; content::BrowserThread::PostTask( - content::BrowserThread::IO, - FROM_HERE, + content::BrowserThread::IO, FROM_HERE, base::Bind(&SdchBrowserTest::SubscribeToSdchNotifications, base::Unretained(this), - make_scoped_refptr( + base::RetainedRef( incognito_browser_->profile()->GetRequestContext()))); return true; @@ -609,11 +607,10 @@ class SdchBrowserTest : public InProcessBrowserTest, url_request_context_getter_ = browser()->profile()->GetRequestContext(); content::BrowserThread::PostTask( - content::BrowserThread::IO, - FROM_HERE, + content::BrowserThread::IO, FROM_HERE, base::Bind(&SdchBrowserTest::SubscribeToSdchNotifications, base::Unretained(this), - url_request_context_getter_)); + base::RetainedRef(url_request_context_getter_))); } void TearDownOnMainThread() override { diff --git a/chrome/browser/policy/policy_network_browsertest.cc b/chrome/browser/policy/policy_network_browsertest.cc index d69178a..75765cf 100644 --- a/chrome/browser/policy/policy_network_browsertest.cc +++ b/chrome/browser/policy/policy_network_browsertest.cc @@ -37,15 +37,12 @@ void VerifyQuicEnabledStatus(net::URLRequestContextGetter* getter, void VerifyQuicEnabledStatusInIOThread(bool quic_enabled_expected) { base::RunLoop run_loop; - content::BrowserThread::PostTask( - content::BrowserThread::IO, - FROM_HERE, - base::Bind( - VerifyQuicEnabledStatus, - make_scoped_refptr(g_browser_process->system_request_context()), - quic_enabled_expected, - run_loop.QuitClosure())); - run_loop.Run(); + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, + base::Bind(VerifyQuicEnabledStatus, + base::RetainedRef(g_browser_process->system_request_context()), + quic_enabled_expected, run_loop.QuitClosure())); + run_loop.Run(); } } // namespace diff --git a/chrome/browser/printing/print_job.cc b/chrome/browser/printing/print_job.cc index 55a3b8e..6acbc23 100644 --- a/chrome/browser/printing/print_job.cc +++ b/chrome/browser/printing/print_job.cc @@ -131,11 +131,10 @@ void PrintJob::StartPrinting() { // Real work is done in PrintJobWorker::StartPrinting(). worker_->PostTask(FROM_HERE, - base::Bind(&HoldRefCallback, - make_scoped_refptr(this), + base::Bind(&HoldRefCallback, make_scoped_refptr(this), base::Bind(&PrintJobWorker::StartPrinting, base::Unretained(worker_.get()), - document_))); + base::RetainedRef(document_)))); // Set the flag right now. is_job_pending_ = true; @@ -332,11 +331,10 @@ void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) { DCHECK(!is_job_pending_); // Sync the document with the worker. worker_->PostTask(FROM_HERE, - base::Bind(&HoldRefCallback, - make_scoped_refptr(this), + base::Bind(&HoldRefCallback, make_scoped_refptr(this), base::Bind(&PrintJobWorker::OnDocumentChanged, base::Unretained(worker_.get()), - document_))); + base::RetainedRef(document_)))); } } diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc index e7cdf14..283a509 100644 --- a/chrome/browser/printing/print_job_worker.cc +++ b/chrome/browser/printing/print_job_worker.cc @@ -374,11 +374,9 @@ void PrintJobWorker::OnDocumentDone() { } owner_->PostTask(FROM_HERE, - base::Bind(&NotificationCallback, - make_scoped_refptr(owner_), + base::Bind(&NotificationCallback, base::RetainedRef(owner_), JobEventDetails::DOC_DONE, - document_, - scoped_refptr<PrintedPage>())); + base::RetainedRef(document_), nullptr)); // Makes sure the variables are reinitialized. document_ = NULL; @@ -389,12 +387,11 @@ void PrintJobWorker::SpoolPage(PrintedPage* page) { DCHECK_NE(page_number_, PageNumber::npos()); // Signal everyone that the page is about to be printed. - owner_->PostTask(FROM_HERE, - base::Bind(&NotificationCallback, - make_scoped_refptr(owner_), - JobEventDetails::NEW_PAGE, - document_, - make_scoped_refptr(page))); + owner_->PostTask( + FROM_HERE, + base::Bind(&NotificationCallback, base::RetainedRef(owner_), + JobEventDetails::NEW_PAGE, base::RetainedRef(document_), + base::RetainedRef(page))); // Preprocess. if (printing_context_->NewPage() != PrintingContext::OK) { @@ -416,12 +413,11 @@ void PrintJobWorker::SpoolPage(PrintedPage* page) { } // Signal everyone that the page is printed. - owner_->PostTask(FROM_HERE, - base::Bind(&NotificationCallback, - make_scoped_refptr(owner_), - JobEventDetails::PAGE_DONE, - document_, - make_scoped_refptr(page))); + owner_->PostTask( + FROM_HERE, + base::Bind(&NotificationCallback, base::RetainedRef(owner_), + JobEventDetails::PAGE_DONE, base::RetainedRef(document_), + base::RetainedRef(page))); } void PrintJobWorker::OnFailure() { @@ -431,11 +427,9 @@ void PrintJobWorker::OnFailure() { scoped_refptr<PrintJobWorkerOwner> handle(owner_); owner_->PostTask(FROM_HERE, - base::Bind(&NotificationCallback, - make_scoped_refptr(owner_), + base::Bind(&NotificationCallback, base::RetainedRef(owner_), JobEventDetails::FAILED, - document_, - scoped_refptr<PrintedPage>())); + base::RetainedRef(document_), nullptr)); Cancel(); // Makes sure the variables are reinitialized. diff --git a/chrome/browser/printing/pwg_raster_converter.cc b/chrome/browser/printing/pwg_raster_converter.cc index 44e47ad..1b0b4d8 100644 --- a/chrome/browser/printing/pwg_raster_converter.cc +++ b/chrome/browser/printing/pwg_raster_converter.cc @@ -167,7 +167,7 @@ void PwgUtilityProcessHostClient::Convert( BrowserThread::PostTaskAndReply( BrowserThread::FILE, FROM_HERE, base::Bind(&FileHandlers::Init, base::Unretained(files_.get()), - make_scoped_refptr(data)), + base::RetainedRef(data)), base::Bind(&PwgUtilityProcessHostClient::OnFilesReadyOnUIThread, this)); } diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index e31bc57..939b4f3 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -582,7 +582,7 @@ void SafeBrowsingService::Start() { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&SafeBrowsingService::StartOnIOThread, this, - url_request_context_getter_)); + base::RetainedRef(url_request_context_getter_))); } void SafeBrowsingService::Stop(bool shutdown) { diff --git a/chrome/browser/safe_browsing/threat_details_unittest.cc b/chrome/browser/safe_browsing/threat_details_unittest.cc index 88969c4..76380f2 100644 --- a/chrome/browser/safe_browsing/threat_details_unittest.cc +++ b/chrome/browser/safe_browsing/threat_details_unittest.cc @@ -719,7 +719,7 @@ TEST_F(ThreatDetailsTest, HTTPCache) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&FillCache, - make_scoped_refptr(profile()->GetRequestContext()))); + base::RetainedRef(profile()->GetRequestContext()))); // The cache collection starts after the IPC from the DOM is fired. std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params; diff --git a/chrome/browser/ssl/certificate_reporting_test_utils.cc b/chrome/browser/ssl/certificate_reporting_test_utils.cc index 5e7c378..82b78b6 100644 --- a/chrome/browser/ssl/certificate_reporting_test_utils.cc +++ b/chrome/browser/ssl/certificate_reporting_test_utils.cc @@ -140,7 +140,7 @@ void CertificateReportingTest::SetUpMockReporter() { content::BrowserThread::PostTask( content::BrowserThread::IO, FROM_HERE, - base::Bind(SetMockReporter, safe_browsing_service, + base::Bind(SetMockReporter, base::RetainedRef(safe_browsing_service), base::Passed(scoped_ptr<certificate_reporting::ErrorReporter>( reporter_)))); } diff --git a/chrome/browser/ssl/ssl_add_certificate.cc b/chrome/browser/ssl/ssl_add_certificate.cc index 97117f4..a038873 100644 --- a/chrome/browser/ssl/ssl_add_certificate.cc +++ b/chrome/browser/ssl/ssl_add_certificate.cc @@ -212,8 +212,8 @@ void SSLAddCertificate( } else { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&ShowSuccessInfoBar, - render_process_id, render_frame_id, cert)); + base::Bind(&ShowSuccessInfoBar, render_process_id, render_frame_id, + base::RetainedRef(cert))); } } diff --git a/chrome/browser/supervised_user/supervised_user_service.cc b/chrome/browser/supervised_user/supervised_user_service.cc index f3c6ad0..9248854 100644 --- a/chrome/browser/supervised_user/supervised_user_service.cc +++ b/chrome/browser/supervised_user/supervised_user_service.cc @@ -477,10 +477,9 @@ void SupervisedUserService::URLFilterContext::InitAsyncURLChecker( const scoped_refptr<net::URLRequestContextGetter>& context) { ui_url_filter_->InitAsyncURLChecker(context.get()); BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&SupervisedUserURLFilter::InitAsyncURLChecker, - io_url_filter_, context)); + BrowserThread::IO, FROM_HERE, + base::Bind(&SupervisedUserURLFilter::InitAsyncURLChecker, io_url_filter_, + base::RetainedRef(context))); } bool SupervisedUserService::URLFilterContext::HasAsyncURLChecker() const { diff --git a/chrome/browser/sync_file_system/drive_backend/callback_helper_unittest.cc b/chrome/browser/sync_file_system/drive_backend/callback_helper_unittest.cc index 3020c79..6a5cfaa 100644 --- a/chrome/browser/sync_file_system/drive_backend/callback_helper_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/callback_helper_unittest.cc @@ -74,11 +74,10 @@ TEST(DriveBackendCallbackHelperTest, RunOnOtherThreadTest) { bool called = false; base::RunLoop run_loop; worker_task_runner->PostTask( - FROM_HERE, - RelayCallbackToTaskRunner( - ui_task_runner.get(), - FROM_HERE, - base::Bind(&VerifyCalledOnTaskRunner, ui_task_runner, &called))); + FROM_HERE, RelayCallbackToTaskRunner( + ui_task_runner.get(), FROM_HERE, + base::Bind(&VerifyCalledOnTaskRunner, + base::RetainedRef(ui_task_runner), &called))); worker_task_runner->PostTask( FROM_HERE, RelayCallbackToTaskRunner( diff --git a/chrome/browser/sync_file_system/local/canned_syncable_file_system.cc b/chrome/browser/sync_file_system/local/canned_syncable_file_system.cc index 309a53a..3c09c35 100644 --- a/chrome/browser/sync_file_system/local/canned_syncable_file_system.cc +++ b/chrome/browser/sync_file_system/local/canned_syncable_file_system.cc @@ -69,9 +69,9 @@ R RunOnThread( task_runner->PostTask( location, base::Bind(task, base::Bind(&AssignAndQuit<R>, - base::ThreadTaskRunnerHandle::Get(), - run_loop.QuitClosure(), - &result))); + base::RetainedRef( + base::ThreadTaskRunnerHandle::Get()), + run_loop.QuitClosure(), &result))); run_loop.Run(); return result; } @@ -99,7 +99,7 @@ void VerifySameTaskRunner( ASSERT_TRUE(runner1 != nullptr); ASSERT_TRUE(runner2 != nullptr); runner1->PostTask(FROM_HERE, - base::Bind(&EnsureRunningOn, make_scoped_refptr(runner2))); + base::Bind(&EnsureRunningOn, base::RetainedRef(runner2))); } void OnCreateSnapshotFileAndVerifyData( @@ -292,12 +292,12 @@ File::Error CannedSyncableFileSystem::OpenFileSystem() { base::RunLoop run_loop; io_task_runner_->PostTask( FROM_HERE, - base::Bind(&CannedSyncableFileSystem::DoOpenFileSystem, - base::Unretained(this), - base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, - base::Unretained(this), - base::ThreadTaskRunnerHandle::Get(), - run_loop.QuitClosure()))); + base::Bind( + &CannedSyncableFileSystem::DoOpenFileSystem, base::Unretained(this), + base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, + base::Unretained(this), + base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), + run_loop.QuitClosure()))); run_loop.Run(); if (backend()->sync_context()) { @@ -738,12 +738,10 @@ void CannedSyncableFileSystem::DidOpenFileSystem( if (!original_task_runner->RunsTasksOnCurrentThread()) { DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); original_task_runner->PostTask( - FROM_HERE, - base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, - base::Unretained(this), - make_scoped_refptr(original_task_runner), - quit_closure, - root, name, result)); + FROM_HERE, base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, + base::Unretained(this), + base::RetainedRef(original_task_runner), + quit_closure, root, name, result)); return; } result_ = result; diff --git a/chrome/browser/sync_file_system/local/local_file_sync_context.cc b/chrome/browser/sync_file_system/local/local_file_sync_context.cc index d0b9aa6..22c008e 100644 --- a/chrome/browser/sync_file_system/local/local_file_sync_context.cc +++ b/chrome/browser/sync_file_system/local/local_file_sync_context.cc @@ -86,9 +86,7 @@ void LocalFileSyncContext::MaybeInitializeFileSystemContext( // CREATE_IF_NONEXISTENT here. storage::FileSystemBackend::OpenFileSystemCallback open_filesystem_callback = base::Bind(&LocalFileSyncContext::InitializeFileSystemContextOnIOThread, - this, - source_url, - make_scoped_refptr(file_system_context)); + this, source_url, base::RetainedRef(file_system_context)); io_task_runner_->PostTask( FROM_HERE, base::Bind(&storage::SandboxFileSystemBackendDelegate::OpenFileSystem, @@ -115,12 +113,11 @@ void LocalFileSyncContext::GetFileForLocalSync( DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); base::PostTaskAndReplyWithResult( - file_system_context->default_file_task_runner(), - FROM_HERE, - base::Bind(&LocalFileSyncContext::GetNextURLsForSyncOnFileThread, - this, make_scoped_refptr(file_system_context)), - base::Bind(&LocalFileSyncContext::TryPrepareForLocalSync, - this, make_scoped_refptr(file_system_context), callback)); + file_system_context->default_file_task_runner(), FROM_HERE, + base::Bind(&LocalFileSyncContext::GetNextURLsForSyncOnFileThread, this, + base::RetainedRef(file_system_context)), + base::Bind(&LocalFileSyncContext::TryPrepareForLocalSync, this, + base::RetainedRef(file_system_context), callback)); } void LocalFileSyncContext::ClearChangesForURL( @@ -134,9 +131,8 @@ void LocalFileSyncContext::ClearChangesForURL( DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); file_system_context->default_file_task_runner()->PostTask( FROM_HERE, - base::Bind(&LocalFileSyncContext::ClearChangesForURL, - this, make_scoped_refptr(file_system_context), - url, done_callback)); + base::Bind(&LocalFileSyncContext::ClearChangesForURL, this, + base::RetainedRef(file_system_context), url, done_callback)); return; } @@ -160,10 +156,9 @@ void LocalFileSyncContext::FinalizeSnapshotSync( if (!file_system_context->default_file_task_runner()-> RunsTasksOnCurrentThread()) { file_system_context->default_file_task_runner()->PostTask( - FROM_HERE, - base::Bind(&LocalFileSyncContext::FinalizeSnapshotSync, - this, make_scoped_refptr(file_system_context), - url, sync_finish_status, done_callback)); + FROM_HERE, base::Bind(&LocalFileSyncContext::FinalizeSnapshotSync, this, + base::RetainedRef(file_system_context), url, + sync_finish_status, done_callback)); return; } @@ -205,7 +200,7 @@ void LocalFileSyncContext::FinalizeExclusiveSync( if (clear_local_changes) { ClearChangesForURL(file_system_context, url, base::Bind(&LocalFileSyncContext::FinalizeExclusiveSync, - this, make_scoped_refptr(file_system_context), + this, base::RetainedRef(file_system_context), url, false, done_callback)); return; } @@ -227,10 +222,9 @@ void LocalFileSyncContext::PrepareForSync( if (!io_task_runner_->RunsTasksOnCurrentThread()) { DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); io_task_runner_->PostTask( - FROM_HERE, - base::Bind(&LocalFileSyncContext::PrepareForSync, this, - make_scoped_refptr(file_system_context), url, - sync_mode, callback)); + FROM_HERE, base::Bind(&LocalFileSyncContext::PrepareForSync, this, + base::RetainedRef(file_system_context), url, + sync_mode, callback)); return; } DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); @@ -239,12 +233,10 @@ void LocalFileSyncContext::PrepareForSync( if (syncable) sync_status()->StartSyncing(url); ui_task_runner_->PostTask( - FROM_HERE, - base::Bind(&LocalFileSyncContext::DidGetWritingStatusForSync, - this, make_scoped_refptr(file_system_context), - syncable ? SYNC_STATUS_OK : - SYNC_STATUS_FILE_BUSY, - url, sync_mode, callback)); + FROM_HERE, base::Bind(&LocalFileSyncContext::DidGetWritingStatusForSync, + this, base::RetainedRef(file_system_context), + syncable ? SYNC_STATUS_OK : SYNC_STATUS_FILE_BUSY, + url, sync_mode, callback)); } void LocalFileSyncContext::RegisterURLForWaitingSync( @@ -280,10 +272,9 @@ void LocalFileSyncContext::ApplyRemoteChange( if (!io_task_runner_->RunsTasksOnCurrentThread()) { DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); io_task_runner_->PostTask( - FROM_HERE, - base::Bind(&LocalFileSyncContext::ApplyRemoteChange, this, - make_scoped_refptr(file_system_context), - change, local_path, url, callback)); + FROM_HERE, base::Bind(&LocalFileSyncContext::ApplyRemoteChange, this, + base::RetainedRef(file_system_context), change, + local_path, url, callback)); return; } DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); @@ -346,11 +337,7 @@ void LocalFileSyncContext::HandleRemoteAddOrUpdate( url_for_sync, true /* recursive */, base::Bind( &LocalFileSyncContext::DidRemoveExistingEntryForRemoteAddOrUpdate, - this, - make_scoped_refptr(file_system_context), - change, - local_path, - url, + this, base::RetainedRef(file_system_context), change, local_path, url, callback)); } @@ -394,14 +381,9 @@ void LocalFileSyncContext::DidRemoveExistingEntryForRemoteAddOrUpdate( url_for_sync.mount_type(), storage::VirtualPath::DirName(url_for_sync.virtual_path())); file_system_context->operation_runner()->CreateDirectory( - dir_url, - false /* exclusive */, - true /* recursive */, - base::Bind(&LocalFileSyncContext::DidCreateDirectoryForCopyIn, - this, - make_scoped_refptr(file_system_context), - local_path, - url, + dir_url, false /* exclusive */, true /* recursive */, + base::Bind(&LocalFileSyncContext::DidCreateDirectoryForCopyIn, this, + base::RetainedRef(file_system_context), local_path, url, operation_callback)); } break; @@ -427,10 +409,9 @@ void LocalFileSyncContext::RecordFakeLocalChange( RunsTasksOnCurrentThread()) { DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); file_system_context->default_file_task_runner()->PostTask( - FROM_HERE, - base::Bind(&LocalFileSyncContext::RecordFakeLocalChange, - this, make_scoped_refptr(file_system_context), - url, change, callback)); + FROM_HERE, base::Bind(&LocalFileSyncContext::RecordFakeLocalChange, + this, base::RetainedRef(file_system_context), url, + change, callback)); return; } @@ -457,7 +438,7 @@ void LocalFileSyncContext::GetFileMetadata( io_task_runner_->PostTask( FROM_HERE, base::Bind(&LocalFileSyncContext::GetFileMetadata, this, - make_scoped_refptr(file_system_context), url, callback)); + base::RetainedRef(file_system_context), url, callback)); return; } DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); @@ -482,9 +463,8 @@ void LocalFileSyncContext::HasPendingLocalChanges( DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); file_system_context->default_file_task_runner()->PostTask( FROM_HERE, - base::Bind(&LocalFileSyncContext::HasPendingLocalChanges, - this, make_scoped_refptr(file_system_context), - url, callback)); + base::Bind(&LocalFileSyncContext::HasPendingLocalChanges, this, + base::RetainedRef(file_system_context), url, callback)); return; } @@ -513,9 +493,8 @@ void LocalFileSyncContext::PromoteDemotedChanges( DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); file_system_context->default_file_task_runner()->PostTask( FROM_HERE, - base::Bind(&LocalFileSyncContext::PromoteDemotedChanges, - this, origin, make_scoped_refptr(file_system_context), - callback)); + base::Bind(&LocalFileSyncContext::PromoteDemotedChanges, this, origin, + base::RetainedRef(file_system_context), callback)); return; } @@ -665,16 +644,13 @@ void LocalFileSyncContext::InitializeFileSystemContextOnIOThread( scoped_ptr<LocalFileChangeTracker>* tracker_ptr( new scoped_ptr<LocalFileChangeTracker>); base::PostTaskAndReplyWithResult( - file_system_context->default_file_task_runner(), - FROM_HERE, + file_system_context->default_file_task_runner(), FROM_HERE, base::Bind(&LocalFileSyncContext::InitializeChangeTrackerOnFileThread, - this, tracker_ptr, - make_scoped_refptr(file_system_context), + this, tracker_ptr, base::RetainedRef(file_system_context), origins_with_changes), base::Bind(&LocalFileSyncContext::DidInitializeChangeTrackerOnIOThread, - this, base::Owned(tracker_ptr), - source_url, - make_scoped_refptr(file_system_context), + this, base::Owned(tracker_ptr), source_url, + base::RetainedRef(file_system_context), base::Owned(origins_with_changes))); return; } @@ -759,9 +735,8 @@ void LocalFileSyncContext::DidInitialize( if (!ui_task_runner_->RunsTasksOnCurrentThread()) { ui_task_runner_->PostTask( FROM_HERE, - base::Bind(&LocalFileSyncContext::DidInitialize, - this, source_url, - make_scoped_refptr(file_system_context), status)); + base::Bind(&LocalFileSyncContext::DidInitialize, this, source_url, + base::RetainedRef(file_system_context), status)); return; } DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); @@ -826,11 +801,10 @@ void LocalFileSyncContext::TryPrepareForLocalSync( const FileSystemURL url = urls->front(); urls->pop_front(); - PrepareForSync( - file_system_context, url, SYNC_SNAPSHOT, - base::Bind(&LocalFileSyncContext::DidTryPrepareForLocalSync, - this, make_scoped_refptr(file_system_context), - base::Passed(&urls), callback)); + PrepareForSync(file_system_context, url, SYNC_SNAPSHOT, + base::Bind(&LocalFileSyncContext::DidTryPrepareForLocalSync, + this, base::RetainedRef(file_system_context), + base::Passed(&urls), callback)); } void LocalFileSyncContext::DidTryPrepareForLocalSync( @@ -866,8 +840,8 @@ void LocalFileSyncContext::PromoteDemotedChangesForURL( return; file_system_context->default_file_task_runner()->PostTask( FROM_HERE, - base::Bind(&LocalFileSyncContext::PromoteDemotedChangesForURL, - this, make_scoped_refptr(file_system_context), url)); + base::Bind(&LocalFileSyncContext::PromoteDemotedChangesForURL, this, + base::RetainedRef(file_system_context), url)); return; } @@ -889,8 +863,8 @@ void LocalFileSyncContext::PromoteDemotedChangesForURLs( return; file_system_context->default_file_task_runner()->PostTask( FROM_HERE, - base::Bind(&LocalFileSyncContext::PromoteDemotedChangesForURLs, - this, make_scoped_refptr(file_system_context), + base::Bind(&LocalFileSyncContext::PromoteDemotedChangesForURLs, this, + base::RetainedRef(file_system_context), base::Passed(&urls))); return; } @@ -917,10 +891,9 @@ void LocalFileSyncContext::DidGetWritingStatusForSync( return; } file_system_context->default_file_task_runner()->PostTask( - FROM_HERE, - base::Bind(&LocalFileSyncContext::DidGetWritingStatusForSync, - this, make_scoped_refptr(file_system_context), - status, url, sync_mode, callback)); + FROM_HERE, base::Bind(&LocalFileSyncContext::DidGetWritingStatusForSync, + this, base::RetainedRef(file_system_context), + status, url, sync_mode, callback)); return; } diff --git a/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc b/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc index e09596e..73cd0df 100644 --- a/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc +++ b/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc @@ -160,7 +160,7 @@ class LocalFileSyncContextTest : public testing::Test { file_system_context, change, local_path, url, base::Bind(&LocalFileSyncContextTest::DidApplyRemoteChange, base::Unretained(this), - make_scoped_refptr(file_system_context), url)); + base::RetainedRef(file_system_context), url)); base::MessageLoop::current()->Run(); return status_; } diff --git a/chrome/browser/sync_file_system/local/local_file_sync_service.cc b/chrome/browser/sync_file_system/local/local_file_sync_service.cc index d9904fb..c2d9778 100644 --- a/chrome/browser/sync_file_system/local/local_file_sync_service.cc +++ b/chrome/browser/sync_file_system/local/local_file_sync_service.cc @@ -138,7 +138,7 @@ void LocalFileSyncService::MaybeInitializeFileSystemContext( app_origin, file_system_context, base::Bind(&LocalFileSyncService::DidInitializeFileSystemContext, AsWeakPtr(), app_origin, - make_scoped_refptr(file_system_context), callback)); + base::RetainedRef(file_system_context), callback)); } void LocalFileSyncService::AddChangeObserver(Observer* observer) { @@ -251,12 +251,9 @@ void LocalFileSyncService::PrepareForProcessRemoteChange( content::BrowserContext::GetStoragePartitionForSite(profile_, site_url) ->GetFileSystemContext(); MaybeInitializeFileSystemContext( - url.origin(), - file_system_context.get(), + url.origin(), file_system_context.get(), base::Bind(&LocalFileSyncService::DidInitializeForRemoteSync, - AsWeakPtr(), - url, - file_system_context, + AsWeakPtr(), url, base::RetainedRef(file_system_context), callback)); return; } diff --git a/chrome/browser/sync_file_system/local/root_delete_helper.cc b/chrome/browser/sync_file_system/local/root_delete_helper.cc index 63a9000..ff36cef 100644 --- a/chrome/browser/sync_file_system/local/root_delete_helper.cc +++ b/chrome/browser/sync_file_system/local/root_delete_helper.cc @@ -76,8 +76,8 @@ void RootDeleteHelper::DidDeleteFileSystem(base::File::Error error) { // TODO(kinuko): This should be probably automatically handled in // DeleteFileSystem via QuotaUtil::DeleteOriginDataOnFileThread. file_system_context_->default_file_task_runner()->PostTaskAndReply( - FROM_HERE, - base::Bind(&ResetFileChangeTracker, file_system_context_, url_), + FROM_HERE, base::Bind(&ResetFileChangeTracker, + base::RetainedRef(file_system_context_), url_), base::Bind(&RootDeleteHelper::DidResetFileChangeTracker, weak_factory_.GetWeakPtr())); } diff --git a/chrome/browser/sync_file_system/local/sync_file_system_backend.cc b/chrome/browser/sync_file_system/local/sync_file_system_backend.cc index cd67ac1..febf9f1 100644 --- a/chrome/browser/sync_file_system/local/sync_file_system_backend.cc +++ b/chrome/browser/sync_file_system/local/sync_file_system_backend.cc @@ -127,12 +127,8 @@ void SyncFileSystemBackend::ResolveURL(const storage::FileSystemURL& url, // It is safe to pass Unretained(this) since |context_| owns it. SyncStatusCallback initialize_callback = base::Bind(&SyncFileSystemBackend::DidInitializeSyncFileSystemService, - base::Unretained(this), - make_scoped_refptr(context_), - url.origin(), - url.type(), - mode, - callback); + base::Unretained(this), base::RetainedRef(context_), + url.origin(), url.type(), mode, callback); InitializeSyncFileSystemService(url.origin(), initialize_callback); } @@ -305,7 +301,7 @@ void SyncFileSystemBackend::DidInitializeSyncFileSystemService( BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&SyncFileSystemBackend::DidInitializeSyncFileSystemService, - base::Unretained(this), make_scoped_refptr(context), + base::Unretained(this), base::RetainedRef(context), origin_url, type, mode, callback, status)); return; } diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc index 298db31..91d8f54 100644 --- a/chrome/browser/themes/theme_service.cc +++ b/chrome/browser/themes/theme_service.cc @@ -844,7 +844,7 @@ void ThemeService::BuildFromExtension(const Extension* extension) { : chrome::kThemePackFilename); service->GetFileTaskRunner()->PostTask( FROM_HERE, - base::Bind(&WritePackToDiskCallback, pack, pack_path)); + base::Bind(&WritePackToDiskCallback, base::RetainedRef(pack), pack_path)); // Save only the extension path. The packed file which matches the // MaterialDesignController::Mode will be loaded via LoadThemePrefs(). diff --git a/chrome/browser/ui/login/login_prompt.cc b/chrome/browser/ui/login/login_prompt.cc index abfc10d..32ea8d4 100644 --- a/chrome/browser/ui/login/login_prompt.cc +++ b/chrome/browser/ui/login/login_prompt.cc @@ -565,10 +565,9 @@ void LoginDialogCallback(const GURL& request_url, request_url.GetOrigin())) { // Show a blank interstitial for main-frame, cross origin requests // so that the correct URL is shown in the omnibox. - base::Closure callback = base::Bind(&ShowLoginPrompt, - request_url, - make_scoped_refptr(auth_info), - make_scoped_refptr(handler)); + base::Closure callback = + base::Bind(&ShowLoginPrompt, request_url, base::RetainedRef(auth_info), + base::RetainedRef(handler)); // The interstitial delegate is owned by the interstitial that it creates. // This cancels any existing interstitial. handler->SetInterstitialDelegate( @@ -589,7 +588,7 @@ LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&LoginDialogCallback, request->url(), - make_scoped_refptr(auth_info), make_scoped_refptr(handler), + base::RetainedRef(auth_info), base::RetainedRef(handler), is_main_frame)); return handler; } diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector.cc b/chrome/browser/ui/views/ssl_client_certificate_selector.cc index fb1c889..95d93ab 100644 --- a/chrome/browser/ui/views/ssl_client_certificate_selector.cc +++ b/chrome/browser/ui/views/ssl_client_certificate_selector.cc @@ -70,7 +70,7 @@ bool SSLClientCertificateSelector::Accept() { cert.get(), chrome::kCryptoModulePasswordClientAuth, cert_request_info()->host_and_port, GetWidget()->GetNativeView(), base::Bind(&SSLClientCertificateSelector::Unlocked, - base::Unretained(this), cert)); + base::Unretained(this), base::RetainedRef(cert))); #else Unlocked(cert.get()); #endif diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc index 97590ec..2b79a66 100644 --- a/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc +++ b/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc @@ -217,10 +217,8 @@ void NetInternalsTest::MessageHandler::AddCacheEntry( BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&AddCacheEntryOnIOThread, - make_scoped_refptr(browser()->profile()->GetRequestContext()), - hostname, - ip_literal, - static_cast<int>(net_error), + base::RetainedRef(browser()->profile()->GetRequestContext()), + hostname, ip_literal, static_cast<int>(net_error), static_cast<int>(expire_days_from_now))); } diff --git a/chrome/utility/profile_import_handler.cc b/chrome/utility/profile_import_handler.cc index 98b6b74..6c09dd3 100644 --- a/chrome/utility/profile_import_handler.cc +++ b/chrome/utility/profile_import_handler.cc @@ -70,7 +70,7 @@ void ProfileImportHandler::OnImportStart( } import_thread_->task_runner()->PostTask( FROM_HERE, base::Bind(&Importer::StartImport, importer_.get(), - source_profile, items, bridge_)); + source_profile, items, base::RetainedRef(bridge_))); } void ProfileImportHandler::OnImportCancel() { diff --git a/components/autofill/core/browser/webdata/autofill_webdata_service.cc b/components/autofill/core/browser/webdata/autofill_webdata_service.cc index 6512492..3e90e62 100644 --- a/components/autofill/core/browser/webdata/autofill_webdata_service.cc +++ b/components/autofill/core/browser/webdata/autofill_webdata_service.cc @@ -274,7 +274,8 @@ base::SupportsUserData* AutofillWebDataService::GetDBUserData() { void AutofillWebDataService::GetAutofillBackend( const base::Callback<void(AutofillWebDataBackend*)>& callback) { - db_thread_->PostTask(FROM_HERE, base::Bind(callback, autofill_backend_)); + db_thread_->PostTask( + FROM_HERE, base::Bind(callback, base::RetainedRef(autofill_backend_))); } AutofillWebDataService::~AutofillWebDataService() { diff --git a/components/bookmarks/browser/bookmark_storage.cc b/components/bookmarks/browser/bookmark_storage.cc index f1c8380..3a18420 100644 --- a/components/bookmarks/browser/bookmark_storage.cc +++ b/components/bookmarks/browser/bookmark_storage.cc @@ -162,12 +162,10 @@ BookmarkStorage::~BookmarkStorage() { void BookmarkStorage::LoadBookmarks( scoped_ptr<BookmarkLoadDetails> details, const scoped_refptr<base::SequencedTaskRunner>& task_runner) { - sequenced_task_runner_->PostTask(FROM_HERE, - base::Bind(&LoadCallback, - writer_.path(), - weak_factory_.GetWeakPtr(), - base::Passed(&details), - task_runner)); + sequenced_task_runner_->PostTask( + FROM_HERE, + base::Bind(&LoadCallback, writer_.path(), weak_factory_.GetWeakPtr(), + base::Passed(&details), base::RetainedRef(task_runner))); } void BookmarkStorage::ScheduleSave() { diff --git a/components/drive/change_list_loader.cc b/components/drive/change_list_loader.cc index b7b5bd6..6f5d22d 100644 --- a/components/drive/change_list_loader.cc +++ b/components/drive/change_list_loader.cc @@ -544,18 +544,15 @@ void ChangeListLoader::LoadChangeListFromServerAfterLoadChangeList( loader_controller_->ScheduleRun(base::Bind( base::IgnoreResult( &base::PostTaskAndReplyWithResult<FileError, FileError>), - blocking_task_runner_, - FROM_HERE, + base::RetainedRef(blocking_task_runner_), FROM_HERE, base::Bind(&ChangeListProcessor::Apply, base::Unretained(change_list_processor), - base::Passed(&about_resource), - base::Passed(&change_lists), + base::Passed(&about_resource), base::Passed(&change_lists), is_delta_update), base::Bind(&ChangeListLoader::LoadChangeListFromServerAfterUpdate, weak_ptr_factory_.GetWeakPtr(), base::Owned(change_list_processor), - should_notify_changed_directories, - base::Time::Now()))); + should_notify_changed_directories, base::Time::Now()))); } void ChangeListLoader::LoadChangeListFromServerAfterUpdate( diff --git a/components/drive/directory_loader.cc b/components/drive/directory_loader.cc index ad42626..4f0b236 100644 --- a/components/drive/directory_loader.cc +++ b/components/drive/directory_loader.cc @@ -141,17 +141,12 @@ class DirectoryLoader::FeedFetcher { loader_->loader_controller_->ScheduleRun(base::Bind( base::IgnoreResult( &base::PostTaskAndReplyWithResult<FileError, FileError>), - loader_->blocking_task_runner_, - FROM_HERE, + base::RetainedRef(loader_->blocking_task_runner_), FROM_HERE, base::Bind(&ChangeListProcessor::RefreshDirectory, - loader_->resource_metadata_, - directory_fetch_info_, - base::Passed(&change_list), - entries), + loader_->resource_metadata_, directory_fetch_info_, + base::Passed(&change_list), entries), base::Bind(&FeedFetcher::OnDirectoryRefreshed, - weak_ptr_factory_.GetWeakPtr(), - callback, - next_url, + weak_ptr_factory_.GetWeakPtr(), callback, next_url, base::Owned(entries)))); } diff --git a/components/drive/file_system/search_operation.cc b/components/drive/file_system/search_operation.cc index 31e8437..fce7d17 100644 --- a/components/drive/file_system/search_operation.cc +++ b/components/drive/file_system/search_operation.cc @@ -145,20 +145,15 @@ void SearchOperation::SearchAfterGetFileList( // server to the local metadata. // This may race with sync tasks so we should ask LoaderController here. std::vector<SearchResultInfo>* result_ptr = result.get(); - loader_controller_->ScheduleRun(base::Bind( - base::IgnoreResult( - &base::PostTaskAndReplyWithResult<FileError, FileError>), - blocking_task_runner_, - FROM_HERE, - base::Bind(&ResolveSearchResultOnBlockingPool, - metadata_, - base::Passed(&file_list), - result_ptr), - base::Bind(&SearchOperation::SearchAfterResolveSearchResult, - weak_ptr_factory_.GetWeakPtr(), - callback, - next_url, - base::Passed(&result)))); + loader_controller_->ScheduleRun( + base::Bind(base::IgnoreResult( + &base::PostTaskAndReplyWithResult<FileError, FileError>), + base::RetainedRef(blocking_task_runner_), FROM_HERE, + base::Bind(&ResolveSearchResultOnBlockingPool, metadata_, + base::Passed(&file_list), result_ptr), + base::Bind(&SearchOperation::SearchAfterResolveSearchResult, + weak_ptr_factory_.GetWeakPtr(), callback, next_url, + base::Passed(&result)))); } void SearchOperation::SearchAfterResolveSearchResult( diff --git a/components/history/core/browser/top_sites_impl.cc b/components/history/core/browser/top_sites_impl.cc index fb8e080..2133076 100644 --- a/components/history/core/browser/top_sites_impl.cc +++ b/components/history/core/browser/top_sites_impl.cc @@ -217,9 +217,10 @@ void TopSitesImpl::GetMostVisitedURLs( if (!loaded_) { // A request came in before we finished loading. Store the callback and // we'll run it on current thread when we finish loading. - pending_callbacks_.push_back(base::Bind( - &RunOrPostGetMostVisitedURLsCallback, - base::ThreadTaskRunnerHandle::Get(), include_forced_urls, callback)); + pending_callbacks_.push_back( + base::Bind(&RunOrPostGetMostVisitedURLsCallback, + base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), + include_forced_urls, callback)); return; } if (include_forced_urls) { diff --git a/components/scheduler/base/task_queue_manager_unittest.cc b/components/scheduler/base/task_queue_manager_unittest.cc index 3da5f0d..161b02b 100644 --- a/components/scheduler/base/task_queue_manager_unittest.cc +++ b/components/scheduler/base/task_queue_manager_unittest.cc @@ -209,9 +209,9 @@ TEST_F(TaskQueueManagerTest, NonNestableTaskDoesntExecuteInNestedLoop) { std::make_pair(base::Bind(&TestTask, 5, &run_order), true)); runners_[0]->PostTask( - FROM_HERE, - base::Bind(&PostFromNestedRunloop, message_loop_.get(), runners_[0], - base::Unretained(&tasks_to_post_from_nested_loop))); + FROM_HERE, base::Bind(&PostFromNestedRunloop, message_loop_.get(), + base::RetainedRef(runners_[0]), + base::Unretained(&tasks_to_post_from_nested_loop))); message_loop_->RunUntilIdle(); // Note we expect task 3 to run last because it's non-nestable. @@ -617,9 +617,9 @@ TEST_F(TaskQueueManagerTest, PostFromNestedRunloop) { runners_[0]->PostTask(FROM_HERE, base::Bind(&TestTask, 0, &run_order)); runners_[0]->PostTask( - FROM_HERE, - base::Bind(&PostFromNestedRunloop, message_loop_.get(), runners_[0], - base::Unretained(&tasks_to_post_from_nested_loop))); + FROM_HERE, base::Bind(&PostFromNestedRunloop, message_loop_.get(), + base::RetainedRef(runners_[0]), + base::Unretained(&tasks_to_post_from_nested_loop))); runners_[0]->PostTask(FROM_HERE, base::Bind(&TestTask, 2, &run_order)); message_loop_->RunUntilIdle(); @@ -1196,10 +1196,10 @@ TEST_F(TaskQueueManagerTest, QuitWhileNested) { bool was_nested = true; base::RunLoop run_loop; - runners_[0]->PostTask( - FROM_HERE, - base::Bind(&PostAndQuitFromNestedRunloop, base::Unretained(&run_loop), - runners_[0], base::Unretained(&was_nested))); + runners_[0]->PostTask(FROM_HERE, base::Bind(&PostAndQuitFromNestedRunloop, + base::Unretained(&run_loop), + base::RetainedRef(runners_[0]), + base::Unretained(&was_nested))); message_loop_->RunUntilIdle(); EXPECT_FALSE(was_nested); @@ -1456,9 +1456,9 @@ TEST_F(TaskQueueManagerTest, UnregisterTaskQueueInNestedLoop) { base::Unretained(task_queue.get())), true)); runners_[0]->PostTask( - FROM_HERE, - base::Bind(&PostFromNestedRunloop, message_loop_.get(), runners_[0], - base::Unretained(&tasks_to_post_from_nested_loop))); + FROM_HERE, base::Bind(&PostFromNestedRunloop, message_loop_.get(), + base::RetainedRef(runners_[0]), + base::Unretained(&tasks_to_post_from_nested_loop))); message_loop_->RunUntilIdle(); // Add a final call to HasOneRefTask. This gives the manager a chance to diff --git a/components/scheduler/child/idle_helper_unittest.cc b/components/scheduler/child/idle_helper_unittest.cc index 03b0447..37a6e1b 100644 --- a/components/scheduler/child/idle_helper_unittest.cc +++ b/components/scheduler/child/idle_helper_unittest.cc @@ -348,8 +348,9 @@ TEST_F(IdleHelperTest, TestRepostingIdleTask) { max_idle_task_reposts = 2; idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingIdleTestTask, idle_task_runner_, - &run_count, &actual_deadline)); + FROM_HERE, + base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_), + &run_count, &actual_deadline)); idle_helper_->StartIdlePeriod( IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(), clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10)); @@ -670,9 +671,10 @@ TEST_F(IdleHelperTestWithIdlePeriodObserver, TestLongIdlePeriodRepeating) { base::TimeTicks clock_before(clock_->NowTicks()); base::TimeDelta idle_task_runtime(base::TimeDelta::FromMilliseconds(10)); idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask, - idle_task_runner_, &run_count, clock_.get(), - idle_task_runtime, &actual_deadlines)); + FROM_HERE, + base::Bind(&RepostingUpdateClockIdleTestTask, + base::RetainedRef(idle_task_runner_), &run_count, clock_.get(), + idle_task_runtime, &actual_deadlines)); // Check each idle task runs in their own idle period. idle_helper_->EnableLongIdlePeriod(); @@ -688,9 +690,10 @@ TEST_F(IdleHelperTestWithIdlePeriodObserver, TestLongIdlePeriodRepeating) { max_idle_task_reposts = 5; idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask, - idle_task_runner_, &run_count, clock_.get(), - idle_task_runtime, &actual_deadlines)); + FROM_HERE, + base::Bind(&RepostingUpdateClockIdleTestTask, + base::RetainedRef(idle_task_runner_), &run_count, clock_.get(), + idle_task_runtime, &actual_deadlines)); idle_task_runner_->PostIdleTask( FROM_HERE, base::Bind(&EndIdlePeriodIdleTask, base::Unretained(idle_helper_.get()))); @@ -786,9 +789,10 @@ TEST_F(IdleHelperTest, TestLongIdlePeriodImmediatelyRestartsIfMaxDeadline) { // they have max deadlines. max_idle_task_reposts = 2; idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask, - idle_task_runner_, &run_count, clock_.get(), - idle_task_runtime, &actual_deadlines)); + FROM_HERE, + base::Bind(&RepostingUpdateClockIdleTestTask, + base::RetainedRef(idle_task_runner_), &run_count, clock_.get(), + idle_task_runtime, &actual_deadlines)); idle_helper_->EnableLongIdlePeriod(); RunUntilIdle(); @@ -816,8 +820,9 @@ TEST_F(IdleHelperTest, TestLongIdlePeriodRestartWaitsIfNotMaxDeadline) { max_idle_task_reposts = 2; idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingIdleTestTask, idle_task_runner_, - &run_count, &actual_deadline)); + FROM_HERE, + base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_), + &run_count, &actual_deadline)); idle_helper_->EnableLongIdlePeriod(); RunUntilIdle(); EXPECT_EQ(1, run_count); @@ -857,9 +862,10 @@ TEST_F(IdleHelperTest, TestLongIdlePeriodPaused) { base::TimeTicks clock_before(clock_->NowTicks()); base::TimeDelta idle_task_runtime(base::TimeDelta::FromMilliseconds(10)); idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask, - idle_task_runner_, &run_count, clock_.get(), - idle_task_runtime, &actual_deadlines)); + FROM_HERE, + base::Bind(&RepostingUpdateClockIdleTestTask, + base::RetainedRef(idle_task_runner_), &run_count, clock_.get(), + idle_task_runtime, &actual_deadlines)); RunUntilIdle(); EXPECT_EQ(2, run_count); EXPECT_THAT( @@ -1003,8 +1009,9 @@ TEST_F(IdleHelperWithQuiescencePeriodTest, int run_count = 0; max_idle_task_reposts = 1; idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingIdleTestTask, idle_task_runner_, - &run_count, &actual_deadline)); + FROM_HERE, + base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_), + &run_count, &actual_deadline)); idle_helper_->EnableLongIdlePeriod(); RunUntilIdle(); @@ -1024,8 +1031,9 @@ TEST_F(IdleHelperWithQuiescencePeriodTestWithIdlePeriodObserver, int run_count = 0; max_idle_task_reposts = 1; idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingIdleTestTask, idle_task_runner_, - &run_count, &actual_deadline)); + FROM_HERE, + base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_), + &run_count, &actual_deadline)); idle_helper_->EnableLongIdlePeriod(); RunUntilIdle(); diff --git a/components/scheduler/child/scheduler_helper_unittest.cc b/components/scheduler/child/scheduler_helper_unittest.cc index 6557e93a..c1afc7d 100644 --- a/components/scheduler/child/scheduler_helper_unittest.cc +++ b/components/scheduler/child/scheduler_helper_unittest.cc @@ -112,8 +112,9 @@ TEST_F(SchedulerHelperTest, TestRentrantTask) { int count = 0; std::vector<int> run_order; default_task_runner_->PostTask( - FROM_HERE, base::Bind(AppendToVectorReentrantTask, default_task_runner_, - &run_order, &count, 5)); + FROM_HERE, base::Bind(AppendToVectorReentrantTask, + base::RetainedRef(default_task_runner_), &run_order, + &count, 5)); RunUntilIdle(); EXPECT_THAT(run_order, testing::ElementsAre(0, 1, 2, 3, 4)); diff --git a/components/scheduler/renderer/renderer_scheduler_impl_unittest.cc b/components/scheduler/renderer/renderer_scheduler_impl_unittest.cc index d2149b7..6cd96dc 100644 --- a/components/scheduler/renderer/renderer_scheduler_impl_unittest.cc +++ b/components/scheduler/renderer/renderer_scheduler_impl_unittest.cc @@ -598,8 +598,9 @@ TEST_F(RendererSchedulerImplTest, TestRentrantTask) { int count = 0; std::vector<int> run_order; default_task_runner_->PostTask( - FROM_HERE, base::Bind(AppendToVectorReentrantTask, default_task_runner_, - &run_order, &count, 5)); + FROM_HERE, base::Bind(AppendToVectorReentrantTask, + base::RetainedRef(default_task_runner_), &run_order, + &count, 5)); RunUntilIdle(); EXPECT_THAT(run_order, testing::ElementsAre(0, 1, 2, 3, 4)); @@ -644,8 +645,8 @@ TEST_F(RendererSchedulerImplTest, TestRepostingIdleTask) { max_idle_task_reposts = 2; idle_task_runner_->PostIdleTask( - FROM_HERE, - base::Bind(&RepostingIdleTestTask, idle_task_runner_, &run_count)); + FROM_HERE, base::Bind(&RepostingIdleTestTask, + base::RetainedRef(idle_task_runner_), &run_count)); EnableIdleTasks(); RunUntilIdle(); EXPECT_EQ(1, run_count); @@ -1427,8 +1428,8 @@ TEST_F(RendererSchedulerImplTest, TestShouldYield) { default_task_runner_->PostTask( FROM_HERE, base::Bind(&PostingYieldingTestTask, scheduler_.get(), - default_task_runner_, false, &should_yield_before, - &should_yield_after)); + base::RetainedRef(default_task_runner_), false, + &should_yield_before, &should_yield_after)); RunUntilIdle(); // Posting to default runner shouldn't cause yielding. EXPECT_FALSE(should_yield_before); @@ -1436,7 +1437,7 @@ TEST_F(RendererSchedulerImplTest, TestShouldYield) { default_task_runner_->PostTask( FROM_HERE, base::Bind(&PostingYieldingTestTask, scheduler_.get(), - compositor_task_runner_, false, + base::RetainedRef(compositor_task_runner_), false, &should_yield_before, &should_yield_after)); RunUntilIdle(); // Posting while not mainthread scrolling shouldn't cause yielding. @@ -1445,8 +1446,8 @@ TEST_F(RendererSchedulerImplTest, TestShouldYield) { default_task_runner_->PostTask( FROM_HERE, base::Bind(&PostingYieldingTestTask, scheduler_.get(), - compositor_task_runner_, true, &should_yield_before, - &should_yield_after)); + base::RetainedRef(compositor_task_runner_), true, + &should_yield_before, &should_yield_after)); RunUntilIdle(); // We should be able to switch to compositor priority mid-task. EXPECT_FALSE(should_yield_before); @@ -1831,9 +1832,10 @@ TEST_F(RendererSchedulerImplTest, TestLongIdlePeriodRepeating) { base::TimeTicks clock_before(clock_->NowTicks()); base::TimeDelta idle_task_runtime(base::TimeDelta::FromMilliseconds(10)); idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask, - idle_task_runner_, &run_count, clock_.get(), - idle_task_runtime, &actual_deadlines)); + FROM_HERE, + base::Bind(&RepostingUpdateClockIdleTestTask, + base::RetainedRef(idle_task_runner_), &run_count, clock_.get(), + idle_task_runtime, &actual_deadlines)); scheduler_->BeginFrameNotExpectedSoon(); RunUntilIdle(); EXPECT_EQ(3, run_count); @@ -1849,9 +1851,10 @@ TEST_F(RendererSchedulerImplTest, TestLongIdlePeriodRepeating) { // new BeginMainFrame. max_idle_task_reposts = 5; idle_task_runner_->PostIdleTask( - FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask, - idle_task_runner_, &run_count, clock_.get(), - idle_task_runtime, &actual_deadlines)); + FROM_HERE, + base::Bind(&RepostingUpdateClockIdleTestTask, + base::RetainedRef(idle_task_runner_), &run_count, clock_.get(), + idle_task_runtime, &actual_deadlines)); idle_task_runner_->PostIdleTask( FROM_HERE, base::Bind(&WillBeginFrameIdleTask, base::Unretained(scheduler_.get()), clock_.get())); @@ -1980,8 +1983,8 @@ TEST_F(RendererSchedulerImplTest, TestRendererHiddenIdlePeriod) { max_idle_task_reposts = 2; idle_task_runner_->PostIdleTask( - FROM_HERE, - base::Bind(&RepostingIdleTestTask, idle_task_runner_, &run_count)); + FROM_HERE, base::Bind(&RepostingIdleTestTask, + base::RetainedRef(idle_task_runner_), &run_count)); // Renderer should start in visible state. RunUntilIdle(); @@ -1998,8 +2001,8 @@ TEST_F(RendererSchedulerImplTest, TestRendererHiddenIdlePeriod) { // idle tasks when hidden (plus some slack) - idle period should have ended. max_idle_task_reposts = 3; idle_task_runner_->PostIdleTask( - FROM_HERE, - base::Bind(&RepostingIdleTestTask, idle_task_runner_, &run_count)); + FROM_HERE, base::Bind(&RepostingIdleTestTask, + base::RetainedRef(idle_task_runner_), &run_count)); clock_->Advance(end_idle_when_hidden_delay() + base::TimeDelta::FromMilliseconds(10)); RunUntilIdle(); diff --git a/components/sessions/core/base_session_service.cc b/components/sessions/core/base_session_service.cc index 4f2d839..ab1dcc8 100644 --- a/components/sessions/core/base_session_service.cc +++ b/components/sessions/core/base_session_service.cc @@ -161,7 +161,8 @@ BaseSessionService::ScheduleGetLastSessionCommands( GetCommandsCallback callback_runner = base::Bind(&PostOrRunInternalGetCommandsCallback, - base::ThreadTaskRunnerHandle::Get(), run_if_not_canceled); + base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), + run_if_not_canceled); RunTaskOnBackendThread( FROM_HERE, diff --git a/components/wallpaper/wallpaper_resizer.cc b/components/wallpaper/wallpaper_resizer.cc index 7de7a26..47e391d 100644 --- a/components/wallpaper/wallpaper_resizer.cc +++ b/components/wallpaper/wallpaper_resizer.cc @@ -124,8 +124,9 @@ void WallpaperResizer::StartResize() { SkBitmap* resized_bitmap = new SkBitmap; scoped_refptr<SequencedWorkerPool> worker_pool_refptr(worker_pool_); if (!worker_pool_->PostTaskAndReply( - FROM_HERE, base::Bind(&Resize, *image_.bitmap(), target_size_, - layout_, resized_bitmap, worker_pool_refptr), + FROM_HERE, + base::Bind(&Resize, *image_.bitmap(), target_size_, layout_, + resized_bitmap, base::RetainedRef(worker_pool_refptr)), base::Bind(&WallpaperResizer::OnResizeFinished, weak_ptr_factory_.GetWeakPtr(), base::Owned(resized_bitmap)))) { diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc index 0eca5fe..a23bde6 100644 --- a/content/browser/appcache/chrome_appcache_service_unittest.cc +++ b/content/browser/appcache/chrome_appcache_service_unittest.cc @@ -102,14 +102,11 @@ ChromeAppCacheServiceTest::CreateAppCacheServiceImpl( browser_context_.GetResourceContext()->GetRequestContext(), message_loop_.task_runner().get()); BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, + BrowserThread::IO, FROM_HERE, base::Bind(&ChromeAppCacheService::InitializeOnIOThread, - appcache_service.get(), - appcache_path, + appcache_service.get(), appcache_path, browser_context_.GetResourceContext(), - mock_request_context_getter, - mock_policy)); + base::RetainedRef(mock_request_context_getter), mock_policy)); // Steps needed to initialize the storage of AppCache data. message_loop_.RunUntilIdle(); if (init_storage) { diff --git a/content/browser/cache_storage/cache_storage_dispatcher_host.cc b/content/browser/cache_storage/cache_storage_dispatcher_host.cc index 05e3568..b53495c 100644 --- a/content/browser/cache_storage/cache_storage_dispatcher_host.cc +++ b/content/browser/cache_storage/cache_storage_dispatcher_host.cc @@ -71,7 +71,7 @@ void CacheStorageDispatcherHost::Init(CacheStorageContextImpl* context) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&CacheStorageDispatcherHost::CreateCacheListener, this, - make_scoped_refptr(context))); + base::RetainedRef(context))); } void CacheStorageDispatcherHost::OnDestruct() const { diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.cc b/content/browser/dom_storage/dom_storage_context_wrapper.cc index 7ab88bb..cfacb08 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper.cc +++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc @@ -253,7 +253,8 @@ void DOMStorageContextWrapper::GetLocalStorageUsage( context_->task_runner()->PostShutdownBlockingTask( FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, base::Bind(&GetLocalStorageUsageHelper, - base::ThreadTaskRunnerHandle::Get(), context_, callback)); + base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), + base::RetainedRef(context_), callback)); } void DOMStorageContextWrapper::GetSessionStorageUsage( @@ -262,7 +263,8 @@ void DOMStorageContextWrapper::GetSessionStorageUsage( context_->task_runner()->PostShutdownBlockingTask( FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, base::Bind(&GetSessionStorageUsageHelper, - base::ThreadTaskRunnerHandle::Get(), context_, callback)); + base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), + base::RetainedRef(context_), callback)); } void DOMStorageContextWrapper::DeleteLocalStorage(const GURL& origin) { diff --git a/content/browser/download/save_file_resource_handler.cc b/content/browser/download/save_file_resource_handler.cc index faf5605..7cba445 100644 --- a/content/browser/download/save_file_resource_handler.cc +++ b/content/browser/download/save_file_resource_handler.cc @@ -85,7 +85,7 @@ bool SaveFileResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind(&SaveFileManager::UpdateSaveProgress, save_manager_, - save_item_id_, buffer, bytes_read)); + save_item_id_, base::RetainedRef(buffer), bytes_read)); return true; } diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc index 5686fcf..40b3d81 100644 --- a/content/browser/download/save_package.cc +++ b/content/browser/download/save_package.cc @@ -1094,7 +1094,8 @@ void SavePackage::OnSerializedHtmlWithLocalLinksResponse( BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind(&SaveFileManager::UpdateSaveProgress, file_manager_, - save_item->id(), new_data, static_cast<int>(data.size()))); + save_item->id(), base::RetainedRef(new_data), + static_cast<int>(data.size()))); } // Current frame is completed saving, call finish in file thread. diff --git a/content/browser/indexed_db/indexed_db_quota_client.cc b/content/browser/indexed_db/indexed_db_quota_client.cc index 1796431..8fc9ce8c 100644 --- a/content/browser/indexed_db/indexed_db_quota_client.cc +++ b/content/browser/indexed_db/indexed_db_quota_client.cc @@ -90,10 +90,9 @@ void IndexedDBQuotaClient::GetOriginUsage(const GURL& origin_url, } base::PostTaskAndReplyWithResult( - indexed_db_context_->TaskRunner(), - FROM_HERE, - base::Bind( - &GetOriginUsageOnIndexedDBThread, indexed_db_context_, origin_url), + indexed_db_context_->TaskRunner(), FROM_HERE, + base::Bind(&GetOriginUsageOnIndexedDBThread, + base::RetainedRef(indexed_db_context_), origin_url), callback); } @@ -117,10 +116,9 @@ void IndexedDBQuotaClient::GetOriginsForType( std::set<GURL>* origins_to_return = new std::set<GURL>(); indexed_db_context_->TaskRunner()->PostTaskAndReply( - FROM_HERE, - base::Bind(&GetAllOriginsOnIndexedDBThread, - indexed_db_context_, - base::Unretained(origins_to_return)), + FROM_HERE, base::Bind(&GetAllOriginsOnIndexedDBThread, + base::RetainedRef(indexed_db_context_), + base::Unretained(origins_to_return)), base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); } @@ -145,11 +143,9 @@ void IndexedDBQuotaClient::GetOriginsForHost( std::set<GURL>* origins_to_return = new std::set<GURL>(); indexed_db_context_->TaskRunner()->PostTaskAndReply( - FROM_HERE, - base::Bind(&GetOriginsForHostOnIndexedDBThread, - indexed_db_context_, - host, - base::Unretained(origins_to_return)), + FROM_HERE, base::Bind(&GetOriginsForHostOnIndexedDBThread, + base::RetainedRef(indexed_db_context_), host, + base::Unretained(origins_to_return)), base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); } @@ -168,10 +164,9 @@ void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin, } base::PostTaskAndReplyWithResult( - indexed_db_context_->TaskRunner(), - FROM_HERE, - base::Bind( - &DeleteOriginDataOnIndexedDBThread, indexed_db_context_, origin), + indexed_db_context_->TaskRunner(), FROM_HERE, + base::Bind(&DeleteOriginDataOnIndexedDBThread, + base::RetainedRef(indexed_db_context_), origin), callback); } diff --git a/content/browser/loader/async_revalidation_driver_unittest.cc b/content/browser/loader/async_revalidation_driver_unittest.cc index 1f5a7e4..893bc21 100644 --- a/content/browser/loader/async_revalidation_driver_unittest.cc +++ b/content/browser/loader/async_revalidation_driver_unittest.cc @@ -233,7 +233,8 @@ class MockClientCertURLRequestJob : public net::URLRequestTestJob { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&MockClientCertURLRequestJob::NotifyCertificateRequested, - weak_factory_.GetWeakPtr(), cert_request_info)); + weak_factory_.GetWeakPtr(), + base::RetainedRef(cert_request_info))); } void ContinueWithCertificate( diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc index 8c8d7ba..56eac13 100644 --- a/content/browser/loader/resource_loader_unittest.cc +++ b/content/browser/loader/resource_loader_unittest.cc @@ -167,7 +167,8 @@ class MockClientCertURLRequestJob : public net::URLRequestTestJob { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&MockClientCertURLRequestJob::NotifyCertificateRequested, - weak_factory_.GetWeakPtr(), cert_request_info)); + weak_factory_.GetWeakPtr(), + base::RetainedRef(cert_request_info))); } void ContinueWithCertificate(net::X509Certificate* cert, @@ -532,7 +533,7 @@ void CreateTemporaryError( base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, error, base::Passed(scoped_ptr<net::FileStream>()), - scoped_refptr<ShareableFileReference>())); + nullptr)); } } // namespace @@ -919,8 +920,9 @@ class ResourceLoaderRedirectToFileTest : public ResourceLoaderTest { scoped_ptr<net::FileStream> file_stream, const CreateTemporaryFileStreamCallback& callback) { base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(callback, base::File::FILE_OK, - base::Passed(&file_stream), deletable_file_)); + FROM_HERE, + base::Bind(callback, base::File::FILE_OK, base::Passed(&file_stream), + base::RetainedRef(deletable_file_))); } base::FilePath temp_path_; diff --git a/content/browser/media/capture/web_contents_audio_input_stream.cc b/content/browser/media/capture/web_contents_audio_input_stream.cc index 50051a1..7dd34e8 100644 --- a/content/browser/media/capture/web_contents_audio_input_stream.cc +++ b/content/browser/media/capture/web_contents_audio_input_stream.cc @@ -228,23 +228,19 @@ void WebContentsAudioInputStream::Impl::ReportError() { void WebContentsAudioInputStream::Impl::StartMirroring() { DCHECK(thread_checker_.CalledOnValidThread()); - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&AudioMirroringManager::StartMirroring, - base::Unretained(mirroring_manager_), - make_scoped_refptr(this))); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&AudioMirroringManager::StartMirroring, + base::Unretained(mirroring_manager_), + base::RetainedRef(this))); } void WebContentsAudioInputStream::Impl::StopMirroring() { DCHECK(thread_checker_.CalledOnValidThread()); - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&AudioMirroringManager::StopMirroring, - base::Unretained(mirroring_manager_), - make_scoped_refptr(this))); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&AudioMirroringManager::StopMirroring, + base::Unretained(mirroring_manager_), + base::RetainedRef(this))); } void WebContentsAudioInputStream::Impl::UnmuteWebContentsAudio() { diff --git a/content/browser/media/capture/web_contents_audio_muter.cc b/content/browser/media/capture/web_contents_audio_muter.cc index 82a03fa..7423498 100644 --- a/content/browser/media/capture/web_contents_audio_muter.cc +++ b/content/browser/media/capture/web_contents_audio_muter.cc @@ -133,11 +133,10 @@ void WebContentsAudioMuter::StartMuting() { return; is_muting_ = true; BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, + BrowserThread::IO, FROM_HERE, base::Bind(&AudioMirroringManager::StartMirroring, base::Unretained(AudioMirroringManager::GetInstance()), - destination_)); + base::RetainedRef(destination_))); } void WebContentsAudioMuter::StopMuting() { @@ -146,11 +145,10 @@ void WebContentsAudioMuter::StopMuting() { return; is_muting_ = false; BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, + BrowserThread::IO, FROM_HERE, base::Bind(&AudioMirroringManager::StopMirroring, base::Unretained(AudioMirroringManager::GetInstance()), - destination_)); + base::RetainedRef(destination_))); } } // namespace content diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index d8a5909..a5cb577 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -603,7 +603,8 @@ void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { ->PostSequencedWorkerTaskWithShutdownBehavior( plugin_list_token_, FROM_HERE, base::Bind(&PluginServiceImpl::GetPluginsInternal, - base::Unretained(this), target_task_runner, callback), + base::Unretained(this), + base::RetainedRef(target_task_runner), callback), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); return; } @@ -611,7 +612,8 @@ void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&PluginServiceImpl::GetPluginsOnIOThread, - base::Unretained(this), target_task_runner, callback)); + base::Unretained(this), base::RetainedRef(target_task_runner), + callback)); #else NOTREACHED(); #endif @@ -642,7 +644,7 @@ void PluginServiceImpl::GetPluginsOnIOThread( plugin_loader_ = new PluginLoaderPosix; plugin_loader_->GetPlugins(base::Bind( - &ForwardCallback, make_scoped_refptr(target_task_runner), callback)); + &ForwardCallback, base::RetainedRef(target_task_runner), callback)); } #endif diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.cc b/content/browser/renderer_host/media/audio_input_renderer_host.cc index da9c5ea..375df8e 100644 --- a/content/browser/renderer_host/media/audio_input_renderer_host.cc +++ b/content/browser/renderer_host/media/audio_input_renderer_host.cc @@ -173,35 +173,25 @@ void AudioInputRendererHost::OnDestruct() const { void AudioInputRendererHost::OnCreated( media::AudioInputController* controller) { BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind( - &AudioInputRendererHost::DoCompleteCreation, - this, - make_scoped_refptr(controller))); + BrowserThread::IO, FROM_HERE, + base::Bind(&AudioInputRendererHost::DoCompleteCreation, this, + base::RetainedRef(controller))); } void AudioInputRendererHost::OnRecording( media::AudioInputController* controller) { BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind( - &AudioInputRendererHost::DoSendRecordingMessage, - this, - make_scoped_refptr(controller))); + BrowserThread::IO, FROM_HERE, + base::Bind(&AudioInputRendererHost::DoSendRecordingMessage, this, + base::RetainedRef(controller))); } void AudioInputRendererHost::OnError(media::AudioInputController* controller, media::AudioInputController::ErrorCode error_code) { BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind( - &AudioInputRendererHost::DoHandleError, - this, - make_scoped_refptr(controller), - error_code)); + BrowserThread::IO, FROM_HERE, + base::Bind(&AudioInputRendererHost::DoHandleError, this, + base::RetainedRef(controller), error_code)); } void AudioInputRendererHost::OnData(media::AudioInputController* controller, @@ -211,12 +201,9 @@ void AudioInputRendererHost::OnData(media::AudioInputController* controller, void AudioInputRendererHost::OnLog(media::AudioInputController* controller, const std::string& message) { - BrowserThread::PostTask(BrowserThread::IO, - FROM_HERE, - base::Bind(&AudioInputRendererHost::DoLog, - this, - make_scoped_refptr(controller), - message)); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&AudioInputRendererHost::DoLog, this, + base::RetainedRef(controller), message)); } void AudioInputRendererHost::set_renderer_pid(int32_t renderer_pid) { diff --git a/content/browser/renderer_host/render_widget_helper.cc b/content/browser/renderer_host/render_widget_helper.cc index d17cd23b..e6a225c 100644 --- a/content/browser/renderer_host/render_widget_helper.cc +++ b/content/browser/renderer_host/render_widget_helper.cc @@ -123,7 +123,7 @@ void RenderWidgetHelper::CreateNewWindow( BrowserThread::UI, FROM_HERE, base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, this, params, *route_id, *main_frame_route_id, *main_frame_widget_route_id, - make_scoped_refptr(session_storage_namespace))); + base::RetainedRef(session_storage_namespace))); } void RenderWidgetHelper::OnCreateWindowOnUI( diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc index 58862d6..b30ea6e 100644 --- a/content/browser/service_worker/service_worker_browsertest.cc +++ b/content/browser/service_worker/service_worker_browsertest.cc @@ -83,12 +83,9 @@ void RunOnIOThreadWithDelay(const base::Closure& closure, base::TimeDelta delay) { base::RunLoop run_loop; BrowserThread::PostDelayedTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&RunAndQuit, - closure, - run_loop.QuitClosure(), - base::ThreadTaskRunnerHandle::Get()), + BrowserThread::IO, FROM_HERE, + base::Bind(&RunAndQuit, closure, run_loop.QuitClosure(), + base::RetainedRef(base::ThreadTaskRunnerHandle::Get())), delay); run_loop.Run(); } @@ -694,9 +691,8 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest { const base::Closure& quit, ChromeBlobStorageContext* blob_context, FetchResult* result) { - return base::Bind( - &self::ReceiveFetchResultOnIOThread, this, quit, - make_scoped_refptr<ChromeBlobStorageContext>(blob_context), result); + return base::Bind(&self::ReceiveFetchResultOnIOThread, this, quit, + base::RetainedRef(blob_context), result); } void StopOnIOThread(const base::Closure& done, diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc index cba52e9..c7d6800 100644 --- a/content/browser/service_worker/service_worker_context_wrapper.cc +++ b/content/browser/service_worker/service_worker_context_wrapper.cc @@ -674,15 +674,11 @@ void ServiceWorkerContextWrapper::InitInternal( storage::SpecialStoragePolicy* special_storage_policy) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&ServiceWorkerContextWrapper::InitInternal, - this, - user_data_directory, - base::Passed(&database_task_manager), - disk_cache_thread, - make_scoped_refptr(quota_manager_proxy), - make_scoped_refptr(special_storage_policy))); + BrowserThread::IO, FROM_HERE, + base::Bind(&ServiceWorkerContextWrapper::InitInternal, this, + user_data_directory, base::Passed(&database_task_manager), + disk_cache_thread, base::RetainedRef(quota_manager_proxy), + base::RetainedRef(special_storage_policy))); return; } // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. diff --git a/content/browser/service_worker/service_worker_controllee_request_handler.cc b/content/browser/service_worker/service_worker_controllee_request_handler.cc index c6089fc..8a28576 100644 --- a/content/browser/service_worker/service_worker_controllee_request_handler.cc +++ b/content/browser/service_worker/service_worker_controllee_request_handler.cc @@ -233,11 +233,9 @@ ServiceWorkerControlleeRequestHandler::DidLookupRegistrationForMainResource( if (active_version.get() && active_version->status() == ServiceWorkerVersion::ACTIVATING) { provider_host_->SetAllowAssociation(false); - registration->active_version()->RegisterStatusChangeCallback( - base::Bind(&self::OnVersionStatusChanged, - weak_factory_.GetWeakPtr(), - registration, - active_version)); + registration->active_version()->RegisterStatusChangeCallback(base::Bind( + &self::OnVersionStatusChanged, weak_factory_.GetWeakPtr(), + base::RetainedRef(registration), base::RetainedRef(active_version))); TRACE_EVENT_ASYNC_END2( "ServiceWorker", "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc index d75ab4a..f6b90cd 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host.cc +++ b/content/browser/service_worker/service_worker_dispatcher_host.cc @@ -109,10 +109,9 @@ ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() { void ServiceWorkerDispatcherHost::Init( ServiceWorkerContextWrapper* context_wrapper) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&ServiceWorkerDispatcherHost::Init, - this, make_scoped_refptr(context_wrapper))); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&ServiceWorkerDispatcherHost::Init, this, + base::RetainedRef(context_wrapper))); return; } diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc index b54f24c..2aed605a 100644 --- a/content/browser/service_worker/service_worker_provider_host.cc +++ b/content/browser/service_worker/service_worker_provider_host.cc @@ -515,12 +515,11 @@ void ServiceWorkerProviderHost::SendSetVersionAttributesMessage( return; if (!IsReadyToSendMessages()) { - queued_events_.push_back( - base::Bind(&ServiceWorkerProviderHost::SendSetVersionAttributesMessage, - AsWeakPtr(), registration_handle_id, changed_mask, - make_scoped_refptr(installing_version), - make_scoped_refptr(waiting_version), - make_scoped_refptr(active_version))); + queued_events_.push_back(base::Bind( + &ServiceWorkerProviderHost::SendSetVersionAttributesMessage, + AsWeakPtr(), registration_handle_id, changed_mask, + base::RetainedRef(installing_version), + base::RetainedRef(waiting_version), base::RetainedRef(active_version))); return; } diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc index 6f0155a..2b443765 100644 --- a/content/browser/service_worker/service_worker_register_job.cc +++ b/content/browser/service_worker/service_worker_register_job.cc @@ -87,7 +87,7 @@ void ServiceWorkerRegisterJob::AddCallback( } RunSoon(base::Bind(callback, promise_resolved_status_, promise_resolved_status_message_, - promise_resolved_registration_)); + base::RetainedRef(promise_resolved_registration_))); } void ServiceWorkerRegisterJob::Start() { diff --git a/content/browser/service_worker/service_worker_version_unittest.cc b/content/browser/service_worker/service_worker_version_unittest.cc index 628d625..e47df282 100644 --- a/content/browser/service_worker/service_worker_version_unittest.cc +++ b/content/browser/service_worker/service_worker_version_unittest.cc @@ -570,8 +570,8 @@ TEST_F(ServiceWorkerVersionTest, RepeatedlyObserveStatusChanges) { // Repeatedly observe status changes (the callback re-registers itself). std::vector<ServiceWorkerVersion::Status> statuses; - version_->RegisterStatusChangeCallback( - base::Bind(&ObserveStatusChanges, version_, &statuses)); + version_->RegisterStatusChangeCallback(base::Bind( + &ObserveStatusChanges, base::RetainedRef(version_), &statuses)); version_->SetStatus(ServiceWorkerVersion::INSTALLING); version_->SetStatus(ServiceWorkerVersion::INSTALLED); diff --git a/content/browser/speech/speech_recognizer_impl.cc b/content/browser/speech/speech_recognizer_impl.cc index c993eb9..f11b5d3 100644 --- a/content/browser/speech/speech_recognizer_impl.cc +++ b/content/browser/speech/speech_recognizer_impl.cc @@ -793,7 +793,8 @@ void SpeechRecognizerImpl::CloseAudioControllerAsynchronously() { // Close has completed (in the audio thread) and automatically destroy it // afterwards (upon return from OnAudioClosed). audio_controller_->Close(base::Bind(&SpeechRecognizerImpl::OnAudioClosed, - this, audio_controller_)); + this, + base::RetainedRef(audio_controller_))); audio_controller_ = NULL; // The controller is still refcounted by Bind. audio_log_->OnClosed(0); } diff --git a/content/browser/ssl/ssl_client_auth_handler.cc b/content/browser/ssl/ssl_client_auth_handler.cc index d0bc275..9f5efae 100644 --- a/content/browser/ssl/ssl_client_auth_handler.cc +++ b/content/browser/ssl/ssl_client_auth_handler.cc @@ -45,7 +45,7 @@ class ClientCertificateDelegateImpl : public ClientCertificateDelegate { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&SSLClientAuthHandler::ContinueWithCertificate, handler_, - make_scoped_refptr(cert))); + base::RetainedRef(cert))); } private: @@ -178,8 +178,7 @@ void SSLClientAuthHandler::DidGetClientCerts() { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&SSLClientAuthHandler::ContinueWithCertificate, - weak_factory_.GetWeakPtr(), - scoped_refptr<net::X509Certificate>())); + weak_factory_.GetWeakPtr(), nullptr)); return; } @@ -198,7 +197,7 @@ void SSLClientAuthHandler::DidGetClientCerts() { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&SelectCertificateOnUIThread, render_process_host_id, - render_frame_host_id, cert_request_info_, + render_frame_host_id, base::RetainedRef(cert_request_info_), weak_factory_.GetWeakPtr())); } diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc index 4b4a554..f56bc57 100644 --- a/content/browser/storage_partition_impl.cc +++ b/content/browser/storage_partition_impl.cc @@ -662,42 +662,30 @@ void StoragePartitionImpl::QuotaManagedDataDeletionHelper::ClearDataOnIOThread( // within the user-specified timeframe, and deal with the resulting set in // ClearQuotaManagedOriginsOnIOThread(). quota_manager->GetOriginsModifiedSince( - storage::kStorageTypePersistent, - begin, + storage::kStorageTypePersistent, begin, base::Bind(&QuotaManagedDataDeletionHelper::ClearOriginsOnIOThread, - base::Unretained(this), - quota_manager, - special_storage_policy, - origin_matcher, - decrement_callback)); + base::Unretained(this), base::RetainedRef(quota_manager), + special_storage_policy, origin_matcher, decrement_callback)); } // Do the same for temporary quota. if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_TEMPORARY) { IncrementTaskCountOnIO(); quota_manager->GetOriginsModifiedSince( - storage::kStorageTypeTemporary, - begin, + storage::kStorageTypeTemporary, begin, base::Bind(&QuotaManagedDataDeletionHelper::ClearOriginsOnIOThread, - base::Unretained(this), - quota_manager, - special_storage_policy, - origin_matcher, - decrement_callback)); + base::Unretained(this), base::RetainedRef(quota_manager), + special_storage_policy, origin_matcher, decrement_callback)); } // Do the same for syncable quota. if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_SYNCABLE) { IncrementTaskCountOnIO(); quota_manager->GetOriginsModifiedSince( - storage::kStorageTypeSyncable, - begin, + storage::kStorageTypeSyncable, begin, base::Bind(&QuotaManagedDataDeletionHelper::ClearOriginsOnIOThread, - base::Unretained(this), - quota_manager, - special_storage_policy, - origin_matcher, - decrement_callback)); + base::Unretained(this), base::RetainedRef(quota_manager), + special_storage_policy, origin_matcher, decrement_callback)); } DecrementTaskCountOnIO(); diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc index 4e98e17..73947cf 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc @@ -589,21 +589,21 @@ void StoragePartitionImplMap::PostCreateInitialization( if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&ChromeAppCacheService::InitializeOnIOThread, - partition->GetAppCacheService(), - in_memory ? base::FilePath() : - partition->GetPath().Append(kAppCacheDirname), - browser_context_->GetResourceContext(), - make_scoped_refptr(partition->GetURLRequestContext()), - make_scoped_refptr( - browser_context_->GetSpecialStoragePolicy()))); + base::Bind( + &ChromeAppCacheService::InitializeOnIOThread, + partition->GetAppCacheService(), + in_memory ? base::FilePath() + : partition->GetPath().Append(kAppCacheDirname), + browser_context_->GetResourceContext(), + base::RetainedRef(partition->GetURLRequestContext()), + base::RetainedRef(browser_context_->GetSpecialStoragePolicy()))); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&CacheStorageContextImpl::SetBlobParametersForCache, partition->GetCacheStorageContext(), - make_scoped_refptr(partition->GetURLRequestContext()), - make_scoped_refptr( + base::RetainedRef(partition->GetURLRequestContext()), + base::RetainedRef( ChromeBlobStorageContext::GetFor(browser_context_)))); BrowserThread::PostTask( @@ -611,7 +611,7 @@ void StoragePartitionImplMap::PostCreateInitialization( base::Bind(&ServiceWorkerContextWrapper::InitializeResourceContext, partition->GetServiceWorkerContext(), browser_context_->GetResourceContext(), - make_scoped_refptr(partition->GetURLRequestContext()))); + base::RetainedRef(partition->GetURLRequestContext()))); // We do not call InitializeURLRequestContext() for media contexts because, // other than the HTTP cache, the media contexts share the same backing diff --git a/content/browser/tracing/tracing_controller_browsertest.cc b/content/browser/tracing/tracing_controller_browsertest.cc index edb11c0..8cafbd7d 100644 --- a/content/browser/tracing/tracing_controller_browsertest.cc +++ b/content/browser/tracing/tracing_controller_browsertest.cc @@ -80,7 +80,7 @@ class TracingControllerTestEndpoint BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(done_callback_, base::Passed(std::move(metadata)), - chunk_ptr)); + base::RetainedRef(chunk_ptr))); } protected: diff --git a/content/browser/tracing/tracing_controller_impl.cc b/content/browser/tracing/tracing_controller_impl.cc index c3d0e09..86b0db3 100644 --- a/content/browser/tracing/tracing_controller_impl.cc +++ b/content/browser/tracing/tracing_controller_impl.cc @@ -412,8 +412,7 @@ bool TracingControllerImpl::GetTraceBufferUsage( BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&TracingControllerImpl::OnTraceLogStatusReply, - base::Unretained(this), scoped_refptr<TraceMessageFilter>(), - status)); + base::Unretained(this), nullptr, status)); // Notify all child processes. for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); @@ -470,10 +469,11 @@ bool TracingControllerImpl::IsTracing() const { void TracingControllerImpl::AddTraceMessageFilter( TraceMessageFilter* trace_message_filter) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, base::Bind(&TracingControllerImpl::AddTraceMessageFilter, base::Unretained(this), - make_scoped_refptr(trace_message_filter))); + base::RetainedRef(trace_message_filter))); return; } @@ -501,10 +501,11 @@ void TracingControllerImpl::AddTraceMessageFilter( void TracingControllerImpl::RemoveTraceMessageFilter( TraceMessageFilter* trace_message_filter) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, base::Bind(&TracingControllerImpl::RemoveTraceMessageFilter, base::Unretained(this), - make_scoped_refptr(trace_message_filter))); + base::RetainedRef(trace_message_filter))); return; } @@ -520,10 +521,11 @@ void TracingControllerImpl::RemoveTraceMessageFilter( TraceMessageFilterSet::const_iterator it = pending_stop_tracing_filters_.find(trace_message_filter); if (it != pending_stop_tracing_filters_.end()) { - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, base::Bind(&TracingControllerImpl::OnStopTracingAcked, base::Unretained(this), - make_scoped_refptr(trace_message_filter), + base::RetainedRef(trace_message_filter), std::vector<std::string>())); } } @@ -535,7 +537,7 @@ void TracingControllerImpl::RemoveTraceMessageFilter( BrowserThread::UI, FROM_HERE, base::Bind(&TracingControllerImpl::OnTraceLogStatusReply, base::Unretained(this), - make_scoped_refptr(trace_message_filter), + base::RetainedRef(trace_message_filter), base::trace_event::TraceLogStatus())); } } @@ -547,7 +549,7 @@ void TracingControllerImpl::RemoveTraceMessageFilter( BrowserThread::UI, FROM_HERE, base::Bind(&TracingControllerImpl::OnProcessMemoryDumpResponse, base::Unretained(this), - make_scoped_refptr(trace_message_filter), + base::RetainedRef(trace_message_filter), pending_memory_dump_guid_, false /* success */)); } } @@ -605,11 +607,11 @@ void TracingControllerImpl::OnStopTracingAcked( TraceMessageFilter* trace_message_filter, const std::vector<std::string>& known_category_groups) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(&TracingControllerImpl::OnStopTracingAcked, - base::Unretained(this), - make_scoped_refptr(trace_message_filter), - known_category_groups)); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind( + &TracingControllerImpl::OnStopTracingAcked, base::Unretained(this), + base::RetainedRef(trace_message_filter), known_category_groups)); return; } @@ -720,7 +722,7 @@ void TracingControllerImpl::OnTraceLogStatusReply( BrowserThread::UI, FROM_HERE, base::Bind(&TracingControllerImpl::OnTraceLogStatusReply, base::Unretained(this), - make_scoped_refptr(trace_message_filter), status)); + base::RetainedRef(trace_message_filter), status)); return; } @@ -961,7 +963,7 @@ void TracingControllerImpl::OnProcessMemoryDumpResponse( BrowserThread::UI, FROM_HERE, base::Bind(&TracingControllerImpl::OnProcessMemoryDumpResponse, base::Unretained(this), - make_scoped_refptr(trace_message_filter), dump_guid, + base::RetainedRef(trace_message_filter), dump_guid, success)); return; } diff --git a/content/browser/tracing/tracing_controller_impl_data_sinks.cc b/content/browser/tracing/tracing_controller_impl_data_sinks.cc index 025619f2..1ee6327 100644 --- a/content/browser/tracing/tracing_controller_impl_data_sinks.cc +++ b/content/browser/tracing/tracing_controller_impl_data_sinks.cc @@ -34,9 +34,10 @@ class StringTraceDataEndpoint : public TracingController::TraceDataEndpoint { scoped_refptr<base::RefCountedString> str = base::RefCountedString::TakeString(&tmp); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(completion_callback_, - base::Passed(std::move(metadata)), str)); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(completion_callback_, base::Passed(std::move(metadata)), + base::RetainedRef(str))); } private: diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc index b604a46..7dfd757 100644 --- a/content/browser/webui/url_data_manager_backend.cc +++ b/content/browser/webui/url_data_manager_backend.cc @@ -674,15 +674,14 @@ bool URLDataManagerBackend::StartRequest(const net::URLRequest* request, // message loop before request for data. And correspondingly their // replies are put on the IO thread in the same order. target_message_loop->task_runner()->PostTask( - FROM_HERE, - base::Bind(&GetMimeTypeOnUI, scoped_refptr<URLDataSourceImpl>(source), - path, job->AsWeakPtr())); + FROM_HERE, base::Bind(&GetMimeTypeOnUI, base::RetainedRef(source), path, + job->AsWeakPtr())); // The DataSource wants StartDataRequest to be called on a specific thread, // usually the UI thread, for this path. target_message_loop->task_runner()->PostTask( FROM_HERE, base::Bind(&URLDataManagerBackend::CallStartRequest, - make_scoped_refptr(source), path, + base::RetainedRef(source), path, render_process_id, render_frame_id, request_id)); } return true; diff --git a/content/child/child_gpu_memory_buffer_manager.cc b/content/child/child_gpu_memory_buffer_manager.cc index e88b6bd..883c99d 100644 --- a/content/child/child_gpu_memory_buffer_manager.cc +++ b/content/child/child_gpu_memory_buffer_manager.cc @@ -52,7 +52,8 @@ ChildGpuMemoryBufferManager::AllocateGpuMemoryBuffer(const gfx::Size& size, scoped_ptr<GpuMemoryBufferImpl> buffer(GpuMemoryBufferImpl::CreateFromHandle( handle, size, format, usage, - base::Bind(&DeletedGpuMemoryBuffer, sender_, handle.id))); + base::Bind(&DeletedGpuMemoryBuffer, base::RetainedRef(sender_), + handle.id))); if (!buffer) { sender_->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer( handle.id, gpu::SyncToken())); diff --git a/content/child/fileapi/webfilesystem_impl.cc b/content/child/fileapi/webfilesystem_impl.cc index 75b1ec0..141b5de 100644 --- a/content/child/fileapi/webfilesystem_impl.cc +++ b/content/child/fileapi/webfilesystem_impl.cc @@ -103,8 +103,7 @@ void CallDispatcherOnMainThread( main_thread_task_runner->PostTask( FROM_HERE, base::Bind(&CallDispatcherOnMainThread<Method, Params>, - main_thread_task_runner, method, params, - scoped_refptr<WaitableCallbackResults>())); + main_thread_task_runner, method, params, nullptr)); if (!waitable_results) return; waitable_results->WaitAndRun(); @@ -424,10 +423,10 @@ void WebFileSystemImpl::openFileSystem( static_cast<storage::FileSystemType>(type), base::Bind(&OpenFileSystemCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results), + base::RetainedRef(waitable_results)), base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -442,10 +441,10 @@ void WebFileSystemImpl::resolveURL( MakeTuple(GURL(filesystem_url), base::Bind(&ResolveURLCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results), + base::RetainedRef(waitable_results)), base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -462,7 +461,7 @@ void WebFileSystemImpl::deleteFileSystem( static_cast<storage::FileSystemType>(type), base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -478,7 +477,7 @@ void WebFileSystemImpl::move( MakeTuple(GURL(src_path), GURL(dest_path), base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -494,7 +493,7 @@ void WebFileSystemImpl::copy( MakeTuple(GURL(src_path), GURL(dest_path), base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -509,7 +508,7 @@ void WebFileSystemImpl::remove( MakeTuple(GURL(path), false /* recursive */, base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -524,7 +523,7 @@ void WebFileSystemImpl::removeRecursively( MakeTuple(GURL(path), true /* recursive */, base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -536,12 +535,13 @@ void WebFileSystemImpl::readMetadata( MaybeCreateWaitableResults(callbacks, callbacks_id); CallDispatcherOnMainThread( main_thread_task_runner_, &FileSystemDispatcher::ReadMetadata, - MakeTuple(GURL(path), base::Bind(&ReadMetadataCallbackAdapter, - base::ThreadTaskRunnerHandle::Get(), - callbacks_id, waitable_results), + MakeTuple(GURL(path), + base::Bind(&ReadMetadataCallbackAdapter, + base::ThreadTaskRunnerHandle::Get(), callbacks_id, + base::RetainedRef(waitable_results)), base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -557,7 +557,7 @@ void WebFileSystemImpl::createFile( MakeTuple(GURL(path), exclusive, base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -573,7 +573,7 @@ void WebFileSystemImpl::createDirectory( MakeTuple(GURL(path), exclusive, false /* recursive */, base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -588,7 +588,7 @@ void WebFileSystemImpl::fileExists( MakeTuple(GURL(path), false /* directory */, base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -603,7 +603,7 @@ void WebFileSystemImpl::directoryExists( MakeTuple(GURL(path), true /* directory */, base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -615,12 +615,13 @@ int WebFileSystemImpl::readDirectory( MaybeCreateWaitableResults(callbacks, callbacks_id); CallDispatcherOnMainThread( main_thread_task_runner_, &FileSystemDispatcher::ReadDirectory, - MakeTuple(GURL(path), base::Bind(&ReadDirectoryCallbackAdapter, - base::ThreadTaskRunnerHandle::Get(), - callbacks_id, waitable_results), + MakeTuple(GURL(path), + base::Bind(&ReadDirectoryCallbackAdapter, + base::ThreadTaskRunnerHandle::Get(), callbacks_id, + base::RetainedRef(waitable_results)), base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); return callbacks_id; } @@ -637,11 +638,11 @@ void WebFileSystemImpl::createFileWriter( MakeTuple(GURL(path), base::Bind(&CreateFileWriterCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results, main_thread_task_runner_, - GURL(path), client), + base::RetainedRef(waitable_results), + main_thread_task_runner_, GURL(path), client), base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } @@ -656,10 +657,11 @@ void WebFileSystemImpl::createSnapshotFileAndReadMetadata( MakeTuple(GURL(path), base::Bind(&CreateSnapshotFileCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results, main_thread_task_runner_), + base::RetainedRef(waitable_results), + main_thread_task_runner_), base::Bind(&StatusCallbackAdapter, base::ThreadTaskRunnerHandle::Get(), callbacks_id, - waitable_results)), + base::RetainedRef(waitable_results))), waitable_results.get()); } diff --git a/content/child/service_worker/web_service_worker_impl.cc b/content/child/service_worker/web_service_worker_impl.cc index 7c5a510..397f945 100644 --- a/content/child/service_worker/web_service_worker_impl.cc +++ b/content/child/service_worker/web_service_worker_impl.cc @@ -122,7 +122,8 @@ void WebServiceWorkerImpl::postMessage( // to overtake those messages. dispatcher->main_thread_task_runner()->PostTask( FROM_HERE, - base::Bind(&SendPostMessageToWorkerOnMainThread, thread_safe_sender_, + base::Bind(&SendPostMessageToWorkerOnMainThread, + base::RetainedRef(thread_safe_sender_), handle_ref_->handle_id(), provider_impl->provider_id(), // We cast WebString to string16 before crossing // threads for thread-safety. diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc index 1761a9c..eb4ec5b 100644 --- a/content/public/test/browser_test_utils.cc +++ b/content/public/test/browser_test_utils.cc @@ -781,8 +781,8 @@ std::string GetCookies(BrowserContext* browser_context, const GURL& url) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&GetCookiesOnIOThread, url, - make_scoped_refptr(context_getter), &event, &cookies)); + base::Bind(&GetCookiesOnIOThread, url, base::RetainedRef(context_getter), + &event, &cookies)); event.Wait(); return cookies; } @@ -798,7 +798,7 @@ bool SetCookie(BrowserContext* browser_context, BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&SetCookieOnIOThread, url, value, - make_scoped_refptr(context_getter), &event, &result)); + base::RetainedRef(context_getter), &event, &result)); event.Wait(); return result; } diff --git a/content/renderer/browser_render_view_browsertest.cc b/content/renderer/browser_render_view_browsertest.cc index 380f95f..9020a8b 100644 --- a/content/renderer/browser_render_view_browsertest.cc +++ b/content/renderer/browser_render_view_browsertest.cc @@ -210,7 +210,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewBrowserTest, ConfirmCacheInformationPlumbed) { GetRequestContextForRenderProcess(renderer_id); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&InterceptNetworkTransactions, url_request_context_getter, + base::Bind(&InterceptNetworkTransactions, + base::RetainedRef(url_request_context_getter), net::ERR_FAILED)); // An error results in one completed navigation. @@ -226,7 +227,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewBrowserTest, ConfirmCacheInformationPlumbed) { scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&ClearCache, url_request_context_getter, + base::Bind(&ClearCache, base::RetainedRef(url_request_context_getter), runner->QuitClosure())); runner->Run(); diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc index 1715fe0..560b70b 100644 --- a/content/renderer/gpu/gpu_benchmarking_extension.cc +++ b/content/renderer/gpu/gpu_benchmarking_extension.cc @@ -398,7 +398,8 @@ bool BeginSmoothScroll(v8::Isolate* isolate, // somehow. context.render_view_impl()->GetWidget()->QueueSyntheticGesture( std::move(gesture_params), - base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); + base::Bind(&OnSyntheticGestureCompleted, + base::RetainedRef(callback_and_context))); return true; } @@ -440,7 +441,8 @@ bool BeginSmoothDrag(v8::Isolate* isolate, // somehow. context.render_view_impl()->GetWidget()->QueueSyntheticGesture( std::move(gesture_params), - base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); + base::Bind(&OnSyntheticGestureCompleted, + base::RetainedRef(callback_and_context))); return true; } @@ -731,7 +733,8 @@ bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) { // somehow. context.render_view_impl()->GetWidget()->QueueSyntheticGesture( std::move(gesture_params), - base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); + base::Bind(&OnSyntheticGestureCompleted, + base::RetainedRef(callback_and_context))); return true; } @@ -779,7 +782,8 @@ bool GpuBenchmarking::PinchBy(gin::Arguments* args) { // somehow. context.render_view_impl()->GetWidget()->QueueSyntheticGesture( std::move(gesture_params), - base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); + base::Bind(&OnSyntheticGestureCompleted, + base::RetainedRef(callback_and_context))); return true; } @@ -845,7 +849,8 @@ bool GpuBenchmarking::Tap(gin::Arguments* args) { // somehow. context.render_view_impl()->GetWidget()->QueueSyntheticGesture( std::move(gesture_params), - base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); + base::Bind(&OnSyntheticGestureCompleted, + base::RetainedRef(callback_and_context))); return true; } @@ -881,7 +886,8 @@ int GpuBenchmarking::RunMicroBenchmark(gin::Arguments* args) { return context.compositor()->ScheduleMicroBenchmark( name, std::move(value), - base::Bind(&OnMicroBenchmarkCompleted, callback_and_context)); + base::Bind(&OnMicroBenchmarkCompleted, + base::RetainedRef(callback_and_context))); } bool GpuBenchmarking::SendMessageToMicroBenchmark( diff --git a/content/renderer/media/rtc_peer_connection_handler.cc b/content/renderer/media/rtc_peer_connection_handler.cc index e8ddec6..171a388 100644 --- a/content/renderer/media/rtc_peer_connection_handler.cc +++ b/content/renderer/media/rtc_peer_connection_handler.cc @@ -1159,11 +1159,13 @@ void RTCPeerConnectionHandler::setLocalDescription( weak_factory_.GetWeakPtr(), peer_connection_tracker_, PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION)); - signaling_thread()->PostTask(FROM_HERE, - base::Bind(&RunClosureWithTrace, + signaling_thread()->PostTask( + FROM_HERE, + base::Bind( + &RunClosureWithTrace, base::Bind(&webrtc::PeerConnectionInterface::SetLocalDescription, - native_peer_connection_, set_request, - base::Unretained(native_desc)), + native_peer_connection_, base::RetainedRef(set_request), + base::Unretained(native_desc)), "SetLocalDescription")); } @@ -1210,11 +1212,13 @@ void RTCPeerConnectionHandler::setRemoteDescription( base::ThreadTaskRunnerHandle::Get(), request, weak_factory_.GetWeakPtr(), peer_connection_tracker_, PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION)); - signaling_thread()->PostTask(FROM_HERE, - base::Bind(&RunClosureWithTrace, + signaling_thread()->PostTask( + FROM_HERE, + base::Bind( + &RunClosureWithTrace, base::Bind(&webrtc::PeerConnectionInterface::SetRemoteDescription, - native_peer_connection_, set_request, - base::Unretained(native_desc)), + native_peer_connection_, base::RetainedRef(set_request), + base::Unretained(native_desc)), "SetRemoteDescription")); } diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc index 3c3e384..a8c3247 100644 --- a/content/renderer/service_worker/service_worker_context_client.cc +++ b/content/renderer/service_worker/service_worker_context_client.cc @@ -621,13 +621,11 @@ void ServiceWorkerContextClient::postMessageToClient( // to overtake those messages. scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels); main_thread_task_runner_->PostTask( - FROM_HERE, - base::Bind(&SendPostMessageToClientOnMainThread, - sender_, - GetRoutingID(), - base::UTF16ToUTF8(base::StringPiece16(uuid)), - static_cast<base::string16>(message), - base::Passed(&channel_array))); + FROM_HERE, base::Bind(&SendPostMessageToClientOnMainThread, + base::RetainedRef(sender_), GetRoutingID(), + base::UTF16ToUTF8(base::StringPiece16(uuid)), + static_cast<base::string16>(message), + base::Passed(&channel_array))); } void ServiceWorkerContextClient::postMessageToCrossOriginClient( @@ -640,11 +638,10 @@ void ServiceWorkerContextClient::postMessageToCrossOriginClient( // to overtake those messages. scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels); main_thread_task_runner_->PostTask( - FROM_HERE, - base::Bind(&SendCrossOriginMessageToClientOnMainThread, - sender_, client.clientID, - static_cast<base::string16>(message), - base::Passed(&channel_array))); + FROM_HERE, base::Bind(&SendCrossOriginMessageToClientOnMainThread, + base::RetainedRef(sender_), client.clientID, + static_cast<base::string16>(message), + base::Passed(&channel_array))); } void ServiceWorkerContextClient::focus( diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc index 89df797..69e7f38 100644 --- a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc +++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc @@ -468,7 +468,7 @@ LayoutTestBluetoothAdapterProvider::GetDelayedServicesDiscoveryAdapter() { device_ptr->AddMockService(std::move(heart_rate)); base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&NotifyServicesDiscovered, - make_scoped_refptr(adapter_ptr), device_ptr)); + base::RetainedRef(adapter_ptr), device_ptr)); DCHECK(services.size() == 0); return services; @@ -655,7 +655,7 @@ LayoutTestBluetoothAdapterProvider::GetConnectableDevice( [adapter, device_ptr]() { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&NotifyServicesDiscovered, - make_scoped_refptr(adapter), device_ptr)); + base::RetainedRef(adapter), device_ptr)); return make_scoped_ptr(new NiceMockBluetoothGattConnection( adapter, device_ptr->GetAddress())); })); diff --git a/extensions/browser/api/bluetooth/bluetooth_event_router.cc b/extensions/browser/api/bluetooth/bluetooth_event_router.cc index d11d17e..0f9345b 100644 --- a/extensions/browser/api/bluetooth/bluetooth_event_router.cc +++ b/extensions/browser/api/bluetooth/bluetooth_event_router.cc @@ -100,7 +100,7 @@ void BluetoothEventRouter::StartDiscoverySession( GetAdapter(base::Bind( &IgnoreAdapterResultAndThen, base::Bind(&BluetoothEventRouter::StartDiscoverySessionImpl, - weak_ptr_factory_.GetWeakPtr(), make_scoped_refptr(adapter), + weak_ptr_factory_.GetWeakPtr(), base::RetainedRef(adapter), extension_id, callback, error_callback))); return; } diff --git a/extensions/shell/browser/shell_extension_system.cc b/extensions/shell/browser/shell_extension_system.cc index e3a75bf..2ed9d7b 100644 --- a/extensions/shell/browser/shell_extension_system.cc +++ b/extensions/shell/browser/shell_extension_system.cc @@ -151,11 +151,11 @@ AppSorting* ShellExtensionSystem::app_sorting() { void ShellExtensionSystem::RegisterExtensionWithRequestContexts( const Extension* extension, const base::Closure& callback) { - BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, - base::Bind(&InfoMap::AddExtension, info_map(), - make_scoped_refptr(extension), - base::Time::Now(), false, false), - callback); + BrowserThread::PostTaskAndReply( + BrowserThread::IO, FROM_HERE, + base::Bind(&InfoMap::AddExtension, info_map(), + base::RetainedRef(extension), base::Time::Now(), false, false), + callback); } void ShellExtensionSystem::UnregisterExtensionWithRequestContexts( diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc index 5e70261..ab2672c 100644 --- a/ipc/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -483,7 +483,7 @@ void ChannelProxy::RemoveFilter(MessageFilter* filter) { context_->ipc_task_runner()->PostTask( FROM_HERE, base::Bind(&Context::OnRemoveFilter, context_.get(), - make_scoped_refptr(filter))); + base::RetainedRef(filter))); } void ChannelProxy::ClearIPCTaskRunner() { diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc index d194211..445a60e 100644 --- a/ipc/ipc_sync_channel.cc +++ b/ipc/ipc_sync_channel.cc @@ -80,7 +80,7 @@ class SyncChannel::ReceivedSyncMsgQueue : if (!was_task_pending) { listener_task_runner_->PostTask( FROM_HERE, base::Bind(&ReceivedSyncMsgQueue::DispatchMessagesTask, - this, scoped_refptr<SyncContext>(context))); + this, base::RetainedRef(context))); } } diff --git a/net/cert/cert_database.cc b/net/cert/cert_database.cc index 7b85fc7..3d423b0 100644 --- a/net/cert/cert_database.cc +++ b/net/cert/cert_database.cc @@ -27,18 +27,18 @@ void CertDatabase::RemoveObserver(Observer* observer) { void CertDatabase::NotifyObserversOfCertAdded(const X509Certificate* cert) { observer_list_->Notify(FROM_HERE, &Observer::OnCertAdded, - make_scoped_refptr(cert)); + base::RetainedRef(cert)); } void CertDatabase::NotifyObserversOfCertRemoved(const X509Certificate* cert) { observer_list_->Notify(FROM_HERE, &Observer::OnCertRemoved, - make_scoped_refptr(cert)); + base::RetainedRef(cert)); } void CertDatabase::NotifyObserversOfCACertChanged( const X509Certificate* cert) { observer_list_->Notify(FROM_HERE, &Observer::OnCACertChanged, - make_scoped_refptr(cert)); + base::RetainedRef(cert)); } } // namespace net diff --git a/net/cert/nss_cert_database.cc b/net/cert/nss_cert_database.cc index e85ce3b..896d1d3 100644 --- a/net/cert/nss_cert_database.cc +++ b/net/cert/nss_cert_database.cc @@ -455,19 +455,19 @@ void NSSCertDatabase::NotifyCertRemovalAndCallBack( void NSSCertDatabase::NotifyObserversOfCertAdded(const X509Certificate* cert) { observer_list_->Notify(FROM_HERE, &Observer::OnCertAdded, - make_scoped_refptr(cert)); + base::RetainedRef(cert)); } void NSSCertDatabase::NotifyObserversOfCertRemoved( const X509Certificate* cert) { observer_list_->Notify(FROM_HERE, &Observer::OnCertRemoved, - make_scoped_refptr(cert)); + base::RetainedRef(cert)); } void NSSCertDatabase::NotifyObserversOfCACertChanged( const X509Certificate* cert) { observer_list_->Notify(FROM_HERE, &Observer::OnCACertChanged, - make_scoped_refptr(cert)); + base::RetainedRef(cert)); } // static diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc index c7dc073..643b13c 100644 --- a/net/disk_cache/simple/simple_entry_impl.cc +++ b/net/disk_cache/simple/simple_entry_impl.cc @@ -789,13 +789,11 @@ void SimpleEntryImpl::CloseInternal() { } if (synchronous_entry_) { - Closure task = - base::Bind(&SimpleSynchronousEntry::Close, - base::Unretained(synchronous_entry_), - SimpleEntryStat(last_used_, last_modified_, data_size_, - sparse_data_size_), - base::Passed(&crc32s_to_write), - stream_0_data_); + Closure task = base::Bind( + &SimpleSynchronousEntry::Close, base::Unretained(synchronous_entry_), + SimpleEntryStat(last_used_, last_modified_, data_size_, + sparse_data_size_), + base::Passed(&crc32s_to_write), base::RetainedRef(stream_0_data_)); Closure reply = base::Bind(&SimpleEntryImpl::CloseOperationComplete, this); synchronous_entry_ = NULL; worker_pool_->PostTaskAndReply(FROM_HERE, task, reply); @@ -876,13 +874,9 @@ void SimpleEntryImpl::ReadDataInternal(int stream_index, new SimpleEntryStat(last_used_, last_modified_, data_size_, sparse_data_size_)); Closure task = base::Bind( - &SimpleSynchronousEntry::ReadData, - base::Unretained(synchronous_entry_), + &SimpleSynchronousEntry::ReadData, base::Unretained(synchronous_entry_), SimpleSynchronousEntry::EntryOperationData(stream_index, offset, buf_len), - make_scoped_refptr(buf), - read_crc32.get(), - entry_stat.get(), - result.get()); + base::RetainedRef(buf), read_crc32.get(), entry_stat.get(), result.get()); Closure reply = base::Bind(&SimpleEntryImpl::ReadOperationComplete, this, stream_index, @@ -977,14 +971,11 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, have_written_[0] = true; scoped_ptr<int> result(new int()); - Closure task = base::Bind(&SimpleSynchronousEntry::WriteData, - base::Unretained(synchronous_entry_), - SimpleSynchronousEntry::EntryOperationData( - stream_index, offset, buf_len, truncate, - doomed_), - make_scoped_refptr(buf), - entry_stat.get(), - result.get()); + Closure task = base::Bind( + &SimpleSynchronousEntry::WriteData, base::Unretained(synchronous_entry_), + SimpleSynchronousEntry::EntryOperationData(stream_index, offset, buf_len, + truncate, doomed_), + base::RetainedRef(buf), entry_stat.get(), result.get()); Closure reply = base::Bind(&SimpleEntryImpl::WriteOperationComplete, this, stream_index, @@ -1013,13 +1004,11 @@ void SimpleEntryImpl::ReadSparseDataInternal( scoped_ptr<int> result(new int()); scoped_ptr<base::Time> last_used(new base::Time()); - Closure task = base::Bind(&SimpleSynchronousEntry::ReadSparseData, - base::Unretained(synchronous_entry_), - SimpleSynchronousEntry::EntryOperationData( - sparse_offset, buf_len), - make_scoped_refptr(buf), - last_used.get(), - result.get()); + Closure task = base::Bind( + &SimpleSynchronousEntry::ReadSparseData, + base::Unretained(synchronous_entry_), + SimpleSynchronousEntry::EntryOperationData(sparse_offset, buf_len), + base::RetainedRef(buf), last_used.get(), result.get()); Closure reply = base::Bind(&SimpleEntryImpl::ReadSparseOperationComplete, this, callback, @@ -1058,14 +1047,12 @@ void SimpleEntryImpl::WriteSparseDataInternal( last_used_ = last_modified_ = base::Time::Now(); scoped_ptr<int> result(new int()); - Closure task = base::Bind(&SimpleSynchronousEntry::WriteSparseData, - base::Unretained(synchronous_entry_), - SimpleSynchronousEntry::EntryOperationData( - sparse_offset, buf_len), - make_scoped_refptr(buf), - max_sparse_data_size, - entry_stat.get(), - result.get()); + Closure task = base::Bind( + &SimpleSynchronousEntry::WriteSparseData, + base::Unretained(synchronous_entry_), + SimpleSynchronousEntry::EntryOperationData(sparse_offset, buf_len), + base::RetainedRef(buf), max_sparse_data_size, entry_stat.get(), + result.get()); Closure reply = base::Bind(&SimpleEntryImpl::WriteSparseOperationComplete, this, callback, diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc index 24f888b..fc2b9ca 100644 --- a/net/http/http_stream_factory_impl_job.cc +++ b/net/http/http_stream_factory_impl_job.cc @@ -651,15 +651,17 @@ int HttpStreamFactoryImpl::Job::RunLoop(int result) { FROM_HERE, base::Bind(&Job::OnNeedsProxyAuthCallback, ptr_factory_.GetWeakPtr(), *proxy_socket->GetConnectResponseInfo(), - proxy_socket->GetAuthController())); + base::RetainedRef(proxy_socket->GetAuthController()))); return ERR_IO_PENDING; } case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::Bind(&Job::OnNeedsClientAuthCallback, ptr_factory_.GetWeakPtr(), - connection_->ssl_error_response_info().cert_request_info)); + base::Bind( + &Job::OnNeedsClientAuthCallback, ptr_factory_.GetWeakPtr(), + base::RetainedRef( + connection_->ssl_error_response_info().cert_request_info))); return ERR_IO_PENDING; case ERR_HTTPS_PROXY_TUNNEL_RESPONSE: { diff --git a/ppapi/proxy/ppapi_proxy_test.cc b/ppapi/proxy/ppapi_proxy_test.cc index 71b8816..5ff1a4e 100644 --- a/ppapi/proxy/ppapi_proxy_test.cc +++ b/ppapi/proxy/ppapi_proxy_test.cc @@ -558,8 +558,8 @@ void TwoWayTest::SetUp() { base::WaitableEvent remote_harness_set_up(true, false); plugin_thread_.task_runner()->PostTask( FROM_HERE, base::Bind(&SetUpRemoteHarness, remote_harness_, handle, - io_thread_.task_runner(), &shutdown_event_, - &remote_harness_set_up)); + base::RetainedRef(io_thread_.task_runner()), + &shutdown_event_, &remote_harness_set_up)); remote_harness_set_up.Wait(); local_harness_->SetUpHarnessWithChannel( handle, io_thread_.task_runner().get(), &shutdown_event_, diff --git a/printing/printed_document.cc b/printing/printed_document.cc index 472ebd5..c4f2fb7 100644 --- a/printing/printed_document.cc +++ b/printing/printed_document.cc @@ -81,10 +81,9 @@ void DebugDumpSettings(const base::string16& doc_name, job_settings, base::JSONWriter::OPTIONS_PRETTY_PRINT, &settings_str); scoped_refptr<base::RefCountedMemory> data = base::RefCountedString::TakeString(&settings_str); - blocking_runner->PostTask( - FROM_HERE, - base::Bind( - &DebugDumpDataTask, doc_name, FILE_PATH_LITERAL(".json"), data)); + blocking_runner->PostTask(FROM_HERE, base::Bind(&DebugDumpDataTask, doc_name, + FILE_PATH_LITERAL(".json"), + base::RetainedRef(data))); } } // namespace @@ -136,7 +135,8 @@ void PrintedDocument::SetPage(int page_number, if (!g_debug_dump_info.Get().empty()) { immutable_.blocking_runner_->PostTask( - FROM_HERE, base::Bind(&DebugDumpPageTask, name(), page)); + FROM_HERE, + base::Bind(&DebugDumpPageTask, name(), base::RetainedRef(page))); } } diff --git a/storage/browser/database/database_quota_client.cc b/storage/browser/database/database_quota_client.cc index 0724d05..3a80aa4 100644 --- a/storage/browser/database/database_quota_client.cc +++ b/storage/browser/database/database_quota_client.cc @@ -133,9 +133,9 @@ void DatabaseQuotaClient::GetOriginUsage(const GURL& origin_url, } base::PostTaskAndReplyWithResult( - db_tracker_thread_.get(), - FROM_HERE, - base::Bind(&GetOriginUsageOnDBThread, db_tracker_, origin_url), + db_tracker_thread_.get(), FROM_HERE, + base::Bind(&GetOriginUsageOnDBThread, base::RetainedRef(db_tracker_), + origin_url), callback); } @@ -154,12 +154,9 @@ void DatabaseQuotaClient::GetOriginsForType( std::set<GURL>* origins_ptr = new std::set<GURL>(); db_tracker_thread_->PostTaskAndReply( FROM_HERE, - base::Bind(&GetOriginsOnDBThread, - db_tracker_, + base::Bind(&GetOriginsOnDBThread, base::RetainedRef(db_tracker_), base::Unretained(origins_ptr)), - base::Bind(&DidGetOrigins, - callback, - base::Owned(origins_ptr))); + base::Bind(&DidGetOrigins, callback, base::Owned(origins_ptr))); } void DatabaseQuotaClient::GetOriginsForHost( @@ -178,13 +175,9 @@ void DatabaseQuotaClient::GetOriginsForHost( std::set<GURL>* origins_ptr = new std::set<GURL>(); db_tracker_thread_->PostTaskAndReply( FROM_HERE, - base::Bind(&GetOriginsForHostOnDBThread, - db_tracker_, - base::Unretained(origins_ptr), - host), - base::Bind(&DidGetOrigins, - callback, - base::Owned(origins_ptr))); + base::Bind(&GetOriginsForHostOnDBThread, base::RetainedRef(db_tracker_), + base::Unretained(origins_ptr), host), + base::Bind(&DidGetOrigins, callback, base::Owned(origins_ptr))); } void DatabaseQuotaClient::DeleteOriginData(const GURL& origin, @@ -199,10 +192,9 @@ void DatabaseQuotaClient::DeleteOriginData(const GURL& origin, return; } - base::Callback<void(int)> delete_callback = - base::Bind(&DidDeleteOriginData, - base::ThreadTaskRunnerHandle::Get(), - callback); + base::Callback<void(int)> delete_callback = base::Bind( + &DidDeleteOriginData, + base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), callback); PostTaskAndReplyWithResult( db_tracker_thread_.get(), diff --git a/storage/browser/fileapi/async_file_util_adapter.cc b/storage/browser/fileapi/async_file_util_adapter.cc index 361c73a..cf79022 100644 --- a/storage/browser/fileapi/async_file_util_adapter.cc +++ b/storage/browser/fileapi/async_file_util_adapter.cc @@ -218,9 +218,9 @@ void AsyncFileUtilAdapter::ReadDirectory( FileSystemOperationContext* context_ptr = context.release(); const bool success = context_ptr->task_runner()->PostTask( FROM_HERE, - Bind(&ReadDirectoryHelper, - sync_file_util_.get(), base::Owned(context_ptr), url, - base::ThreadTaskRunnerHandle::Get(), callback)); + Bind(&ReadDirectoryHelper, sync_file_util_.get(), + base::Owned(context_ptr), url, + base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), callback)); DCHECK(success); } diff --git a/storage/browser/fileapi/file_system_context.cc b/storage/browser/fileapi/file_system_context.cc index 8631801..166413c 100644 --- a/storage/browser/fileapi/file_system_context.cc +++ b/storage/browser/fileapi/file_system_context.cc @@ -428,15 +428,12 @@ void FileSystemContext::DeleteFileSystem( } base::PostTaskAndReplyWithResult( - default_file_task_runner(), - FROM_HERE, + default_file_task_runner(), FROM_HERE, // It is safe to pass Unretained(quota_util) since context owns it. base::Bind(&FileSystemQuotaUtil::DeleteOriginDataOnFileTaskRunner, base::Unretained(backend->GetQuotaUtil()), - make_scoped_refptr(this), - base::Unretained(quota_manager_proxy()), - origin_url, - type), + base::RetainedRef(this), + base::Unretained(quota_manager_proxy()), origin_url, type), callback); } diff --git a/storage/browser/fileapi/file_system_file_stream_reader.cc b/storage/browser/fileapi/file_system_file_stream_reader.cc index 0f30eb3..1b749be 100644 --- a/storage/browser/fileapi/file_system_file_stream_reader.cc +++ b/storage/browser/fileapi/file_system_file_stream_reader.cc @@ -69,10 +69,9 @@ int FileSystemFileStreamReader::Read( const net::CompletionCallback& callback) { if (local_file_reader_) return local_file_reader_->Read(buf, buf_len, callback); - return CreateSnapshot( - base::Bind(&ReadAdapter, weak_factory_.GetWeakPtr(), - make_scoped_refptr(buf), buf_len, callback), - callback); + return CreateSnapshot(base::Bind(&ReadAdapter, weak_factory_.GetWeakPtr(), + base::RetainedRef(buf), buf_len, callback), + callback); } int64_t FileSystemFileStreamReader::GetLength( diff --git a/storage/browser/fileapi/file_system_quota_client.cc b/storage/browser/fileapi/file_system_quota_client.cc index f6cab0d..58a219d 100644 --- a/storage/browser/fileapi/file_system_quota_client.cc +++ b/storage/browser/fileapi/file_system_quota_client.cc @@ -114,14 +114,11 @@ void FileSystemQuotaClient::GetOriginUsage( } base::PostTaskAndReplyWithResult( - file_task_runner(), - FROM_HERE, + file_task_runner(), FROM_HERE, // It is safe to pass Unretained(quota_util) since context owns it. base::Bind(&FileSystemQuotaUtil::GetOriginUsageOnFileTaskRunner, base::Unretained(quota_util), - file_system_context_, - origin_url, - type), + base::RetainedRef(file_system_context_), origin_url, type), callback); } @@ -139,14 +136,10 @@ void FileSystemQuotaClient::GetOriginsForType( std::set<GURL>* origins_ptr = new std::set<GURL>(); file_task_runner()->PostTaskAndReply( - FROM_HERE, - base::Bind(&GetOriginsForTypeOnFileTaskRunner, - file_system_context_, - storage_type, - base::Unretained(origins_ptr)), - base::Bind(&DidGetOrigins, - callback, - base::Owned(origins_ptr))); + FROM_HERE, base::Bind(&GetOriginsForTypeOnFileTaskRunner, + base::RetainedRef(file_system_context_), + storage_type, base::Unretained(origins_ptr)), + base::Bind(&DidGetOrigins, callback, base::Owned(origins_ptr))); } void FileSystemQuotaClient::GetOriginsForHost( @@ -164,15 +157,10 @@ void FileSystemQuotaClient::GetOriginsForHost( std::set<GURL>* origins_ptr = new std::set<GURL>(); file_task_runner()->PostTaskAndReply( - FROM_HERE, - base::Bind(&GetOriginsForHostOnFileTaskRunner, - file_system_context_, - storage_type, - host, - base::Unretained(origins_ptr)), - base::Bind(&DidGetOrigins, - callback, - base::Owned(origins_ptr))); + FROM_HERE, base::Bind(&GetOriginsForHostOnFileTaskRunner, + base::RetainedRef(file_system_context_), + storage_type, host, base::Unretained(origins_ptr)), + base::Bind(&DidGetOrigins, callback, base::Owned(origins_ptr))); } void FileSystemQuotaClient::DeleteOriginData( @@ -183,12 +171,9 @@ void FileSystemQuotaClient::DeleteOriginData( DCHECK(fs_type != kFileSystemTypeUnknown); base::PostTaskAndReplyWithResult( - file_task_runner(), - FROM_HERE, + file_task_runner(), FROM_HERE, base::Bind(&DeleteOriginOnFileTaskRunner, - file_system_context_, - origin, - fs_type), + base::RetainedRef(file_system_context_), origin, fs_type), callback); } diff --git a/storage/browser/fileapi/local_file_stream_reader.cc b/storage/browser/fileapi/local_file_stream_reader.cc index c6bfbbd..74a9cc9 100644 --- a/storage/browser/fileapi/local_file_stream_reader.cc +++ b/storage/browser/fileapi/local_file_stream_reader.cc @@ -43,8 +43,8 @@ int LocalFileStreamReader::Read(net::IOBuffer* buf, int buf_len, if (stream_impl_) return stream_impl_->Read(buf, buf_len, callback); return Open(base::Bind(&LocalFileStreamReader::DidOpenForRead, - weak_factory_.GetWeakPtr(), - make_scoped_refptr(buf), buf_len, callback)); + weak_factory_.GetWeakPtr(), base::RetainedRef(buf), + buf_len, callback)); } int64_t LocalFileStreamReader::GetLength( diff --git a/storage/browser/fileapi/local_file_stream_writer.cc b/storage/browser/fileapi/local_file_stream_writer.cc index e586fd1..03ca22b 100644 --- a/storage/browser/fileapi/local_file_stream_writer.cc +++ b/storage/browser/fileapi/local_file_stream_writer.cc @@ -55,10 +55,10 @@ int LocalFileStreamWriter::Write(net::IOBuffer* buf, int buf_len, has_pending_operation_ = false; return result; } - return InitiateOpen(callback, - base::Bind(&LocalFileStreamWriter::ReadyToWrite, - weak_factory_.GetWeakPtr(), - make_scoped_refptr(buf), buf_len, callback)); + return InitiateOpen( + callback, base::Bind(&LocalFileStreamWriter::ReadyToWrite, + weak_factory_.GetWeakPtr(), base::RetainedRef(buf), + buf_len, callback)); } int LocalFileStreamWriter::Cancel(const net::CompletionCallback& callback) { diff --git a/storage/browser/fileapi/sandbox_file_stream_writer.cc b/storage/browser/fileapi/sandbox_file_stream_writer.cc index 363fb01..3cca3d3 100644 --- a/storage/browser/fileapi/sandbox_file_stream_writer.cc +++ b/storage/browser/fileapi/sandbox_file_stream_writer.cc @@ -70,10 +70,9 @@ int SandboxFileStreamWriter::Write( if (local_file_writer_) return WriteInternal(buf, buf_len, callback); - net::CompletionCallback write_task = - base::Bind(&SandboxFileStreamWriter::DidInitializeForWrite, - weak_factory_.GetWeakPtr(), - make_scoped_refptr(buf), buf_len, callback); + net::CompletionCallback write_task = base::Bind( + &SandboxFileStreamWriter::DidInitializeForWrite, + weak_factory_.GetWeakPtr(), base::RetainedRef(buf), buf_len, callback); file_system_context_->operation_runner()->CreateSnapshotFile( url_, base::Bind(&SandboxFileStreamWriter::DidCreateSnapshotFile, weak_factory_.GetWeakPtr(), write_task)); diff --git a/storage/browser/quota/quota_manager.cc b/storage/browser/quota/quota_manager.cc index cb1add8..a464f67 100644 --- a/storage/browser/quota/quota_manager.cc +++ b/storage/browser/quota/quota_manager.cc @@ -1668,7 +1668,8 @@ void QuotaManager::GetLRUOrigin(StorageType type, PostTaskAndReplyWithResultForDBThread( FROM_HERE, base::Bind(&GetLRUOriginOnDBThread, type, GetEvictionOriginExceptions(std::set<GURL>()), - special_storage_policy_, base::Unretained(url)), + base::RetainedRef(special_storage_policy_), + base::Unretained(url)), base::Bind(&QuotaManager::DidGetLRUOrigin, weak_factory_.GetWeakPtr(), base::Owned(url))); } diff --git a/storage/browser/quota/quota_manager_proxy.cc b/storage/browser/quota/quota_manager_proxy.cc index 2efd22c..0c1ad0a 100644 --- a/storage/browser/quota/quota_manager_proxy.cc +++ b/storage/browser/quota/quota_manager_proxy.cc @@ -26,10 +26,9 @@ void DidGetUsageAndQuota( int64_t quota) { if (!original_task_runner->RunsTasksOnCurrentThread()) { original_task_runner->PostTask( - FROM_HERE, - base::Bind(&DidGetUsageAndQuota, - make_scoped_refptr(original_task_runner), - callback, status, usage, quota)); + FROM_HERE, base::Bind(&DidGetUsageAndQuota, + base::RetainedRef(original_task_runner), callback, + status, usage, quota)); return; } @@ -134,10 +133,9 @@ void QuotaManagerProxy::GetUsageAndQuota( const GetUsageAndQuotaCallback& callback) { if (!io_thread_->BelongsToCurrentThread()) { io_thread_->PostTask( - FROM_HERE, - base::Bind(&QuotaManagerProxy::GetUsageAndQuota, this, - make_scoped_refptr(original_task_runner), - origin, type, callback)); + FROM_HERE, base::Bind(&QuotaManagerProxy::GetUsageAndQuota, this, + base::RetainedRef(original_task_runner), origin, + type, callback)); return; } if (!manager_) { @@ -150,8 +148,8 @@ void QuotaManagerProxy::GetUsageAndQuota( manager_->GetUsageAndQuota( origin, type, - base::Bind(&DidGetUsageAndQuota, - make_scoped_refptr(original_task_runner), callback)); + base::Bind(&DidGetUsageAndQuota, base::RetainedRef(original_task_runner), + callback)); } QuotaManager* QuotaManagerProxy::quota_manager() const { diff --git a/sync/internal_api/http_bridge_unittest.cc b/sync/internal_api/http_bridge_unittest.cc index 1c83634..f69bc75 100644 --- a/sync/internal_api/http_bridge_unittest.cc +++ b/sync/internal_api/http_bridge_unittest.cc @@ -385,8 +385,8 @@ TEST_F(MAYBE_SyncHttpBridgeTest, Abort) { int response_code = 0; io_thread()->task_runner()->PostTask( - FROM_HERE, - base::Bind(&MAYBE_SyncHttpBridgeTest::Abort, http_bridge)); + FROM_HERE, base::Bind(&MAYBE_SyncHttpBridgeTest::Abort, + base::RetainedRef(http_bridge))); bool success = http_bridge->MakeSynchronousPost(&os_error, &response_code); EXPECT_FALSE(success); EXPECT_EQ(net::ERR_ABORTED, os_error); |