| 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 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 target_info.extension_id = extension_id; | 715 target_info.extension_id = extension_id; |
| 716 stream_target_info_[request] = target_info; | 716 stream_target_info_[request] = target_info; |
| 717 return true; | 717 return true; |
| 718 } | 718 } |
| 719 } | 719 } |
| 720 } | 720 } |
| 721 #endif | 721 #endif |
| 722 return false; | 722 return false; |
| 723 } | 723 } |
| 724 | 724 |
| 725 bool ChromeResourceDispatcherHostDelegate::ShouldSinkResponse( |
| 726 net::URLRequest* request, |
| 727 ResourceType resource_type) { |
| 728 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) |
| 729 return false; |
| 730 |
| 731 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 732 if (info->GetVisibilityState() != blink::WebPageVisibilityStatePrerender) |
| 733 return false; |
| 734 |
| 735 // TODO: Use this when implemented. Could there be a race condition though? |
| 736 // return prerender::PrerenderManager::GetMode() == |
| 737 // prerender::PRERENDER_MODE_NOSTATE_PREFETCH; |
| 738 return true; |
| 739 } |
| 740 |
| 725 void ChromeResourceDispatcherHostDelegate::OnStreamCreated( | 741 void ChromeResourceDispatcherHostDelegate::OnStreamCreated( |
| 726 net::URLRequest* request, | 742 net::URLRequest* request, |
| 727 std::unique_ptr<content::StreamInfo> stream) { | 743 std::unique_ptr<content::StreamInfo> stream) { |
| 728 #if defined(ENABLE_EXTENSIONS) | 744 #if defined(ENABLE_EXTENSIONS) |
| 729 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 745 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 730 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix = | 746 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix = |
| 731 stream_target_info_.find(request); | 747 stream_target_info_.find(request); |
| 732 CHECK(ix != stream_target_info_.end()); | 748 CHECK(ix != stream_target_info_.end()); |
| 733 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; | 749 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; |
| 734 content::BrowserThread::PostTask( | 750 content::BrowserThread::PostTask( |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 906 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 891 base::Unretained(this), url, request_loading_time)); | 907 base::Unretained(this), url, request_loading_time)); |
| 892 return; | 908 return; |
| 893 } | 909 } |
| 894 | 910 |
| 895 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 911 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 896 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 912 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 897 rappor::SampleDomainAndRegistryFromGURL( | 913 rappor::SampleDomainAndRegistryFromGURL( |
| 898 g_browser_process->rappor_service(), metric_name, url); | 914 g_browser_process->rappor_service(), metric_name, url); |
| 899 } | 915 } |
| OLD | NEW |