| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/net/prerender_interceptor.h" | 5 #include "chrome/browser/prerender/prerender_interceptor.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/io_thread.h" | 12 #include "chrome/browser/io_thread.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
| 15 | 15 |
| 16 DISABLE_RUNNABLE_METHOD_REFCOUNT(chrome_browser_net::PrerenderInterceptor); | 16 DISABLE_RUNNABLE_METHOD_REFCOUNT(PrerenderInterceptor); |
| 17 | |
| 18 namespace chrome_browser_net { | |
| 19 | 17 |
| 20 PrerenderInterceptor::PrerenderInterceptor() | 18 PrerenderInterceptor::PrerenderInterceptor() |
| 21 : ALLOW_THIS_IN_INITIALIZER_LIST( | 19 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 22 callback_(NewCallback(this, | 20 callback_(NewCallback(this, |
| 23 &PrerenderInterceptor::PrerenderDispatch))) { | 21 &PrerenderInterceptor::PrerenderDispatch))) { |
| 24 URLRequest::RegisterRequestInterceptor(this); | 22 net::URLRequest::RegisterRequestInterceptor(this); |
| 25 } | 23 } |
| 26 | 24 |
| 27 PrerenderInterceptor::PrerenderInterceptor( | 25 PrerenderInterceptor::PrerenderInterceptor( |
| 28 PrerenderInterceptorCallback* callback) | 26 PrerenderInterceptorCallback* callback) |
| 29 : callback_(callback) { | 27 : callback_(callback) { |
| 30 URLRequest::RegisterRequestInterceptor(this); | 28 net::URLRequest::RegisterRequestInterceptor(this); |
| 31 } | 29 } |
| 32 | 30 |
| 33 PrerenderInterceptor::~PrerenderInterceptor() { | 31 PrerenderInterceptor::~PrerenderInterceptor() { |
| 34 URLRequest::UnregisterRequestInterceptor(this); | 32 net::URLRequest::UnregisterRequestInterceptor(this); |
| 35 } | 33 } |
| 36 | 34 |
| 37 URLRequestJob* PrerenderInterceptor::MaybeIntercept(URLRequest* request) { | 35 net::URLRequestJob* PrerenderInterceptor::MaybeIntercept( |
| 36 net::URLRequest* request) { |
| 38 return NULL; | 37 return NULL; |
| 39 } | 38 } |
| 40 | 39 |
| 41 URLRequestJob* PrerenderInterceptor::MaybeInterceptResponse( | 40 net::URLRequestJob* PrerenderInterceptor::MaybeInterceptResponse( |
| 42 URLRequest* request) { | 41 net::URLRequest* request) { |
| 43 // TODO(gavinp): unfortunately, we can't figure out the origin | 42 // TODO(gavinp): unfortunately, we can't figure out the origin |
| 44 // of this request here on systems where the referrer is blocked by | 43 // of this request here on systems where the referrer is blocked by |
| 45 // configuration. | 44 // configuration. |
| 46 | 45 |
| 47 // TODO(gavinp): note that the response still might be intercepted | 46 // TODO(gavinp): note that the response still might be intercepted |
| 48 // by a later interceptor. Should we write an interposing delegate | 47 // by a later interceptor. Should we write an interposing delegate |
| 49 // and only prerender dispatch on requests that aren't intercepted? | 48 // and only prerender dispatch on requests that aren't intercepted? |
| 50 // Or is this a slippery slope? | 49 // Or is this a slippery slope? |
| 51 | 50 |
| 52 if (request->load_flags() & net::LOAD_PREFETCH) { | 51 if (request->load_flags() & net::LOAD_PREFETCH) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 68 callback_->Run(url); | 67 callback_->Run(url); |
| 69 } | 68 } |
| 70 | 69 |
| 71 void PrerenderInterceptor::PrerenderDispatch( | 70 void PrerenderInterceptor::PrerenderDispatch( |
| 72 const GURL& url) { | 71 const GURL& url) { |
| 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 74 DVLOG(2) << "PrerenderDispatchOnUIThread: url=" << url; | 73 DVLOG(2) << "PrerenderDispatchOnUIThread: url=" << url; |
| 75 } | 74 } |
| 76 | 75 |
| 77 } // namespace chrome_browser_net | |
| 78 | |
| OLD | NEW |