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 CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ |
6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ | 6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 enum ResponseCode { | 69 enum ResponseCode { |
70 RESPONSE_CODE_INVALID = -1 | 70 RESPONSE_CODE_INVALID = -1 |
71 }; | 71 }; |
72 | 72 |
73 enum RequestType { | 73 enum RequestType { |
74 GET, | 74 GET, |
75 POST, | 75 POST, |
76 HEAD, | 76 HEAD, |
77 DELETE_REQUEST, // DELETE is already taken on Windows. | 77 DELETE_REQUEST, // DELETE is already taken on Windows. |
78 // <winnt.h> defines a DELETE macro. | 78 // <winnt.h> defines a DELETE macro. |
| 79 PUT, |
79 }; | 80 }; |
80 | 81 |
81 // |url| is the URL to send the request to. | 82 // |url| is the URL to send the request to. |
82 // |request_type| is the type of request to make. | 83 // |request_type| is the type of request to make. |
83 // |d| the object that will receive the callback on fetch completion. | 84 // |d| the object that will receive the callback on fetch completion. |
84 static URLFetcher* Create(const GURL& url, | 85 static URLFetcher* Create(const GURL& url, |
85 RequestType request_type, | 86 RequestType request_type, |
86 URLFetcherDelegate* d); | 87 URLFetcherDelegate* d); |
87 | 88 |
88 // Like above, but if there's a URLFetcherFactory registered with the | 89 // Like above, but if there's a URLFetcherFactory registered with the |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 133 |
133 // Returns the current load flags. | 134 // Returns the current load flags. |
134 virtual int GetLoadFlags() const = 0; | 135 virtual int GetLoadFlags() const = 0; |
135 | 136 |
136 // The referrer URL for the request. Must be called before the request is | 137 // The referrer URL for the request. Must be called before the request is |
137 // started. | 138 // started. |
138 virtual void SetReferrer(const std::string& referrer) = 0; | 139 virtual void SetReferrer(const std::string& referrer) = 0; |
139 | 140 |
140 // Set extra headers on the request. Must be called before the request | 141 // Set extra headers on the request. Must be called before the request |
141 // is started. | 142 // is started. |
| 143 // This replaces the entire extra request headers. |
142 virtual void SetExtraRequestHeaders( | 144 virtual void SetExtraRequestHeaders( |
143 const std::string& extra_request_headers) = 0; | 145 const std::string& extra_request_headers) = 0; |
144 | 146 |
| 147 // Add header (with format field-name ":" [ field-value ]) to the request |
| 148 // headers. Must be called before the request is started. |
| 149 // This appends the header to the current extra request headers. |
| 150 virtual void AddExtraRequestHeader(const std::string& header_line) = 0; |
| 151 |
145 virtual void GetExtraRequestHeaders(net::HttpRequestHeaders* headers) = 0; | 152 virtual void GetExtraRequestHeaders(net::HttpRequestHeaders* headers) = 0; |
146 | 153 |
147 // Set the net::URLRequestContext on the request. Must be called before the | 154 // Set the net::URLRequestContext on the request. Must be called before the |
148 // request is started. | 155 // request is started. |
149 virtual void SetRequestContext( | 156 virtual void SetRequestContext( |
150 net::URLRequestContextGetter* request_context_getter) = 0; | 157 net::URLRequestContextGetter* request_context_getter) = 0; |
151 | 158 |
152 // If |retry| is false, 5xx responses will be propagated to the observer, | 159 // If |retry| is false, 5xx responses will be propagated to the observer, |
153 // if it is true URLFetcher will automatically re-execute the request, | 160 // if it is true URLFetcher will automatically re-execute the request, |
154 // after backoff_delay() elapses. URLFetcher has it set to true by default. | 161 // after backoff_delay() elapses. URLFetcher has it set to true by default. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // true, caller takes responsibility for the temp file, and it will not | 230 // true, caller takes responsibility for the temp file, and it will not |
224 // be removed once the URLFetcher is destroyed. User should not take | 231 // be removed once the URLFetcher is destroyed. User should not take |
225 // ownership more than once, or call this method after taking ownership. | 232 // ownership more than once, or call this method after taking ownership. |
226 virtual bool GetResponseAsFilePath(bool take_ownership, | 233 virtual bool GetResponseAsFilePath(bool take_ownership, |
227 FilePath* out_response_path) const = 0; | 234 FilePath* out_response_path) const = 0; |
228 }; | 235 }; |
229 | 236 |
230 } // namespace content | 237 } // namespace content |
231 | 238 |
232 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ | 239 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ |
OLD | NEW |