Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Side by Side Diff: content/child/web_url_request_util.cc

Issue 1317833005: PlzNavigate: Expose blink to content enum type converters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/child/web_url_request_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "net/base/load_flags.h" 9 #include "net/base/load_flags.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 request_body->AppendBlob(element.blobUUID.utf8()); 269 request_body->AppendBlob(element.blobUUID.utf8());
270 break; 270 break;
271 default: 271 default:
272 NOTREACHED(); 272 NOTREACHED();
273 } 273 }
274 } 274 }
275 request_body->set_identifier(request.httpBody().identifier()); 275 request_body->set_identifier(request.httpBody().identifier());
276 return request_body; 276 return request_body;
277 } 277 }
278 278
279 #define STATIC_ASSERT_MATCHING_ENUMS(content_name, blink_name) \
280 static_assert( \
281 static_cast<int>(content_name) == static_cast<int>(blink_name), \
282 "mismatching enums: " #content_name)
283
284 STATIC_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_SAME_ORIGIN,
285 WebURLRequest::FetchRequestModeSameOrigin);
286 STATIC_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_NO_CORS,
287 WebURLRequest::FetchRequestModeNoCORS);
288 STATIC_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_CORS,
289 WebURLRequest::FetchRequestModeCORS);
290 STATIC_ASSERT_MATCHING_ENUMS(
291 FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT,
292 WebURLRequest::FetchRequestModeCORSWithForcedPreflight);
293
294 FetchRequestMode GetFetchRequestModeForWebURLRequest(
295 const blink::WebURLRequest& request) {
296 return static_cast<FetchRequestMode>(request.fetchRequestMode());
297 }
298
299 STATIC_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_OMIT,
300 WebURLRequest::FetchCredentialsModeOmit);
301 STATIC_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_SAME_ORIGIN,
302 WebURLRequest::FetchCredentialsModeSameOrigin);
303 STATIC_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_INCLUDE,
304 WebURLRequest::FetchCredentialsModeInclude);
305
306 FetchCredentialsMode GetFetchCredentialsModeForWebURLRequest(
307 const blink::WebURLRequest& request) {
308 return static_cast<FetchCredentialsMode>(request.fetchCredentialsMode());
309 }
310
311 STATIC_ASSERT_MATCHING_ENUMS(FetchRedirectMode::FOLLOW_MODE,
312 WebURLRequest::FetchRedirectModeFollow);
313 STATIC_ASSERT_MATCHING_ENUMS(FetchRedirectMode::ERROR_MODE,
314 WebURLRequest::FetchRedirectModeError);
315 STATIC_ASSERT_MATCHING_ENUMS(FetchRedirectMode::MANUAL_MODE,
316 WebURLRequest::FetchRedirectModeManual);
317
318 FetchRedirectMode GetFetchRedirectModeForWebURLRequest(
319 const blink::WebURLRequest& request) {
320 return static_cast<FetchRedirectMode>(request.fetchRedirectMode());
321 }
322
323 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_AUXILIARY,
324 WebURLRequest::FrameTypeAuxiliary);
325 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_NESTED,
326 WebURLRequest::FrameTypeNested);
327 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_NONE,
328 WebURLRequest::FrameTypeNone);
329 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
330 WebURLRequest::FrameTypeTopLevel);
331
332 RequestContextFrameType GetRequestContextFrameTypeForWebURLRequest(
333 const blink::WebURLRequest& request) {
334 return static_cast<RequestContextFrameType>(request.frameType());
335 }
336
337 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_UNSPECIFIED,
338 WebURLRequest::RequestContextUnspecified);
339 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_AUDIO,
340 WebURLRequest::RequestContextAudio);
341 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_BEACON,
342 WebURLRequest::RequestContextBeacon);
343 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_CSP_REPORT,
344 WebURLRequest::RequestContextCSPReport);
345 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_DOWNLOAD,
346 WebURLRequest::RequestContextDownload);
347 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_EMBED,
348 WebURLRequest::RequestContextEmbed);
349 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_EVENT_SOURCE,
350 WebURLRequest::RequestContextEventSource);
351 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FAVICON,
352 WebURLRequest::RequestContextFavicon);
353 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FETCH,
354 WebURLRequest::RequestContextFetch);
355 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FONT,
356 WebURLRequest::RequestContextFont);
357 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FORM,
358 WebURLRequest::RequestContextForm);
359 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FRAME,
360 WebURLRequest::RequestContextFrame);
361 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_HYPERLINK,
362 WebURLRequest::RequestContextHyperlink);
363 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IFRAME,
364 WebURLRequest::RequestContextIframe);
365 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IMAGE,
366 WebURLRequest::RequestContextImage);
367 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IMAGE_SET,
368 WebURLRequest::RequestContextImageSet);
369 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IMPORT,
370 WebURLRequest::RequestContextImport);
371 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_INTERNAL,
372 WebURLRequest::RequestContextInternal);
373 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_LOCATION,
374 WebURLRequest::RequestContextLocation);
375 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_MANIFEST,
376 WebURLRequest::RequestContextManifest);
377 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_OBJECT,
378 WebURLRequest::RequestContextObject);
379 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_PING,
380 WebURLRequest::RequestContextPing);
381 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_PLUGIN,
382 WebURLRequest::RequestContextPlugin);
383 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_PREFETCH,
384 WebURLRequest::RequestContextPrefetch);
385 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SCRIPT,
386 WebURLRequest::RequestContextScript);
387 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SERVICE_WORKER,
388 WebURLRequest::RequestContextServiceWorker);
389 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SHARED_WORKER,
390 WebURLRequest::RequestContextSharedWorker);
391 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SUBRESOURCE,
392 WebURLRequest::RequestContextSubresource);
393 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_STYLE,
394 WebURLRequest::RequestContextStyle);
395 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_TRACK,
396 WebURLRequest::RequestContextTrack);
397 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_VIDEO,
398 WebURLRequest::RequestContextVideo);
399 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_WORKER,
400 WebURLRequest::RequestContextWorker);
401 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_XML_HTTP_REQUEST,
402 WebURLRequest::RequestContextXMLHttpRequest);
403 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_XSLT,
404 WebURLRequest::RequestContextXSLT);
405
406 RequestContextType GetRequestContextTypeForWebURLRequest(
407 const blink::WebURLRequest& request) {
408 return static_cast<RequestContextType>(request.requestContext());
409 }
410
279 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url, 411 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url,
280 bool stale_copy_in_cache, 412 bool stale_copy_in_cache,
281 int reason) { 413 int reason) {
282 blink::WebURLError error; 414 blink::WebURLError error;
283 error.domain = WebString::fromUTF8(net::kErrorDomain); 415 error.domain = WebString::fromUTF8(net::kErrorDomain);
284 error.reason = reason; 416 error.reason = reason;
285 error.unreachableURL = unreachable_url; 417 error.unreachableURL = unreachable_url;
286 error.staleCopyInCache = stale_copy_in_cache; 418 error.staleCopyInCache = stale_copy_in_cache;
287 if (reason == net::ERR_ABORTED) { 419 if (reason == net::ERR_ABORTED) {
288 error.isCancellation = true; 420 error.isCancellation = true;
(...skipping 11 matching lines...) Expand all
300 bool stale_copy_in_cache, 432 bool stale_copy_in_cache,
301 int reason, 433 int reason,
302 bool was_ignored_by_handler) { 434 bool was_ignored_by_handler) {
303 blink::WebURLError error = 435 blink::WebURLError error =
304 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason); 436 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason);
305 error.wasIgnoredByHandler = was_ignored_by_handler; 437 error.wasIgnoredByHandler = was_ignored_by_handler;
306 return error; 438 return error;
307 } 439 }
308 440
309 } // namespace content 441 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_url_request_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698