| 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 <stdint.h> |
| 8 |
| 9 #include <limits> |
| 10 |
| 7 #include "base/logging.h" | 11 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 9 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
| 10 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 11 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" | 15 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" |
| 12 #include "third_party/WebKit/public/platform/WebString.h" | 16 #include "third_party/WebKit/public/platform/WebString.h" |
| 13 #include "third_party/WebKit/public/platform/WebURL.h" | 17 #include "third_party/WebKit/public/platform/WebURL.h" |
| 14 #include "third_party/WebKit/public/platform/WebURLError.h" | 18 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 15 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 19 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 16 | 20 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 if (!element.data.isEmpty()) { | 242 if (!element.data.isEmpty()) { |
| 239 // Blink sometimes gives empty data to append. These aren't | 243 // Blink sometimes gives empty data to append. These aren't |
| 240 // necessary so they are just optimized out here. | 244 // necessary so they are just optimized out here. |
| 241 request_body->AppendBytes( | 245 request_body->AppendBytes( |
| 242 element.data.data(), static_cast<int>(element.data.size())); | 246 element.data.data(), static_cast<int>(element.data.size())); |
| 243 } | 247 } |
| 244 break; | 248 break; |
| 245 case WebHTTPBody::Element::TypeFile: | 249 case WebHTTPBody::Element::TypeFile: |
| 246 if (element.fileLength == -1) { | 250 if (element.fileLength == -1) { |
| 247 request_body->AppendFileRange( | 251 request_body->AppendFileRange( |
| 248 base::FilePath::FromUTF16Unsafe(element.filePath), | 252 base::FilePath::FromUTF16Unsafe(element.filePath), 0, |
| 249 0, kuint64max, base::Time()); | 253 std::numeric_limits<uint64_t>::max(), base::Time()); |
| 250 } else { | 254 } else { |
| 251 request_body->AppendFileRange( | 255 request_body->AppendFileRange( |
| 252 base::FilePath::FromUTF16Unsafe(element.filePath), | 256 base::FilePath::FromUTF16Unsafe(element.filePath), |
| 253 static_cast<uint64>(element.fileStart), | 257 static_cast<uint64_t>(element.fileStart), |
| 254 static_cast<uint64>(element.fileLength), | 258 static_cast<uint64_t>(element.fileLength), |
| 255 base::Time::FromDoubleT(element.modificationTime)); | 259 base::Time::FromDoubleT(element.modificationTime)); |
| 256 } | 260 } |
| 257 break; | 261 break; |
| 258 case WebHTTPBody::Element::TypeFileSystemURL: { | 262 case WebHTTPBody::Element::TypeFileSystemURL: { |
| 259 GURL file_system_url = element.fileSystemURL; | 263 GURL file_system_url = element.fileSystemURL; |
| 260 DCHECK(file_system_url.SchemeIsFileSystem()); | 264 DCHECK(file_system_url.SchemeIsFileSystem()); |
| 261 request_body->AppendFileSystemFileRange( | 265 request_body->AppendFileSystemFileRange( |
| 262 file_system_url, | 266 file_system_url, static_cast<uint64_t>(element.fileStart), |
| 263 static_cast<uint64>(element.fileStart), | 267 static_cast<uint64_t>(element.fileLength), |
| 264 static_cast<uint64>(element.fileLength), | |
| 265 base::Time::FromDoubleT(element.modificationTime)); | 268 base::Time::FromDoubleT(element.modificationTime)); |
| 266 break; | 269 break; |
| 267 } | 270 } |
| 268 case WebHTTPBody::Element::TypeBlob: | 271 case WebHTTPBody::Element::TypeBlob: |
| 269 request_body->AppendBlob(element.blobUUID.utf8()); | 272 request_body->AppendBlob(element.blobUUID.utf8()); |
| 270 break; | 273 break; |
| 271 default: | 274 default: |
| 272 NOTREACHED(); | 275 NOTREACHED(); |
| 273 } | 276 } |
| 274 } | 277 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 bool stale_copy_in_cache, | 437 bool stale_copy_in_cache, |
| 435 int reason, | 438 int reason, |
| 436 bool was_ignored_by_handler) { | 439 bool was_ignored_by_handler) { |
| 437 blink::WebURLError error = | 440 blink::WebURLError error = |
| 438 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason); | 441 CreateWebURLError(unreachable_url, stale_copy_in_cache, reason); |
| 439 error.wasIgnoredByHandler = was_ignored_by_handler; | 442 error.wasIgnoredByHandler = was_ignored_by_handler; |
| 440 return error; | 443 return error; |
| 441 } | 444 } |
| 442 | 445 |
| 443 } // namespace content | 446 } // namespace content |
| OLD | NEW |