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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 if (!rvh) | 121 if (!rvh) |
122 return NULL; | 122 return NULL; |
123 content::WebContents* web_contents = | 123 content::WebContents* web_contents = |
124 content::WebContents::FromRenderViewHost(rvh); | 124 content::WebContents::FromRenderViewHost(rvh); |
125 if (!web_contents) | 125 if (!web_contents) |
126 return NULL; | 126 return NULL; |
127 | 127 |
128 return prerender::PrerenderContents::FromWebContents(web_contents); | 128 return prerender::PrerenderContents::FromWebContents(web_contents); |
129 } | 129 } |
130 | 130 |
131 prerender::PrerenderManager* GetPrerenderManager(int render_process_id, | |
132 int render_view_id) { | |
133 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
134 | |
135 content::RenderViewHost* render_view_host = | |
136 content::RenderViewHost::FromID(render_process_id, render_view_id); | |
137 if (!render_view_host) | |
jochen (gone - plz use gerrit)
2014/02/19 16:54:24
when is that possible?
jkarlin
2014/02/19 17:31:58
Nearly everything that calls RenderViewHost::FromI
| |
138 return NULL; | |
139 | |
140 content::WebContents* web_contents = | |
141 content::WebContents::FromRenderViewHost(render_view_host); | |
142 if (!web_contents) | |
143 return NULL; | |
144 | |
145 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); | |
146 if (!browser_context) | |
147 return NULL; | |
jochen (gone - plz use gerrit)
2014/02/19 16:54:24
or this?
jkarlin
2014/02/19 17:31:58
Done.
| |
148 | |
149 Profile* profile = Profile::FromBrowserContext(browser_context); | |
150 if (!profile) | |
151 return NULL; | |
jochen (gone - plz use gerrit)
2014/02/19 16:54:24
or this?
jkarlin
2014/02/19 17:31:58
Done.
| |
152 | |
153 return prerender::PrerenderManagerFactory::GetForProfile(profile); | |
154 } | |
155 | |
131 void UpdatePrerenderNetworkBytesCallback(int render_process_id, | 156 void UpdatePrerenderNetworkBytesCallback(int render_process_id, |
132 int render_view_id, | 157 int render_view_id, |
133 int64 bytes) { | 158 int64 bytes) { |
134 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 159 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
135 | 160 |
136 prerender::PrerenderContents* prerender_contents = | 161 prerender::PrerenderContents* prerender_contents = |
137 FindPrerenderContents(render_process_id, render_view_id); | 162 FindPrerenderContents(render_process_id, render_view_id); |
138 | 163 |
139 if (!prerender_contents) | 164 if (prerender_contents) |
140 return; | 165 prerender_contents->AddNetworkBytes(bytes); |
141 prerender_contents->AddNetworkBytes(bytes); | 166 |
142 prerender_contents->prerender_manager()->AddProfileNetworkBytesIfEnabled( | 167 prerender::PrerenderManager* prerender_manager = |
143 bytes); | 168 GetPrerenderManager(render_process_id, render_view_id); |
169 if (prerender_manager) | |
170 prerender_manager->AddProfileNetworkBytesIfEnabled(bytes); | |
144 } | 171 } |
145 | 172 |
146 #if !defined(OS_ANDROID) | 173 #if !defined(OS_ANDROID) |
147 // Goes through the extension's file browser handlers and checks if there is one | 174 // Goes through the extension's file browser handlers and checks if there is one |
148 // that can handle the |mime_type|. | 175 // that can handle the |mime_type|. |
149 // |extension| must not be NULL. | 176 // |extension| must not be NULL. |
150 bool ExtensionCanHandleMimeType(const Extension* extension, | 177 bool ExtensionCanHandleMimeType(const Extension* extension, |
151 const std::string& mime_type) { | 178 const std::string& mime_type) { |
152 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 179 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
153 if (!handler) | 180 if (!handler) |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 url_request->GetTotalReceivedBytes())); | 693 url_request->GetTotalReceivedBytes())); |
667 } | 694 } |
668 } | 695 } |
669 | 696 |
670 // static | 697 // static |
671 void ChromeResourceDispatcherHostDelegate:: | 698 void ChromeResourceDispatcherHostDelegate:: |
672 SetExternalProtocolHandlerDelegateForTesting( | 699 SetExternalProtocolHandlerDelegateForTesting( |
673 ExternalProtocolHandler::Delegate* delegate) { | 700 ExternalProtocolHandler::Delegate* delegate) { |
674 g_external_protocol_handler_delegate = delegate; | 701 g_external_protocol_handler_delegate = delegate; |
675 } | 702 } |
OLD | NEW |