| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/prerender/prerender_resource_handler.h" | 5 #include "chrome/browser/prerender/prerender_resource_handler.h" |
| 6 | 6 |
| 7 #include "chrome/browser/net/chrome_url_request_context.h" | 7 #include "chrome/browser/net/chrome_url_request_context.h" |
| 8 #include "chrome/common/resource_response.h" | 8 #include "chrome/common/resource_response.h" |
| 9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
| 10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
| 11 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 bool ShouldPrerender(const GURL& url, const ResourceResponse* response) { | 15 bool ShouldPrerender(const GURL& url, const ResourceResponse* response) { |
| 16 if (!response) | 16 if (!response) |
| 17 return false; | 17 return false; |
| 18 const ResourceResponseHead& rrh = response->response_head; | 18 const ResourceResponseHead& rrh = response->response_head; |
| 19 if (!url.is_valid()) | 19 if (!url.is_valid()) |
| 20 return false; | 20 return false; |
| 21 if (!rrh.headers) | 21 if (!rrh.headers) |
| 22 return false; | 22 return false; |
| 23 if (!(url.SchemeIs("http") || url.SchemeIs("https"))) | 23 if (!(url.SchemeIs("http") || url.SchemeIs("https") || |
| 24 url.SchemeIs("httpsv"))) |
| 24 return false; | 25 return false; |
| 25 if (rrh.mime_type != "text/html") | 26 if (rrh.mime_type != "text/html") |
| 26 return false; | 27 return false; |
| 27 if (rrh.headers->response_code() != 200) | 28 if (rrh.headers->response_code() != 200) |
| 28 return false; | 29 return false; |
| 29 return true; | 30 return true; |
| 30 } | 31 } |
| 31 | 32 |
| 32 } // namespace | 33 } // namespace |
| 33 | 34 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 145 prerender_callback_->Run(url, alias_urls); | 146 prerender_callback_->Run(url, alias_urls); |
| 146 } | 147 } |
| 147 | 148 |
| 148 void PrerenderResourceHandler::StartPrerender(const GURL& url, | 149 void PrerenderResourceHandler::StartPrerender(const GURL& url, |
| 149 const std::vector<GURL>& | 150 const std::vector<GURL>& |
| 150 alias_urls) { | 151 alias_urls) { |
| 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 152 prerender_manager_->AddPreload(url, alias_urls); | 153 prerender_manager_->AddPreload(url, alias_urls); |
| 153 } | 154 } |
| OLD | NEW |