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 #ifndef CONTENT_CHILD_WEB_URL_REQUEST_UTIL_H_ | 5 #ifndef CONTENT_CHILD_WEB_URL_REQUEST_UTIL_H_ |
6 #define CONTENT_CHILD_WEB_URL_REQUEST_UTIL_H_ | 6 #define CONTENT_CHILD_WEB_URL_REQUEST_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 #include "content/common/resource_request_body.h" | 11 #include "content/common/resource_request_body_impl.h" |
12 #include "content/common/service_worker/service_worker_types.h" | 12 #include "content/common/service_worker/service_worker_types.h" |
13 #include "content/public/common/request_context_frame_type.h" | 13 #include "content/public/common/request_context_frame_type.h" |
14 #include "content/public/common/request_context_type.h" | 14 #include "content/public/common/request_context_type.h" |
15 #include "content/public/common/resource_type.h" | 15 #include "content/public/common/resource_type.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 class WebHTTPBody; | 18 class WebHTTPBody; |
19 class WebURL; | 19 class WebURL; |
20 class WebURLRequest; | 20 class WebURLRequest; |
21 struct WebURLError; | 21 struct WebURLError; |
22 } | 22 } |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 CONTENT_EXPORT ResourceType WebURLRequestToResourceType( | 26 CONTENT_EXPORT ResourceType WebURLRequestToResourceType( |
27 const blink::WebURLRequest& request); | 27 const blink::WebURLRequest& request); |
28 | 28 |
29 std::string GetWebURLRequestHeaders(const blink::WebURLRequest& request); | 29 std::string GetWebURLRequestHeaders(const blink::WebURLRequest& request); |
30 | 30 |
31 int GetLoadFlagsForWebURLRequest(const blink::WebURLRequest& request); | 31 int GetLoadFlagsForWebURLRequest(const blink::WebURLRequest& request); |
32 | 32 |
33 // Takes a ResourceRequestBody and converts into WebHTTPBody. | 33 // Takes a ResourceRequestBodyImpl and converts into WebHTTPBody. |
34 blink::WebHTTPBody GetWebHTTPBodyForRequestBody( | 34 blink::WebHTTPBody GetWebHTTPBodyForRequestBody( |
35 const scoped_refptr<ResourceRequestBody>& input); | 35 const scoped_refptr<ResourceRequestBodyImpl>& input); |
36 | 36 |
37 // Takes a WebHTTPBody and converts into a ResourceRequestBody. | 37 // Takes a WebHTTPBody and converts into a ResourceRequestBodyImpl. |
38 scoped_refptr<ResourceRequestBody> GetRequestBodyForWebHTTPBody( | 38 scoped_refptr<ResourceRequestBodyImpl> GetRequestBodyForWebHTTPBody( |
39 const blink::WebHTTPBody& httpBody); | 39 const blink::WebHTTPBody& httpBody); |
40 | 40 |
41 // Takes a WebURLRequest and sets the appropriate information | 41 // Takes a WebURLRequest and sets the appropriate information |
42 // in a ResourceRequestBody structure. Returns an empty scoped_refptr | 42 // in a ResourceRequestBodyImpl structure. Returns an empty scoped_refptr |
43 // if the request body is not present. | 43 // if the request body is not present. |
44 scoped_refptr<ResourceRequestBody> GetRequestBodyForWebURLRequest( | 44 scoped_refptr<ResourceRequestBodyImpl> GetRequestBodyForWebURLRequest( |
45 const blink::WebURLRequest& request); | 45 const blink::WebURLRequest& request); |
46 | 46 |
47 // Helper functions to convert enums from the blink type to the content | 47 // Helper functions to convert enums from the blink type to the content |
48 // type. | 48 // type. |
49 FetchRequestMode GetFetchRequestModeForWebURLRequest( | 49 FetchRequestMode GetFetchRequestModeForWebURLRequest( |
50 const blink::WebURLRequest& request); | 50 const blink::WebURLRequest& request); |
51 FetchCredentialsMode GetFetchCredentialsModeForWebURLRequest( | 51 FetchCredentialsMode GetFetchCredentialsModeForWebURLRequest( |
52 const blink::WebURLRequest& request); | 52 const blink::WebURLRequest& request); |
53 FetchRedirectMode GetFetchRedirectModeForWebURLRequest( | 53 FetchRedirectMode GetFetchRedirectModeForWebURLRequest( |
54 const blink::WebURLRequest& request); | 54 const blink::WebURLRequest& request); |
55 RequestContextFrameType GetRequestContextFrameTypeForWebURLRequest( | 55 RequestContextFrameType GetRequestContextFrameTypeForWebURLRequest( |
56 const blink::WebURLRequest& request); | 56 const blink::WebURLRequest& request); |
57 RequestContextType GetRequestContextTypeForWebURLRequest( | 57 RequestContextType GetRequestContextTypeForWebURLRequest( |
58 const blink::WebURLRequest& request); | 58 const blink::WebURLRequest& request); |
59 | 59 |
60 // Generates a WebURLError based on |reason|. | 60 // Generates a WebURLError based on |reason|. |
61 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url, | 61 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url, |
62 bool stale_copy_in_cache, | 62 bool stale_copy_in_cache, |
63 int reason); | 63 int reason); |
64 | 64 |
65 // Generates a WebURLError based on |reason|. | 65 // Generates a WebURLError based on |reason|. |
66 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url, | 66 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url, |
67 bool stale_copy_in_cache, | 67 bool stale_copy_in_cache, |
68 int reason, | 68 int reason, |
69 bool was_ignored_by_handler); | 69 bool was_ignored_by_handler); |
70 | 70 |
71 } // namespace content | 71 } // namespace content |
72 | 72 |
73 #endif // CONTENT_CHILD_WEB_URL_REQUEST_UTIL_H_ | 73 #endif // CONTENT_CHILD_WEB_URL_REQUEST_UTIL_H_ |
OLD | NEW |