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" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 namespace net { | 55 namespace net { |
56 | 56 |
57 class URLRequestHttpJob::HttpFilterContext : public FilterContext { | 57 class URLRequestHttpJob::HttpFilterContext : public FilterContext { |
58 public: | 58 public: |
59 explicit HttpFilterContext(URLRequestHttpJob* job); | 59 explicit HttpFilterContext(URLRequestHttpJob* job); |
60 ~HttpFilterContext() override; | 60 ~HttpFilterContext() override; |
61 | 61 |
62 // FilterContext implementation. | 62 // FilterContext implementation. |
63 bool GetMimeType(std::string* mime_type) const override; | 63 bool GetMimeType(std::string* mime_type) const override; |
64 bool GetURL(GURL* gurl) const override; | 64 bool GetURL(GURL* gurl) const override; |
65 bool GetContentDisposition(std::string* disposition) const override; | |
66 base::Time GetRequestTime() const override; | 65 base::Time GetRequestTime() const override; |
67 bool IsCachedContent() const override; | 66 bool IsCachedContent() const override; |
68 bool IsDownload() const override; | |
69 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override; | 67 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override; |
70 int64 GetByteReadCount() const override; | 68 int64 GetByteReadCount() const override; |
71 int GetResponseCode() const override; | 69 int GetResponseCode() const override; |
72 const URLRequestContext* GetURLRequestContext() const override; | 70 const URLRequestContext* GetURLRequestContext() const override; |
73 void RecordPacketStats(StatisticSelector statistic) const override; | 71 void RecordPacketStats(StatisticSelector statistic) const override; |
74 const BoundNetLog& GetNetLog() const override; | 72 const BoundNetLog& GetNetLog() const override; |
75 | 73 |
76 private: | 74 private: |
77 URLRequestHttpJob* job_; | 75 URLRequestHttpJob* job_; |
78 | 76 |
(...skipping 17 matching lines...) Expand all Loading... |
96 return job_->GetMimeType(mime_type); | 94 return job_->GetMimeType(mime_type); |
97 } | 95 } |
98 | 96 |
99 bool URLRequestHttpJob::HttpFilterContext::GetURL(GURL* gurl) const { | 97 bool URLRequestHttpJob::HttpFilterContext::GetURL(GURL* gurl) const { |
100 if (!job_->request()) | 98 if (!job_->request()) |
101 return false; | 99 return false; |
102 *gurl = job_->request()->url(); | 100 *gurl = job_->request()->url(); |
103 return true; | 101 return true; |
104 } | 102 } |
105 | 103 |
106 bool URLRequestHttpJob::HttpFilterContext::GetContentDisposition( | |
107 std::string* disposition) const { | |
108 HttpResponseHeaders* headers = job_->GetResponseHeaders(); | |
109 void *iter = NULL; | |
110 return headers->EnumerateHeader(&iter, "Content-Disposition", disposition); | |
111 } | |
112 | |
113 base::Time URLRequestHttpJob::HttpFilterContext::GetRequestTime() const { | 104 base::Time URLRequestHttpJob::HttpFilterContext::GetRequestTime() const { |
114 return job_->request() ? job_->request()->request_time() : base::Time(); | 105 return job_->request() ? job_->request()->request_time() : base::Time(); |
115 } | 106 } |
116 | 107 |
117 bool URLRequestHttpJob::HttpFilterContext::IsCachedContent() const { | 108 bool URLRequestHttpJob::HttpFilterContext::IsCachedContent() const { |
118 return job_->is_cached_content_; | 109 return job_->is_cached_content_; |
119 } | 110 } |
120 | 111 |
121 bool URLRequestHttpJob::HttpFilterContext::IsDownload() const { | |
122 return (job_->request_info_.load_flags & LOAD_IS_DOWNLOAD) != 0; | |
123 } | |
124 | |
125 SdchManager::DictionarySet* | 112 SdchManager::DictionarySet* |
126 URLRequestHttpJob::HttpFilterContext::SdchDictionariesAdvertised() const { | 113 URLRequestHttpJob::HttpFilterContext::SdchDictionariesAdvertised() const { |
127 return job_->dictionaries_advertised_.get(); | 114 return job_->dictionaries_advertised_.get(); |
128 } | 115 } |
129 | 116 |
130 int64 URLRequestHttpJob::HttpFilterContext::GetByteReadCount() const { | 117 int64 URLRequestHttpJob::HttpFilterContext::GetByteReadCount() const { |
131 return job_->filter_input_byte_count(); | 118 return job_->filter_input_byte_count(); |
132 } | 119 } |
133 | 120 |
134 int URLRequestHttpJob::HttpFilterContext::GetResponseCode() const { | 121 int URLRequestHttpJob::HttpFilterContext::GetResponseCode() const { |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 return override_response_headers_.get() ? | 1489 return override_response_headers_.get() ? |
1503 override_response_headers_.get() : | 1490 override_response_headers_.get() : |
1504 transaction_->GetResponseInfo()->headers.get(); | 1491 transaction_->GetResponseInfo()->headers.get(); |
1505 } | 1492 } |
1506 | 1493 |
1507 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1494 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1508 awaiting_callback_ = false; | 1495 awaiting_callback_ = false; |
1509 } | 1496 } |
1510 | 1497 |
1511 } // namespace net | 1498 } // namespace net |
OLD | NEW |