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 /content/browser | |
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}
Diffstat (limited to 'content/browser')
15 files changed, 68 insertions, 49 deletions
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_); } |