| 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 #ifndef CHROME_BROWSER_NET_PRERENDER_INTERCEPTOR_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_INTERCEPTOR_H_ |
| 6 #define CHROME_BROWSER_NET_PRERENDER_INTERCEPTOR_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_INTERCEPTOR_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 | 15 |
| 16 namespace chrome_browser_net { | |
| 17 | |
| 18 // The PrerenderInterceptor watches prefetch requests, and when | 16 // The PrerenderInterceptor watches prefetch requests, and when |
| 19 // they are for type text/html, notifies the prerendering | 17 // they are for type text/html, notifies the prerendering |
| 20 // system about the fetch so it may consider the URL. | 18 // system about the fetch so it may consider the URL. |
| 21 class PrerenderInterceptor : public URLRequest::Interceptor { | 19 class PrerenderInterceptor : public net::URLRequest::Interceptor { |
| 22 public: | 20 public: |
| 23 PrerenderInterceptor(); | 21 PrerenderInterceptor(); |
| 24 virtual ~PrerenderInterceptor(); | 22 virtual ~PrerenderInterceptor(); |
| 25 | 23 |
| 26 // URLRequest::Interceptor overrides. We only care about | 24 // URLRequest::Interceptor overrides. We only care about |
| 27 // MaybeInterceptResponse, but must capture MaybeIntercept since | 25 // MaybeInterceptResponse, but must capture MaybeIntercept since |
| 28 // it is pure virtual. | 26 // it is pure virtual. |
| 29 virtual URLRequestJob* MaybeIntercept(URLRequest* request); | 27 virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request); |
| 30 virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request); | 28 virtual net::URLRequestJob* MaybeInterceptResponse(net::URLRequest* request); |
| 31 | 29 |
| 32 private: | 30 private: |
| 33 friend class PrerenderInterceptorTest; | 31 friend class PrerenderInterceptorTest; |
| 34 | 32 |
| 35 typedef Callback1<const GURL&>::Type PrerenderInterceptorCallback; | 33 typedef Callback1<const GURL&>::Type PrerenderInterceptorCallback; |
| 36 | 34 |
| 37 // This constructor is provided for the unit test only, to provide | 35 // This constructor is provided for the unit test only, to provide |
| 38 // an an alternative dispatch target for the test only. The callback | 36 // an an alternative dispatch target for the test only. The callback |
| 39 // parameter is owned and deleted by this object. | 37 // parameter is owned and deleted by this object. |
| 40 explicit PrerenderInterceptor(PrerenderInterceptorCallback* callback); | 38 explicit PrerenderInterceptor(PrerenderInterceptorCallback* callback); |
| 41 | 39 |
| 42 void RunCallbackFromUIThread(const GURL& url); | 40 void RunCallbackFromUIThread(const GURL& url); |
| 43 void PrerenderDispatch(const GURL& url); | 41 void PrerenderDispatch(const GURL& url); |
| 44 | 42 |
| 45 scoped_ptr<PrerenderInterceptorCallback> callback_; | 43 scoped_ptr<PrerenderInterceptorCallback> callback_; |
| 46 | 44 |
| 47 DISALLOW_COPY_AND_ASSIGN(PrerenderInterceptor); | 45 DISALLOW_COPY_AND_ASSIGN(PrerenderInterceptor); |
| 48 }; | 46 }; |
| 49 | 47 |
| 50 } // namespace chrome_browser_net | 48 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_INTERCEPTOR_H_ |
| 51 | 49 |
| 52 #endif // CHROME_BROWSER_NET_PRERENDER_INTERCEPTOR_H_ | |
| 53 | |
| OLD | NEW |