diff options
author | svaldez <svaldez@chromium.org> | 2015-08-24 14:36:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-24 21:39:35 +0000 |
commit | 5d58c9eb2baa203be1b84ac88cde82c59d72f143 (patch) | |
tree | 3446bf04741d0b6e307fdc0b51593323834e680d | |
parent | cc19cb9a644b1c385b36b108bd9bf5438d8d1f2b (diff) | |
download | chromium_src-5d58c9eb2baa203be1b84ac88cde82c59d72f143.zip chromium_src-5d58c9eb2baa203be1b84ac88cde82c59d72f143.tar.gz chromium_src-5d58c9eb2baa203be1b84ac88cde82c59d72f143.tar.bz2 |
Using scoped_ptr for URLRequestJobFactoryImpl::SetProtocolHandler
Adding scoped_ptr to call in order to take ownership of handler.
BUG=517161
Review URL: https://codereview.chromium.org/1295523006
Cr-Commit-Position: refs/heads/master@{#345185}
52 files changed, 203 insertions, 165 deletions
diff --git a/android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc b/android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc index c7e3c68..651d01d 100644 --- a/android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc +++ b/android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc @@ -218,12 +218,14 @@ class AndroidStreamReaderURLRequestJobTest : public Test { // The Interceptor is owned by the |factory_|. TestJobInterceptor* protocol_handler = new TestJobInterceptor; protocol_handler->set_main_intercept_job(test_stream_reader_job); - bool set_protocol = factory_.SetProtocolHandler("http", protocol_handler); + bool set_protocol = + factory_.SetProtocolHandler("http", make_scoped_ptr(protocol_handler)); DCHECK(set_protocol); protocol_handler = new TestJobInterceptor; protocol_handler->set_main_intercept_job(test_stream_reader_job); - set_protocol = factory_.SetProtocolHandler("content", protocol_handler); + set_protocol = factory_.SetProtocolHandler( + "content", make_scoped_ptr(protocol_handler)); DCHECK(set_protocol); } diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc index bdfb014..446f85a 100644 --- a/android_webview/browser/net/aw_url_request_context_getter.cc +++ b/android_webview/browser/net/aw_url_request_context_getter.cc @@ -116,29 +116,31 @@ scoped_ptr<net::URLRequestJobFactory> CreateJobFactory( // AwContentBrowserClient::IsHandledURL. bool set_protocol = aw_job_factory->SetProtocolHandler( url::kFileScheme, - new net::FileProtocolHandler( - content::BrowserThread::GetBlockingPool()-> - GetTaskRunnerWithShutdownBehavior( - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); + make_scoped_ptr(new net::FileProtocolHandler( + content::BrowserThread::GetBlockingPool() + ->GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); DCHECK(set_protocol); set_protocol = aw_job_factory->SetProtocolHandler( - url::kDataScheme, new net::DataProtocolHandler()); + url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler())); DCHECK(set_protocol); set_protocol = aw_job_factory->SetProtocolHandler( url::kBlobScheme, - (*protocol_handlers)[url::kBlobScheme].release()); + make_scoped_ptr((*protocol_handlers)[url::kBlobScheme].release())); DCHECK(set_protocol); set_protocol = aw_job_factory->SetProtocolHandler( url::kFileSystemScheme, - (*protocol_handlers)[url::kFileSystemScheme].release()); + make_scoped_ptr((*protocol_handlers)[url::kFileSystemScheme].release())); DCHECK(set_protocol); set_protocol = aw_job_factory->SetProtocolHandler( content::kChromeUIScheme, - (*protocol_handlers)[content::kChromeUIScheme].release()); + make_scoped_ptr( + (*protocol_handlers)[content::kChromeUIScheme].release())); DCHECK(set_protocol); set_protocol = aw_job_factory->SetProtocolHandler( content::kChromeDevToolsScheme, - (*protocol_handlers)[content::kChromeDevToolsScheme].release()); + make_scoped_ptr( + (*protocol_handlers)[content::kChromeDevToolsScheme].release())); DCHECK(set_protocol); protocol_handlers->clear(); diff --git a/android_webview/browser/net/aw_url_request_job_factory.cc b/android_webview/browser/net/aw_url_request_job_factory.cc index 984458c..389d543 100644 --- a/android_webview/browser/net/aw_url_request_job_factory.cc +++ b/android_webview/browser/net/aw_url_request_job_factory.cc @@ -73,8 +73,8 @@ net::URLRequestJob* AwURLRequestJobFactory::MaybeInterceptResponse( bool AwURLRequestJobFactory::SetProtocolHandler( const std::string& scheme, - ProtocolHandler* protocol_handler) { - return next_factory_->SetProtocolHandler(scheme, protocol_handler); + scoped_ptr<ProtocolHandler> protocol_handler) { + return next_factory_->SetProtocolHandler(scheme, protocol_handler.Pass()); } bool AwURLRequestJobFactory::IsSafeRedirectTarget(const GURL& location) const { diff --git a/android_webview/browser/net/aw_url_request_job_factory.h b/android_webview/browser/net/aw_url_request_job_factory.h index 458c1b0..1e7f8b2 100644 --- a/android_webview/browser/net/aw_url_request_job_factory.h +++ b/android_webview/browser/net/aw_url_request_job_factory.h @@ -26,7 +26,7 @@ class AwURLRequestJobFactory : public net::URLRequestJobFactory { ~AwURLRequestJobFactory() override; bool SetProtocolHandler(const std::string& scheme, - ProtocolHandler* protocol_handler); + scoped_ptr<ProtocolHandler> protocol_handler); // net::URLRequestJobFactory implementation. net::URLRequestJob* MaybeCreateJobWithProtocolHandler( diff --git a/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc b/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc index 2006e6f..5cfdd3b 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc +++ b/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc @@ -238,8 +238,9 @@ TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) { ipc_sender_factory.GetWeakPtr()); net::URLRequestJobFactoryImpl job_factory; - job_factory.SetProtocolHandler(url::kAboutScheme, - new about_handler::AboutProtocolHandler()); + job_factory.SetProtocolHandler( + url::kAboutScheme, + make_scoped_ptr(new about_handler::AboutProtocolHandler())); context_->set_job_factory(&job_factory); GURL redirect_url("about:redirected"); diff --git a/chrome/browser/extensions/extension_resource_protocols.cc b/chrome/browser/extensions/extension_resource_protocols.cc index c24b53f..d40de60 100644 --- a/chrome/browser/extensions/extension_resource_protocols.cc +++ b/chrome/browser/extensions/extension_resource_protocols.cc @@ -94,7 +94,7 @@ ExtensionResourceProtocolHandler::MaybeCreateJob( } // namespace -net::URLRequestJobFactory::ProtocolHandler* +scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> CreateExtensionResourceProtocolHandler() { - return new ExtensionResourceProtocolHandler(); + return make_scoped_ptr(new ExtensionResourceProtocolHandler()); } diff --git a/chrome/browser/extensions/extension_resource_protocols.h b/chrome/browser/extensions/extension_resource_protocols.h index cf6c1e4..85933a7 100644 --- a/chrome/browser/extensions/extension_resource_protocols.h +++ b/chrome/browser/extensions/extension_resource_protocols.h @@ -5,10 +5,11 @@ #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_RESOURCE_PROTOCOLS_H_ #define CHROME_BROWSER_EXTENSIONS_EXTENSION_RESOURCE_PROTOCOLS_H_ +#include "base/memory/scoped_ptr.h" #include "net/url_request/url_request_job_factory.h" // Creates the handlers for the chrome-extension-resource:// scheme. -net::URLRequestJobFactory::ProtocolHandler* +scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> CreateExtensionResourceProtocolHandler(); #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RESOURCE_PROTOCOLS_H_ diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 1df1aff..3b513e2 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -849,21 +849,21 @@ void IOThread::Init() { tracked_objects::ScopedTracker tracking_profile16( FROM_HERE_WITH_EXPLICIT_FUNCTION( "466432 IOThread::InitAsync::SetProtocolHandler")); - job_factory->SetProtocolHandler(url::kDataScheme, - new net::DataProtocolHandler()); + job_factory->SetProtocolHandler( + url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler())); job_factory->SetProtocolHandler( url::kFileScheme, - new net::FileProtocolHandler( - content::BrowserThread::GetBlockingPool()-> - GetTaskRunnerWithShutdownBehavior( - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); + make_scoped_ptr(new net::FileProtocolHandler( + content::BrowserThread::GetBlockingPool() + ->GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); #if !defined(DISABLE_FTP_SUPPORT) globals_->proxy_script_fetcher_ftp_transaction_factory.reset( new net::FtpNetworkLayer(globals_->host_resolver.get())); job_factory->SetProtocolHandler( url::kFtpScheme, - new net::FtpProtocolHandler( - globals_->proxy_script_fetcher_ftp_transaction_factory.get())); + make_scoped_ptr(new net::FtpProtocolHandler( + globals_->proxy_script_fetcher_ftp_transaction_factory.get()))); #endif globals_->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index bd766ae..911d5b9 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -741,7 +741,7 @@ void ProfileIOData::InstallProtocolHandlers( it != protocol_handlers->end(); ++it) { bool set_protocol = job_factory->SetProtocolHandler( - it->first, it->second.release()); + it->first, make_scoped_ptr(it->second.release())); DCHECK(set_protocol); } protocol_handlers->clear(); @@ -1160,10 +1160,10 @@ scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults( // ProfileIOData::IsHandledProtocol(). bool set_protocol = job_factory->SetProtocolHandler( url::kFileScheme, - new net::FileProtocolHandler( - content::BrowserThread::GetBlockingPool()-> - GetTaskRunnerWithShutdownBehavior( - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); + make_scoped_ptr(new net::FileProtocolHandler( + content::BrowserThread::GetBlockingPool() + ->GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); DCHECK(set_protocol); #if defined(ENABLE_EXTENSIONS) @@ -1181,13 +1181,14 @@ scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults( DCHECK(set_protocol); #endif set_protocol = job_factory->SetProtocolHandler( - url::kDataScheme, new net::DataProtocolHandler()); + url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler())); DCHECK(set_protocol); #if defined(OS_CHROMEOS) if (profile_params_) { set_protocol = job_factory->SetProtocolHandler( content::kExternalFileScheme, - new chromeos::ExternalFileProtocolHandler(profile_params_->profile)); + make_scoped_ptr(new chromeos::ExternalFileProtocolHandler( + profile_params_->profile))); DCHECK(set_protocol); } #endif // defined(OS_CHROMEOS) @@ -1195,18 +1196,19 @@ scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults( set_protocol = job_factory->SetProtocolHandler( url::kContentScheme, content::ContentProtocolHandler::Create( - content::BrowserThread::GetBlockingPool()-> - GetTaskRunnerWithShutdownBehavior( + content::BrowserThread::GetBlockingPool() + ->GetTaskRunnerWithShutdownBehavior( base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); #endif - job_factory->SetProtocolHandler(url::kAboutScheme, - new about_handler::AboutProtocolHandler()); + job_factory->SetProtocolHandler( + url::kAboutScheme, + make_scoped_ptr(new about_handler::AboutProtocolHandler())); #if !defined(DISABLE_FTP_SUPPORT) DCHECK(ftp_transaction_factory); job_factory->SetProtocolHandler( url::kFtpScheme, - new net::FtpProtocolHandler(ftp_transaction_factory)); + make_scoped_ptr(new net::FtpProtocolHandler(ftp_transaction_factory))); #endif // !defined(DISABLE_FTP_SUPPORT) #if defined(DEBUG_DEVTOOLS) diff --git a/chromecast/browser/url_request_context_factory.cc b/chromecast/browser/url_request_context_factory.cc index c60ec6b..c3b0f88 100644 --- a/chromecast/browser/url_request_context_factory.cc +++ b/chromecast/browser/url_request_context_factory.cc @@ -238,22 +238,21 @@ void URLRequestContextFactory::InitializeMainContextDependencies( it != protocol_handlers->end(); ++it) { set_protocol = job_factory->SetProtocolHandler( - it->first, it->second.release()); + it->first, make_scoped_ptr(it->second.release())); DCHECK(set_protocol); } set_protocol = job_factory->SetProtocolHandler( - url::kDataScheme, - new net::DataProtocolHandler); + url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler)); DCHECK(set_protocol); if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableLocalFileAccesses)) { set_protocol = job_factory->SetProtocolHandler( url::kFileScheme, - new net::FileProtocolHandler( - content::BrowserThread::GetBlockingPool()-> - GetTaskRunnerWithShutdownBehavior( - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); + make_scoped_ptr(new net::FileProtocolHandler( + content::BrowserThread::GetBlockingPool() + ->GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); DCHECK(set_protocol); } diff --git a/components/data_reduction_proxy/content/browser/data_reduction_proxy_debug_resource_throttle_unittest.cc b/components/data_reduction_proxy/content/browser/data_reduction_proxy_debug_resource_throttle_unittest.cc index 7845c05..4ca477e 100644 --- a/components/data_reduction_proxy/content/browser/data_reduction_proxy_debug_resource_throttle_unittest.cc +++ b/components/data_reduction_proxy/content/browser/data_reduction_proxy_debug_resource_throttle_unittest.cc @@ -59,10 +59,8 @@ class DataReductionProxyDebugResourceThrottleTest : public testing::Test { DataReductionProxyDebugResourceThrottleTest() : context_(true) { context_.Init(); - // The |test_job_factory_| takes ownership of the interceptor. - test_job_interceptor_ = new net::TestJobInterceptor(); - EXPECT_TRUE(test_job_factory_.SetProtocolHandler(url::kHttpScheme, - test_job_interceptor_)); + EXPECT_TRUE(test_job_factory_.SetProtocolHandler( + url::kHttpScheme, make_scoped_ptr(new net::TestJobInterceptor()))); context_.set_job_factory(&test_job_factory_); @@ -108,8 +106,6 @@ class DataReductionProxyDebugResourceThrottleTest : public testing::Test { base::MessageLoop message_loop_; net::TestURLRequestContext context_; net::TestDelegate delegate_; - // |test_job_interceptor_| is owned by |test_job_factory_|. - net::TestJobInterceptor* test_job_interceptor_; net::URLRequestJobFactoryImpl test_job_factory_; net::ProxyConfig proxy_config_; diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc index ba0501f..cf21046 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc @@ -64,8 +64,8 @@ class DataReductionProxyBypassStatsTest : public testing::Test { // The |test_job_factory_| takes ownership of the interceptor. test_job_interceptor_ = new net::TestJobInterceptor(); - EXPECT_TRUE(test_job_factory_.SetProtocolHandler(url::kHttpScheme, - test_job_interceptor_)); + EXPECT_TRUE(test_job_factory_.SetProtocolHandler( + url::kHttpScheme, make_scoped_ptr(test_job_interceptor_))); context_.set_job_factory(&test_job_factory_); diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc index 0e37cbf..1cf8288 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc @@ -74,8 +74,8 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test { // The |test_job_factory_| takes ownership of the interceptor. test_job_interceptor_ = new net::TestJobInterceptor(); - EXPECT_TRUE(test_job_factory_.SetProtocolHandler(url::kHttpScheme, - test_job_interceptor_)); + EXPECT_TRUE(test_job_factory_.SetProtocolHandler( + url::kHttpScheme, make_scoped_ptr(test_job_interceptor_))); context_.set_job_factory(&test_job_factory_); test_context_ = DataReductionProxyTestContext::Builder() diff --git a/content/browser/android/content_protocol_handler_impl.cc b/content/browser/android/content_protocol_handler_impl.cc index f5e5d20..8f8b13a 100644 --- a/content/browser/android/content_protocol_handler_impl.cc +++ b/content/browser/android/content_protocol_handler_impl.cc @@ -13,9 +13,9 @@ namespace content { // static -ContentProtocolHandler* ContentProtocolHandler::Create( +scoped_ptr<ContentProtocolHandler> ContentProtocolHandler::Create( const scoped_refptr<base::TaskRunner>& content_task_runner) { - return new ContentProtocolHandlerImpl(content_task_runner); + return make_scoped_ptr(new ContentProtocolHandlerImpl(content_task_runner)); } ContentProtocolHandlerImpl::ContentProtocolHandlerImpl( diff --git a/content/browser/appcache/appcache_storage_impl_unittest.cc b/content/browser/appcache/appcache_storage_impl_unittest.cc index 9c980da..669db8c 100644 --- a/content/browser/appcache/appcache_storage_impl_unittest.cc +++ b/content/browser/appcache/appcache_storage_impl_unittest.cc @@ -163,9 +163,8 @@ class IOThread : public base::Thread { scoped_ptr<net::URLRequestJobFactoryImpl> factory( new net::URLRequestJobFactoryImpl()); factory->SetProtocolHandler( - "http", - new MockHttpServerJobFactory( - make_scoped_ptr(new AppCacheInterceptor()))); + "http", make_scoped_ptr(new MockHttpServerJobFactory( + make_scoped_ptr(new AppCacheInterceptor())))); job_factory_ = factory.Pass(); request_context_.reset(new net::TestURLRequestContext()); request_context_->set_job_factory(job_factory_.get()); diff --git a/content/browser/appcache/appcache_update_job_unittest.cc b/content/browser/appcache/appcache_update_job_unittest.cc index 917228d..569532a 100644 --- a/content/browser/appcache/appcache_update_job_unittest.cc +++ b/content/browser/appcache/appcache_update_job_unittest.cc @@ -574,8 +574,10 @@ class IOThread : public base::Thread { void Init() override { scoped_ptr<net::URLRequestJobFactoryImpl> factory( new net::URLRequestJobFactoryImpl()); - factory->SetProtocolHandler("http", new MockHttpServerJobFactory); - factory->SetProtocolHandler("https", new MockHttpServerJobFactory); + factory->SetProtocolHandler("http", + make_scoped_ptr(new MockHttpServerJobFactory)); + factory->SetProtocolHandler("https", + make_scoped_ptr(new MockHttpServerJobFactory)); job_factory_ = factory.Pass(); request_context_.reset(new net::TestURLRequestContext()); request_context_->set_job_factory(job_factory_.get()); @@ -796,7 +798,8 @@ class AppCacheUpdateJobTest : public testing::Test, net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new RedirectFactory); + new_factory->SetProtocolHandler("http", + make_scoped_ptr(new RedirectFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1682,7 +1685,8 @@ class AppCacheUpdateJobTest : public testing::Test, RetryRequestTestJob::Initialize(5, RetryRequestTestJob::RETRY_AFTER_0, 4); net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1715,7 +1719,8 @@ class AppCacheUpdateJobTest : public testing::Test, RetryRequestTestJob::Initialize(5, RetryRequestTestJob::NO_RETRY_AFTER, 1); net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1749,7 +1754,8 @@ class AppCacheUpdateJobTest : public testing::Test, 5, RetryRequestTestJob::NONZERO_RETRY_AFTER, 1); net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1782,7 +1788,8 @@ class AppCacheUpdateJobTest : public testing::Test, RetryRequestTestJob::Initialize(2, RetryRequestTestJob::RETRY_AFTER_0, 5); net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1815,7 +1822,8 @@ class AppCacheUpdateJobTest : public testing::Test, RetryRequestTestJob::Initialize(1, RetryRequestTestJob::RETRY_AFTER_0, 4); net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2680,7 +2688,8 @@ class AppCacheUpdateJobTest : public testing::Test, net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2751,7 +2760,8 @@ class AppCacheUpdateJobTest : public testing::Test, std::string()); net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2814,7 +2824,8 @@ class AppCacheUpdateJobTest : public testing::Test, HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2877,7 +2888,8 @@ class AppCacheUpdateJobTest : public testing::Test, HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\""); net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2915,7 +2927,8 @@ class AppCacheUpdateJobTest : public testing::Test, "Sat, 29 Oct 1994 19:43:31 GMT", "\"LadeDade\""); net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); - new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory); + new_factory->SetProtocolHandler( + "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); diff --git a/content/browser/cache_storage/cache_storage_blob_to_disk_cache_unittest.cc b/content/browser/cache_storage/cache_storage_blob_to_disk_cache_unittest.cc index 99ff067..b4e88a8 100644 --- a/content/browser/cache_storage/cache_storage_blob_to_disk_cache_unittest.cc +++ b/content/browser/cache_storage/cache_storage_blob_to_disk_cache_unittest.cc @@ -55,12 +55,13 @@ class NullURLRequestContextGetter : public net::URLRequestContextGetter { // Returns a BlobProtocolHandler that uses |blob_storage_context|. Caller owns // the memory. -storage::BlobProtocolHandler* CreateMockBlobProtocolHandler( +scoped_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { // The FileSystemContext and thread task runner are not actually used but a // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. - return new storage::BlobProtocolHandler( - blob_storage_context, nullptr, base::ThreadTaskRunnerHandle::Get().get()); + return make_scoped_ptr(new storage::BlobProtocolHandler( + blob_storage_context, nullptr, + base::ThreadTaskRunnerHandle::Get().get())); } // A CacheStorageBlobToDiskCache that can delay reading from blobs. diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc index f250b23..88363a7 100644 --- a/content/browser/cache_storage/cache_storage_cache_unittest.cc +++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc @@ -7,6 +7,7 @@ #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/strings/string_split.h" #include "base/thread_task_runner_handle.h" @@ -38,12 +39,12 @@ const char kTestData[] = "Hello World"; // Returns a BlobProtocolHandler that uses |blob_storage_context|. Caller owns // the memory. -storage::BlobProtocolHandler* CreateMockBlobProtocolHandler( +scoped_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { // The FileSystemContext and thread task runner are not actually used but a // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. - return new storage::BlobProtocolHandler( - blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get()); + return make_scoped_ptr(new storage::BlobProtocolHandler( + blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get())); } // A disk_cache::Backend wrapper that can delay operations. diff --git a/content/browser/fileapi/blob_url_request_job_unittest.cc b/content/browser/fileapi/blob_url_request_job_unittest.cc index 17526b8..9debd4d 100644 --- a/content/browser/fileapi/blob_url_request_job_unittest.cc +++ b/content/browser/fileapi/blob_url_request_job_unittest.cc @@ -150,8 +150,8 @@ class BlobURLRequestJobTest : public testing::Test { disk_cache_entry_ = CreateDiskCacheEntry( disk_cache_backend_.get(), kTestDiskCacheKey, kTestDiskCacheData); - url_request_job_factory_.SetProtocolHandler("blob", - new MockProtocolHandler(this)); + url_request_job_factory_.SetProtocolHandler( + "blob", make_scoped_ptr(new MockProtocolHandler(this))); url_request_context_.set_job_factory(&url_request_job_factory_); } diff --git a/content/browser/loader/navigation_url_loader_unittest.cc b/content/browser/loader/navigation_url_loader_unittest.cc index df5e9d6..1cefb9b 100644 --- a/content/browser/loader/navigation_url_loader_unittest.cc +++ b/content/browser/loader/navigation_url_loader_unittest.cc @@ -165,8 +165,9 @@ class NavigationURLLoaderTest : public testing::Test { job_factory_.SetProtocolHandler( "test", net::URLRequestTestJob::CreateProtocolHandler()); job_factory_.SetProtocolHandler( - "blob", new StreamProtocolHandler( - StreamContext::GetFor(browser_context_.get())->registry())); + "blob", + make_scoped_ptr(new StreamProtocolHandler( + StreamContext::GetFor(browser_context_.get())->registry()))); request_context->set_job_factory(&job_factory_); // NavigationURLLoader is only used for browser-side navigations. diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc index 0131f2f..fad86d5 100644 --- a/content/browser/loader/resource_loader_unittest.cc +++ b/content/browser/loader/resource_loader_unittest.cc @@ -8,6 +8,7 @@ #include "base/files/file_util.h" #include "base/location.h" #include "base/macros.h" +#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -527,7 +528,8 @@ class ResourceLoaderTest : public testing::Test, } } - virtual net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler() { + virtual scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> + CreateProtocolHandler() { return net::URLRequestTestJob::CreateProtocolHandler(); } @@ -615,8 +617,9 @@ class ResourceLoaderTest : public testing::Test, class ClientCertResourceLoaderTest : public ResourceLoaderTest { protected: - net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler() override { - return new MockClientCertJobProtocolHandler; + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> CreateProtocolHandler() + override { + return make_scoped_ptr(new MockClientCertJobProtocolHandler); } }; diff --git a/content/browser/service_worker/service_worker_url_request_job_unittest.cc b/content/browser/service_worker/service_worker_url_request_job_unittest.cc index 149c524..a4ba903 100644 --- a/content/browser/service_worker/service_worker_url_request_job_unittest.cc +++ b/content/browser/service_worker/service_worker_url_request_job_unittest.cc @@ -100,12 +100,13 @@ class MockHttpProtocolHandler // Returns a BlobProtocolHandler that uses |blob_storage_context|. Caller owns // the memory. -storage::BlobProtocolHandler* CreateMockBlobProtocolHandler( +scoped_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { // The FileSystemContext and task runner are not actually used but a // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. - return new storage::BlobProtocolHandler( - blob_storage_context, nullptr, base::ThreadTaskRunnerHandle::Get().get()); + return make_scoped_ptr(new storage::BlobProtocolHandler( + blob_storage_context, nullptr, + base::ThreadTaskRunnerHandle::Get().get())); } } // namespace @@ -183,9 +184,9 @@ class ServiceWorkerURLRequestJobTest : public testing::Test { url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); url_request_job_factory_->SetProtocolHandler( "http", - new MockHttpProtocolHandler(provider_host->AsWeakPtr(), - browser_context_->GetResourceContext(), - blob_storage_context->AsWeakPtr())); + make_scoped_ptr(new MockHttpProtocolHandler( + provider_host->AsWeakPtr(), browser_context_->GetResourceContext(), + blob_storage_context->AsWeakPtr()))); url_request_job_factory_->SetProtocolHandler( "blob", CreateMockBlobProtocolHandler(blob_storage_context)); url_request_context_.set_job_factory(url_request_job_factory_.get()); diff --git a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc index 373f422..18115d9 100644 --- a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc +++ b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc @@ -280,8 +280,8 @@ class ServiceWorkerWriteToCacheJobTest : public testing::Test { url_request_context_.reset(new net::URLRequestContext); mock_protocol_handler_ = new MockHttpProtocolHandler(&resource_context_); url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); - url_request_job_factory_->SetProtocolHandler("https", - mock_protocol_handler_); + url_request_job_factory_->SetProtocolHandler( + "https", make_scoped_ptr(mock_protocol_handler_)); url_request_context_->set_job_factory(url_request_job_factory_.get()); request_ = url_request_context_->CreateRequest( diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc index 8b99d04..b9030ab7 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc @@ -416,7 +416,7 @@ StoragePartitionImpl* StoragePartitionImplMap::Get( browser_context_->GetResourceContext(), browser_context_->IsOffTheRecord(), partition->GetAppCacheService(), - blob_storage_context)); + blob_storage_context).release()); std::vector<std::string> additional_webui_schemes; GetContentClient()->browser()->GetAdditionalWebUISchemes( &additional_webui_schemes); @@ -430,7 +430,7 @@ StoragePartitionImpl* StoragePartitionImplMap::Get( browser_context_->GetResourceContext(), browser_context_->IsOffTheRecord(), partition->GetAppCacheService(), - blob_storage_context)); + blob_storage_context).release()); } protocol_handlers[kChromeDevToolsScheme] = linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( diff --git a/content/browser/streams/stream_url_request_job_unittest.cc b/content/browser/streams/stream_url_request_job_unittest.cc index 871b1af..354a075 100644 --- a/content/browser/streams/stream_url_request_job_unittest.cc +++ b/content/browser/streams/stream_url_request_job_unittest.cc @@ -57,7 +57,7 @@ class StreamURLRequestJobTest : public testing::Test { registry_.reset(new StreamRegistry()); url_request_job_factory_.SetProtocolHandler( - "blob", new MockProtocolHandler(registry_.get())); + "blob", make_scoped_ptr(new MockProtocolHandler(registry_.get()))); url_request_context_.set_job_factory(&url_request_job_factory_); } diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc index 3bfb0e7..f7538c8 100644 --- a/content/browser/webui/url_data_manager_backend.cc +++ b/content/browser/webui/url_data_manager_backend.cc @@ -540,15 +540,15 @@ URLDataManagerBackend::~URLDataManagerBackend() { } // static -net::URLRequestJobFactory::ProtocolHandler* +scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> URLDataManagerBackend::CreateProtocolHandler( content::ResourceContext* resource_context, bool is_incognito, AppCacheServiceImpl* appcache_service, ChromeBlobStorageContext* blob_storage_context) { DCHECK(resource_context); - return new ChromeProtocolHandler( - resource_context, is_incognito, appcache_service, blob_storage_context); + return make_scoped_ptr(new ChromeProtocolHandler( + resource_context, is_incognito, appcache_service, blob_storage_context)); } void URLDataManagerBackend::AddDataSource( diff --git a/content/browser/webui/url_data_manager_backend.h b/content/browser/webui/url_data_manager_backend.h index e0af605..6a326a0 100644 --- a/content/browser/webui/url_data_manager_backend.h +++ b/content/browser/webui/url_data_manager_backend.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" #include "base/supports_user_data.h" #include "content/browser/webui/url_data_manager.h" #include "content/public/browser/url_data_source.h" @@ -43,7 +44,7 @@ class URLDataManagerBackend : public base::SupportsUserData::Data { // Invoked to create the protocol handler for chrome://. |is_incognito| should // be set for incognito profiles. Called on the UI thread. - CONTENT_EXPORT static net::URLRequestJobFactory::ProtocolHandler* + CONTENT_EXPORT static scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> CreateProtocolHandler(content::ResourceContext* resource_context, bool is_incognito, AppCacheServiceImpl* appcache_service, diff --git a/content/browser/webui/url_data_manager_backend_unittest.cc b/content/browser/webui/url_data_manager_backend_unittest.cc index 1030533..9a511f1 100644 --- a/content/browser/webui/url_data_manager_backend_unittest.cc +++ b/content/browser/webui/url_data_manager_backend_unittest.cc @@ -43,9 +43,8 @@ class UrlDataManagerBackendTest : public testing::Test { UrlDataManagerBackendTest() { // URLRequestJobFactory takes ownership of the passed in ProtocolHandler. url_request_job_factory_.SetProtocolHandler( - "chrome", - URLDataManagerBackend::CreateProtocolHandler( - &resource_context_, false, nullptr, nullptr)); + "chrome", URLDataManagerBackend::CreateProtocolHandler( + &resource_context_, false, nullptr, nullptr)); url_request_context_.set_job_factory(&url_request_job_factory_); } diff --git a/content/public/browser/android/content_protocol_handler.h b/content/public/browser/android/content_protocol_handler.h index be9473e..74a564f 100644 --- a/content/public/browser/android/content_protocol_handler.h +++ b/content/public/browser/android/content_protocol_handler.h @@ -6,6 +6,7 @@ #define CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_PROTOCOL_HANDLER_H_ #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "net/url_request/url_request_job_factory.h" @@ -20,10 +21,9 @@ class CONTENT_EXPORT ContentProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { public: // Creates and returns a ContentProtocolHandler instance. - static ContentProtocolHandler* Create( + static scoped_ptr<ContentProtocolHandler> Create( const scoped_refptr<base::TaskRunner>& content_task_runner); - protected: ~ContentProtocolHandler() override {} }; diff --git a/content/public/test/mock_blob_url_request_context.cc b/content/public/test/mock_blob_url_request_context.cc index e2c6fa3..7ba9cbe 100644 --- a/content/public/test/mock_blob_url_request_context.cc +++ b/content/public/test/mock_blob_url_request_context.cc @@ -17,9 +17,9 @@ MockBlobURLRequestContext::MockBlobURLRequestContext( : blob_storage_context_(new storage::BlobStorageContext) { // Job factory owns the protocol handler. job_factory_.SetProtocolHandler( - "blob", new storage::BlobProtocolHandler( + "blob", make_scoped_ptr(new storage::BlobProtocolHandler( blob_storage_context_.get(), file_system_context, - base::ThreadTaskRunnerHandle::Get())); + base::ThreadTaskRunnerHandle::Get()))); set_job_factory(&job_factory_); } diff --git a/content/shell/browser/shell_url_request_context_getter.cc b/content/shell/browser/shell_url_request_context_getter.cc index cafda2d..6554e05 100644 --- a/content/shell/browser/shell_url_request_context_getter.cc +++ b/content/shell/browser/shell_url_request_context_getter.cc @@ -52,7 +52,7 @@ void InstallProtocolHandlers(net::URLRequestJobFactoryImpl* job_factory, it != protocol_handlers->end(); ++it) { bool set_protocol = job_factory->SetProtocolHandler( - it->first, it->second.release()); + it->first, make_scoped_ptr(it->second.release())); DCHECK(set_protocol); } protocol_handlers->clear(); @@ -209,14 +209,14 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { // ShellContentBrowserClient::IsHandledURL(). InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); bool set_protocol = job_factory->SetProtocolHandler( - url::kDataScheme, new net::DataProtocolHandler); + url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler)); DCHECK(set_protocol); #if !defined(DISABLE_FILE_SUPPORT) set_protocol = job_factory->SetProtocolHandler( url::kFileScheme, - new net::FileProtocolHandler( + make_scoped_ptr(new net::FileProtocolHandler( BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); DCHECK(set_protocol); #endif diff --git a/extensions/browser/extension_protocols.cc b/extensions/browser/extension_protocols.cc index 4e8f9d9..d00ba0b 100644 --- a/extensions/browser/extension_protocols.cc +++ b/extensions/browser/extension_protocols.cc @@ -557,10 +557,11 @@ net::HttpResponseHeaders* BuildHttpHeaders( return new net::HttpResponseHeaders(raw_headers); } -net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( - bool is_incognito, - extensions::InfoMap* extension_info_map) { - return new ExtensionProtocolHandler(is_incognito, extension_info_map); +scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> +CreateExtensionProtocolHandler(bool is_incognito, + extensions::InfoMap* extension_info_map) { + return make_scoped_ptr( + new ExtensionProtocolHandler(is_incognito, extension_info_map)); } } // namespace extensions diff --git a/extensions/browser/extension_protocols.h b/extensions/browser/extension_protocols.h index 51db6e2..190b50f 100644 --- a/extensions/browser/extension_protocols.h +++ b/extensions/browser/extension_protocols.h @@ -7,6 +7,7 @@ #include <string> +#include "base/memory/scoped_ptr.h" #include "net/url_request/url_request_job_factory.h" namespace base { @@ -31,9 +32,8 @@ net::HttpResponseHeaders* BuildHttpHeaders( // Creates the handlers for the chrome-extension:// scheme. Pass true for // |is_incognito| only for incognito profiles and not for Chrome OS guest mode // profiles. -net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( - bool is_incognito, - InfoMap* extension_info_map); +scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> +CreateExtensionProtocolHandler(bool is_incognito, InfoMap* extension_info_map); } // namespace extensions diff --git a/extensions/shell/browser/shell_content_browser_client.cc b/extensions/shell/browser/shell_content_browser_client.cc index c9314ad..06cf81b 100644 --- a/extensions/shell/browser/shell_content_browser_client.cc +++ b/extensions/shell/browser/shell_content_browser_client.cc @@ -123,7 +123,8 @@ net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( (*protocol_handlers)[kExtensionScheme] = linked_ptr<net::URLRequestJobFactory::ProtocolHandler>( CreateExtensionProtocolHandler(false /* is_incognito */, - extension_info_map)); + extension_info_map) + .release()); return browser_main_parts_->browser_context()->CreateRequestContext( protocol_handlers, request_interceptors.Pass(), extension_info_map); } diff --git a/ios/crnet/crnet_environment.mm b/ios/crnet/crnet_environment.mm index cdc4546..3eb873a 100644 --- a/ios/crnet/crnet_environment.mm +++ b/ios/crnet/crnet_environment.mm @@ -456,9 +456,11 @@ void CrNetEnvironment::InitializeOnNetworkThread() { net::URLRequestJobFactoryImpl* job_factory = new net::URLRequestJobFactoryImpl; - job_factory->SetProtocolHandler("data", new net::DataProtocolHandler); job_factory->SetProtocolHandler( - "file", new net::FileProtocolHandler(file_thread_->task_runner())); + "data", make_scoped_ptr(new net::DataProtocolHandler)); + job_factory->SetProtocolHandler( + "file", make_scoped_ptr( + new net::FileProtocolHandler(file_thread_->task_runner()))); main_context_->set_job_factory(job_factory); main_context_->set_net_log(net_log_.get()); diff --git a/ios/net/protocol_handler_util_unittest.mm b/ios/net/protocol_handler_util_unittest.mm index da39df6..1193dc7 100644 --- a/ios/net/protocol_handler_util_unittest.mm +++ b/ios/net/protocol_handler_util_unittest.mm @@ -110,8 +110,10 @@ class ProtocolHandlerUtilTest : public testing::Test, public: ProtocolHandlerUtilTest() : request_context_(new TestURLRequestContext) { // Ownership of the protocol handlers is transferred to the factory. - job_factory_.SetProtocolHandler("http", new NetProtocolHandler); - job_factory_.SetProtocolHandler("data", new DataProtocolHandler); + job_factory_.SetProtocolHandler("http", + make_scoped_ptr(new NetProtocolHandler)); + job_factory_.SetProtocolHandler("data", + make_scoped_ptr(new DataProtocolHandler)); request_context_->set_job_factory(&job_factory_); } diff --git a/ios/web/net/request_tracker_impl_unittest.mm b/ios/web/net/request_tracker_impl_unittest.mm index 893f9ab..64da31f 100644 --- a/ios/web/net/request_tracker_impl_unittest.mm +++ b/ios/web/net/request_tracker_impl_unittest.mm @@ -224,7 +224,7 @@ class RequestTrackerTest : public PlatformTest { net::TestJobInterceptor* AddInterceptorToRequest(size_t i) { // |interceptor| will be deleted from |job_factory_|'s destructor. net::TestJobInterceptor* protocol_handler = new net::TestJobInterceptor(); - job_factory_.SetProtocolHandler("http", protocol_handler); + job_factory_.SetProtocolHandler("http", make_scoped_ptr(protocol_handler)); contexts_[i]->set_job_factory(&job_factory_); return protocol_handler; } diff --git a/ios/web/shell/shell_url_request_context_getter.cc b/ios/web/shell/shell_url_request_context_getter.cc index 8cffb68..5d8c660 100644 --- a/ios/web/shell/shell_url_request_context_getter.cc +++ b/ios/web/shell/shell_url_request_context_getter.cc @@ -141,8 +141,8 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( new net::URLRequestJobFactoryImpl()); - bool set_protocol = - job_factory->SetProtocolHandler("data", new net::DataProtocolHandler); + bool set_protocol = job_factory->SetProtocolHandler( + "data", make_scoped_ptr(new net::DataProtocolHandler)); DCHECK(set_protocol); storage_->set_job_factory(job_factory.release()); diff --git a/ios/web/webui/url_data_manager_ios_backend.cc b/ios/web/webui/url_data_manager_ios_backend.cc index 8d1a464..cc3e3e9 100644 --- a/ios/web/webui/url_data_manager_ios_backend.cc +++ b/ios/web/webui/url_data_manager_ios_backend.cc @@ -415,12 +415,11 @@ URLDataManagerIOSBackend::~URLDataManagerIOSBackend() { } // static -net::URLRequestJobFactory::ProtocolHandler* -URLDataManagerIOSBackend::CreateProtocolHandler( - BrowserState* browser_state) { +scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> +URLDataManagerIOSBackend::CreateProtocolHandler(BrowserState* browser_state) { DCHECK(browser_state); - return new ChromeProtocolHandler(browser_state, - browser_state->IsOffTheRecord()); + return make_scoped_ptr(new ChromeProtocolHandler( + browser_state, browser_state->IsOffTheRecord())); } void URLDataManagerIOSBackend::AddDataSource(URLDataSourceIOSImpl* source) { diff --git a/ios/web/webui/url_data_manager_ios_backend.h b/ios/web/webui/url_data_manager_ios_backend.h index d505238..1ad5c84 100644 --- a/ios/web/webui/url_data_manager_ios_backend.h +++ b/ios/web/webui/url_data_manager_ios_backend.h @@ -39,8 +39,8 @@ class URLDataManagerIOSBackend : public base::SupportsUserData::Data { // Invoked to create the protocol handler for chrome://. |is_incognito| should // be set for incognito browser states. Called on the UI thread. - static net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler( - BrowserState* browser_state); + static scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> + CreateProtocolHandler(BrowserState* browser_state); // Adds a DataSource to the collection of data sources. void AddDataSource(URLDataSourceIOSImpl* source); diff --git a/mojo/services/network/url_loader_impl_apptest.cc b/mojo/services/network/url_loader_impl_apptest.cc index 777889a..2fb2210 100644 --- a/mojo/services/network/url_loader_impl_apptest.cc +++ b/mojo/services/network/url_loader_impl_apptest.cc @@ -93,7 +93,6 @@ class TestProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { return new TestURLRequestJob(request, network_delegate); } - private: ~TestProtocolHandler() override {} }; @@ -112,7 +111,7 @@ class UrlLoaderImplTest : public test::ApplicationTestBase { scoped_ptr<net::TestURLRequestContext> url_request_context( new net::TestURLRequestContext(true)); ASSERT_TRUE(url_request_job_factory_.SetProtocolHandler( - "http", new TestProtocolHandler())); + "http", make_scoped_ptr(new TestProtocolHandler()))); url_request_context->set_job_factory(&url_request_job_factory_); url_request_context->Init(); network_context_.reset(new NetworkContext(url_request_context.Pass())); diff --git a/net/proxy/proxy_script_fetcher_impl_unittest.cc b/net/proxy/proxy_script_fetcher_impl_unittest.cc index 651c950..0ffe0c0 100644 --- a/net/proxy/proxy_script_fetcher_impl_unittest.cc +++ b/net/proxy/proxy_script_fetcher_impl_unittest.cc @@ -81,8 +81,9 @@ class RequestContext : public URLRequestContext { network_session.get(), HttpCache::DefaultBackend::InMemory(0))); URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl(); #if !defined(DISABLE_FILE_SUPPORT) - job_factory->SetProtocolHandler( - "file", new FileProtocolHandler(base::ThreadTaskRunnerHandle::Get())); + job_factory->SetProtocolHandler("file", + make_scoped_ptr(new FileProtocolHandler( + base::ThreadTaskRunnerHandle::Get()))); #endif storage_.set_job_factory(job_factory); } diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc index e029a1e..5a79041 100644 --- a/net/url_request/url_request_context_builder.cc +++ b/net/url_request/url_request_context_builder.cc @@ -409,12 +409,14 @@ URLRequestContext* URLRequestContextBuilder::Build() { URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl; if (data_enabled_) - job_factory->SetProtocolHandler("data", new DataProtocolHandler); + job_factory->SetProtocolHandler("data", + make_scoped_ptr(new DataProtocolHandler)); #if !defined(DISABLE_FILE_SUPPORT) if (file_enabled_) { job_factory->SetProtocolHandler( - "file", new FileProtocolHandler(context->GetFileTaskRunner())); + "file", + make_scoped_ptr(new FileProtocolHandler(context->GetFileTaskRunner()))); } #endif // !defined(DISABLE_FILE_SUPPORT) @@ -422,8 +424,9 @@ URLRequestContext* URLRequestContextBuilder::Build() { if (ftp_enabled_) { ftp_transaction_factory_.reset( new FtpNetworkLayer(context->host_resolver())); - job_factory->SetProtocolHandler("ftp", - new FtpProtocolHandler(ftp_transaction_factory_.get())); + job_factory->SetProtocolHandler( + "ftp", make_scoped_ptr( + new FtpProtocolHandler(ftp_transaction_factory_.get()))); } #endif // !defined(DISABLE_FTP_SUPPORT) diff --git a/net/url_request/url_request_ftp_job_unittest.cc b/net/url_request/url_request_ftp_job_unittest.cc index 4a8178d..093b74a 100644 --- a/net/url_request/url_request_ftp_job_unittest.cc +++ b/net/url_request/url_request_ftp_job_unittest.cc @@ -57,7 +57,8 @@ class FtpTestURLRequestContext : public TestURLRequestContext { context_storage_.set_proxy_service(proxy_service); set_network_delegate(network_delegate); URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl; - job_factory->SetProtocolHandler("ftp", ftp_protocol_handler_); + job_factory->SetProtocolHandler("ftp", + make_scoped_ptr(ftp_protocol_handler_)); context_storage_.set_job_factory(job_factory); Init(); } diff --git a/net/url_request/url_request_job_factory_impl.cc b/net/url_request/url_request_job_factory_impl.cc index 264a7a1..b7024ad 100644 --- a/net/url_request/url_request_job_factory_impl.cc +++ b/net/url_request/url_request_job_factory_impl.cc @@ -26,7 +26,7 @@ URLRequestJobFactoryImpl::~URLRequestJobFactoryImpl() { bool URLRequestJobFactoryImpl::SetProtocolHandler( const std::string& scheme, - ProtocolHandler* protocol_handler) { + scoped_ptr<ProtocolHandler> protocol_handler) { DCHECK(CalledOnValidThread()); if (!protocol_handler) { @@ -41,7 +41,7 @@ bool URLRequestJobFactoryImpl::SetProtocolHandler( if (ContainsKey(protocol_handler_map_, scheme)) return false; - protocol_handler_map_[scheme] = protocol_handler; + protocol_handler_map_[scheme] = protocol_handler.release(); return true; } diff --git a/net/url_request/url_request_job_factory_impl.h b/net/url_request/url_request_job_factory_impl.h index 8d1d8d9..cba1124 100644 --- a/net/url_request/url_request_job_factory_impl.h +++ b/net/url_request/url_request_job_factory_impl.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" #include "net/base/net_export.h" #include "net/url_request/url_request_job_factory.h" @@ -23,10 +24,9 @@ class NET_EXPORT URLRequestJobFactoryImpl : public URLRequestJobFactory { ~URLRequestJobFactoryImpl() override; // Sets the ProtocolHandler for a scheme. Returns true on success, false on - // failure (a ProtocolHandler already exists for |scheme|). On success, - // URLRequestJobFactory takes ownership of |protocol_handler|. + // failure (a ProtocolHandler already exists for |scheme|). bool SetProtocolHandler(const std::string& scheme, - ProtocolHandler* protocol_handler); + scoped_ptr<ProtocolHandler> protocol_handler); // URLRequestJobFactory implementation URLRequestJob* MaybeCreateJobWithProtocolHandler( diff --git a/net/url_request/url_request_job_factory_impl_unittest.cc b/net/url_request/url_request_job_factory_impl_unittest.cc index e480755..adce41b 100644 --- a/net/url_request/url_request_job_factory_impl_unittest.cc +++ b/net/url_request/url_request_job_factory_impl_unittest.cc @@ -79,7 +79,8 @@ TEST(URLRequestJobFactoryTest, BasicProtocolHandler) { URLRequestJobFactoryImpl job_factory; TestURLRequestContext request_context; request_context.set_job_factory(&job_factory); - job_factory.SetProtocolHandler("foo", new DummyProtocolHandler); + job_factory.SetProtocolHandler("foo", + make_scoped_ptr(new DummyProtocolHandler)); scoped_ptr<URLRequest> request(request_context.CreateRequest( GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); request->Start(); @@ -93,8 +94,9 @@ TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) { URLRequestJobFactoryImpl job_factory; TestURLRequestContext request_context; request_context.set_job_factory(&job_factory); - job_factory.SetProtocolHandler("foo", new DummyProtocolHandler); - job_factory.SetProtocolHandler("foo", NULL); + job_factory.SetProtocolHandler("foo", + make_scoped_ptr(new DummyProtocolHandler)); + job_factory.SetProtocolHandler("foo", nullptr); } } // namespace diff --git a/net/url_request/url_request_simple_job_unittest.cc b/net/url_request/url_request_simple_job_unittest.cc index abccbe050..1286977 100644 --- a/net/url_request/url_request_simple_job_unittest.cc +++ b/net/url_request/url_request_simple_job_unittest.cc @@ -105,10 +105,10 @@ class SimpleJobProtocolHandler : kTestData); } + ~SimpleJobProtocolHandler() override {} + private: scoped_refptr<base::TaskRunner> task_runner_; - - ~SimpleJobProtocolHandler() override {} }; class URLRequestSimpleJobTest : public ::testing::Test { @@ -120,8 +120,8 @@ class URLRequestSimpleJobTest : public ::testing::Test { worker_pool_->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), context_(true) { - job_factory_.SetProtocolHandler("data", - new SimpleJobProtocolHandler(task_runner_)); + job_factory_.SetProtocolHandler( + "data", make_scoped_ptr(new SimpleJobProtocolHandler(task_runner_))); context_.set_job_factory(&job_factory_); context_.Init(); diff --git a/net/url_request/url_request_test_job.cc b/net/url_request/url_request_test_job.cc index 9ca0f5a..7530d42 100644 --- a/net/url_request/url_request_test_job.cc +++ b/net/url_request/url_request_test_job.cc @@ -110,9 +110,9 @@ std::string URLRequestTestJob::test_error_headers() { } // static -URLRequestJobFactory::ProtocolHandler* +scoped_ptr<URLRequestJobFactory::ProtocolHandler> URLRequestTestJob::CreateProtocolHandler() { - return new TestJobProtocolHandler(); + return make_scoped_ptr(new TestJobProtocolHandler()); } URLRequestTestJob::URLRequestTestJob(URLRequest* request, diff --git a/net/url_request/url_request_test_job.h b/net/url_request/url_request_test_job.h index cb8dcd9..db88fb8 100644 --- a/net/url_request/url_request_test_job.h +++ b/net/url_request/url_request_test_job.h @@ -105,7 +105,8 @@ class NET_EXPORT_PRIVATE URLRequestTestJob : public URLRequestJob { RequestPriority priority() const { return priority_; } // Create a protocol handler for callers that don't subclass. - static URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler(); + static scoped_ptr<URLRequestJobFactory::ProtocolHandler> + CreateProtocolHandler(); // Job functions void SetPriority(RequestPriority priority) override; diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index ee8ee7d..da340ea 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -666,10 +666,12 @@ class URLRequestTest : public PlatformTest { } virtual void SetUpFactory() { - job_factory_impl_->SetProtocolHandler("data", new DataProtocolHandler); + job_factory_impl_->SetProtocolHandler( + "data", make_scoped_ptr(new DataProtocolHandler)); #if !defined(DISABLE_FILE_SUPPORT) job_factory_impl_->SetProtocolHandler( - "file", new FileProtocolHandler(base::ThreadTaskRunnerHandle::Get())); + "file", make_scoped_ptr(new FileProtocolHandler( + base::ThreadTaskRunnerHandle::Get()))); #endif } @@ -685,8 +687,9 @@ class URLRequestTest : public PlatformTest { // Adds the TestJobInterceptor to the default context. TestJobInterceptor* AddTestInterceptor() { TestJobInterceptor* protocol_handler_ = new TestJobInterceptor(); - job_factory_impl_->SetProtocolHandler("http", NULL); - job_factory_impl_->SetProtocolHandler("http", protocol_handler_); + job_factory_impl_->SetProtocolHandler("http", nullptr); + job_factory_impl_->SetProtocolHandler("http", + make_scoped_ptr(protocol_handler_)); return protocol_handler_; } @@ -9090,7 +9093,8 @@ class URLRequestTestFTP : public URLRequestTest { void SetUpFactory() override { // Add FTP support to the default URLRequestContext. job_factory_impl_->SetProtocolHandler( - "ftp", new FtpProtocolHandler(&ftp_transaction_factory_)); + "ftp", + make_scoped_ptr(new FtpProtocolHandler(&ftp_transaction_factory_))); } std::string GetTestFileContents() { diff --git a/remoting/host/token_validator_factory_impl_unittest.cc b/remoting/host/token_validator_factory_impl_unittest.cc index ef5aaf5..38a7e82 100644 --- a/remoting/host/token_validator_factory_impl_unittest.cc +++ b/remoting/host/token_validator_factory_impl_unittest.cc @@ -58,7 +58,7 @@ class SetResponseURLRequestContext: public net::TestURLRequestContext { net::URLRequestJobFactoryImpl* factory = new net::URLRequestJobFactoryImpl(); factory->SetProtocolHandler( - "https", new FakeProtocolHandler(headers, response)); + "https", make_scoped_ptr(new FakeProtocolHandler(headers, response))); context_storage_.set_job_factory(factory); } }; |