OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 ~Context() {} | 226 ~Context() {} |
227 | 227 |
228 void HandleDataURL(); | 228 void HandleDataURL(); |
229 | 229 |
230 WebURLLoaderImpl* loader_; | 230 WebURLLoaderImpl* loader_; |
231 WebURLRequest request_; | 231 WebURLRequest request_; |
232 WebURLLoaderClient* client_; | 232 WebURLLoaderClient* client_; |
233 scoped_ptr<ResourceLoaderBridge> bridge_; | 233 scoped_ptr<ResourceLoaderBridge> bridge_; |
234 scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_; | 234 scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_; |
235 scoped_ptr<MultipartResponseDelegate> multipart_delegate_; | 235 scoped_ptr<MultipartResponseDelegate> multipart_delegate_; |
236 int64 expected_content_length_; | |
237 }; | 236 }; |
238 | 237 |
239 WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader) | 238 WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader) |
240 : loader_(loader), | 239 : loader_(loader), |
241 client_(NULL) { | 240 client_(NULL) { |
242 } | 241 } |
243 | 242 |
244 void WebURLLoaderImpl::Context::Cancel() { | 243 void WebURLLoaderImpl::Context::Cancel() { |
245 // The bridge will still send OnCompletedRequest, which will Release() us, so | 244 // The bridge will still send OnCompletedRequest, which will Release() us, so |
246 // we don't do that here. | 245 // we don't do that here. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 const ResourceLoaderBridge::ResponseInfo& info, | 424 const ResourceLoaderBridge::ResponseInfo& info, |
426 bool content_filtered) { | 425 bool content_filtered) { |
427 if (!client_) | 426 if (!client_) |
428 return; | 427 return; |
429 | 428 |
430 WebURLResponse response; | 429 WebURLResponse response; |
431 response.initialize(); | 430 response.initialize(); |
432 PopulateURLResponse(request_.url(), info, &response); | 431 PopulateURLResponse(request_.url(), info, &response); |
433 response.setIsContentFiltered(content_filtered); | 432 response.setIsContentFiltered(content_filtered); |
434 | 433 |
435 expected_content_length_ = response.expectedContentLength(); | |
436 | |
437 if (info.mime_type == "text/vnd.chromium.ftp-dir") | 434 if (info.mime_type == "text/vnd.chromium.ftp-dir") |
438 response.setMIMEType(WebString::fromUTF8("text/html")); | 435 response.setMIMEType(WebString::fromUTF8("text/html")); |
439 | 436 |
440 client_->didReceiveResponse(loader_, response); | 437 client_->didReceiveResponse(loader_, response); |
441 | 438 |
442 // We may have been cancelled after didReceiveResponse, which would leave us | 439 // We may have been cancelled after didReceiveResponse, which would leave us |
443 // without a client and therefore without much need to do further handling. | 440 // without a client and therefore without much need to do further handling. |
444 if (!client_) | 441 if (!client_) |
445 return; | 442 return; |
446 | 443 |
(...skipping 24 matching lines...) Expand all Loading... |
471 | 468 |
472 if (ftp_listing_delegate_.get()) { | 469 if (ftp_listing_delegate_.get()) { |
473 // The FTP listing delegate will make the appropriate calls to | 470 // The FTP listing delegate will make the appropriate calls to |
474 // client_->didReceiveData and client_->didReceiveResponse. | 471 // client_->didReceiveData and client_->didReceiveResponse. |
475 ftp_listing_delegate_->OnReceivedData(data, len); | 472 ftp_listing_delegate_->OnReceivedData(data, len); |
476 } else if (multipart_delegate_.get()) { | 473 } else if (multipart_delegate_.get()) { |
477 // The multipart delegate will make the appropriate calls to | 474 // The multipart delegate will make the appropriate calls to |
478 // client_->didReceiveData and client_->didReceiveResponse. | 475 // client_->didReceiveData and client_->didReceiveResponse. |
479 multipart_delegate_->OnReceivedData(data, len); | 476 multipart_delegate_->OnReceivedData(data, len); |
480 } else { | 477 } else { |
481 client_->didReceiveData(loader_, data, len, expected_content_length_); | 478 client_->didReceiveData(loader_, data, len); |
482 } | 479 } |
483 } | 480 } |
484 | 481 |
485 void WebURLLoaderImpl::Context::OnCompletedRequest( | 482 void WebURLLoaderImpl::Context::OnCompletedRequest( |
486 const URLRequestStatus& status, | 483 const URLRequestStatus& status, |
487 const std::string& security_info) { | 484 const std::string& security_info) { |
488 if (ftp_listing_delegate_.get()) { | 485 if (ftp_listing_delegate_.get()) { |
489 ftp_listing_delegate_->OnCompletedRequest(); | 486 ftp_listing_delegate_->OnCompletedRequest(); |
490 ftp_listing_delegate_.reset(NULL); | 487 ftp_listing_delegate_.reset(NULL); |
491 } else if (multipart_delegate_.get()) { | 488 } else if (multipart_delegate_.get()) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 584 |
588 void WebURLLoaderImpl::cancel() { | 585 void WebURLLoaderImpl::cancel() { |
589 context_->Cancel(); | 586 context_->Cancel(); |
590 } | 587 } |
591 | 588 |
592 void WebURLLoaderImpl::setDefersLoading(bool value) { | 589 void WebURLLoaderImpl::setDefersLoading(bool value) { |
593 context_->SetDefersLoading(value); | 590 context_->SetDefersLoading(value); |
594 } | 591 } |
595 | 592 |
596 } // namespace webkit_glue | 593 } // namespace webkit_glue |
OLD | NEW |