diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 11:01:53 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 11:01:53 +0000 |
commit | 280829fd02a85c407ecc3c64e6450cb76efa421e (patch) | |
tree | 941158cf5ac02ecea297b853d62a06a3b1037f64 | |
parent | f37595062cde15c3229cd68d8cfe9916b98d5fbb (diff) | |
download | chromium_src-280829fd02a85c407ecc3c64e6450cb76efa421e.zip chromium_src-280829fd02a85c407ecc3c64e6450cb76efa421e.tar.gz chromium_src-280829fd02a85c407ecc3c64e6450cb76efa421e.tar.bz2 |
Revert 92511 - Make the URLRequestContext constant
The URLRequestContext is basically a collection of pointers to other data structures. This CL makes sure that these pointers are not easily modified after the construction of the URLRequestContext.
BUG=67597
TEST=no
Review URL: http://codereview.chromium.org/7322010
TBR=battre@chromium.org
Review URL: http://codereview.chromium.org/7366005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92512 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/net/view_blob_internals_job_factory.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chrome_url_data_manager_backend.cc | 4 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host.cc | 2 | ||||
-rw-r--r-- | net/proxy/proxy_script_fetcher_impl.cc | 2 | ||||
-rw-r--r-- | net/url_request/https_prober.cc | 3 | ||||
-rw-r--r-- | net/url_request/https_prober.h | 2 | ||||
-rw-r--r-- | net/url_request/url_request.cc | 6 | ||||
-rw-r--r-- | net/url_request/url_request.h | 6 | ||||
-rw-r--r-- | net/url_request/url_request_context.cc | 1 | ||||
-rw-r--r-- | net/url_request/url_request_context.h | 7 | ||||
-rw-r--r-- | net/url_request/url_request_ftp_job.h | 2 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.cc | 4 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.h | 2 | ||||
-rw-r--r-- | net/url_request/url_request_unittest.cc | 5 | ||||
-rw-r--r-- | net/url_request/view_cache_helper.cc | 6 | ||||
-rw-r--r-- | net/url_request/view_cache_helper.h | 8 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation_write_unittest.cc | 13 |
17 files changed, 33 insertions, 42 deletions
diff --git a/chrome/browser/net/view_blob_internals_job_factory.cc b/chrome/browser/net/view_blob_internals_job_factory.cc index dd955e5..2b84f23 100644 --- a/chrome/browser/net/view_blob_internals_job_factory.cc +++ b/chrome/browser/net/view_blob_internals_job_factory.cc @@ -21,7 +21,7 @@ bool ViewBlobInternalsJobFactory::IsSupportedURL(const GURL& url) { net::URLRequestJob* ViewBlobInternalsJobFactory::CreateJobForRequest( net::URLRequest* request) { webkit_blob::BlobStorageController* blob_storage_controller = - static_cast<const ChromeURLRequestContext*>(request->context())-> + static_cast<ChromeURLRequestContext*>(request->context())-> blob_storage_context()->controller(); return new webkit_blob::ViewBlobInternalsJob( request, blob_storage_controller); diff --git a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc index a2344d0..8c11a4f 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc @@ -342,8 +342,8 @@ bool ChromeURLDataManagerBackend::StartRequest(const GURL& url, // going to get called once we return. job->SetMimeType(source->GetMimeType(path)); - const ChromeURLRequestContext* context = - static_cast<const ChromeURLRequestContext*>(job->request()->context()); + ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( + job->request()->context()); // Forward along the request to the data source. MessageLoop* target_message_loop = source->MessageLoopForRequestPath(path); diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index 4580bd8..0243717 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -1108,7 +1108,7 @@ bool ResourceDispatcherHost::CanGetCookies(net::URLRequest* request) { if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) return false; - const net::URLRequestContext* context = request->context(); + net::URLRequestContext* context = request->context(); net::CookieMonster* cookie_monster = context->cookie_store()->GetCookieMonster(); net::CookieList cookie_list = diff --git a/net/proxy/proxy_script_fetcher_impl.cc b/net/proxy/proxy_script_fetcher_impl.cc index 0c4bb6f..d0b9d6a 100644 --- a/net/proxy/proxy_script_fetcher_impl.cc +++ b/net/proxy/proxy_script_fetcher_impl.cc @@ -293,7 +293,7 @@ void ProxyScriptFetcherImpl::FetchCompleted() { // Hold a reference to the URLRequestContext to prevent re-entrancy from // ~URLRequestContext. - scoped_refptr<const URLRequestContext> context(cur_request_->context()); + scoped_refptr<URLRequestContext> context(cur_request_->context()); ResetCurRequestState(); callback->Run(result_code); diff --git a/net/url_request/https_prober.cc b/net/url_request/https_prober.cc index de0dc9b..bc7ba04 100644 --- a/net/url_request/https_prober.cc +++ b/net/url_request/https_prober.cc @@ -23,8 +23,7 @@ bool HTTPSProber::InFlight(const std::string& host) const { return inflight_probes_.find(host) != inflight_probes_.end(); } -bool HTTPSProber::ProbeHost(const std::string& host, - const URLRequestContext* ctx, +bool HTTPSProber::ProbeHost(const std::string& host, URLRequestContext* ctx, HTTPSProberDelegate* delegate) { if (HaveProbed(host) || InFlight(host)) { return false; diff --git a/net/url_request/https_prober.h b/net/url_request/https_prober.h index 467a6d8..d152e76 100644 --- a/net/url_request/https_prober.h +++ b/net/url_request/https_prober.h @@ -50,7 +50,7 @@ class HTTPSProber : public URLRequest::Delegate { // false will be returned, and no other action is taken. Otherwise, a new // probe is started, true is returned and the Delegate will be called with the // results (true means a successful handshake). - bool ProbeHost(const std::string& host, const URLRequestContext* ctx, + bool ProbeHost(const std::string& host, URLRequestContext* ctx, HTTPSProberDelegate* delegate); // Implementation of URLRequest::Delegate diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc index 5c30d67..192c419 100644 --- a/net/url_request/url_request.cc +++ b/net/url_request/url_request.cc @@ -681,12 +681,12 @@ int URLRequest::Redirect(const GURL& location, int http_status_code) { return OK; } -const URLRequestContext* URLRequest::context() const { +URLRequestContext* URLRequest::context() const { return context_.get(); } -void URLRequest::set_context(const URLRequestContext* context) { - scoped_refptr<const URLRequestContext> prev_context = context_; +void URLRequest::set_context(URLRequestContext* context) { + scoped_refptr<URLRequestContext> prev_context = context_; context_ = context; diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index de4ca27..cbd7bab 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -544,8 +544,8 @@ class NET_API URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe) { void ContinueDespiteLastError(); // Used to specify the context (cookie store, cache) for this request. - const URLRequestContext* context() const; - void set_context(const URLRequestContext* context); + URLRequestContext* context() const; + void set_context(URLRequestContext* context); const BoundNetLog& net_log() const { return net_log_; } @@ -634,7 +634,7 @@ class NET_API URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe) { // Contextual information used for this request (can be NULL). This contains // most of the dependencies which are shared between requests (disk cache, // cookie store, socket pool, etc.) - scoped_refptr<const URLRequestContext> context_; + scoped_refptr<URLRequestContext> context_; // Tracks the time spent in various load states throughout this request. BoundNetLog net_log_; diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc index 608196c..f34e196 100644 --- a/net/url_request/url_request_context.cc +++ b/net/url_request/url_request_context.cc @@ -22,7 +22,6 @@ URLRequestContext::URLRequestContext() proxy_service_(NULL), network_delegate_(NULL), transport_security_state_(NULL), - ftp_auth_cache_(new FtpAuthCache), http_transaction_factory_(NULL), ftp_transaction_factory_(NULL), job_factory_(NULL) { diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h index 4e3b9c1..998e3fb 100644 --- a/net/url_request/url_request_context.h +++ b/net/url_request/url_request_context.h @@ -12,7 +12,6 @@ #pragma once #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/threading/non_thread_safe.h" #include "net/base/net_api.h" #include "net/base/net_log.h" @@ -116,7 +115,7 @@ class NET_API URLRequestContext } // Gets the ftp transaction factory for this context. - FtpTransactionFactory* ftp_transaction_factory() const { + FtpTransactionFactory* ftp_transaction_factory() { return ftp_transaction_factory_; } void set_ftp_transaction_factory(FtpTransactionFactory* factory) { @@ -142,7 +141,7 @@ class NET_API URLRequestContext } // Gets the FTP authentication cache for this context. - FtpAuthCache* ftp_auth_cache() const { return ftp_auth_cache_.get(); } + FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } // Gets the value of 'Accept-Charset' header field. const std::string& accept_charset() const { return accept_charset_; } @@ -197,7 +196,7 @@ class NET_API URLRequestContext NetworkDelegate* network_delegate_; scoped_refptr<CookieStore> cookie_store_; scoped_refptr<TransportSecurityState> transport_security_state_; - scoped_ptr<FtpAuthCache> ftp_auth_cache_; + FtpAuthCache ftp_auth_cache_; std::string accept_language_; std::string accept_charset_; // The charset of the referrer where this request comes from. It's not diff --git a/net/url_request/url_request_ftp_job.h b/net/url_request/url_request_ftp_job.h index 5fc5a13..84c54e1 100644 --- a/net/url_request/url_request_ftp_job.h +++ b/net/url_request/url_request_ftp_job.h @@ -72,7 +72,7 @@ class URLRequestFtpJob : public URLRequestJob { // Keep a reference to the url request context to be sure it's not deleted // before us. - scoped_refptr<const URLRequestContext> context_; + scoped_refptr<URLRequestContext> context_; ScopedRunnableMethodFactory<URLRequestFtpJob> method_factory_; diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 9a31d72..c3f354c 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -477,7 +477,7 @@ void URLRequestHttpJob::AddExtraHeaders() { } } - const URLRequestContext* context = request_->context(); + URLRequestContext* context = request_->context(); if (context) { // Only add default Accept-Language and Accept-Charset if the request // didn't have them specified. @@ -597,7 +597,7 @@ void URLRequestHttpJob::FetchResponseCookies( void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { DCHECK(response_info_); - const URLRequestContext* ctx = request_->context(); + URLRequestContext* ctx = request_->context(); if (!ctx || !ctx->transport_security_state()) return; diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h index c5b045d..67632cb 100644 --- a/net/url_request/url_request_http_job.h +++ b/net/url_request/url_request_http_job.h @@ -89,7 +89,7 @@ class URLRequestHttpJob : public URLRequestJob { // Keep a reference to the url request context to be sure it's not deleted // before us. - scoped_refptr<const URLRequestContext> context_; + scoped_refptr<URLRequestContext> context_; HttpRequestInfo request_info_; const HttpResponseInfo* response_info_; diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 28ec3e1..281daaf 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -2527,11 +2527,10 @@ TEST_F(URLRequestTest, DoNotOverrideReferrer) { // content is empty. TEST_F(URLRequestTest, RequestCompletionForEmptyResponse) { TestNetworkDelegate network_delegate; - scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); - context->set_network_delegate(&network_delegate); TestDelegate d; TestURLRequest req(GURL("data:,"), &d); - req.set_context(context); + req.set_context(new TestURLRequestContext()); + req.context()->set_network_delegate(&network_delegate); req.Start(); MessageLoop::current()->Run(); EXPECT_EQ("", d.data_received()); diff --git a/net/url_request/view_cache_helper.cc b/net/url_request/view_cache_helper.cc index 768782e..d6761e1 100644 --- a/net/url_request/view_cache_helper.cc +++ b/net/url_request/view_cache_helper.cc @@ -63,13 +63,13 @@ ViewCacheHelper::~ViewCacheHelper() { } int ViewCacheHelper::GetEntryInfoHTML(const std::string& key, - const URLRequestContext* context, + URLRequestContext* context, std::string* out, CompletionCallback* callback) { return GetInfoHTML(key, context, std::string(), out, callback); } -int ViewCacheHelper::GetContentsHTML(const URLRequestContext* context, +int ViewCacheHelper::GetContentsHTML(URLRequestContext* context, const std::string& url_prefix, std::string* out, CompletionCallback* callback) { @@ -118,7 +118,7 @@ void ViewCacheHelper::HexDump(const char *buf, size_t buf_len, //----------------------------------------------------------------------------- int ViewCacheHelper::GetInfoHTML(const std::string& key, - const URLRequestContext* context, + URLRequestContext* context, const std::string& url_prefix, std::string* out, CompletionCallback* callback) { diff --git a/net/url_request/view_cache_helper.h b/net/url_request/view_cache_helper.h index 4f8c2b5..18979ea 100644 --- a/net/url_request/view_cache_helper.h +++ b/net/url_request/view_cache_helper.h @@ -31,7 +31,7 @@ class NET_API ViewCacheHelper { // operation completes. |out| must remain valid until this operation completes // or the object is destroyed. int GetEntryInfoHTML(const std::string& key, - const URLRequestContext* context, + URLRequestContext* context, std::string* out, CompletionCallback* callback); @@ -40,7 +40,7 @@ class NET_API ViewCacheHelper { // operation completes. |out| must remain valid until this operation completes // or the object is destroyed. |url_prefix| will be prepended to each entry // key as a link to the entry. - int GetContentsHTML(const URLRequestContext* context, + int GetContentsHTML(URLRequestContext* context, const std::string& url_prefix, std::string* out, CompletionCallback* callback); @@ -67,7 +67,7 @@ class NET_API ViewCacheHelper { // Implements GetEntryInfoHTML and GetContentsHTML. int GetInfoHTML(const std::string& key, - const URLRequestContext* context, + URLRequestContext* context, const std::string& url_prefix, std::string* out, CompletionCallback* callback); @@ -99,7 +99,7 @@ class NET_API ViewCacheHelper { // Called to signal completion of asynchronous IO. void OnIOComplete(int result); - scoped_refptr<const URLRequestContext> context_; + scoped_refptr<URLRequestContext> context_; disk_cache::Backend* disk_cache_; disk_cache::Entry* entry_; void* iter_; diff --git a/webkit/fileapi/file_system_operation_write_unittest.cc b/webkit/fileapi/file_system_operation_write_unittest.cc index 04b7c9d..6d33626 100644 --- a/webkit/fileapi/file_system_operation_write_unittest.cc +++ b/webkit/fileapi/file_system_operation_write_unittest.cc @@ -123,23 +123,18 @@ namespace { class TestURLRequestContext : public net::URLRequestContext { public: - TestURLRequestContext() - : blob_storage_controller_(new webkit_blob::BlobStorageController) {} - - virtual ~TestURLRequestContext() {} - - webkit_blob::BlobStorageController* blob_storage_controller() const { - return blob_storage_controller_.get(); + webkit_blob::BlobStorageController* blob_storage_controller() { + return &blob_storage_controller_; } private: - scoped_ptr<webkit_blob::BlobStorageController> blob_storage_controller_; + webkit_blob::BlobStorageController blob_storage_controller_; }; static net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request, const std::string& scheme) { webkit_blob::BlobStorageController* blob_storage_controller = - static_cast<const TestURLRequestContext*>(request->context())-> + static_cast<TestURLRequestContext*>(request->context())-> blob_storage_controller(); return new webkit_blob::BlobURLRequestJob( request, |