| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 prerender::PrerenderManager* GetPrerenderManager( | 147 prerender::PrerenderManager* GetPrerenderManager( |
| 148 content::WebContents* web_contents) { | 148 content::WebContents* web_contents) { |
| 149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 150 if (!web_contents) | 150 if (!web_contents) |
| 151 return NULL; | 151 return NULL; |
| 152 | 152 |
| 153 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); | 153 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); |
| 154 if (!browser_context) | 154 if (!browser_context) |
| 155 return NULL; | 155 return NULL; |
| 156 | 156 |
| 157 Profile* profile = Profile::FromBrowserContext(browser_context); | 157 return prerender::PrerenderManagerFactory::GetForBrowserContext( |
| 158 if (!profile) | 158 browser_context); |
| 159 return NULL; | |
| 160 | |
| 161 return prerender::PrerenderManagerFactory::GetForProfile(profile); | |
| 162 } | 159 } |
| 163 | 160 |
| 164 void UpdatePrerenderNetworkBytesCallback(content::WebContents* web_contents, | 161 void UpdatePrerenderNetworkBytesCallback(content::WebContents* web_contents, |
| 165 int64_t bytes) { | 162 int64_t bytes) { |
| 166 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 163 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 167 // PrerenderContents::FromWebContents handles the NULL case. | 164 // PrerenderContents::FromWebContents handles the NULL case. |
| 168 prerender::PrerenderContents* prerender_contents = | 165 prerender::PrerenderContents* prerender_contents = |
| 169 prerender::PrerenderContents::FromWebContents(web_contents); | 166 prerender::PrerenderContents::FromWebContents(web_contents); |
| 170 | 167 |
| 171 if (prerender_contents) | 168 if (prerender_contents) |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 861 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 865 base::Unretained(this), url, request_loading_time)); | 862 base::Unretained(this), url, request_loading_time)); |
| 866 return; | 863 return; |
| 867 } | 864 } |
| 868 | 865 |
| 869 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 866 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 870 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 867 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 871 rappor::SampleDomainAndRegistryFromGURL( | 868 rappor::SampleDomainAndRegistryFromGURL( |
| 872 g_browser_process->rappor_service(), metric_name, url); | 869 g_browser_process->rappor_service(), metric_name, url); |
| 873 } | 870 } |
| OLD | NEW |