OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/web_url_request_util.h" | 5 #include "content/child/web_url_request_util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 #include "third_party/WebKit/public/platform/FilePathConversion.h" | 16 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
| 17 #include "third_party/WebKit/public/platform/WebCachePolicy.h" |
17 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" | 18 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" |
18 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
19 #include "third_party/WebKit/public/platform/WebURL.h" | 20 #include "third_party/WebKit/public/platform/WebURL.h" |
20 #include "third_party/WebKit/public/platform/WebURLError.h" | 21 #include "third_party/WebKit/public/platform/WebURLError.h" |
21 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 22 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
22 | 23 |
| 24 using blink::WebCachePolicy; |
23 using blink::WebHTTPBody; | 25 using blink::WebHTTPBody; |
24 using blink::WebString; | 26 using blink::WebString; |
25 using blink::WebURLRequest; | 27 using blink::WebURLRequest; |
26 | 28 |
27 namespace content { | 29 namespace content { |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 const char kThrottledErrorDescription[] = | 33 const char kThrottledErrorDescription[] = |
32 "Request throttled. Visit http://dev.chromium.org/throttling for more " | 34 "Request throttled. Visit http://dev.chromium.org/throttling for more " |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 std::string GetWebURLRequestHeaders(const blink::WebURLRequest& request) { | 193 std::string GetWebURLRequestHeaders(const blink::WebURLRequest& request) { |
192 HeaderFlattener flattener; | 194 HeaderFlattener flattener; |
193 request.visitHTTPHeaderFields(&flattener); | 195 request.visitHTTPHeaderFields(&flattener); |
194 return flattener.GetBuffer(); | 196 return flattener.GetBuffer(); |
195 } | 197 } |
196 | 198 |
197 int GetLoadFlagsForWebURLRequest(const blink::WebURLRequest& request) { | 199 int GetLoadFlagsForWebURLRequest(const blink::WebURLRequest& request) { |
198 int load_flags = net::LOAD_NORMAL; | 200 int load_flags = net::LOAD_NORMAL; |
199 GURL url = request.url(); | 201 GURL url = request.url(); |
200 switch (request.getCachePolicy()) { | 202 switch (request.getCachePolicy()) { |
201 case WebURLRequest::ValidatingCacheData: | 203 case WebCachePolicy::ValidatingCacheData: |
202 load_flags |= net::LOAD_VALIDATE_CACHE; | 204 load_flags |= net::LOAD_VALIDATE_CACHE; |
203 break; | 205 break; |
204 case WebURLRequest::BypassingCache: | 206 case WebCachePolicy::BypassingCache: |
205 load_flags |= net::LOAD_BYPASS_CACHE; | 207 load_flags |= net::LOAD_BYPASS_CACHE; |
206 break; | 208 break; |
207 case WebURLRequest::ReturnCacheDataElseLoad: | 209 case WebCachePolicy::ReturnCacheDataElseLoad: |
208 load_flags |= net::LOAD_PREFERRING_CACHE; | 210 load_flags |= net::LOAD_PREFERRING_CACHE; |
209 break; | 211 break; |
210 case WebURLRequest::ReturnCacheDataDontLoad: | 212 case WebCachePolicy::ReturnCacheDataDontLoad: |
211 load_flags |= net::LOAD_ONLY_FROM_CACHE; | 213 load_flags |= net::LOAD_ONLY_FROM_CACHE; |
212 break; | 214 break; |
213 case WebURLRequest::UseProtocolCachePolicy: | 215 case WebCachePolicy::UseProtocolCachePolicy: |
214 break; | 216 break; |
215 default: | 217 default: |
216 NOTREACHED(); | 218 NOTREACHED(); |
217 } | 219 } |
218 | 220 |
219 if (!request.allowStoredCredentials()) { | 221 if (!request.allowStoredCredentials()) { |
220 load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES; | 222 load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES; |
221 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES; | 223 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES; |
222 } | 224 } |
223 | 225 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 bool stale_copy_in_cache, | 444 bool stale_copy_in_cache, |
443 int reason, | 445 int reason, |
444 bool was_ignored_by_handler) { | 446 bool was_ignored_by_handler) { |
445 blink::WebURLError error = | 447 blink::WebURLError error = |
446 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason); | 448 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason); |
447 error.wasIgnoredByHandler = was_ignored_by_handler; | 449 error.wasIgnoredByHandler = was_ignored_by_handler; |
448 return error; | 450 return error; |
449 } | 451 } |
450 | 452 |
451 } // namespace content | 453 } // namespace content |
OLD | NEW |