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/child/weburlloader_impl.h" | 7 #include "webkit/child/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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE; | 240 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE; |
241 virtual void OnReceivedData(const char* data, | 241 virtual void OnReceivedData(const char* data, |
242 int data_length, | 242 int data_length, |
243 int encoded_data_length) OVERRIDE; | 243 int encoded_data_length) OVERRIDE; |
244 virtual void OnReceivedCachedMetadata(const char* data, int len) OVERRIDE; | 244 virtual void OnReceivedCachedMetadata(const char* data, int len) OVERRIDE; |
245 virtual void OnCompletedRequest( | 245 virtual void OnCompletedRequest( |
246 int error_code, | 246 int error_code, |
247 bool was_ignored_by_handler, | 247 bool was_ignored_by_handler, |
248 const std::string& security_info, | 248 const std::string& security_info, |
249 const base::TimeTicks& completion_time) OVERRIDE; | 249 const base::TimeTicks& completion_time) OVERRIDE; |
| 250 virtual void OnStartedRequestForFrame() OVERRIDE; |
250 | 251 |
251 private: | 252 private: |
252 friend class base::RefCounted<Context>; | 253 friend class base::RefCounted<Context>; |
253 virtual ~Context() {} | 254 virtual ~Context() {} |
254 | 255 |
255 // We can optimize the handling of data URLs in most cases. | 256 // We can optimize the handling of data URLs in most cases. |
256 bool CanHandleDataURL(const GURL& url) const; | 257 bool CanHandleDataURL(const GURL& url) const; |
257 void HandleDataURL(); | 258 void HandleDataURL(); |
258 | 259 |
259 WebURLLoaderImpl* loader_; | 260 WebURLLoaderImpl* loader_; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 loader_, (completion_time - TimeTicks()).InSecondsF()); | 620 loader_, (completion_time - TimeTicks()).InSecondsF()); |
620 } | 621 } |
621 } | 622 } |
622 | 623 |
623 // We are done with the bridge now, and so we need to release the reference | 624 // We are done with the bridge now, and so we need to release the reference |
624 // to ourselves that we took on behalf of the bridge. This may cause our | 625 // to ourselves that we took on behalf of the bridge. This may cause our |
625 // destruction. | 626 // destruction. |
626 Release(); | 627 Release(); |
627 } | 628 } |
628 | 629 |
| 630 void WebURLLoaderImpl::Context::OnStartedRequestForFrame() { |
| 631 if (!client_) |
| 632 return; |
| 633 |
| 634 client_->didRequestStartForFrame(loader_); |
| 635 } |
| 636 |
629 bool WebURLLoaderImpl::Context::CanHandleDataURL(const GURL& url) const { | 637 bool WebURLLoaderImpl::Context::CanHandleDataURL(const GURL& url) const { |
630 DCHECK(url.SchemeIs("data")); | 638 DCHECK(url.SchemeIs("data")); |
631 | 639 |
632 // Optimize for the case where we can handle a data URL locally. We must | 640 // Optimize for the case where we can handle a data URL locally. We must |
633 // skip this for data URLs targetted at frames since those could trigger a | 641 // skip this for data URLs targetted at frames since those could trigger a |
634 // download. | 642 // download. |
635 // | 643 // |
636 // NOTE: We special case MIME types we can render both for performance | 644 // NOTE: We special case MIME types we can render both for performance |
637 // reasons as well as to support unit tests, which do not have an underlying | 645 // reasons as well as to support unit tests, which do not have an underlying |
638 // ResourceLoaderBridge implementation. | 646 // ResourceLoaderBridge implementation. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 | 856 |
849 void WebURLLoaderImpl::setDefersLoading(bool value) { | 857 void WebURLLoaderImpl::setDefersLoading(bool value) { |
850 context_->SetDefersLoading(value); | 858 context_->SetDefersLoading(value); |
851 } | 859 } |
852 | 860 |
853 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { | 861 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { |
854 context_->DidChangePriority(new_priority); | 862 context_->DidChangePriority(new_priority); |
855 } | 863 } |
856 | 864 |
857 } // namespace webkit_glue | 865 } // namespace webkit_glue |
OLD | NEW |