| Index: net/url_request/url_request_http_job.cc
|
| diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
|
| index c5c209ce7cb7a1ae9c99c8e66eb83518ffbd9306..de7f3c10148de201ab762b20d48c957f887f0ba4 100644
|
| --- a/net/url_request/url_request_http_job.cc
|
| +++ b/net/url_request/url_request_http_job.cc
|
| @@ -101,7 +101,7 @@ bool URLRequestHttpJob::HttpFilterContext::GetURL(GURL* gurl) const {
|
| bool URLRequestHttpJob::HttpFilterContext::GetContentDisposition(
|
| std::string* disposition) const {
|
| HttpResponseHeaders* headers = job_->GetResponseHeaders();
|
| - void *iter = NULL;
|
| + void* iter = NULL;
|
| return headers->EnumerateHeader(&iter, "Content-Disposition", disposition);
|
| }
|
|
|
| @@ -156,9 +156,12 @@ URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request,
|
| GURL redirect_url;
|
| if (request->GetHSTSRedirect(&redirect_url)) {
|
| return new URLRequestRedirectJob(
|
| - request, network_delegate, redirect_url,
|
| + request,
|
| + network_delegate,
|
| + redirect_url,
|
| // Use status code 307 to preserve the method, so POST requests work.
|
| - URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT, "HSTS");
|
| + URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT,
|
| + "HSTS");
|
| }
|
| return new URLRequestHttpJob(request,
|
| network_delegate,
|
| @@ -261,8 +264,8 @@ void URLRequestHttpJob::Start() {
|
| CanEnablePrivacyMode();
|
| // Privacy mode could still be disabled in OnCookiesLoaded if we are going
|
| // to send previously saved cookies.
|
| - request_info_.privacy_mode = enable_privacy_mode ?
|
| - PRIVACY_MODE_ENABLED : PRIVACY_MODE_DISABLED;
|
| + request_info_.privacy_mode =
|
| + enable_privacy_mode ? PRIVACY_MODE_ENABLED : PRIVACY_MODE_DISABLED;
|
|
|
| // Strip Referer from request_info_.extra_headers to prevent, e.g., plugins
|
| // from overriding headers that are controlled using other means. Otherwise a
|
| @@ -278,8 +281,8 @@ void URLRequestHttpJob::Start() {
|
|
|
| request_info_.extra_headers.SetHeaderIfMissing(
|
| HttpRequestHeaders::kUserAgent,
|
| - http_user_agent_settings_ ?
|
| - http_user_agent_settings_->GetUserAgent() : std::string());
|
| + http_user_agent_settings_ ? http_user_agent_settings_->GetUserAgent()
|
| + : std::string());
|
|
|
| AddExtraHeaders();
|
| AddCookieHeaderAndStart();
|
| @@ -367,7 +370,8 @@ void URLRequestHttpJob::StartTransaction() {
|
| if (network_delegate()) {
|
| OnCallToDelegate();
|
| int rv = network_delegate()->NotifyBeforeSendHeaders(
|
| - request_, notify_before_headers_sent_callback_,
|
| + request_,
|
| + notify_before_headers_sent_callback_,
|
| &request_info_.extra_headers);
|
| // If an extension blocks the request, we rely on the callback to
|
| // MaybeStartTransactionInternal().
|
| @@ -408,8 +412,8 @@ void URLRequestHttpJob::StartTransactionInternal() {
|
| int rv;
|
|
|
| if (network_delegate()) {
|
| - network_delegate()->NotifySendHeaders(
|
| - request_, request_info_.extra_headers);
|
| + network_delegate()->NotifySendHeaders(request_,
|
| + request_info_.extra_headers);
|
| }
|
|
|
| if (transaction_.get()) {
|
| @@ -459,7 +463,8 @@ void URLRequestHttpJob::StartTransactionInternal() {
|
| base::MessageLoop::current()->PostTask(
|
| FROM_HERE,
|
| base::Bind(&URLRequestHttpJob::OnStartCompleted,
|
| - weak_factory_.GetWeakPtr(), rv));
|
| + weak_factory_.GetWeakPtr(),
|
| + rv));
|
| }
|
|
|
| void URLRequestHttpJob::AddExtraHeaders() {
|
| @@ -471,8 +476,9 @@ void URLRequestHttpJob::AddExtraHeaders() {
|
| // possible. Right now it is done only by buffered_resource_loader and
|
| // simple_data_source.
|
| if (!request_info_.extra_headers.HasHeader(
|
| - HttpRequestHeaders::kAcceptEncoding)) {
|
| - bool advertise_sdch = SdchManager::Global() &&
|
| + HttpRequestHeaders::kAcceptEncoding)) {
|
| + bool advertise_sdch =
|
| + SdchManager::Global() &&
|
| SdchManager::Global()->IsInSupportedDomain(request_->url());
|
| std::string avail_dictionaries;
|
| if (advertise_sdch) {
|
| @@ -505,16 +511,15 @@ void URLRequestHttpJob::AddExtraHeaders() {
|
| // headers.
|
| if (!advertise_sdch) {
|
| // Tell the server what compression formats we support (other than SDCH).
|
| - request_info_.extra_headers.SetHeader(
|
| - HttpRequestHeaders::kAcceptEncoding, "gzip,deflate");
|
| + request_info_.extra_headers.SetHeader(HttpRequestHeaders::kAcceptEncoding,
|
| + "gzip,deflate");
|
| } else {
|
| // Include SDCH in acceptable list.
|
| - request_info_.extra_headers.SetHeader(
|
| - HttpRequestHeaders::kAcceptEncoding, "gzip,deflate,sdch");
|
| + request_info_.extra_headers.SetHeader(HttpRequestHeaders::kAcceptEncoding,
|
| + "gzip,deflate,sdch");
|
| if (!avail_dictionaries.empty()) {
|
| - request_info_.extra_headers.SetHeader(
|
| - kAvailDictionaryHeader,
|
| - avail_dictionaries);
|
| + request_info_.extra_headers.SetHeader(kAvailDictionaryHeader,
|
| + avail_dictionaries);
|
| sdch_dictionary_advertised_ = true;
|
| // Since we're tagging this transaction as advertising a dictionary,
|
| // we'll definitely employ an SDCH filter (or tentative sdch filter)
|
| @@ -533,8 +538,7 @@ void URLRequestHttpJob::AddExtraHeaders() {
|
| http_user_agent_settings_->GetAcceptLanguage();
|
| if (!accept_language.empty()) {
|
| request_info_.extra_headers.SetHeaderIfMissing(
|
| - HttpRequestHeaders::kAcceptLanguage,
|
| - accept_language);
|
| + HttpRequestHeaders::kAcceptLanguage, accept_language);
|
| }
|
| }
|
| }
|
| @@ -563,7 +567,8 @@ void URLRequestHttpJob::DoLoadCookies() {
|
| CookieOptions options;
|
| options.set_include_httponly();
|
| GetCookieStore()->GetCookiesWithOptionsAsync(
|
| - request_->url(), options,
|
| + request_->url(),
|
| + options,
|
| base::Bind(&URLRequestHttpJob::OnCookiesLoaded,
|
| weak_factory_.GetWeakPtr()));
|
| }
|
| @@ -578,8 +583,8 @@ void URLRequestHttpJob::CheckCookiePolicyAndLoad(
|
|
|
| void URLRequestHttpJob::OnCookiesLoaded(const std::string& cookie_line) {
|
| if (!cookie_line.empty()) {
|
| - request_info_.extra_headers.SetHeader(
|
| - HttpRequestHeaders::kCookie, cookie_line);
|
| + request_info_.extra_headers.SetHeader(HttpRequestHeaders::kCookie,
|
| + cookie_line);
|
| // Disable privacy mode as we are sending cookies anyway.
|
| request_info_.privacy_mode = PRIVACY_MODE_DISABLED;
|
| }
|
| @@ -657,12 +662,14 @@ void URLRequestHttpJob::SaveNextCookie() {
|
| // synchronously.
|
| while (!callback_pending->data &&
|
| response_cookies_save_index_ < response_cookies_.size()) {
|
| - if (CanSetCookie(
|
| - response_cookies_[response_cookies_save_index_], &options)) {
|
| + if (CanSetCookie(response_cookies_[response_cookies_save_index_],
|
| + &options)) {
|
| callback_pending->data = true;
|
| GetCookieStore()->SetCookieWithOptionsAsync(
|
| - request_->url(), response_cookies_[response_cookies_save_index_],
|
| - options, callback);
|
| + request_->url(),
|
| + response_cookies_[response_cookies_save_index_],
|
| + options,
|
| + callback);
|
| }
|
| ++response_cookies_save_index_;
|
| }
|
| @@ -789,11 +796,11 @@ void URLRequestHttpJob::OnStartCompleted(int result) {
|
| if (result == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN &&
|
| transaction_->GetResponseInfo() != NULL) {
|
| FraudulentCertificateReporter* reporter =
|
| - context->fraudulent_certificate_reporter();
|
| + context->fraudulent_certificate_reporter();
|
| if (reporter != NULL) {
|
| const SSLInfo& ssl_info = transaction_->GetResponseInfo()->ssl_info;
|
| - bool sni_available = SSLConfigService::IsSNIAvailable(
|
| - context->ssl_config_service());
|
| + bool sni_available =
|
| + SSLConfigService::IsSNIAvailable(context->ssl_config_service());
|
| const std::string& host = request_->url().host();
|
|
|
| reporter->SendReport(host, ssl_info, sni_available);
|
| @@ -819,9 +826,9 @@ void URLRequestHttpJob::OnStartCompleted(int result) {
|
| awaiting_callback_ = true;
|
| } else {
|
| std::string source("delegate");
|
| - request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
|
| - NetLog::StringCallback("source",
|
| - &source));
|
| + request_->net_log().AddEvent(
|
| + NetLog::TYPE_CANCELLED,
|
| + NetLog::StringCallback("source", &source));
|
| OnCallToDelegateComplete();
|
| NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error));
|
| }
|
| @@ -843,14 +850,15 @@ void URLRequestHttpJob::OnStartCompleted(int result) {
|
| // Maybe overridable, maybe not. Ask the delegate to decide.
|
| TransportSecurityState::DomainState domain_state;
|
| const URLRequestContext* context = request_->context();
|
| - const bool fatal = context->transport_security_state() &&
|
| + const bool fatal =
|
| + context->transport_security_state() &&
|
| context->transport_security_state()->GetDomainState(
|
| request_info_.url.host(),
|
| SSLConfigService::IsSNIAvailable(context->ssl_config_service()),
|
| &domain_state) &&
|
| domain_state.ShouldSSLErrorsBeFatal();
|
| - NotifySSLCertificateError(
|
| - transaction_->GetResponseInfo()->ssl_info, fatal);
|
| + NotifySSLCertificateError(transaction_->GetResponseInfo()->ssl_info,
|
| + fatal);
|
| }
|
| } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
|
| NotifyCertificateRequested(
|
| @@ -922,13 +930,12 @@ void URLRequestHttpJob::SetExtraRequestHeaders(
|
| }
|
|
|
| LoadState URLRequestHttpJob::GetLoadState() const {
|
| - return transaction_.get() ?
|
| - transaction_->GetLoadState() : LOAD_STATE_IDLE;
|
| + return transaction_.get() ? transaction_->GetLoadState() : LOAD_STATE_IDLE;
|
| }
|
|
|
| UploadProgress URLRequestHttpJob::GetUploadProgress() const {
|
| - return transaction_.get() ?
|
| - transaction_->GetUploadProgress() : UploadProgress();
|
| + return transaction_.get() ? transaction_->GetUploadProgress()
|
| + : UploadProgress();
|
| }
|
|
|
| bool URLRequestHttpJob::GetMimeType(std::string* mime_type) const {
|
| @@ -1015,8 +1022,8 @@ Filter* URLRequestHttpJob::SetupFilter() const {
|
| // encoded).
|
| std::string sdch_response_status;
|
| iter = NULL;
|
| - while (headers->EnumerateHeader(&iter, "X-Sdch-Encode",
|
| - &sdch_response_status)) {
|
| + while (headers->EnumerateHeader(
|
| + &iter, "X-Sdch-Encode", &sdch_response_status)) {
|
| if (sdch_response_status == "0") {
|
| filter_context_->ResetSdchResponseToFalse();
|
| break;
|
| @@ -1031,7 +1038,8 @@ Filter* URLRequestHttpJob::SetupFilter() const {
|
| Filter::FixupEncodingTypes(*filter_context_, &encoding_types);
|
|
|
| return !encoding_types.empty()
|
| - ? Filter::Factory(encoding_types, *filter_context_) : NULL;
|
| + ? Filter::Factory(encoding_types, *filter_context_)
|
| + : NULL;
|
| }
|
|
|
| bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const {
|
| @@ -1041,7 +1049,7 @@ bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const {
|
| // desired redirect URL (with or without fragment), so it must not be changed
|
| // any more.
|
| return !allowed_unsafe_redirect_url_.is_valid() ||
|
| - allowed_unsafe_redirect_url_ != location;
|
| + allowed_unsafe_redirect_url_ != location;
|
| }
|
|
|
| bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) {
|
| @@ -1059,7 +1067,7 @@ bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) {
|
| // Query URLRequestJobFactory as to whether |location| would be safe to
|
| // redirect to.
|
| return request_->context()->job_factory() &&
|
| - request_->context()->job_factory()->IsSafeRedirectTarget(location);
|
| + request_->context()->job_factory()->IsSafeRedirectTarget(location);
|
| }
|
|
|
| bool URLRequestHttpJob::NeedsAuth() {
|
| @@ -1140,11 +1148,11 @@ void URLRequestHttpJob::CancelAuth() {
|
| base::MessageLoop::current()->PostTask(
|
| FROM_HERE,
|
| base::Bind(&URLRequestHttpJob::OnStartCompleted,
|
| - weak_factory_.GetWeakPtr(), OK));
|
| + weak_factory_.GetWeakPtr(),
|
| + OK));
|
| }
|
|
|
| -void URLRequestHttpJob::ContinueWithCertificate(
|
| - X509Certificate* client_cert) {
|
| +void URLRequestHttpJob::ContinueWithCertificate(X509Certificate* client_cert) {
|
| DCHECK(transaction_.get());
|
|
|
| DCHECK(!response_info_) << "should not have a response yet";
|
| @@ -1165,7 +1173,8 @@ void URLRequestHttpJob::ContinueWithCertificate(
|
| base::MessageLoop::current()->PostTask(
|
| FROM_HERE,
|
| base::Bind(&URLRequestHttpJob::OnStartCompleted,
|
| - weak_factory_.GetWeakPtr(), rv));
|
| + weak_factory_.GetWeakPtr(),
|
| + rv));
|
| }
|
|
|
| void URLRequestHttpJob::ContinueDespiteLastError() {
|
| @@ -1191,7 +1200,8 @@ void URLRequestHttpJob::ContinueDespiteLastError() {
|
| base::MessageLoop::current()->PostTask(
|
| FROM_HERE,
|
| base::Bind(&URLRequestHttpJob::OnStartCompleted,
|
| - weak_factory_.GetWeakPtr(), rv));
|
| + weak_factory_.GetWeakPtr(),
|
| + rv));
|
| }
|
|
|
| void URLRequestHttpJob::ResumeNetworkStart() {
|
| @@ -1222,14 +1232,16 @@ bool URLRequestHttpJob::ShouldFixMismatchedContentLength(int rv) const {
|
| return false;
|
| }
|
|
|
| -bool URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size,
|
| +bool URLRequestHttpJob::ReadRawData(IOBuffer* buf,
|
| + int buf_size,
|
| int* bytes_read) {
|
| DCHECK_NE(buf_size, 0);
|
| DCHECK(bytes_read);
|
| DCHECK(!read_in_progress_);
|
|
|
| int rv = transaction_->Read(
|
| - buf, buf_size,
|
| + buf,
|
| + buf_size,
|
| base::Bind(&URLRequestHttpJob::OnReadCompleted, base::Unretained(this)));
|
|
|
| if (ShouldFixMismatchedContentLength(rv))
|
| @@ -1316,8 +1328,7 @@ void URLRequestHttpJob::RecordTimer() {
|
|
|
| void URLRequestHttpJob::ResetTimer() {
|
| if (!request_creation_time_.is_null()) {
|
| - NOTREACHED()
|
| - << "The timer was reset before it was recorded.";
|
| + NOTREACHED() << "The timer was reset before it was recorded.";
|
| return;
|
| }
|
| request_creation_time_ = base::Time::Now();
|
| @@ -1348,7 +1359,10 @@ void URLRequestHttpJob::RecordPacketStats(
|
| switch (statistic) {
|
| case FilterContext::SDCH_DECODE: {
|
| UMA_HISTOGRAM_CUSTOM_COUNTS("Sdch3.Network_Decode_Bytes_Processed_b",
|
| - static_cast<int>(bytes_observed_in_packets_), 500, 100000, 100);
|
| + static_cast<int>(bytes_observed_in_packets_),
|
| + 500,
|
| + 100000,
|
| + 100);
|
| return;
|
| }
|
| case FilterContext::SDCH_PASSTHROUGH: {
|
| @@ -1359,16 +1373,18 @@ void URLRequestHttpJob::RecordPacketStats(
|
|
|
| case FilterContext::SDCH_EXPERIMENT_DECODE: {
|
| UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment2_Decode",
|
| - duration,
|
| - base::TimeDelta::FromMilliseconds(20),
|
| - base::TimeDelta::FromMinutes(10), 100);
|
| + duration,
|
| + base::TimeDelta::FromMilliseconds(20),
|
| + base::TimeDelta::FromMinutes(10),
|
| + 100);
|
| return;
|
| }
|
| case FilterContext::SDCH_EXPERIMENT_HOLDBACK: {
|
| UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment2_Holdback",
|
| - duration,
|
| - base::TimeDelta::FromMilliseconds(20),
|
| - base::TimeDelta::FromMinutes(10), 100);
|
| + duration,
|
| + base::TimeDelta::FromMilliseconds(20),
|
| + base::TimeDelta::FromMinutes(10),
|
| + 100);
|
| return;
|
| }
|
| default:
|
| @@ -1378,21 +1394,21 @@ void URLRequestHttpJob::RecordPacketStats(
|
| }
|
|
|
| // The common type of histogram we use for all compression-tracking histograms.
|
| -#define COMPRESSION_HISTOGRAM(name, sample) \
|
| - do { \
|
| - UMA_HISTOGRAM_CUSTOM_COUNTS("Net.Compress." name, sample, \
|
| - 500, 1000000, 100); \
|
| - } while (0)
|
| +#define COMPRESSION_HISTOGRAM(name, sample) \
|
| + do { \
|
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \
|
| + "Net.Compress." name, sample, 500, 1000000, 100); \
|
| + } while (0)
|
|
|
| void URLRequestHttpJob::RecordCompressionHistograms() {
|
| DCHECK(request_);
|
| if (!request_)
|
| return;
|
|
|
| - if (is_cached_content_ || // Don't record cached content
|
| - !GetStatus().is_success() || // Don't record failed content
|
| - !IsCompressibleContent() || // Only record compressible content
|
| - !prefilter_bytes_read()) // Zero-byte responses aren't useful.
|
| + if (is_cached_content_ || // Don't record cached content
|
| + !GetStatus().is_success() || // Don't record failed content
|
| + !IsCompressibleContent() || // Only record compressible content
|
| + !prefilter_bytes_read()) // Zero-byte responses aren't useful.
|
| return;
|
|
|
| // Miniature requests aren't really compressible. Don't count them.
|
| @@ -1455,8 +1471,8 @@ void URLRequestHttpJob::RecordCompressionHistograms() {
|
| bool URLRequestHttpJob::IsCompressibleContent() const {
|
| std::string mime_type;
|
| return GetMimeType(&mime_type) &&
|
| - (IsSupportedJavascriptMimeType(mime_type.c_str()) ||
|
| - IsSupportedNonImageMimeType(mime_type.c_str()));
|
| + (IsSupportedJavascriptMimeType(mime_type.c_str()) ||
|
| + IsSupportedNonImageMimeType(mime_type.c_str()));
|
| }
|
|
|
| void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) {
|
| @@ -1475,7 +1491,7 @@ void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) {
|
| if (response_info_) {
|
| if (response_info_->was_cached) {
|
| UMA_HISTOGRAM_TIMES("Net.HttpJob.TotalTimeCached", total_time);
|
| - } else {
|
| + } else {
|
| UMA_HISTOGRAM_TIMES("Net.HttpJob.TotalTimeNotCached", total_time);
|
| }
|
| }
|
| @@ -1501,9 +1517,9 @@ void URLRequestHttpJob::DoneWithRequest(CompletionCause reason) {
|
| HttpResponseHeaders* URLRequestHttpJob::GetResponseHeaders() const {
|
| DCHECK(transaction_.get());
|
| DCHECK(transaction_->GetResponseInfo());
|
| - return override_response_headers_.get() ?
|
| - override_response_headers_.get() :
|
| - transaction_->GetResponseInfo()->headers.get();
|
| + return override_response_headers_.get()
|
| + ? override_response_headers_.get()
|
| + : transaction_->GetResponseInfo()->headers.get();
|
| }
|
|
|
| void URLRequestHttpJob::NotifyURLRequestDestroyed() {
|
|
|