Roll src/third_party/WebKit 27253e2:e5fc8b6 (svn 202580:202581)
[chromium-blink-merge.git] / content / child / web_url_request_util.h
blob4a1da0cf0fca844ecbe38d83ab1ca7b7f2e266dc
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_CHILD_WEB_URL_REQUEST_UTIL_H_
6 #define CONTENT_CHILD_WEB_URL_REQUEST_UTIL_H_
8 #include <string>
10 #include "content/common/content_export.h"
11 #include "content/common/resource_request_body.h"
12 #include "content/common/service_worker/service_worker_types.h"
13 #include "content/public/common/request_context_frame_type.h"
14 #include "content/public/common/request_context_type.h"
15 #include "content/public/common/resource_type.h"
17 namespace blink {
18 class WebURL;
19 class WebURLRequest;
20 struct WebURLError;
23 namespace content {
25 CONTENT_EXPORT ResourceType WebURLRequestToResourceType(
26 const blink::WebURLRequest& request);
28 std::string GetWebURLRequestHeaders(const blink::WebURLRequest& request);
30 int GetLoadFlagsForWebURLRequest(const blink::WebURLRequest& request);
32 // Takes a WebURLRequest and sets the appropriate information
33 // in a ResourceRequestBody structure. Returns an empty scoped_refptr
34 // if the request body is not present.
35 scoped_refptr<ResourceRequestBody> GetRequestBodyForWebURLRequest(
36 const blink::WebURLRequest& request);
38 // Helper functions to convert enums from the blink type to the content
39 // type.
40 FetchRequestMode GetFetchRequestModeForWebURLRequest(
41 const blink::WebURLRequest& request);
42 FetchCredentialsMode GetFetchCredentialsModeForWebURLRequest(
43 const blink::WebURLRequest& request);
44 FetchRedirectMode GetFetchRedirectModeForWebURLRequest(
45 const blink::WebURLRequest& request);
46 RequestContextFrameType GetRequestContextFrameTypeForWebURLRequest(
47 const blink::WebURLRequest& request);
48 RequestContextType GetRequestContextTypeForWebURLRequest(
49 const blink::WebURLRequest& request);
51 // Generates a WebURLError based on |reason|.
52 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url,
53 bool stale_copy_in_cache,
54 int reason);
56 // Generates a WebURLError based on |reason|.
57 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url,
58 bool stale_copy_in_cache,
59 int reason,
60 bool was_ignored_by_handler);
62 } // namespace content
64 #endif // CONTENT_CHILD_WEB_URL_REQUEST_UTIL_H_