| 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> |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 http_body.initialize(); | 238 http_body.initialize(); |
| 239 http_body.setIdentifier(input->identifier()); | 239 http_body.setIdentifier(input->identifier()); |
| 240 http_body.setContainsPasswordData(input->contains_sensitive_info()); | 240 http_body.setContainsPasswordData(input->contains_sensitive_info()); |
| 241 for (const auto& element : *input->elements()) { | 241 for (const auto& element : *input->elements()) { |
| 242 switch (element.type()) { | 242 switch (element.type()) { |
| 243 case ResourceRequestBodyImpl::Element::TYPE_BYTES: | 243 case ResourceRequestBodyImpl::Element::TYPE_BYTES: |
| 244 http_body.appendData(WebData(element.bytes(), element.length())); | 244 http_body.appendData(WebData(element.bytes(), element.length())); |
| 245 break; | 245 break; |
| 246 case ResourceRequestBodyImpl::Element::TYPE_FILE: | 246 case ResourceRequestBodyImpl::Element::TYPE_FILE: |
| 247 http_body.appendFileRange( | 247 http_body.appendFileRange( |
| 248 element.path().AsUTF16Unsafe(), element.offset(), | 248 blink::FilePathToWebString(element.path()), element.offset(), |
| 249 (element.length() != std::numeric_limits<uint64_t>::max()) | 249 (element.length() != std::numeric_limits<uint64_t>::max()) |
| 250 ? element.length() | 250 ? element.length() |
| 251 : -1, | 251 : -1, |
| 252 element.expected_modification_time().ToDoubleT()); | 252 element.expected_modification_time().ToDoubleT()); |
| 253 break; | 253 break; |
| 254 case ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM: | 254 case ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM: |
| 255 http_body.appendFileSystemURLRange( | 255 http_body.appendFileSystemURLRange( |
| 256 element.filesystem_url(), element.offset(), | 256 element.filesystem_url(), element.offset(), |
| 257 (element.length() != std::numeric_limits<uint64_t>::max()) | 257 (element.length() != std::numeric_limits<uint64_t>::max()) |
| 258 ? element.length() | 258 ? element.length() |
| 259 : -1, | 259 : -1, |
| 260 element.expected_modification_time().ToDoubleT()); | 260 element.expected_modification_time().ToDoubleT()); |
| 261 break; | 261 break; |
| 262 case ResourceRequestBodyImpl::Element::TYPE_BLOB: | 262 case ResourceRequestBodyImpl::Element::TYPE_BLOB: |
| 263 http_body.appendBlob(WebString::fromUTF8(element.blob_uuid())); | 263 http_body.appendBlob(WebString::fromASCII(element.blob_uuid())); |
| 264 break; | 264 break; |
| 265 case ResourceRequestBodyImpl::Element::TYPE_BYTES_DESCRIPTION: | 265 case ResourceRequestBodyImpl::Element::TYPE_BYTES_DESCRIPTION: |
| 266 case ResourceRequestBodyImpl::Element::TYPE_DISK_CACHE_ENTRY: | 266 case ResourceRequestBodyImpl::Element::TYPE_DISK_CACHE_ENTRY: |
| 267 default: | 267 default: |
| 268 NOTREACHED(); | 268 NOTREACHED(); |
| 269 break; | 269 break; |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 return http_body; | 272 return http_body; |
| 273 } | 273 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 480 |
| 481 SkipServiceWorker GetSkipServiceWorkerForWebURLRequest( | 481 SkipServiceWorker GetSkipServiceWorkerForWebURLRequest( |
| 482 const blink::WebURLRequest& request) { | 482 const blink::WebURLRequest& request) { |
| 483 return static_cast<SkipServiceWorker>(request.skipServiceWorker()); | 483 return static_cast<SkipServiceWorker>(request.skipServiceWorker()); |
| 484 } | 484 } |
| 485 | 485 |
| 486 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url, | 486 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url, |
| 487 bool stale_copy_in_cache, | 487 bool stale_copy_in_cache, |
| 488 int reason) { | 488 int reason) { |
| 489 blink::WebURLError error; | 489 blink::WebURLError error; |
| 490 error.domain = WebString::fromUTF8(net::kErrorDomain); | 490 error.domain = WebString::fromASCII(net::kErrorDomain); |
| 491 error.reason = reason; | 491 error.reason = reason; |
| 492 error.unreachableURL = unreachable_url; | 492 error.unreachableURL = unreachable_url; |
| 493 error.staleCopyInCache = stale_copy_in_cache; | 493 error.staleCopyInCache = stale_copy_in_cache; |
| 494 if (reason == net::ERR_ABORTED) { | 494 if (reason == net::ERR_ABORTED) { |
| 495 error.isCancellation = true; | 495 error.isCancellation = true; |
| 496 } else if (reason == net::ERR_CACHE_MISS) { | 496 } else if (reason == net::ERR_CACHE_MISS) { |
| 497 error.isCacheMiss = true; | 497 error.isCacheMiss = true; |
| 498 } else if (reason == net::ERR_TEMPORARILY_THROTTLED) { | 498 } else if (reason == net::ERR_TEMPORARILY_THROTTLED) { |
| 499 error.localizedDescription = | 499 error.localizedDescription = |
| 500 WebString::fromUTF8(kThrottledErrorDescription); | 500 WebString::fromASCII(kThrottledErrorDescription); |
| 501 } else { | 501 } else { |
| 502 error.localizedDescription = | 502 error.localizedDescription = |
| 503 WebString::fromUTF8(net::ErrorToString(reason)); | 503 WebString::fromASCII(net::ErrorToString(reason)); |
| 504 } | 504 } |
| 505 return error; | 505 return error; |
| 506 } | 506 } |
| 507 | 507 |
| 508 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url, | 508 blink::WebURLError CreateWebURLError(const blink::WebURL& unreachable_url, |
| 509 bool stale_copy_in_cache, | 509 bool stale_copy_in_cache, |
| 510 int reason, | 510 int reason, |
| 511 bool was_ignored_by_handler) { | 511 bool was_ignored_by_handler) { |
| 512 blink::WebURLError error = | 512 blink::WebURLError error = |
| 513 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason); | 513 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason); |
| 514 error.wasIgnoredByHandler = was_ignored_by_handler; | 514 error.wasIgnoredByHandler = was_ignored_by_handler; |
| 515 return error; | 515 return error; |
| 516 } | 516 } |
| 517 | 517 |
| 518 } // namespace content | 518 } // namespace content |
| OLD | NEW |