OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/file_version_info.h" | 12 #include "base/file_version_info.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
20 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
21 #include "net/base/mime_util.h" | 21 #include "net/base/mime_util.h" |
22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
23 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
24 #include "net/base/network_delegate.h" | 24 #include "net/base/network_delegate.h" |
25 #include "net/base/sdch_manager.h" | 25 #include "net/base/sdch_manager.h" |
26 #include "net/base/sdch_net_log_params.h" | |
26 #include "net/cert/cert_status_flags.h" | 27 #include "net/cert/cert_status_flags.h" |
27 #include "net/cookies/cookie_store.h" | 28 #include "net/cookies/cookie_store.h" |
28 #include "net/http/http_content_disposition.h" | 29 #include "net/http/http_content_disposition.h" |
29 #include "net/http/http_network_session.h" | 30 #include "net/http/http_network_session.h" |
30 #include "net/http/http_request_headers.h" | 31 #include "net/http/http_request_headers.h" |
31 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
32 #include "net/http/http_response_info.h" | 33 #include "net/http/http_response_info.h" |
33 #include "net/http/http_status_code.h" | 34 #include "net/http/http_status_code.h" |
34 #include "net/http/http_transaction.h" | 35 #include "net/http/http_transaction.h" |
35 #include "net/http/http_transaction_factory.h" | 36 #include "net/http/http_transaction_factory.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
62 virtual bool GetURL(GURL* gurl) const OVERRIDE; | 63 virtual bool GetURL(GURL* gurl) const OVERRIDE; |
63 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE; | 64 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE; |
64 virtual base::Time GetRequestTime() const OVERRIDE; | 65 virtual base::Time GetRequestTime() const OVERRIDE; |
65 virtual bool IsCachedContent() const OVERRIDE; | 66 virtual bool IsCachedContent() const OVERRIDE; |
66 virtual bool IsDownload() const OVERRIDE; | 67 virtual bool IsDownload() const OVERRIDE; |
67 virtual bool IsSdchResponse() const OVERRIDE; | 68 virtual bool IsSdchResponse() const OVERRIDE; |
68 virtual int64 GetByteReadCount() const OVERRIDE; | 69 virtual int64 GetByteReadCount() const OVERRIDE; |
69 virtual int GetResponseCode() const OVERRIDE; | 70 virtual int GetResponseCode() const OVERRIDE; |
70 virtual const URLRequestContext* GetURLRequestContext() const OVERRIDE; | 71 virtual const URLRequestContext* GetURLRequestContext() const OVERRIDE; |
71 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE; | 72 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE; |
73 virtual void LogSdchProblem(SdchManager::ProblemCodes problem) const OVERRIDE; | |
72 | 74 |
73 // Method to allow us to reset filter context for a response that should have | 75 // Method to allow us to reset filter context for a response that should have |
74 // been SDCH encoded when there is an update due to an explicit HTTP header. | 76 // been SDCH encoded when there is an update due to an explicit HTTP header. |
75 void ResetSdchResponseToFalse(); | 77 void ResetSdchResponseToFalse(); |
76 | 78 |
77 private: | 79 private: |
78 URLRequestHttpJob* job_; | 80 URLRequestHttpJob* job_; |
79 | 81 |
80 DISALLOW_COPY_AND_ASSIGN(HttpFilterContext); | 82 DISALLOW_COPY_AND_ASSIGN(HttpFilterContext); |
81 }; | 83 }; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 const URLRequestContext* | 141 const URLRequestContext* |
140 URLRequestHttpJob::HttpFilterContext::GetURLRequestContext() const { | 142 URLRequestHttpJob::HttpFilterContext::GetURLRequestContext() const { |
141 return job_->request() ? job_->request()->context() : NULL; | 143 return job_->request() ? job_->request()->context() : NULL; |
142 } | 144 } |
143 | 145 |
144 void URLRequestHttpJob::HttpFilterContext::RecordPacketStats( | 146 void URLRequestHttpJob::HttpFilterContext::RecordPacketStats( |
145 StatisticSelector statistic) const { | 147 StatisticSelector statistic) const { |
146 job_->RecordPacketStats(statistic); | 148 job_->RecordPacketStats(statistic); |
147 } | 149 } |
148 | 150 |
151 void URLRequestHttpJob::HttpFilterContext::LogSdchProblem( | |
152 SdchManager::ProblemCodes problem) const { | |
153 SdchManager::SdchErrorRecovery(problem); | |
154 if (job_->request()) | |
155 job_->request()->net_log().AddEvent( | |
156 NetLog::TYPE_SDCH_RESOURCE_ERROR, | |
157 base::Bind(&NetLogSdchResourceProblemCallback, problem)); | |
158 } | |
159 | |
149 // TODO(darin): make sure the port blocking code is not lost | 160 // TODO(darin): make sure the port blocking code is not lost |
150 // static | 161 // static |
151 URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request, | 162 URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request, |
152 NetworkDelegate* network_delegate, | 163 NetworkDelegate* network_delegate, |
153 const std::string& scheme) { | 164 const std::string& scheme) { |
154 DCHECK(scheme == "http" || scheme == "https" || scheme == "ws" || | 165 DCHECK(scheme == "http" || scheme == "https" || scheme == "ws" || |
155 scheme == "wss"); | 166 scheme == "wss"); |
156 | 167 |
157 if (!request->context()->http_transaction_factory()) { | 168 if (!request->context()->http_transaction_factory()) { |
158 NOTREACHED() << "requires a valid context"; | 169 NOTREACHED() << "requires a valid context"; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 // TODO(jar): We need to not fetch dictionaries the first time they are | 338 // TODO(jar): We need to not fetch dictionaries the first time they are |
328 // seen, but rather wait until we can justify their usefulness. | 339 // seen, but rather wait until we can justify their usefulness. |
329 // For now, we will only fetch the first dictionary, which will at least | 340 // For now, we will only fetch the first dictionary, which will at least |
330 // require multiple suggestions before we get additional ones for this site. | 341 // require multiple suggestions before we get additional ones for this site. |
331 // Eventually we should wait until a dictionary is requested several times | 342 // Eventually we should wait until a dictionary is requested several times |
332 // before we even download it (so that we don't waste memory or bandwidth). | 343 // before we even download it (so that we don't waste memory or bandwidth). |
333 if (GetResponseHeaders()->EnumerateHeader(&iter, name, &url_text)) { | 344 if (GetResponseHeaders()->EnumerateHeader(&iter, name, &url_text)) { |
334 // Resolve suggested URL relative to request url. | 345 // Resolve suggested URL relative to request url. |
335 GURL sdch_dictionary_url = request_->url().Resolve(url_text); | 346 GURL sdch_dictionary_url = request_->url().Resolve(url_text); |
336 if (sdch_dictionary_url.is_valid()) { | 347 if (sdch_dictionary_url.is_valid()) { |
337 sdch_manager->FetchDictionary(request_->url(), sdch_dictionary_url); | 348 SdchManager::ProblemCodes rv = |
349 sdch_manager->FetchDictionary(request_->url(), sdch_dictionary_url); | |
350 if (rv != SdchManager::PROBLEM_CODE_OK) { | |
351 SdchManager::SdchErrorRecovery(rv); | |
352 if (request_) | |
Randy Smith (Not in Mondays)
2014/08/05 17:50:34
We've indirected request_ several lines above; eit
baranovich
2014/08/12 20:54:50
Done.
| |
353 request_->net_log().AddEvent( | |
354 NetLog::TYPE_SDCH_DICTIONARY_FETCH_ERROR, | |
355 base::Bind(&NetLogSdchDictionaryFetchProblemCallback, | |
356 rv, | |
357 &sdch_dictionary_url)); | |
358 } | |
338 } | 359 } |
339 } | 360 } |
340 } | 361 } |
341 | 362 |
342 // The HTTP transaction may be restarted several times for the purposes | 363 // The HTTP transaction may be restarted several times for the purposes |
343 // of sending authorization information. Each time it restarts, we get | 364 // of sending authorization information. Each time it restarts, we get |
344 // notified of the headers completion so that we can update the cookie store. | 365 // notified of the headers completion so that we can update the cookie store. |
345 if (transaction_->IsReadyToRestartForAuth()) { | 366 if (transaction_->IsReadyToRestartForAuth()) { |
346 DCHECK(!response_info_->auth_challenge.get()); | 367 DCHECK(!response_info_->auth_challenge.get()); |
347 // TODO(battre): This breaks the webrequest API for | 368 // TODO(battre): This breaks the webrequest API for |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1523 return override_response_headers_.get() ? | 1544 return override_response_headers_.get() ? |
1524 override_response_headers_.get() : | 1545 override_response_headers_.get() : |
1525 transaction_->GetResponseInfo()->headers.get(); | 1546 transaction_->GetResponseInfo()->headers.get(); |
1526 } | 1547 } |
1527 | 1548 |
1528 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1549 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1529 awaiting_callback_ = false; | 1550 awaiting_callback_ = false; |
1530 } | 1551 } |
1531 | 1552 |
1532 } // namespace net | 1553 } // namespace net |
OLD | NEW |