| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. | 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. |
| 6 | 6 |
| 7 #include "webkit/glue/weburlloader_impl.h" | 7 #include "webkit/glue/weburlloader_impl.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 215 |
| 216 // If there's no received headers end time, don't set load timing. This is | 216 // If there's no received headers end time, don't set load timing. This is |
| 217 // the case for non-HTTP requests, requests that don't go over the wire, and | 217 // the case for non-HTTP requests, requests that don't go over the wire, and |
| 218 // certain error cases. | 218 // certain error cases. |
| 219 if (!info.load_timing.receive_headers_end.is_null()) { | 219 if (!info.load_timing.receive_headers_end.is_null()) { |
| 220 WebURLLoadTiming timing; | 220 WebURLLoadTiming timing; |
| 221 PopulateURLLoadTiming(info.load_timing, &timing); | 221 PopulateURLLoadTiming(info.load_timing, &timing); |
| 222 response->setLoadTiming(timing); | 222 response->setLoadTiming(timing); |
| 223 } | 223 } |
| 224 | 224 |
| 225 if (info.devtools_info) { | 225 if (info.devtools_info.get()) { |
| 226 WebHTTPLoadInfo load_info; | 226 WebHTTPLoadInfo load_info; |
| 227 | 227 |
| 228 load_info.setHTTPStatusCode(info.devtools_info->http_status_code); | 228 load_info.setHTTPStatusCode(info.devtools_info->http_status_code); |
| 229 load_info.setHTTPStatusText(WebString::fromUTF8( | 229 load_info.setHTTPStatusText(WebString::fromUTF8( |
| 230 info.devtools_info->http_status_text)); | 230 info.devtools_info->http_status_text)); |
| 231 load_info.setEncodedDataLength(info.encoded_data_length); | 231 load_info.setEncodedDataLength(info.encoded_data_length); |
| 232 | 232 |
| 233 load_info.setRequestHeadersText(WebString::fromUTF8( | 233 load_info.setRequestHeadersText(WebString::fromUTF8( |
| 234 info.devtools_info->request_headers_text)); | 234 info.devtools_info->request_headers_text)); |
| 235 load_info.setResponseHeadersText(WebString::fromUTF8( | 235 load_info.setResponseHeadersText(WebString::fromUTF8( |
| 236 info.devtools_info->response_headers_text)); | 236 info.devtools_info->response_headers_text)); |
| 237 const HeadersVector& request_headers = info.devtools_info->request_headers; | 237 const HeadersVector& request_headers = info.devtools_info->request_headers; |
| 238 for (HeadersVector::const_iterator it = request_headers.begin(); | 238 for (HeadersVector::const_iterator it = request_headers.begin(); |
| 239 it != request_headers.end(); ++it) { | 239 it != request_headers.end(); ++it) { |
| 240 load_info.addRequestHeader(WebString::fromUTF8(it->first), | 240 load_info.addRequestHeader(WebString::fromUTF8(it->first), |
| 241 WebString::fromUTF8(it->second)); | 241 WebString::fromUTF8(it->second)); |
| 242 } | 242 } |
| 243 const HeadersVector& response_headers = | 243 const HeadersVector& response_headers = |
| 244 info.devtools_info->response_headers; | 244 info.devtools_info->response_headers; |
| 245 for (HeadersVector::const_iterator it = response_headers.begin(); | 245 for (HeadersVector::const_iterator it = response_headers.begin(); |
| 246 it != response_headers.end(); ++it) { | 246 it != response_headers.end(); ++it) { |
| 247 load_info.addResponseHeader(WebString::fromUTF8(it->first), | 247 load_info.addResponseHeader(WebString::fromUTF8(it->first), |
| 248 WebString::fromUTF8(it->second)); | 248 WebString::fromUTF8(it->second)); |
| 249 } | 249 } |
| 250 response->setHTTPLoadInfo(load_info); | 250 response->setHTTPLoadInfo(load_info); |
| 251 } | 251 } |
| 252 | 252 |
| 253 const net::HttpResponseHeaders* headers = info.headers; | 253 const net::HttpResponseHeaders* headers = info.headers.get(); |
| 254 if (!headers) | 254 if (!headers) |
| 255 return; | 255 return; |
| 256 | 256 |
| 257 WebURLResponse::HTTPVersion version = WebURLResponse::Unknown; | 257 WebURLResponse::HTTPVersion version = WebURLResponse::Unknown; |
| 258 if (headers->GetHttpVersion() == net::HttpVersion(0, 9)) | 258 if (headers->GetHttpVersion() == net::HttpVersion(0, 9)) |
| 259 version = WebURLResponse::HTTP_0_9; | 259 version = WebURLResponse::HTTP_0_9; |
| 260 else if (headers->GetHttpVersion() == net::HttpVersion(1, 0)) | 260 else if (headers->GetHttpVersion() == net::HttpVersion(1, 0)) |
| 261 version = WebURLResponse::HTTP_1_0; | 261 version = WebURLResponse::HTTP_1_0; |
| 262 else if (headers->GetHttpVersion() == net::HttpVersion(1, 1)) | 262 else if (headers->GetHttpVersion() == net::HttpVersion(1, 1)) |
| 263 version = WebURLResponse::HTTP_1_1; | 263 version = WebURLResponse::HTTP_1_1; |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 break; | 545 break; |
| 546 } | 546 } |
| 547 case WebHTTPBody::Element::TypeBlob: | 547 case WebHTTPBody::Element::TypeBlob: |
| 548 request_body->AppendBlob(GURL(element.blobURL)); | 548 request_body->AppendBlob(GURL(element.blobURL)); |
| 549 break; | 549 break; |
| 550 default: | 550 default: |
| 551 NOTREACHED(); | 551 NOTREACHED(); |
| 552 } | 552 } |
| 553 } | 553 } |
| 554 request_body->set_identifier(request.httpBody().identifier()); | 554 request_body->set_identifier(request.httpBody().identifier()); |
| 555 bridge_->SetRequestBody(request_body); | 555 bridge_->SetRequestBody(request_body.get()); |
| 556 } | 556 } |
| 557 | 557 |
| 558 if (sync_load_response) { | 558 if (sync_load_response) { |
| 559 bridge_->SyncLoad(sync_load_response); | 559 bridge_->SyncLoad(sync_load_response); |
| 560 return; | 560 return; |
| 561 } | 561 } |
| 562 | 562 |
| 563 if (bridge_->Start(this)) { | 563 if (bridge_->Start(this)) { |
| 564 AddRef(); // Balanced in OnCompletedRequest | 564 AddRef(); // Balanced in OnCompletedRequest |
| 565 } else { | 565 } else { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 639 |
| 640 client_->didReceiveResponse(loader_, response); | 640 client_->didReceiveResponse(loader_, response); |
| 641 | 641 |
| 642 // We may have been cancelled after didReceiveResponse, which would leave us | 642 // We may have been cancelled after didReceiveResponse, which would leave us |
| 643 // without a client and therefore without much need to do further handling. | 643 // without a client and therefore without much need to do further handling. |
| 644 if (!client_) | 644 if (!client_) |
| 645 return; | 645 return; |
| 646 | 646 |
| 647 DCHECK(!ftp_listing_delegate_.get()); | 647 DCHECK(!ftp_listing_delegate_.get()); |
| 648 DCHECK(!multipart_delegate_.get()); | 648 DCHECK(!multipart_delegate_.get()); |
| 649 if (info.headers && info.mime_type == "multipart/x-mixed-replace") { | 649 if (info.headers.get() && info.mime_type == "multipart/x-mixed-replace") { |
| 650 std::string content_type; | 650 std::string content_type; |
| 651 info.headers->EnumerateHeader(NULL, "content-type", &content_type); | 651 info.headers->EnumerateHeader(NULL, "content-type", &content_type); |
| 652 | 652 |
| 653 std::string mime_type; | 653 std::string mime_type; |
| 654 std::string charset; | 654 std::string charset; |
| 655 bool had_charset = false; | 655 bool had_charset = false; |
| 656 std::string boundary; | 656 std::string boundary; |
| 657 net::HttpUtil::ParseContentType(content_type, &mime_type, &charset, | 657 net::HttpUtil::ParseContentType(content_type, &mime_type, &charset, |
| 658 &had_charset, &boundary); | 658 &had_charset, &boundary); |
| 659 TrimString(boundary, " \"", &boundary); | 659 TrimString(boundary, " \"", &boundary); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 | 845 |
| 846 void WebURLLoaderImpl::setDefersLoading(bool value) { | 846 void WebURLLoaderImpl::setDefersLoading(bool value) { |
| 847 context_->SetDefersLoading(value); | 847 context_->SetDefersLoading(value); |
| 848 } | 848 } |
| 849 | 849 |
| 850 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { | 850 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { |
| 851 context_->DidChangePriority(new_priority); | 851 context_->DidChangePriority(new_priority); |
| 852 } | 852 } |
| 853 | 853 |
| 854 } // namespace webkit_glue | 854 } // namespace webkit_glue |
| OLD | NEW |