diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 10:47:09 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 10:47:09 +0000 |
commit | 4f5656c620d7ed91516571e01560ae417dd8cf2e (patch) | |
tree | a0409f2de6d5405b4e560a14da021bb3f86894fd /net | |
parent | 9ffd987bff794559488f6c3455fbb29c222dd7d1 (diff) | |
download | chromium_src-4f5656c620d7ed91516571e01560ae417dd8cf2e.zip chromium_src-4f5656c620d7ed91516571e01560ae417dd8cf2e.tar.gz chromium_src-4f5656c620d7ed91516571e01560ae417dd8cf2e.tar.bz2 |
net: Add namespace net to URLRequestHttpJob.
BUG=64263
TEST=compiled locally and trybots
Review URL: http://codereview.chromium.org/5682009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68986 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/url_request/url_request_http_job.cc | 260 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.h | 55 | ||||
-rw-r--r-- | net/url_request/url_request_job_manager.cc | 4 | ||||
-rw-r--r-- | net/url_request/url_request_throttler_entry.h | 4 | ||||
-rw-r--r-- | net/url_request/url_request_throttler_entry_interface.h | 4 |
5 files changed, 169 insertions, 158 deletions
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 3a4bcd7..bb560b0 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -38,30 +38,70 @@ static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; +namespace net { + +namespace { + +class HTTPSProberDelegateImpl : public HTTPSProberDelegate { + public: + HTTPSProberDelegateImpl(const std::string& host, int max_age, + bool include_subdomains, + TransportSecurityState* sts) + : host_(host), + max_age_(max_age), + include_subdomains_(include_subdomains), + sts_(sts) { } + + virtual void ProbeComplete(bool result) { + if (result) { + base::Time current_time(base::Time::Now()); + base::TimeDelta max_age_delta = base::TimeDelta::FromSeconds(max_age_); + + TransportSecurityState::DomainState domain_state; + domain_state.expiry = current_time + max_age_delta; + domain_state.mode = + TransportSecurityState::DomainState::MODE_OPPORTUNISTIC; + domain_state.include_subdomains = include_subdomains_; + + sts_->EnableHost(host_, domain_state); + } + + delete this; + } + + private: + const std::string host_; + const int max_age_; + const bool include_subdomains_; + scoped_refptr<TransportSecurityState> sts_; +}; + +} // namespace + // TODO(darin): make sure the port blocking code is not lost // static -net::URLRequestJob* URLRequestHttpJob::Factory(net::URLRequest* request, - const std::string& scheme) { +URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request, + const std::string& scheme) { DCHECK(scheme == "http" || scheme == "https"); int port = request->url().IntPort(); - if (!net::IsPortAllowedByDefault(port) && !net::IsPortAllowedByOverride(port)) - return new URLRequestErrorJob(request, net::ERR_UNSAFE_PORT); + if (!IsPortAllowedByDefault(port) && !IsPortAllowedByOverride(port)) + return new URLRequestErrorJob(request, ERR_UNSAFE_PORT); if (!request->context() || !request->context()->http_transaction_factory()) { NOTREACHED() << "requires a valid context"; - return new URLRequestErrorJob(request, net::ERR_INVALID_ARGUMENT); + return new URLRequestErrorJob(request, ERR_INVALID_ARGUMENT); } - net::TransportSecurityState::DomainState domain_state; + TransportSecurityState::DomainState domain_state; if (scheme == "http" && (request->url().port().empty() || port == 80) && request->context()->transport_security_state() && request->context()->transport_security_state()->IsEnabledForHost( &domain_state, request->url().host())) { if (domain_state.mode == - net::TransportSecurityState::DomainState::MODE_STRICT) { + TransportSecurityState::DomainState::MODE_STRICT) { DCHECK_EQ(request->url().scheme(), "http"); url_canon::Replacements<char> replacements; static const char kNewScheme[] = "https"; @@ -77,12 +117,12 @@ net::URLRequestJob* URLRequestHttpJob::Factory(net::URLRequest* request, return new URLRequestHttpJob(request); } -URLRequestHttpJob::URLRequestHttpJob(net::URLRequest* request) - : net::URLRequestJob(request), +URLRequestHttpJob::URLRequestHttpJob(URLRequest* request) + : URLRequestJob(request), response_info_(NULL), response_cookies_save_index_(0), - proxy_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), - server_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), + proxy_auth_state_(AUTH_STATE_DONT_NEED_AUTH), + server_auth_state_(AUTH_STATE_DONT_NEED_AUTH), ALLOW_THIS_IN_INITIALIZER_LIST(can_get_cookies_callback_( this, &URLRequestHttpJob::OnCanGetCookiesCompleted)), ALLOW_THIS_IN_INITIALIZER_LIST(can_set_cookie_callback_( @@ -93,7 +133,7 @@ URLRequestHttpJob::URLRequestHttpJob(net::URLRequest* request) this, &URLRequestHttpJob::OnReadCompleted)), read_in_progress_(false), transaction_(NULL), - throttling_entry_(net::URLRequestThrottlerManager::GetInstance()-> + throttling_entry_(URLRequestThrottlerManager::GetInstance()-> RegisterRequestUrl(request->url())), sdch_dictionary_advertised_(false), sdch_test_activated_(false), @@ -130,13 +170,13 @@ URLRequestHttpJob::~URLRequestHttpJob() { } } -void URLRequestHttpJob::SetUpload(net::UploadData* upload) { +void URLRequestHttpJob::SetUpload(UploadData* upload) { DCHECK(!transaction_.get()) << "cannot change once started"; request_info_.upload_data = upload; } void URLRequestHttpJob::SetExtraRequestHeaders( - const net::HttpRequestHeaders& headers) { + const HttpRequestHeaders& headers) { DCHECK(!transaction_.get()) << "cannot change once started"; request_info_.extra_headers.CopyFrom(headers); } @@ -155,7 +195,7 @@ void URLRequestHttpJob::Start() { if (request_->context()) { request_info_.extra_headers.SetHeader( - net::HttpRequestHeaders::kUserAgent, + HttpRequestHeaders::kUserAgent, request_->context()->GetUserAgent(request_->url())); } @@ -168,12 +208,12 @@ void URLRequestHttpJob::Kill() { return; DestroyTransaction(); - net::URLRequestJob::Kill(); + URLRequestJob::Kill(); } -net::LoadState URLRequestHttpJob::GetLoadState() const { +LoadState URLRequestHttpJob::GetLoadState() const { return transaction_.get() ? - transaction_->GetLoadState() : net::LOAD_STATE_IDLE; + transaction_->GetLoadState() : LOAD_STATE_IDLE; } uint64 URLRequestHttpJob::GetUploadProgress() const { @@ -198,7 +238,7 @@ bool URLRequestHttpJob::GetCharset(std::string* charset) { return response_info_->headers->GetCharset(charset); } -void URLRequestHttpJob::GetResponseInfo(net::HttpResponseInfo* info) { +void URLRequestHttpJob::GetResponseInfo(HttpResponseInfo* info) { DCHECK(request_); DCHECK(transaction_.get()); @@ -262,7 +302,7 @@ bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { // restrict redirects to externally handled protocols. Our consumer would // need to take care of those. - if (!net::URLRequest::IsHandledURL(location)) + if (!URLRequest::IsHandledURL(location)) return true; static const char* kSafeSchemes[] = { @@ -288,27 +328,27 @@ bool URLRequestHttpJob::NeedsAuth() { // because we either provided no auth info, or provided incorrect info. switch (code) { case 407: - if (proxy_auth_state_ == net::AUTH_STATE_CANCELED) + if (proxy_auth_state_ == AUTH_STATE_CANCELED) return false; - proxy_auth_state_ = net::AUTH_STATE_NEED_AUTH; + proxy_auth_state_ = AUTH_STATE_NEED_AUTH; return true; case 401: - if (server_auth_state_ == net::AUTH_STATE_CANCELED) + if (server_auth_state_ == AUTH_STATE_CANCELED) return false; - server_auth_state_ = net::AUTH_STATE_NEED_AUTH; + server_auth_state_ = AUTH_STATE_NEED_AUTH; return true; } return false; } void URLRequestHttpJob::GetAuthChallengeInfo( - scoped_refptr<net::AuthChallengeInfo>* result) { + scoped_refptr<AuthChallengeInfo>* result) { DCHECK(transaction_.get()); DCHECK(response_info_); // sanity checks: - DCHECK(proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH || - server_auth_state_ == net::AUTH_STATE_NEED_AUTH); + DCHECK(proxy_auth_state_ == AUTH_STATE_NEED_AUTH || + server_auth_state_ == AUTH_STATE_NEED_AUTH); DCHECK(response_info_->headers->response_code() == 401 || response_info_->headers->response_code() == 407); @@ -320,11 +360,11 @@ void URLRequestHttpJob::SetAuth(const string16& username, DCHECK(transaction_.get()); // Proxy gets set first, then WWW. - if (proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH) { - proxy_auth_state_ = net::AUTH_STATE_HAVE_AUTH; + if (proxy_auth_state_ == AUTH_STATE_NEED_AUTH) { + proxy_auth_state_ = AUTH_STATE_HAVE_AUTH; } else { - DCHECK(server_auth_state_ == net::AUTH_STATE_NEED_AUTH); - server_auth_state_ = net::AUTH_STATE_HAVE_AUTH; + DCHECK(server_auth_state_ == AUTH_STATE_NEED_AUTH); + server_auth_state_ = AUTH_STATE_HAVE_AUTH; } RestartTransactionWithAuth(username, password); @@ -344,18 +384,18 @@ void URLRequestHttpJob::RestartTransactionWithAuth( // headers in the 401/407. Since cookies were already appended to // extra_headers, we need to strip them out before adding them again. request_info_.extra_headers.RemoveHeader( - net::HttpRequestHeaders::kCookie); + HttpRequestHeaders::kCookie); AddCookieHeaderAndStart(); } void URLRequestHttpJob::CancelAuth() { // Proxy gets set first, then WWW. - if (proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH) { - proxy_auth_state_ = net::AUTH_STATE_CANCELED; + if (proxy_auth_state_ == AUTH_STATE_NEED_AUTH) { + proxy_auth_state_ = AUTH_STATE_CANCELED; } else { - DCHECK(server_auth_state_ == net::AUTH_STATE_NEED_AUTH); - server_auth_state_ = net::AUTH_STATE_CANCELED; + DCHECK(server_auth_state_ == AUTH_STATE_NEED_AUTH); + server_auth_state_ = AUTH_STATE_CANCELED; } // These will be reset in OnStartCompleted. @@ -373,11 +413,11 @@ void URLRequestHttpJob::CancelAuth() { MessageLoop::current()->PostTask( FROM_HERE, method_factory_.NewRunnableMethod( - &URLRequestHttpJob::OnStartCompleted, net::OK)); + &URLRequestHttpJob::OnStartCompleted, OK)); } void URLRequestHttpJob::ContinueWithCertificate( - net::X509Certificate* client_cert) { + X509Certificate* client_cert) { DCHECK(transaction_.get()); DCHECK(!response_info_) << "should not have a response yet"; @@ -387,11 +427,11 @@ void URLRequestHttpJob::ContinueWithCertificate( SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); int rv = transaction_->RestartWithCertificate(client_cert, &start_callback_); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) return; // The transaction started synchronously, but we need to notify the - // net::URLRequest delegate via the message loop. + // URLRequest delegate via the message loop. MessageLoop::current()->PostTask( FROM_HERE, method_factory_.NewRunnableMethod( @@ -410,18 +450,18 @@ void URLRequestHttpJob::ContinueDespiteLastError() { SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); int rv = transaction_->RestartIgnoringLastError(&start_callback_); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) return; // The transaction started synchronously, but we need to notify the - // net::URLRequest delegate via the message loop. + // URLRequest delegate via the message loop. MessageLoop::current()->PostTask( FROM_HERE, method_factory_.NewRunnableMethod( &URLRequestHttpJob::OnStartCompleted, rv)); } -bool URLRequestHttpJob::ReadRawData(net::IOBuffer* buf, int buf_size, +bool URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read) { DCHECK_NE(buf_size, 0); DCHECK(bytes_read); @@ -433,7 +473,7 @@ bool URLRequestHttpJob::ReadRawData(net::IOBuffer* buf, int buf_size, return true; } - if (rv == net::ERR_IO_PENDING) { + if (rv == ERR_IO_PENDING) { read_in_progress_ = true; SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); } else { @@ -452,18 +492,18 @@ void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) { // If the request was destroyed, then there is no more work to do. if (request_ && request_->delegate()) { if (request_->context()->cookie_store()) { - if (policy == net::ERR_ACCESS_DENIED) { + if (policy == ERR_ACCESS_DENIED) { request_->delegate()->OnGetCookies(request_, true); - } else if (policy == net::OK) { + } else if (policy == OK) { request_->delegate()->OnGetCookies(request_, false); - net::CookieOptions options; + CookieOptions options; options.set_include_httponly(); std::string cookies = request_->context()->cookie_store()->GetCookiesWithOptions( request_->url(), options); if (!cookies.empty()) { request_info_.extra_headers.SetHeader( - net::HttpRequestHeaders::kCookie, cookies); + HttpRequestHeaders::kCookie, cookies); } } } @@ -481,17 +521,17 @@ void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) { // If the request was destroyed, then there is no more work to do. if (request_ && request_->delegate()) { if (request_->context()->cookie_store()) { - if (policy == net::ERR_ACCESS_DENIED) { + if (policy == ERR_ACCESS_DENIED) { request_->delegate()->OnSetCookie( request_, response_cookies_[response_cookies_save_index_], - net::CookieOptions(), + CookieOptions(), true); - } else if (policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) { + } else if (policy == OK || policy == OK_FOR_SESSION_ONLY) { // OK to save the current response cookie now. - net::CookieOptions options; + CookieOptions options; options.set_include_httponly(); - if (policy == net::OK_FOR_SESSION_ONLY) + if (policy == OK_FOR_SESSION_ONLY) options.set_force_session(); request_->context()->cookie_store()->SetCookieWithOptions( request_->url(), response_cookies_[response_cookies_save_index_], @@ -527,7 +567,7 @@ void URLRequestHttpJob::OnStartCompleted(int result) { // Clear the IO_PENDING status SetStatus(URLRequestStatus()); - if (result == net::OK) { + if (result == OK) { SaveCookiesAndNotifyHeadersComplete(); } else if (ShouldTreatAsCertificateError(result)) { // We encountered an SSL certificate error. Ask our delegate to decide @@ -536,7 +576,7 @@ void URLRequestHttpJob::OnStartCompleted(int result) { // ssl_info. request_->delegate()->OnSSLCertificateError( request_, result, transaction_->GetResponseInfo()->ssl_info.cert); - } else if (result == net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { + } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { request_->delegate()->OnCertificateRequested( request_, transaction_->GetResponseInfo()->cert_request_info); } else { @@ -560,20 +600,20 @@ void URLRequestHttpJob::OnReadCompleted(int result) { } bool URLRequestHttpJob::ShouldTreatAsCertificateError(int result) { - if (!net::IsCertificateError(result)) + if (!IsCertificateError(result)) return false; // Check whether our context is using Strict-Transport-Security. if (!context_->transport_security_state()) return true; - net::TransportSecurityState::DomainState domain_state; + TransportSecurityState::DomainState domain_state; // TODO(agl): don't ignore opportunistic mode. const bool r = context_->transport_security_state()->IsEnabledForHost( &domain_state, request_info_.url.host()); return !r || domain_state.mode == - net::TransportSecurityState::DomainState::MODE_OPPORTUNISTIC; + TransportSecurityState::DomainState::MODE_OPPORTUNISTIC; } void URLRequestHttpJob::NotifyHeadersComplete() { @@ -586,7 +626,7 @@ void URLRequestHttpJob::NotifyHeadersComplete() { is_cached_content_ = response_info_->was_cached; if (!is_cached_content_) { - net::URLRequestThrottlerHeaderAdapter response_adapter( + URLRequestThrottlerHeaderAdapter response_adapter( response_info_->headers); throttling_entry_->UpdateWithResponse(&response_adapter); } @@ -622,7 +662,7 @@ void URLRequestHttpJob::NotifyHeadersComplete() { return; } - net::URLRequestJob::NotifyHeadersComplete(); + URLRequestJob::NotifyHeadersComplete(); } void URLRequestHttpJob::DestroyTransaction() { @@ -651,13 +691,13 @@ void URLRequestHttpJob::StartTransaction() { rv = request_->context()->http_transaction_factory()->CreateTransaction( &transaction_); - if (rv == net::OK) { + if (rv == OK) { if (!throttling_entry_->IsDuringExponentialBackoff()) { rv = transaction_->Start( &request_info_, &start_callback_, request_->net_log()); } else { // Special error code for the exponential back-off module. - rv = net::ERR_TEMPORARILY_THROTTLED; + rv = ERR_TEMPORARILY_THROTTLED; } // Make sure the context is alive for the duration of the // transaction. @@ -665,11 +705,11 @@ void URLRequestHttpJob::StartTransaction() { } } - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) return; // The transaction started synchronously, but we need to notify the - // net::URLRequest delegate via the message loop. + // URLRequest delegate via the message loop. MessageLoop::current()->PostTask( FROM_HERE, method_factory_.NewRunnableMethod( @@ -712,11 +752,11 @@ void URLRequestHttpJob::AddExtraHeaders() { if (!advertise_sdch) { // Tell the server what compression formats we support (other than SDCH). request_info_.extra_headers.SetHeader( - net::HttpRequestHeaders::kAcceptEncoding, "gzip,deflate"); + HttpRequestHeaders::kAcceptEncoding, "gzip,deflate"); } else { // Include SDCH in acceptable list. request_info_.extra_headers.SetHeader( - net::HttpRequestHeaders::kAcceptEncoding, "gzip,deflate,sdch"); + HttpRequestHeaders::kAcceptEncoding, "gzip,deflate,sdch"); if (!avail_dictionaries.empty()) { request_info_.extra_headers.SetHeader( kAvailDictionaryHeader, @@ -735,15 +775,15 @@ void URLRequestHttpJob::AddExtraHeaders() { // Only add default Accept-Language and Accept-Charset if the request // didn't have them specified. if (!request_info_.extra_headers.HasHeader( - net::HttpRequestHeaders::kAcceptLanguage)) { + HttpRequestHeaders::kAcceptLanguage)) { request_info_.extra_headers.SetHeader( - net::HttpRequestHeaders::kAcceptLanguage, + HttpRequestHeaders::kAcceptLanguage, context->accept_language()); } if (!request_info_.extra_headers.HasHeader( - net::HttpRequestHeaders::kAcceptCharset)) { + HttpRequestHeaders::kAcceptCharset)) { request_info_.extra_headers.SetHeader( - net::HttpRequestHeaders::kAcceptCharset, + HttpRequestHeaders::kAcceptCharset, context->accept_charset()); } } @@ -756,16 +796,16 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() { AddRef(); // Balanced in OnCanGetCookiesCompleted - int policy = net::OK; + int policy = OK; - if (request_info_.load_flags & net::LOAD_DO_NOT_SEND_COOKIES) { - policy = net::ERR_FAILED; + if (request_info_.load_flags & LOAD_DO_NOT_SEND_COOKIES) { + policy = ERR_FAILED; } else if (request_->context()->cookie_policy()) { policy = request_->context()->cookie_policy()->CanGetCookies( request_->url(), request_->first_party_for_cookies(), &can_get_cookies_callback_); - if (policy == net::ERR_IO_PENDING) + if (policy == ERR_IO_PENDING) return; // Wait for completion callback } @@ -775,7 +815,7 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() { void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete() { DCHECK(transaction_.get()); - const net::HttpResponseInfo* response_info = transaction_->GetResponseInfo(); + const HttpResponseInfo* response_info = transaction_->GetResponseInfo(); DCHECK(response_info); response_cookies_.clear(); @@ -802,17 +842,17 @@ void URLRequestHttpJob::SaveNextCookie() { AddRef(); // Balanced in OnCanSetCookieCompleted - int policy = net::OK; + int policy = OK; - if (request_info_.load_flags & net::LOAD_DO_NOT_SAVE_COOKIES) { - policy = net::ERR_FAILED; + if (request_info_.load_flags & LOAD_DO_NOT_SAVE_COOKIES) { + policy = ERR_FAILED; } else if (request_->context()->cookie_policy()) { policy = request_->context()->cookie_policy()->CanSetCookie( request_->url(), request_->first_party_for_cookies(), response_cookies_[response_cookies_save_index_], &can_set_cookie_callback_); - if (policy == net::ERR_IO_PENDING) + if (policy == ERR_IO_PENDING) return; // Wait for completion callback } @@ -820,7 +860,7 @@ void URLRequestHttpJob::SaveNextCookie() { } void URLRequestHttpJob::FetchResponseCookies( - const net::HttpResponseInfo* response_info, + const HttpResponseInfo* response_info, std::vector<std::string>* cookies) { std::string name = "Set-Cookie"; std::string value; @@ -832,40 +872,6 @@ void URLRequestHttpJob::FetchResponseCookies( } } -class HTTPSProberDelegate : public net::HTTPSProberDelegate { - public: - HTTPSProberDelegate(const std::string& host, int max_age, - bool include_subdomains, - net::TransportSecurityState* sts) - : host_(host), - max_age_(max_age), - include_subdomains_(include_subdomains), - sts_(sts) { } - - virtual void ProbeComplete(bool result) { - if (result) { - base::Time current_time(base::Time::Now()); - base::TimeDelta max_age_delta = base::TimeDelta::FromSeconds(max_age_); - - net::TransportSecurityState::DomainState domain_state; - domain_state.expiry = current_time + max_age_delta; - domain_state.mode = - net::TransportSecurityState::DomainState::MODE_OPPORTUNISTIC; - domain_state.include_subdomains = include_subdomains_; - - sts_->EnableHost(host_, domain_state); - } - - delete this; - } - - private: - const std::string host_; - const int max_age_; - const bool include_subdomains_; - scoped_refptr<net::TransportSecurityState> sts_; -}; - void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { DCHECK(response_info_); @@ -875,7 +881,7 @@ void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { const bool https = response_info_->ssl_info.is_valid(); const bool valid_https = - https && !net::IsCertStatusError(response_info_->ssl_info.cert_status); + https && !IsCertStatusError(response_info_->ssl_info.cert_status); std::string name = "Strict-Transport-Security"; std::string value; @@ -885,7 +891,7 @@ void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { void* iter = NULL; while (response_info_->headers->EnumerateHeader(&iter, name, &value)) { - const bool ok = net::TransportSecurityState::ParseHeader( + const bool ok = TransportSecurityState::ParseHeader( value, &max_age, &include_subdomains); if (!ok) continue; @@ -896,9 +902,9 @@ void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { base::Time current_time(base::Time::Now()); base::TimeDelta max_age_delta = base::TimeDelta::FromSeconds(max_age); - net::TransportSecurityState::DomainState domain_state; + TransportSecurityState::DomainState domain_state; domain_state.expiry = current_time + max_age_delta; - domain_state.mode = net::TransportSecurityState::DomainState::MODE_STRICT; + domain_state.mode = TransportSecurityState::DomainState::MODE_STRICT; domain_state.include_subdomains = include_subdomains; ctx->transport_security_state()->EnableHost(request_info_.url.host(), @@ -910,7 +916,7 @@ void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { name = "X-Bodge-Transport-Security"; while (response_info_->headers->EnumerateHeader(&iter, name, &value)) { - const bool ok = net::TransportSecurityState::ParseHeader( + const bool ok = TransportSecurityState::ParseHeader( value, &max_age, &include_subdomains); if (!ok) continue; @@ -920,10 +926,10 @@ void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { base::Time current_time(base::Time::Now()); base::TimeDelta max_age_delta = base::TimeDelta::FromSeconds(max_age); - net::TransportSecurityState::DomainState domain_state; + TransportSecurityState::DomainState domain_state; domain_state.expiry = current_time + max_age_delta; domain_state.mode = - net::TransportSecurityState::DomainState::MODE_SPDY_ONLY; + TransportSecurityState::DomainState::MODE_SPDY_ONLY; domain_state.include_subdomains = include_subdomains; ctx->transport_security_state()->EnableHost(request_info_.url.host(), @@ -937,19 +943,21 @@ void URLRequestHttpJob::ProcessStrictTransportSecurityHeader() { // At this point, we have a request for opportunistic encryption over HTTP. // In this case we need to probe to check that we can make HTTPS // connections to that host. - net::HTTPSProber* const prober = net::HTTPSProber::GetInstance(); + HTTPSProber* const prober = HTTPSProber::GetInstance(); if (prober->HaveProbed(request_info_.url.host()) || prober->InFlight(request_info_.url.host())) { continue; } - HTTPSProberDelegate* delegate = - new HTTPSProberDelegate(request_info_.url.host(), max_age, - include_subdomains, - ctx->transport_security_state()); + HTTPSProberDelegateImpl* delegate = + new HTTPSProberDelegateImpl(request_info_.url.host(), max_age, + include_subdomains, + ctx->transport_security_state()); if (!prober->ProbeHost(request_info_.url.host(), request()->context(), delegate)) { delete delegate; } } } + +} // namespace net diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h index 6f2beaf..bf1b37f 100644 --- a/net/url_request/url_request_http_job.h +++ b/net/url_request/url_request_http_job.h @@ -18,32 +18,33 @@ #include "net/url_request/url_request_job.h" #include "net/url_request/url_request_throttler_entry_interface.h" +class URLRequestContext; + namespace net { + class HttpResponseInfo; class HttpTransaction; -} -class URLRequestContext; // A net::URLRequestJob subclass that is built on top of HttpTransaction. It // provides an implementation for both HTTP and HTTPS. -class URLRequestHttpJob : public net::URLRequestJob { +class URLRequestHttpJob : public URLRequestJob { public: - static net::URLRequestJob* Factory(net::URLRequest* request, - const std::string& scheme); + static URLRequestJob* Factory(URLRequest* request, + const std::string& scheme); protected: - explicit URLRequestHttpJob(net::URLRequest* request); + explicit URLRequestHttpJob(URLRequest* request); - // net::URLRequestJob methods: - virtual void SetUpload(net::UploadData* upload); - virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers); + // Overridden from URLRequestJob: + virtual void SetUpload(UploadData* upload); + virtual void SetExtraRequestHeaders(const HttpRequestHeaders& headers); virtual void Start(); virtual void Kill(); - virtual net::LoadState GetLoadState() const; + virtual LoadState GetLoadState() const; virtual uint64 GetUploadProgress() const; virtual bool GetMimeType(std::string* mime_type) const; virtual bool GetCharset(std::string* charset); - virtual void GetResponseInfo(net::HttpResponseInfo* info); + virtual void GetResponseInfo(HttpResponseInfo* info); virtual bool GetResponseCookies(std::vector<std::string>* cookies); virtual int GetResponseCode() const; virtual bool GetContentEncodings( @@ -52,16 +53,16 @@ class URLRequestHttpJob : public net::URLRequestJob { virtual bool IsSdchResponse() const; virtual bool IsSafeRedirect(const GURL& location); virtual bool NeedsAuth(); - virtual void GetAuthChallengeInfo(scoped_refptr<net::AuthChallengeInfo>*); + virtual void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*); virtual void SetAuth(const string16& username, const string16& password); virtual void CancelAuth(); - virtual void ContinueWithCertificate(net::X509Certificate* client_cert); + virtual void ContinueWithCertificate(X509Certificate* client_cert); virtual void ContinueDespiteLastError(); - virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); + virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); virtual void StopCaching(); - // Shadows net::URLRequestJob's version of this method so we can grab cookies. + // Shadows URLRequestJob's version of this method so we can grab cookies. void NotifyHeadersComplete(); void DestroyTransaction(); @@ -70,7 +71,7 @@ class URLRequestHttpJob : public net::URLRequestJob { void AddCookieHeaderAndStart(); void SaveCookiesAndNotifyHeadersComplete(); void SaveNextCookie(); - void FetchResponseCookies(const net::HttpResponseInfo* response_info, + void FetchResponseCookies(const HttpResponseInfo* response_info, std::vector<std::string>* cookies); // Process the Strict-Transport-Security header, if one exists. @@ -90,33 +91,33 @@ class URLRequestHttpJob : public net::URLRequestJob { // before us. scoped_refptr<URLRequestContext> context_; - net::HttpRequestInfo request_info_; - const net::HttpResponseInfo* response_info_; + HttpRequestInfo request_info_; + const HttpResponseInfo* response_info_; std::vector<std::string> response_cookies_; size_t response_cookies_save_index_; // Auth states for proxy and origin server. - net::AuthState proxy_auth_state_; - net::AuthState server_auth_state_; + AuthState proxy_auth_state_; + AuthState server_auth_state_; string16 username_; string16 password_; - net::CompletionCallbackImpl<URLRequestHttpJob> can_get_cookies_callback_; - net::CompletionCallbackImpl<URLRequestHttpJob> can_set_cookie_callback_; - net::CompletionCallbackImpl<URLRequestHttpJob> start_callback_; - net::CompletionCallbackImpl<URLRequestHttpJob> read_callback_; + CompletionCallbackImpl<URLRequestHttpJob> can_get_cookies_callback_; + CompletionCallbackImpl<URLRequestHttpJob> can_set_cookie_callback_; + CompletionCallbackImpl<URLRequestHttpJob> start_callback_; + CompletionCallbackImpl<URLRequestHttpJob> read_callback_; bool read_in_progress_; // An URL for an SDCH dictionary as suggested in a Get-Dictionary HTTP header. GURL sdch_dictionary_url_; - scoped_ptr<net::HttpTransaction> transaction_; + scoped_ptr<HttpTransaction> transaction_; // This is used to supervise traffic and enforce exponential back-off. - scoped_refptr<net::URLRequestThrottlerEntryInterface> throttling_entry_; + scoped_refptr<URLRequestThrottlerEntryInterface> throttling_entry_; // Indicated if an SDCH dictionary was advertised, and hence an SDCH // compressed response is expected. We use this to help detect (accidental?) @@ -141,4 +142,6 @@ class URLRequestHttpJob : public net::URLRequestJob { DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); }; +} // namespace net + #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ diff --git a/net/url_request/url_request_job_manager.cc b/net/url_request/url_request_job_manager.cc index e3e66fb..2000832 100644 --- a/net/url_request/url_request_job_manager.cc +++ b/net/url_request/url_request_job_manager.cc @@ -29,8 +29,8 @@ struct SchemeToFactory { } // namespace static const SchemeToFactory kBuiltinFactories[] = { - { "http", URLRequestHttpJob::Factory }, - { "https", URLRequestHttpJob::Factory }, + { "http", net::URLRequestHttpJob::Factory }, + { "https", net::URLRequestHttpJob::Factory }, { "file", net::URLRequestFileJob::Factory }, { "ftp", net::URLRequestFtpJob::Factory }, { "about", net::URLRequestAboutJob::Factory }, diff --git a/net/url_request/url_request_throttler_entry.h b/net/url_request/url_request_throttler_entry.h index 9b8955d..ac33fa1 100644 --- a/net/url_request/url_request_throttler_entry.h +++ b/net/url_request/url_request_throttler_entry.h @@ -18,8 +18,8 @@ namespace net { // deduce the back-off time for every request. // The back-off algorithm consists of two parts. Firstly, exponential back-off // is used when receiving 5XX server errors or malformed response bodies. -// The exponential back-off rule is enforced by URLRequestHttpJob. Any request -// sent during the back-off period will be cancelled. +// The exponential back-off rule is enforced by URLRequestHttpJob. Any +// request sent during the back-off period will be cancelled. // Secondly, a sliding window is used to count recent requests to a given // destination and provide guidance (to the application level only) on whether // too many requests have been sent and when a good time to send the next one diff --git a/net/url_request/url_request_throttler_entry_interface.h b/net/url_request/url_request_throttler_entry_interface.h index f443b29..ed3c17f 100644 --- a/net/url_request/url_request_throttler_entry_interface.h +++ b/net/url_request/url_request_throttler_entry_interface.h @@ -21,8 +21,8 @@ class URLRequestThrottlerEntryInterface // Returns true when we have encountered server errors and are doing // exponential back-off. - // URLRequestHttpJob checks this method prior to every request; it cancels - // requests if this method returns true. + // net::URLRequestHttpJob checks this method prior to every request; it + // cancels requests if this method returns true. virtual bool IsDuringExponentialBackoff() const = 0; // Calculates a recommended sending time for the next request and reserves it. |