diff options
Diffstat (limited to 'chrome/browser')
24 files changed, 150 insertions, 150 deletions
diff --git a/chrome/browser/automation/automation_resource_message_filter.cc b/chrome/browser/automation/automation_resource_message_filter.cc index fe18281..f8706a2 100644 --- a/chrome/browser/automation/automation_resource_message_filter.cc +++ b/chrome/browser/automation/automation_resource_message_filter.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -53,7 +53,7 @@ AutomationResourceMessageFilter::AutomationDetails::~AutomationDetails() {} struct AutomationResourceMessageFilter::CookieCompletionInfo { scoped_refptr<BrowserMessageFilter> filter; - scoped_refptr<net::URLRequestContext> context; + net::URLRequestContext* context; int render_process_id; IPC::Message* reply_msg; scoped_refptr<AutomationResourceMessageFilter> automation_message_filter; diff --git a/chrome/browser/browsing_data_server_bound_cert_helper_unittest.cc b/chrome/browser/browsing_data_server_bound_cert_helper_unittest.cc index 1307ba6..37f7c7a 100644 --- a/chrome/browser/browsing_data_server_bound_cert_helper_unittest.cc +++ b/chrome/browser/browsing_data_server_bound_cert_helper_unittest.cc @@ -28,7 +28,7 @@ class BrowsingDataServerBoundCertHelperTest : public testing::Test { } void CreateCertsForTest() { - scoped_refptr<net::URLRequestContext> context = + net::URLRequestContext* context = testing_profile_->GetRequestContext()->GetURLRequestContext(); net::ServerBoundCertStore* cert_store = context->server_bound_cert_service()->GetCertStore(); 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 127d561..f2e94be 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 @@ -127,7 +127,7 @@ class ExtensionWebRequestTest : public testing::Test { network_delegate_.reset(new ChromeNetworkDelegate( event_router_.get(), NULL, NULL, &profile_, CookieSettings::Factory::GetForProfile(&profile_), &enable_referrers_)); - context_ = new TestURLRequestContext(); + context_.reset(new TestURLRequestContext()); context_->set_network_delegate(network_delegate_.get()); } @@ -141,7 +141,7 @@ class ExtensionWebRequestTest : public testing::Test { scoped_refptr<ExtensionEventRouterForwarder> event_router_; scoped_refptr<ExtensionInfoMap> extension_info_map_; scoped_ptr<ChromeNetworkDelegate> network_delegate_; - scoped_refptr<TestURLRequestContext> context_; + scoped_ptr<TestURLRequestContext> context_; }; // Tests that we handle disagreements among extensions about responses to @@ -166,7 +166,7 @@ TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) { GURL not_chosen_redirect_url("about:not_chosen"); net::URLRequest request(GURL("about:blank"), &delegate_); - request.set_context(context_); + request.set_context(context_.get()); { // onBeforeRequest will be dispatched twice initially. The second response - // the redirect - should win, since it has a later |install_time|. The @@ -221,7 +221,7 @@ TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) { // Now test the same thing but the extensions answer in reverse order. net::URLRequest request2(GURL("about:blank"), &delegate_); - request2.set_context(context_); + request2.set_context(context_.get()); { ExtensionWebRequestEventRouter::EventResponse* response = NULL; @@ -295,7 +295,7 @@ TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceCancel) { GURL request_url("about:blank"); net::URLRequest request(request_url, &delegate_); - request.set_context(context_); + request.set_context(context_.get()); // onBeforeRequest will be dispatched twice. The second response - // the redirect - would win, since it has a later |install_time|, but @@ -363,7 +363,7 @@ TEST_F(ExtensionWebRequestTest, SimulateChancelWhileBlocked) { GURL request_url("about:blank"); net::URLRequest request(request_url, &delegate_); - request.set_context(context_); + request.set_context(context_.get()); ExtensionWebRequestEventRouter::EventResponse* response = NULL; @@ -444,7 +444,7 @@ class ExtensionWebRequestHeaderModificationTest : network_delegate_.reset(new ChromeNetworkDelegate( event_router_.get(), NULL, NULL, &profile_, CookieSettings::Factory::GetForProfile(&profile_), &enable_referrers_)); - context_ = new TestURLRequestContext(); + context_.reset(new TestURLRequestContext()); context_->set_network_delegate(network_delegate_.get()); } @@ -458,7 +458,7 @@ class ExtensionWebRequestHeaderModificationTest : scoped_refptr<ExtensionEventRouterForwarder> event_router_; scoped_refptr<ExtensionInfoMap> extension_info_map_; scoped_ptr<ChromeNetworkDelegate> network_delegate_; - scoped_refptr<TestURLRequestContext> context_; + scoped_ptr<TestURLRequestContext> context_; }; TEST_P(ExtensionWebRequestHeaderModificationTest, TestModifications) { @@ -489,7 +489,7 @@ TEST_P(ExtensionWebRequestHeaderModificationTest, TestModifications) { GURL request_url("http://doesnotexist/does_not_exist.html"); net::URLRequest request(request_url, &delegate_); - request.set_context(context_); + request.set_context(context_.get()); // Initialize headers available before extensions are notified of the // onBeforeSendHeaders event. diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index b354e32..c371594 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -197,13 +197,13 @@ class LoggingNetworkChangeObserver DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); }; -// Create a separate request context for PAC fetches to avoid reference cycles. +// TODO(willchan): Remove proxy script fetcher context since it's not necessary +// now that I got rid of refcounting URLRequestContexts. // See IOThread::Globals for details. -scoped_refptr<net::URLRequestContext> +net::URLRequestContext* ConstructProxyScriptFetcherContext(IOThread::Globals* globals, net::NetLog* net_log) { - scoped_refptr<net::URLRequestContext> context( - new URLRequestContextWithUserAgent); + net::URLRequestContext* context = new URLRequestContextWithUserAgent; context->set_net_log(net_log); context->set_host_resolver(globals->host_resolver.get()); context->set_cert_verifier(globals->cert_verifier.get()); @@ -226,11 +226,10 @@ ConstructProxyScriptFetcherContext(IOThread::Globals* globals, return context; } -scoped_refptr<net::URLRequestContext> +net::URLRequestContext* ConstructSystemRequestContext(IOThread::Globals* globals, net::NetLog* net_log) { - scoped_refptr<net::URLRequestContext> context( - new SystemURLRequestContext); + net::URLRequestContext* context = new SystemURLRequestContext; context->set_net_log(net_log); context->set_host_resolver(globals->host_resolver.get()); context->set_cert_verifier(globals->cert_verifier.get()); @@ -281,9 +280,9 @@ SystemURLRequestContextGetter::~SystemURLRequestContextGetter() {} net::URLRequestContext* SystemURLRequestContextGetter::GetURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DCHECK(io_thread_->globals()->system_request_context); + DCHECK(io_thread_->globals()->system_request_context.get()); - return io_thread_->globals()->system_request_context; + return io_thread_->globals()->system_request_context.get(); } scoped_refptr<base::MessageLoopProxy> @@ -456,8 +455,8 @@ void IOThread::Init() { } globals_->throttler_manager->set_net_log(net_log_); - globals_->proxy_script_fetcher_context = - ConstructProxyScriptFetcherContext(globals_, net_log_); + globals_->proxy_script_fetcher_context.reset( + ConstructProxyScriptFetcherContext(globals_, net_log_)); sdch_manager_ = new net::SdchManager(); @@ -602,7 +601,7 @@ void IOThread::InitSystemRequestContextOnIOThread() { globals_->system_proxy_service.reset( ProxyServiceFactory::CreateProxyService( net_log_, - globals_->proxy_script_fetcher_context, + globals_->proxy_script_fetcher_context.get(), system_proxy_config_service_.release(), command_line)); net::HttpNetworkSession::Params system_params; @@ -625,8 +624,8 @@ void IOThread::InitSystemRequestContextOnIOThread() { new net::HttpNetworkSession(system_params))); globals_->system_ftp_transaction_factory.reset( new net::FtpNetworkLayer(globals_->host_resolver.get())); - globals_->system_request_context = - ConstructSystemRequestContext(globals_, net_log_); + globals_->system_request_context.reset( + ConstructSystemRequestContext(globals_, net_log_)); sdch_manager_->set_sdch_fetcher( new SdchDictionaryFetcher(system_url_request_context_getter_.get())); diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h index c288ccf..1390c2c 100644 --- a/chrome/browser/io_thread.h +++ b/chrome/browser/io_thread.h @@ -89,17 +89,17 @@ class IOThread : public content::BrowserThreadDelegate { proxy_script_fetcher_ftp_transaction_factory; scoped_ptr<net::URLRequestThrottlerManager> throttler_manager; scoped_ptr<net::URLSecurityManager> url_security_manager; - // We use a separate URLRequestContext for PAC fetches, in order to break - // the reference cycle: - // URLRequestContext=>PAC fetch=>URLRequest=>URLRequestContext. + // TODO(willchan): Remove proxy script fetcher context since it's not + // necessary now that I got rid of refcounting URLRequestContexts. + // // The first URLRequestContext is |system_url_request_context|. We introduce // |proxy_script_fetcher_context| for the second context. It has a direct // ProxyService, since we always directly connect to fetch the PAC script. - scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context; + scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context; scoped_ptr<net::ProxyService> system_proxy_service; scoped_ptr<net::HttpTransactionFactory> system_http_transaction_factory; scoped_ptr<net::FtpTransactionFactory> system_ftp_transaction_factory; - scoped_refptr<net::URLRequestContext> system_request_context; + scoped_ptr<net::URLRequestContext> system_request_context; SystemRequestContextLeakChecker system_request_context_leak_checker; // |system_cookie_store| and |system_server_bound_cert_service| are shared // between |proxy_script_fetcher_context| and |system_request_context|. diff --git a/chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc b/chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc index bafed99..c9a8fee 100644 --- a/chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc +++ b/chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -151,22 +151,22 @@ class MockReporter : public ChromeFraudulentCertificateReporter { }; static void DoReportIsSent() { - scoped_refptr<ChromeURLRequestContext> context = new ChromeURLRequestContext; - SendingTestReporter reporter(context.get()); + ChromeURLRequestContext context; + SendingTestReporter reporter(&context); SSLInfo info = GetGoodSSLInfo(); reporter.SendReport("mail.google.com", info, true); } static void DoReportIsNotSent() { - scoped_refptr<ChromeURLRequestContext> context = new ChromeURLRequestContext; - NotSendingTestReporter reporter(context.get()); + ChromeURLRequestContext context; + NotSendingTestReporter reporter(&context); SSLInfo info = GetBadSSLInfo(); reporter.SendReport("www.example.com", info, true); } static void DoMockReportIsSent() { - scoped_refptr<ChromeURLRequestContext> context = new ChromeURLRequestContext; - MockReporter reporter(context.get()); + ChromeURLRequestContext context; + MockReporter reporter(&context); SSLInfo info = GetGoodSSLInfo(); reporter.SendReport("mail.google.com", info, true); } @@ -201,4 +201,3 @@ TEST(ChromeFraudulentCertificateReporterTest, ReportIsNotSent) { } } // namespace chrome_browser_net - diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 96bdde4..80c0c8a 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -30,7 +30,7 @@ class ChromeURLRequestContextFactory { virtual ~ChromeURLRequestContextFactory() {} // Called to create a new instance (will only be called once). - virtual scoped_refptr<ChromeURLRequestContext> Create() = 0; + virtual ChromeURLRequestContext* Create() = 0; protected: DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); @@ -48,7 +48,7 @@ class FactoryForMain : public ChromeURLRequestContextFactory { explicit FactoryForMain(const ProfileIOData* profile_io_data) : profile_io_data_(profile_io_data) {} - virtual scoped_refptr<ChromeURLRequestContext> Create() { + virtual ChromeURLRequestContext* Create() OVERRIDE { return profile_io_data_->GetMainRequestContext(); } @@ -62,7 +62,7 @@ class FactoryForExtensions : public ChromeURLRequestContextFactory { explicit FactoryForExtensions(const ProfileIOData* profile_io_data) : profile_io_data_(profile_io_data) {} - virtual scoped_refptr<ChromeURLRequestContext> Create() { + virtual ChromeURLRequestContext* Create() OVERRIDE { return profile_io_data_->GetExtensionsRequestContext(); } @@ -80,7 +80,7 @@ class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { app_id_(app_id), main_request_context_getter_(main_context) {} - virtual scoped_refptr<ChromeURLRequestContext> Create() { + virtual ChromeURLRequestContext* Create() OVERRIDE { // We will copy most of the state from the main request context. return profile_io_data_->GetIsolatedAppRequestContext( main_request_context_getter_->GetIOContext(), app_id_); @@ -100,7 +100,7 @@ class FactoryForMedia : public ChromeURLRequestContextFactory { : profile_io_data_(profile_io_data) { } - virtual scoped_refptr<ChromeURLRequestContext> Create() { + virtual ChromeURLRequestContext* Create() OVERRIDE { return profile_io_data_->GetMediaRequestContext(); } @@ -315,7 +315,12 @@ void ChromeURLRequestContextGetter::OnClearSiteDataOnExitChange( // ---------------------------------------------------------------------------- ChromeURLRequestContext::ChromeURLRequestContext() - : is_incognito_(false) { + : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), + is_incognito_(false) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); +} + +ChromeURLRequestContext::~ChromeURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); } @@ -338,10 +343,6 @@ void ChromeURLRequestContext::set_chrome_url_data_manager_backend( chrome_url_data_manager_backend_ = backend; } -ChromeURLRequestContext::~ChromeURLRequestContext() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); -} - const std::string& ChromeURLRequestContext::GetUserAgent( const GURL& url) const { return content::GetUserAgent(url); diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index be9f5e3..31a41d3 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -29,6 +29,11 @@ class ProfileIOData; class ChromeURLRequestContext : public net::URLRequestContext { public: ChromeURLRequestContext(); + virtual ~ChromeURLRequestContext(); + + base::WeakPtr<ChromeURLRequestContext> GetWeakPtr() { + return weak_factory_.GetWeakPtr(); + } // Copies the state from |other| into this context. void CopyFrom(ChromeURLRequestContext* other); @@ -56,10 +61,9 @@ class ChromeURLRequestContext : public net::URLRequestContext { // Callback for when the default charset changes. void OnDefaultCharsetChange(const std::string& default_charset); - protected: - virtual ~ChromeURLRequestContext(); - private: + base::WeakPtrFactory<ChromeURLRequestContext> weak_factory_; + // --------------------------------------------------------------------------- // Important: When adding any new members below, consider whether they need to // be added to CopyFrom. @@ -177,10 +181,10 @@ class ChromeURLRequestContextGetter : public net::URLRequestContextGetter, // Access only from the IO thread. scoped_ptr<ChromeURLRequestContextFactory> factory_; - // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext + // NULL if not yet initialized. Otherwise, it is the ChromeURLRequestContext // instance that was lazily created by GetURLRequestContext(). // Access only from the IO thread. - base::WeakPtr<net::URLRequestContext> url_request_context_; + base::WeakPtr<ChromeURLRequestContext> url_request_context_; DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); }; diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc index ae5c07f..eb250def 100644 --- a/chrome/browser/net/connection_tester.cc +++ b/chrome/browser/net/connection_tester.cc @@ -53,6 +53,8 @@ class ExperimentURLRequestContext : public net::URLRequestContext { ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} + virtual ~ExperimentURLRequestContext() {} + // Creates a proxy config service for |experiment|. On success returns net::OK // and fills |config_service| with a new pointer. Otherwise returns a network // error code. @@ -127,10 +129,6 @@ class ExperimentURLRequestContext : public net::URLRequestContext { return net::OK; } - protected: - virtual ~ExperimentURLRequestContext() { - } - private: // Creates a host resolver for |experiment|. On success returns net::OK and // fills |host_resolver| with a new pointer. Otherwise returns a network @@ -272,7 +270,7 @@ class ExperimentURLRequestContext : public net::URLRequestContext { #endif } - const scoped_refptr<net::URLRequestContext> proxy_request_context_; + net::URLRequestContext* const proxy_request_context_; net::URLRequestContextStorage storage_; base::WeakPtrFactory<ExperimentURLRequestContext> weak_factory_; }; @@ -296,7 +294,6 @@ class ConnectionTester::TestRunner : public net::URLRequest::Delegate { // after disk access has completed. void ProxyConfigServiceCreated( const Experiment& experiment, - scoped_refptr<ExperimentURLRequestContext> context, scoped_ptr<net::ProxyConfigService>* proxy_config_service, int status); // Starts running |experiment|. Notifies tester->OnExperimentCompleted() when @@ -321,6 +318,7 @@ class ConnectionTester::TestRunner : public net::URLRequest::Delegate { void OnExperimentCompletedWithResult(int result); ConnectionTester* tester_; + scoped_ptr<ExperimentURLRequestContext> request_context_; scoped_ptr<net::URLRequest> request_; base::WeakPtrFactory<TestRunner> weak_factory_; @@ -385,36 +383,35 @@ void ConnectionTester::TestRunner::OnExperimentCompletedWithResult(int result) { void ConnectionTester::TestRunner::ProxyConfigServiceCreated( const Experiment& experiment, - scoped_refptr<ExperimentURLRequestContext> context, scoped_ptr<net::ProxyConfigService>* proxy_config_service, int status) { if (status == net::OK) - status = context->Init(experiment, proxy_config_service); + status = request_context_->Init(experiment, proxy_config_service); if (status != net::OK) { tester_->OnExperimentCompleted(status); return; } // Fetch a request using the experimental context. request_.reset(new net::URLRequest(experiment.url, this)); - request_->set_context(context); + request_->set_context(request_context_.get()); request_->Start(); } void ConnectionTester::TestRunner::Run(const Experiment& experiment) { // Try to create a net::URLRequestContext for this experiment. - scoped_refptr<ExperimentURLRequestContext> context( + request_context_.reset( new ExperimentURLRequestContext(tester_->proxy_request_context_)); scoped_ptr<net::ProxyConfigService>* proxy_config_service = new scoped_ptr<net::ProxyConfigService>(); base::Callback<void(int)> config_service_callback = base::Bind( &TestRunner::ProxyConfigServiceCreated, weak_factory_.GetWeakPtr(), - experiment, context, base::Owned(proxy_config_service)); - int rv = context->CreateProxyConfigService( + experiment, base::Owned(proxy_config_service)); + int rv = request_context_->CreateProxyConfigService( experiment.proxy_settings_experiment, proxy_config_service, config_service_callback); if (rv != net::ERR_IO_PENDING) - ProxyConfigServiceCreated(experiment, context, proxy_config_service, rv); + ProxyConfigServiceCreated(experiment, proxy_config_service, rv); } // ConnectionTester ---------------------------------------------------------- diff --git a/chrome/browser/net/connection_tester.h b/chrome/browser/net/connection_tester.h index 903f0b5..74b8e5e 100644 --- a/chrome/browser/net/connection_tester.h +++ b/chrome/browser/net/connection_tester.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -174,7 +174,7 @@ class ConnectionTester { // of the list is the one currently in progress. ExperimentList remaining_experiments_; - const scoped_refptr<net::URLRequestContext> proxy_request_context_; + net::URLRequestContext* const proxy_request_context_; DISALLOW_COPY_AND_ASSIGN(ConnectionTester); }; diff --git a/chrome/browser/net/connection_tester_unittest.cc b/chrome/browser/net/connection_tester_unittest.cc index 3ecfa48..6dd99b3 100644 --- a/chrome/browser/net/connection_tester_unittest.cc +++ b/chrome/browser/net/connection_tester_unittest.cc @@ -113,8 +113,8 @@ class ConnectionTesterTest : public PlatformTest { scoped_refptr<net::SSLConfigService> ssl_config_service_; scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; - scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context_; net::HttpServerPropertiesImpl http_server_properties_impl_; + scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context_; private: void InitializeRequestContext() { @@ -148,7 +148,7 @@ class ConnectionTesterTest : public PlatformTest { TEST_F(ConnectionTesterTest, RunAllTests) { ASSERT_TRUE(test_server_.Start()); - ConnectionTester tester(&test_delegate_, proxy_script_fetcher_context_); + ConnectionTester tester(&test_delegate_, proxy_script_fetcher_context_.get()); // Start the test suite on URL "echoall". // TODO(eroman): Is this URL right? @@ -173,7 +173,8 @@ TEST_F(ConnectionTesterTest, DeleteWhileInProgress) { ASSERT_TRUE(test_server_.Start()); scoped_ptr<ConnectionTester> tester( - new ConnectionTester(&test_delegate_, proxy_script_fetcher_context_)); + new ConnectionTester(&test_delegate_, + proxy_script_fetcher_context_.get())); // Start the test suite on URL "echoall". // TODO(eroman): Is this URL right? diff --git a/chrome/browser/net/http_pipelining_compatibility_client.cc b/chrome/browser/net/http_pipelining_compatibility_client.cc index 5ba8200..ae81dca 100644 --- a/chrome/browser/net/http_pipelining_compatibility_client.cc +++ b/chrome/browser/net/http_pipelining_compatibility_client.cc @@ -297,7 +297,7 @@ void HttpPipeliningCompatibilityClient::Start( http_transaction_factory_.reset( net::HttpNetworkLayer::CreateFactory(session.get())); - url_request_context_ = new net::URLRequestContext; + url_request_context_.reset(new net::URLRequestContext); url_request_context_->CopyFrom(url_request_context); url_request_context_->set_http_transaction_factory( http_transaction_factory_.get()); diff --git a/chrome/browser/net/http_pipelining_compatibility_client.h b/chrome/browser/net/http_pipelining_compatibility_client.h index b50f9d3..811dc7b 100644 --- a/chrome/browser/net/http_pipelining_compatibility_client.h +++ b/chrome/browser/net/http_pipelining_compatibility_client.h @@ -141,8 +141,8 @@ class HttpPipeliningCompatibilityClient virtual void ReportNetworkError(int request_id, int error_code) OVERRIDE; virtual void ReportResponseCode(int request_id, int response_code) OVERRIDE; - scoped_refptr<net::URLRequestContext> url_request_context_; scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; + scoped_ptr<net::URLRequestContext> url_request_context_; scoped_ptr<internal::PipelineTestRequest::Factory> factory_; ScopedVector<internal::PipelineTestRequest> requests_; scoped_ptr<internal::PipelineTestRequest> canary_request_; diff --git a/chrome/browser/policy/device_management_service.cc b/chrome/browser/policy/device_management_service.cc index aab92e1..3e15e96 100644 --- a/chrome/browser/policy/device_management_service.cc +++ b/chrome/browser/policy/device_management_service.cc @@ -186,10 +186,9 @@ const std::string& GetPlatformString() { class DeviceManagementRequestContext : public net::URLRequestContext { public: explicit DeviceManagementRequestContext(net::URLRequestContext* base_context); - - private: virtual ~DeviceManagementRequestContext(); + private: // Overridden from net::URLRequestContext: virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; }; @@ -243,7 +242,7 @@ class DeviceManagementRequestContextGetter virtual ~DeviceManagementRequestContextGetter() {} private: - scoped_refptr<net::URLRequestContext> context_; + scoped_ptr<net::URLRequestContext> context_; scoped_refptr<net::URLRequestContextGetter> base_context_getter_; }; @@ -251,9 +250,9 @@ class DeviceManagementRequestContextGetter net::URLRequestContext* DeviceManagementRequestContextGetter::GetURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (!context_) { - context_ = new DeviceManagementRequestContext( - base_context_getter_->GetURLRequestContext()); + if (!context_.get()) { + context_.reset(new DeviceManagementRequestContext( + base_context_getter_->GetURLRequestContext())); } return context_.get(); diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc index e90b5ac..c33f78c 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -250,9 +250,9 @@ void OffTheRecordProfileIOData::LazyInitializeInternal( extensions_context->set_job_factory(job_factory()); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* OffTheRecordProfileIOData::InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { AppRequestContext* context = new AppRequestContext; @@ -276,18 +276,18 @@ OffTheRecordProfileIOData::InitializeAppRequestContext( return context; } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* OffTheRecordProfileIOData::AcquireMediaRequestContext() const { NOTREACHED(); return NULL; } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* OffTheRecordProfileIOData::AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { // We create per-app contexts on demand, unlike the others above. - scoped_refptr<ChromeURLRequestContext> app_request_context = + ChromeURLRequestContext* app_request_context = InitializeAppRequestContext(main_context, app_id); DCHECK(app_request_context); return app_request_context; diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.h b/chrome/browser/profiles/off_the_record_profile_io_data.h index a23b8fb..2e119a0 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.h +++ b/chrome/browser/profiles/off_the_record_profile_io_data.h @@ -98,14 +98,14 @@ class OffTheRecordProfileIOData : public ProfileIOData { virtual void LazyInitializeInternal( ProfileParams* profile_params) const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + virtual ChromeURLRequestContext* InitializeAppRequestContext( + ChromeURLRequestContext* main_context, const std::string& app_id) const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireMediaRequestContext() const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const OVERRIDE; mutable scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_; diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index 12355f7..0f4c473 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -252,7 +252,7 @@ ProfileImplIOData::ProfileImplIOData() ProfileImplIOData::~ProfileImplIOData() { DestroyResourceContext(); - if (media_request_context_) + if (media_request_context_.get()) media_request_context_->AssertNoURLRequests(); } @@ -263,7 +263,7 @@ void ProfileImplIOData::LazyInitializeInternal( ChromeURLRequestContext* main_context = main_request_context(); ChromeURLRequestContext* extensions_context = extensions_request_context(); - media_request_context_ = new ChromeURLRequestContext; + media_request_context_.reset(new ChromeURLRequestContext); IOThread* const io_thread = profile_params->io_thread; IOThread::Globals* const io_thread_globals = io_thread->globals(); @@ -275,7 +275,7 @@ void ProfileImplIOData::LazyInitializeInternal( // Initialize context members. ApplyProfileParamsToContext(main_context); - ApplyProfileParamsToContext(media_request_context_); + ApplyProfileParamsToContext(media_request_context_.get()); ApplyProfileParamsToContext(extensions_context); if (http_server_properties_manager()) @@ -449,9 +449,9 @@ void ProfileImplIOData::LazyInitializeInternal( lazy_params_.reset(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileImplIOData::InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { AppRequestContext* context = new AppRequestContext; @@ -511,18 +511,18 @@ ProfileImplIOData::InitializeAppRequestContext( return context; } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileImplIOData::AcquireMediaRequestContext() const { - DCHECK(media_request_context_); - return media_request_context_; + DCHECK(media_request_context_.get()); + return media_request_context_.get(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileImplIOData::AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { // We create per-app contexts on demand, unlike the others above. - scoped_refptr<ChromeURLRequestContext> app_request_context = + ChromeURLRequestContext* app_request_context = InitializeAppRequestContext(main_context, app_id); DCHECK(app_request_context); return app_request_context; diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h index 4bda4a6..153e278 100644 --- a/chrome/browser/profiles/profile_impl_io_data.h +++ b/chrome/browser/profiles/profile_impl_io_data.h @@ -125,14 +125,14 @@ class ProfileImplIOData : public ProfileIOData { virtual void LazyInitializeInternal( ProfileParams* profile_params) const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + virtual ChromeURLRequestContext* InitializeAppRequestContext( + ChromeURLRequestContext* main_context, const std::string& app_id) const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireMediaRequestContext() const OVERRIDE; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const OVERRIDE; // Clears the networking history since |time|. @@ -147,7 +147,7 @@ class ProfileImplIOData : public ProfileIOData { mutable scoped_ptr<chrome_browser_net::Predictor> predictor_; - mutable scoped_refptr<ChromeURLRequestContext> media_request_context_; + mutable scoped_ptr<ChromeURLRequestContext> media_request_context_; // Parameters needed for isolated apps. FilePath app_path_; diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index a9ca5bb..6ea6e86 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -272,13 +272,14 @@ ProfileIOData::~ProfileIOData() { if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (main_request_context_) + if (main_request_context_.get()) main_request_context_->AssertNoURLRequests(); - if (extensions_request_context_) + if (extensions_request_context_.get()) extensions_request_context_->AssertNoURLRequests(); for (AppRequestContextMap::iterator it = app_request_context_map_.begin(); it != app_request_context_map_.end(); ++it) { it->second->AssertNoURLRequests(); + delete it->second; } } @@ -328,33 +329,33 @@ ProfileIOData::GetChromeURLDataManagerBackend() const { return chrome_url_data_manager_backend_.get(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileIOData::GetMainRequestContext() const { LazyInitialize(); - return main_request_context_; + return main_request_context_.get(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileIOData::GetMediaRequestContext() const { LazyInitialize(); - scoped_refptr<ChromeURLRequestContext> context = + ChromeURLRequestContext* context = AcquireMediaRequestContext(); DCHECK(context); return context; } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileIOData::GetExtensionsRequestContext() const { LazyInitialize(); - return extensions_request_context_; + return extensions_request_context_.get(); } -scoped_refptr<ChromeURLRequestContext> +ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const { LazyInitialize(); - scoped_refptr<ChromeURLRequestContext> context; + ChromeURLRequestContext* context; if (ContainsKey(app_request_context_map_, app_id)) { context = app_request_context_map_[app_id]; } else { @@ -467,8 +468,8 @@ void ProfileIOData::LazyInitialize() const { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); // Create the common request contexts. - main_request_context_ = new ChromeURLRequestContext; - extensions_request_context_ = new ChromeURLRequestContext; + main_request_context_.reset(new ChromeURLRequestContext); + extensions_request_context_.reset(new ChromeURLRequestContext); chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend); @@ -482,7 +483,7 @@ void ProfileIOData::LazyInitialize() const { fraudulent_certificate_reporter_.reset( new chrome_browser_net::ChromeFraudulentCertificateReporter( - main_request_context_)); + main_request_context_.get())); proxy_service_.reset( ProxyServiceFactory::CreateProxyService( @@ -545,7 +546,7 @@ void ProfileIOData::LazyInitialize() const { extension_info_map_ = profile_params_->extension_info_map; resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); - resource_context_->request_context_ = main_request_context_; + resource_context_->request_context_ = main_request_context_.get(); LazyInitializeInternal(profile_params_.get()); diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index bc10f01..f4702bb 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -74,11 +74,11 @@ class ProfileIOData { // These should only be called at most once each. Ownership is reversed when // they get called, from ProfileIOData owning ChromeURLRequestContext to vice // versa. - scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; - scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; - scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; - scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* GetMainRequestContext() const; + ChromeURLRequestContext* GetMediaRequestContext() const; + ChromeURLRequestContext* GetExtensionsRequestContext() const; + ChromeURLRequestContext* GetIsolatedAppRequestContext( + ChromeURLRequestContext* main_context, const std::string& app_id) const; // These are useful when the Chrome layer is called from the content layer @@ -225,7 +225,7 @@ class ProfileIOData { chrome_browser_net::HttpServerPropertiesManager* manager) const; ChromeURLRequestContext* main_request_context() const { - return main_request_context_; + return main_request_context_.get(); } // Destroys the ResourceContext first, to cancel any URLRequests that are @@ -254,7 +254,7 @@ class ProfileIOData { net::URLRequestContext* request_context_; }; - typedef base::hash_map<std::string, scoped_refptr<ChromeURLRequestContext> > + typedef base::hash_map<std::string, ChromeURLRequestContext*> AppRequestContextMap; // -------------------------------------------- @@ -267,17 +267,17 @@ class ProfileIOData { // Does an on-demand initialization of a RequestContext for the given // isolated app. - virtual scoped_refptr<ChromeURLRequestContext> InitializeAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + virtual ChromeURLRequestContext* InitializeAppRequestContext( + ChromeURLRequestContext* main_context, const std::string& app_id) const = 0; // These functions are used to transfer ownership of the lazily initialized // context from ProfileIOData to the URLRequestContextGetter. - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireMediaRequestContext() const = 0; - virtual scoped_refptr<ChromeURLRequestContext> + virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - scoped_refptr<ChromeURLRequestContext> main_context, + ChromeURLRequestContext* main_context, const std::string& app_id) const = 0; // The order *DOES* matter for the majority of these member variables, so @@ -341,8 +341,8 @@ class ProfileIOData { // These are only valid in between LazyInitialize() and their accessor being // called. - mutable scoped_refptr<ChromeURLRequestContext> main_request_context_; - mutable scoped_refptr<ChromeURLRequestContext> extensions_request_context_; + mutable scoped_ptr<ChromeURLRequestContext> main_request_context_; + mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_; // One AppRequestContext per isolated app. mutable AppRequestContextMap app_request_context_map_; diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index 642bf38..6fea46f 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -145,9 +145,9 @@ SafeBrowsingURLRequestContextGetter::~SafeBrowsingURLRequestContextGetter() {} net::URLRequestContext* SafeBrowsingURLRequestContextGetter::GetURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DCHECK(sb_service_->url_request_context_); + DCHECK(sb_service_->url_request_context_.get()); - return sb_service_->url_request_context_; + return sb_service_->url_request_context_.get(); } scoped_refptr<base::MessageLoopProxy> @@ -614,7 +614,7 @@ void SafeBrowsingService::InitURLRequestContextOnIOThread( FilePath(BaseFilename().value() + kCookiesFile), false), NULL); - url_request_context_ = new SafeBrowsingURLRequestContext; + url_request_context_.reset(new SafeBrowsingURLRequestContext); // |system_url_request_context_getter| may be NULL during tests. if (system_url_request_context_getter) url_request_context_->CopyFrom( @@ -633,8 +633,7 @@ void SafeBrowsingService::DestroyURLRequestContextOnIOThread() { using base::debug::LeakTracker; LeakTracker<SafeBrowsingURLRequestContextGetter>::CheckForLeaks(); - DCHECK(url_request_context_.get()); - url_request_context_ = NULL; + url_request_context_.reset(); } void SafeBrowsingService::StartOnIOThread() { diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h index 511a758..85eb5ef 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.h +++ b/chrome/browser/safe_browsing/safe_browsing_service.h @@ -514,7 +514,7 @@ class SafeBrowsingService url_request_context_getter_; // The SafeBrowsingURLRequestContext. - scoped_refptr<net::URLRequestContext> url_request_context_; + scoped_ptr<net::URLRequestContext> url_request_context_; // Handles interaction with SafeBrowsing servers. SafeBrowsingProtocolManager* protocol_manager_; diff --git a/chrome/browser/sync/glue/http_bridge.cc b/chrome/browser/sync/glue/http_bridge.cc index dc01ebf..e7a217f 100644 --- a/chrome/browser/sync/glue/http_bridge.cc +++ b/chrome/browser/sync/glue/http_bridge.cc @@ -35,10 +35,10 @@ HttpBridge::RequestContextGetter::~RequestContextGetter() {} net::URLRequestContext* HttpBridge::RequestContextGetter::GetURLRequestContext() { // Lazily create the context. - if (!context_) { + if (!context_.get()) { net::URLRequestContext* baseline_context = baseline_context_getter_->GetURLRequestContext(); - context_ = new RequestContext(baseline_context); + context_.reset(new RequestContext(baseline_context)); baseline_context_getter_ = NULL; } @@ -46,7 +46,7 @@ HttpBridge::RequestContextGetter::GetURLRequestContext() { if (is_user_agent_set()) context_->set_user_agent(user_agent_); - return context_; + return context_.get(); } scoped_refptr<base::MessageLoopProxy> diff --git a/chrome/browser/sync/glue/http_bridge.h b/chrome/browser/sync/glue/http_bridge.h index 3e7e98e..a26410d 100644 --- a/chrome/browser/sync/glue/http_bridge.h +++ b/chrome/browser/sync/glue/http_bridge.h @@ -51,6 +51,9 @@ class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>, // currently active profile. explicit RequestContext(net::URLRequestContext* baseline_context); + // The destructor MUST be called on the IO thread. + virtual ~RequestContext(); + // Set the user agent for requests using this context. The default is // the browser's UA string. void set_user_agent(const std::string& ua) { user_agent_ = ua; } @@ -63,9 +66,6 @@ class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>, } private: - // The destructor MUST be called on the IO thread. - virtual ~RequestContext(); - std::string user_agent_; net::URLRequestContext* baseline_context_; @@ -96,7 +96,7 @@ class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>, scoped_refptr<net::URLRequestContextGetter> baseline_context_getter_; // Lazily initialized by GetURLRequestContext(). - scoped_refptr<RequestContext> context_; + scoped_ptr<RequestContext> context_; DISALLOW_COPY_AND_ASSIGN(RequestContextGetter); }; |