OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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. |
| 4 |
| 5 #ifndef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_FETCH_REQUEST_STRUCT_TRAITS
_H_ |
| 6 #define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_FETCH_REQUEST_STRUCT_TRAITS
_H_ |
| 7 |
| 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "content/public/common/referrer.h" |
| 10 #include "third_party/WebKit/public/platform/modules/fetch/fetch_api_request.moj
om.h" |
| 11 |
| 12 namespace mojo { |
| 13 |
| 14 template <> |
| 15 struct EnumTraits<blink::mojom::FetchCredentialsMode, |
| 16 content::FetchCredentialsMode> { |
| 17 static blink::mojom::FetchCredentialsMode ToMojom( |
| 18 content::FetchCredentialsMode input); |
| 19 |
| 20 static bool FromMojom(blink::mojom::FetchCredentialsMode input, |
| 21 content::FetchCredentialsMode* out); |
| 22 }; |
| 23 |
| 24 template <> |
| 25 struct EnumTraits<blink::mojom::FetchRedirectMode, content::FetchRedirectMode> { |
| 26 static blink::mojom::FetchRedirectMode ToMojom( |
| 27 content::FetchRedirectMode input); |
| 28 |
| 29 static bool FromMojom(blink::mojom::FetchRedirectMode input, |
| 30 content::FetchRedirectMode* out); |
| 31 }; |
| 32 |
| 33 template <> |
| 34 struct EnumTraits<blink::mojom::FetchRequestMode, content::FetchRequestMode> { |
| 35 static blink::mojom::FetchRequestMode ToMojom( |
| 36 content::FetchRequestMode input); |
| 37 |
| 38 static bool FromMojom(blink::mojom::FetchRequestMode input, |
| 39 content::FetchRequestMode* out); |
| 40 }; |
| 41 |
| 42 template <> |
| 43 struct EnumTraits<blink::mojom::RequestContextFrameType, |
| 44 content::RequestContextFrameType> { |
| 45 static blink::mojom::RequestContextFrameType ToMojom( |
| 46 content::RequestContextFrameType input); |
| 47 |
| 48 static bool FromMojom(blink::mojom::RequestContextFrameType input, |
| 49 content::RequestContextFrameType* out); |
| 50 }; |
| 51 |
| 52 template <> |
| 53 struct EnumTraits<blink::mojom::RequestContextType, |
| 54 content::RequestContextType> { |
| 55 static blink::mojom::RequestContextType ToMojom( |
| 56 content::RequestContextType input); |
| 57 |
| 58 static bool FromMojom(blink::mojom::RequestContextType input, |
| 59 content::RequestContextType* out); |
| 60 }; |
| 61 |
| 62 template <> |
| 63 struct EnumTraits<blink::mojom::ServiceWorkerFetchType, |
| 64 content::ServiceWorkerFetchType> { |
| 65 static blink::mojom::ServiceWorkerFetchType ToMojom( |
| 66 content::ServiceWorkerFetchType input); |
| 67 |
| 68 static bool FromMojom(blink::mojom::ServiceWorkerFetchType input, |
| 69 content::ServiceWorkerFetchType* out); |
| 70 }; |
| 71 |
| 72 template <> |
| 73 struct StructTraits<blink::mojom::FetchAPIRequestDataView, |
| 74 content::ServiceWorkerFetchRequest> { |
| 75 static void* SetUpContext(const content::ServiceWorkerFetchRequest& request); |
| 76 static void TearDownContext(const content::ServiceWorkerFetchRequest& request, |
| 77 void* context); |
| 78 |
| 79 static content::FetchRequestMode mode( |
| 80 const content::ServiceWorkerFetchRequest& request) { |
| 81 return request.mode; |
| 82 } |
| 83 |
| 84 static bool is_main_resource_load( |
| 85 const content::ServiceWorkerFetchRequest& request) { |
| 86 return request.is_main_resource_load; |
| 87 } |
| 88 |
| 89 static content::RequestContextType request_context_type( |
| 90 const content::ServiceWorkerFetchRequest& request) { |
| 91 return request.request_context_type; |
| 92 } |
| 93 |
| 94 static content::RequestContextFrameType frame_type( |
| 95 const content::ServiceWorkerFetchRequest& request) { |
| 96 return request.frame_type; |
| 97 } |
| 98 |
| 99 static const GURL& url(const content::ServiceWorkerFetchRequest& request) { |
| 100 return request.url; |
| 101 } |
| 102 |
| 103 static const std::string& method( |
| 104 const content::ServiceWorkerFetchRequest& request) { |
| 105 return request.method; |
| 106 } |
| 107 |
| 108 static const std::map<std::string, std::string>& headers( |
| 109 const content::ServiceWorkerFetchRequest& request, |
| 110 void* context); |
| 111 |
| 112 static const std::string& blob_uuid( |
| 113 const content::ServiceWorkerFetchRequest& request) { |
| 114 return request.blob_uuid; |
| 115 } |
| 116 |
| 117 static uint64_t blob_size(const content::ServiceWorkerFetchRequest& request) { |
| 118 return request.blob_size; |
| 119 } |
| 120 |
| 121 static const content::Referrer& referrer( |
| 122 const content::ServiceWorkerFetchRequest& request) { |
| 123 return request.referrer; |
| 124 } |
| 125 |
| 126 static content::FetchCredentialsMode credentials_mode( |
| 127 const content::ServiceWorkerFetchRequest& request) { |
| 128 return request.credentials_mode; |
| 129 } |
| 130 |
| 131 static content::FetchRedirectMode redirect_mode( |
| 132 const content::ServiceWorkerFetchRequest& request) { |
| 133 return request.redirect_mode; |
| 134 } |
| 135 |
| 136 static const std::string& client_id( |
| 137 const content::ServiceWorkerFetchRequest& request) { |
| 138 return request.client_id; |
| 139 } |
| 140 |
| 141 static bool is_reload(const content::ServiceWorkerFetchRequest& request) { |
| 142 return request.is_reload; |
| 143 } |
| 144 |
| 145 static content::ServiceWorkerFetchType fetch_type( |
| 146 const content::ServiceWorkerFetchRequest& request) { |
| 147 return request.fetch_type; |
| 148 } |
| 149 |
| 150 static bool Read(blink::mojom::FetchAPIRequestDataView data, |
| 151 content::ServiceWorkerFetchRequest* out); |
| 152 }; |
| 153 |
| 154 } // namespace mojo |
| 155 |
| 156 #endif // CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_FETCH_REQUEST_STRUCT_TRA
ITS_H_ |
OLD | NEW |