OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #ifndef NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "net/base/auth.h" | 13 #include "net/base/auth.h" |
14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
15 #include "net/http/http_request_info.h" | 15 #include "net/http/http_request_info.h" |
16 #include "net/url_request/url_request_job.h" | 16 #include "net/url_request/url_request_job.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 class HttpResponseInfo; | 19 class HttpResponseInfo; |
20 class HttpTransaction; | 20 class HttpTransaction; |
21 } | 21 } |
22 class URLRequestContext; | 22 class URLRequestContext; |
23 | 23 |
24 // A URLRequestJob subclass that is built on top of HttpTransaction. It | 24 // A URLRequestJob subclass that is built on top of HttpTransaction. It |
25 // provides an implementation for both HTTP and HTTPS. | 25 // provides an implementation for both HTTP and HTTPS. |
26 class URLRequestHttpJob : public URLRequestJob { | 26 class URLRequestHttpJob : public URLRequestJob { |
27 public: | 27 public: |
28 static URLRequestJob* Factory(URLRequest* request, const std::string& scheme); | 28 static URLRequestJob* Factory(URLRequest* request, const std::string& scheme); |
29 // Specifies a comma separated list of port numbers that should be accepted | |
30 // despite bans. If the string is invalid no allowed ports are stored. | |
31 static void SetExplicitlyAllowedPorts(const std::wstring& allowed_ports); | |
32 static const std::set<int>& explicitly_allowed_ports() { | |
33 return explicitly_allowed_ports_; | |
34 } | |
35 | 29 |
36 virtual ~URLRequestHttpJob(); | 30 virtual ~URLRequestHttpJob(); |
37 | 31 |
38 protected: | 32 protected: |
39 explicit URLRequestHttpJob(URLRequest* request); | 33 explicit URLRequestHttpJob(URLRequest* request); |
40 | 34 |
41 // URLRequestJob methods: | 35 // URLRequestJob methods: |
42 virtual void SetUpload(net::UploadData* upload); | 36 virtual void SetUpload(net::UploadData* upload); |
43 virtual void SetExtraRequestHeaders(const std::string& headers); | 37 virtual void SetExtraRequestHeaders(const std::string& headers); |
44 virtual void Start(); | 38 virtual void Start(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void ProcessStrictTransportSecurityHeader(); | 72 void ProcessStrictTransportSecurityHeader(); |
79 | 73 |
80 void OnStartCompleted(int result); | 74 void OnStartCompleted(int result); |
81 void OnReadCompleted(int result); | 75 void OnReadCompleted(int result); |
82 | 76 |
83 bool ShouldTreatAsCertificateError(int result); | 77 bool ShouldTreatAsCertificateError(int result); |
84 | 78 |
85 void RestartTransactionWithAuth(const std::wstring& username, | 79 void RestartTransactionWithAuth(const std::wstring& username, |
86 const std::wstring& password); | 80 const std::wstring& password); |
87 | 81 |
88 // Check if banned |port| has been overriden by an entry in | |
89 // |explicitly_allowed_ports_|. | |
90 static bool IsPortAllowedByOverride(int port); | |
91 | |
92 // Keep a reference to the url request context to be sure it's not deleted | 82 // Keep a reference to the url request context to be sure it's not deleted |
93 // before us. | 83 // before us. |
94 scoped_refptr<URLRequestContext> context_; | 84 scoped_refptr<URLRequestContext> context_; |
95 | 85 |
96 net::HttpRequestInfo request_info_; | 86 net::HttpRequestInfo request_info_; |
97 const net::HttpResponseInfo* response_info_; | 87 const net::HttpResponseInfo* response_info_; |
98 std::vector<std::string> response_cookies_; | 88 std::vector<std::string> response_cookies_; |
99 | 89 |
100 // Auth states for proxy and origin server. | 90 // Auth states for proxy and origin server. |
101 net::AuthState proxy_auth_state_; | 91 net::AuthState proxy_auth_state_; |
(...skipping 17 matching lines...) Expand all Loading... |
119 | 109 |
120 // For SDCH latency experiments, when we are able to do SDCH, we may enable | 110 // For SDCH latency experiments, when we are able to do SDCH, we may enable |
121 // either an SDCH latency test xor a pass through test. The following bools | 111 // either an SDCH latency test xor a pass through test. The following bools |
122 // indicate what we decided on for this instance. | 112 // indicate what we decided on for this instance. |
123 bool sdch_test_activated_; // Advertising a dictionary for sdch. | 113 bool sdch_test_activated_; // Advertising a dictionary for sdch. |
124 bool sdch_test_control_; // Not even accepting-content sdch. | 114 bool sdch_test_control_; // Not even accepting-content sdch. |
125 | 115 |
126 // For recording of stats, we need to remember if this is cached content. | 116 // For recording of stats, we need to remember if this is cached content. |
127 bool is_cached_content_; | 117 bool is_cached_content_; |
128 | 118 |
129 private: | |
130 // Holds a list of ports that should be accepted despite bans. | |
131 static std::set<int> explicitly_allowed_ports_; | |
132 | |
133 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); | 119 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); |
134 }; | 120 }; |
135 | 121 |
136 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ | 122 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ |
OLD | NEW |