OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 // A net::URLRequestJob subclass that is built on top of HttpTransaction. It | 27 // A net::URLRequestJob subclass that is built on top of HttpTransaction. It |
28 // provides an implementation for both HTTP and HTTPS. | 28 // provides an implementation for both HTTP and HTTPS. |
29 class URLRequestHttpJob : public URLRequestJob { | 29 class URLRequestHttpJob : public URLRequestJob { |
30 public: | 30 public: |
31 static URLRequestJob* Factory(URLRequest* request, | 31 static URLRequestJob* Factory(URLRequest* request, |
32 const std::string& scheme); | 32 const std::string& scheme); |
33 | 33 |
34 protected: | 34 protected: |
35 explicit URLRequestHttpJob(URLRequest* request); | 35 explicit URLRequestHttpJob(URLRequest* request); |
36 | 36 |
| 37 // Shadows URLRequestJob's version of this method so we can grab cookies. |
| 38 void NotifyHeadersComplete(); |
| 39 |
| 40 void DestroyTransaction(); |
| 41 void StartTransaction(); |
| 42 void AddExtraHeaders(); |
| 43 void AddCookieHeaderAndStart(); |
| 44 void SaveCookiesAndNotifyHeadersComplete(); |
| 45 void SaveNextCookie(); |
| 46 void FetchResponseCookies(const HttpResponseInfo* response_info, |
| 47 std::vector<std::string>* cookies); |
| 48 |
| 49 // Process the Strict-Transport-Security header, if one exists. |
| 50 void ProcessStrictTransportSecurityHeader(); |
| 51 |
| 52 void OnCanGetCookiesCompleted(int result); |
| 53 void OnCanSetCookieCompleted(int result); |
| 54 void OnStartCompleted(int result); |
| 55 void OnReadCompleted(int result); |
| 56 |
| 57 bool ShouldTreatAsCertificateError(int result); |
| 58 |
| 59 void RestartTransactionWithAuth(const string16& username, |
| 60 const string16& password); |
| 61 |
37 // Overridden from URLRequestJob: | 62 // Overridden from URLRequestJob: |
38 virtual void SetUpload(UploadData* upload); | 63 virtual void SetUpload(UploadData* upload); |
39 virtual void SetExtraRequestHeaders(const HttpRequestHeaders& headers); | 64 virtual void SetExtraRequestHeaders(const HttpRequestHeaders& headers); |
40 virtual void Start(); | 65 virtual void Start(); |
41 virtual void Kill(); | 66 virtual void Kill(); |
42 virtual LoadState GetLoadState() const; | 67 virtual LoadState GetLoadState() const; |
43 virtual uint64 GetUploadProgress() const; | 68 virtual uint64 GetUploadProgress() const; |
44 virtual bool GetMimeType(std::string* mime_type) const; | 69 virtual bool GetMimeType(std::string* mime_type) const; |
45 virtual bool GetCharset(std::string* charset); | 70 virtual bool GetCharset(std::string* charset); |
46 virtual void GetResponseInfo(HttpResponseInfo* info); | 71 virtual void GetResponseInfo(HttpResponseInfo* info); |
47 virtual bool GetResponseCookies(std::vector<std::string>* cookies); | 72 virtual bool GetResponseCookies(std::vector<std::string>* cookies); |
48 virtual int GetResponseCode() const; | 73 virtual int GetResponseCode() const; |
49 virtual bool GetContentEncodings( | 74 virtual bool GetContentEncodings( |
50 std::vector<Filter::FilterType>* encoding_type); | 75 std::vector<Filter::FilterType>* encoding_type); |
51 virtual bool IsCachedContent() const; | 76 virtual bool IsCachedContent() const; |
52 virtual bool IsSdchResponse() const; | 77 virtual bool IsSdchResponse() const; |
53 virtual bool IsSafeRedirect(const GURL& location); | 78 virtual bool IsSafeRedirect(const GURL& location); |
54 virtual bool NeedsAuth(); | 79 virtual bool NeedsAuth(); |
55 virtual void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*); | 80 virtual void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*); |
56 virtual void SetAuth(const string16& username, | 81 virtual void SetAuth(const string16& username, |
57 const string16& password); | 82 const string16& password); |
58 virtual void CancelAuth(); | 83 virtual void CancelAuth(); |
59 virtual void ContinueWithCertificate(X509Certificate* client_cert); | 84 virtual void ContinueWithCertificate(X509Certificate* client_cert); |
60 virtual void ContinueDespiteLastError(); | 85 virtual void ContinueDespiteLastError(); |
61 virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); | 86 virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); |
62 virtual void StopCaching(); | 87 virtual void StopCaching(); |
63 | 88 |
64 // Shadows URLRequestJob's version of this method so we can grab cookies. | |
65 void NotifyHeadersComplete(); | |
66 | |
67 void DestroyTransaction(); | |
68 void StartTransaction(); | |
69 void AddExtraHeaders(); | |
70 void AddCookieHeaderAndStart(); | |
71 void SaveCookiesAndNotifyHeadersComplete(); | |
72 void SaveNextCookie(); | |
73 void FetchResponseCookies(const HttpResponseInfo* response_info, | |
74 std::vector<std::string>* cookies); | |
75 | |
76 // Process the Strict-Transport-Security header, if one exists. | |
77 void ProcessStrictTransportSecurityHeader(); | |
78 | |
79 void OnCanGetCookiesCompleted(int result); | |
80 void OnCanSetCookieCompleted(int result); | |
81 void OnStartCompleted(int result); | |
82 void OnReadCompleted(int result); | |
83 | |
84 bool ShouldTreatAsCertificateError(int result); | |
85 | |
86 void RestartTransactionWithAuth(const string16& username, | |
87 const string16& password); | |
88 | |
89 // Keep a reference to the url request context to be sure it's not deleted | 89 // Keep a reference to the url request context to be sure it's not deleted |
90 // before us. | 90 // before us. |
91 scoped_refptr<URLRequestContext> context_; | 91 scoped_refptr<URLRequestContext> context_; |
92 | 92 |
93 HttpRequestInfo request_info_; | 93 HttpRequestInfo request_info_; |
94 const HttpResponseInfo* response_info_; | 94 const HttpResponseInfo* response_info_; |
95 | 95 |
96 std::vector<std::string> response_cookies_; | 96 std::vector<std::string> response_cookies_; |
97 size_t response_cookies_save_index_; | 97 size_t response_cookies_save_index_; |
98 | 98 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 virtual ~URLRequestHttpJob(); | 137 virtual ~URLRequestHttpJob(); |
138 | 138 |
139 ScopedRunnableMethodFactory<URLRequestHttpJob> method_factory_; | 139 ScopedRunnableMethodFactory<URLRequestHttpJob> method_factory_; |
140 | 140 |
141 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); | 141 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); |
142 }; | 142 }; |
143 | 143 |
144 } // namespace net | 144 } // namespace net |
145 | 145 |
146 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ | 146 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ |
OLD | NEW |