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/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 const HeadersVector& response_headers = | 219 const HeadersVector& response_headers = |
220 info.devtools_info->response_headers; | 220 info.devtools_info->response_headers; |
221 for (HeadersVector::const_iterator it = response_headers.begin(); | 221 for (HeadersVector::const_iterator it = response_headers.begin(); |
222 it != response_headers.end(); ++it) { | 222 it != response_headers.end(); ++it) { |
223 load_info.addResponseHeader(WebString::fromUTF8(it->first), | 223 load_info.addResponseHeader(WebString::fromUTF8(it->first), |
224 WebString::fromUTF8(it->second)); | 224 WebString::fromUTF8(it->second)); |
225 } | 225 } |
226 response->setHTTPLoadInfo(load_info); | 226 response->setHTTPLoadInfo(load_info); |
227 } | 227 } |
228 | 228 |
229 const net::HttpResponseHeaders* headers = info.headers; | 229 const net::HttpResponseHeaders* headers = info.headers.get(); |
230 if (!headers) | 230 if (!headers) |
231 return; | 231 return; |
232 | 232 |
233 WebURLResponse::HTTPVersion version = WebURLResponse::Unknown; | 233 WebURLResponse::HTTPVersion version = WebURLResponse::Unknown; |
234 if (headers->GetHttpVersion() == net::HttpVersion(0, 9)) | 234 if (headers->GetHttpVersion() == net::HttpVersion(0, 9)) |
235 version = WebURLResponse::HTTP_0_9; | 235 version = WebURLResponse::HTTP_0_9; |
236 else if (headers->GetHttpVersion() == net::HttpVersion(1, 0)) | 236 else if (headers->GetHttpVersion() == net::HttpVersion(1, 0)) |
237 version = WebURLResponse::HTTP_1_0; | 237 version = WebURLResponse::HTTP_1_0; |
238 else if (headers->GetHttpVersion() == net::HttpVersion(1, 1)) | 238 else if (headers->GetHttpVersion() == net::HttpVersion(1, 1)) |
239 version = WebURLResponse::HTTP_1_1; | 239 version = WebURLResponse::HTTP_1_1; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 break; | 481 break; |
482 } | 482 } |
483 case WebHTTPBody::Element::TypeBlob: | 483 case WebHTTPBody::Element::TypeBlob: |
484 request_body->AppendBlob(GURL(element.blobURL)); | 484 request_body->AppendBlob(GURL(element.blobURL)); |
485 break; | 485 break; |
486 default: | 486 default: |
487 NOTREACHED(); | 487 NOTREACHED(); |
488 } | 488 } |
489 } | 489 } |
490 request_body->set_identifier(request.httpBody().identifier()); | 490 request_body->set_identifier(request.httpBody().identifier()); |
491 bridge_->SetRequestBody(request_body); | 491 bridge_->SetRequestBody(request_body.get()); |
492 } | 492 } |
493 | 493 |
494 if (sync_load_response) { | 494 if (sync_load_response) { |
495 bridge_->SyncLoad(sync_load_response); | 495 bridge_->SyncLoad(sync_load_response); |
496 return; | 496 return; |
497 } | 497 } |
498 | 498 |
499 if (bridge_->Start(this)) { | 499 if (bridge_->Start(this)) { |
500 AddRef(); // Balanced in OnCompletedRequest | 500 AddRef(); // Balanced in OnCompletedRequest |
501 } else { | 501 } else { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 | 575 |
576 client_->didReceiveResponse(loader_, response); | 576 client_->didReceiveResponse(loader_, response); |
577 | 577 |
578 // We may have been cancelled after didReceiveResponse, which would leave us | 578 // We may have been cancelled after didReceiveResponse, which would leave us |
579 // without a client and therefore without much need to do further handling. | 579 // without a client and therefore without much need to do further handling. |
580 if (!client_) | 580 if (!client_) |
581 return; | 581 return; |
582 | 582 |
583 DCHECK(!ftp_listing_delegate_.get()); | 583 DCHECK(!ftp_listing_delegate_.get()); |
584 DCHECK(!multipart_delegate_.get()); | 584 DCHECK(!multipart_delegate_.get()); |
585 if (info.headers && info.mime_type == "multipart/x-mixed-replace") { | 585 if (info.headers.get() && info.mime_type == "multipart/x-mixed-replace") { |
586 std::string content_type; | 586 std::string content_type; |
587 info.headers->EnumerateHeader(NULL, "content-type", &content_type); | 587 info.headers->EnumerateHeader(NULL, "content-type", &content_type); |
588 | 588 |
589 std::string mime_type; | 589 std::string mime_type; |
590 std::string charset; | 590 std::string charset; |
591 bool had_charset = false; | 591 bool had_charset = false; |
592 std::string boundary; | 592 std::string boundary; |
593 net::HttpUtil::ParseContentType(content_type, &mime_type, &charset, | 593 net::HttpUtil::ParseContentType(content_type, &mime_type, &charset, |
594 &had_charset, &boundary); | 594 &had_charset, &boundary); |
595 TrimString(boundary, " \"", &boundary); | 595 TrimString(boundary, " \"", &boundary); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 | 772 |
773 void WebURLLoaderImpl::cancel() { | 773 void WebURLLoaderImpl::cancel() { |
774 context_->Cancel(); | 774 context_->Cancel(); |
775 } | 775 } |
776 | 776 |
777 void WebURLLoaderImpl::setDefersLoading(bool value) { | 777 void WebURLLoaderImpl::setDefersLoading(bool value) { |
778 context_->SetDefersLoading(value); | 778 context_->SetDefersLoading(value); |
779 } | 779 } |
780 | 780 |
781 } // namespace webkit_glue | 781 } // namespace webkit_glue |
OLD | NEW |