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 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_HANDLER_H_ |
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_HANDLER_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 public: | 30 public: |
31 // Creates a new PrerenderResourceHandler if appropriate for the | 31 // Creates a new PrerenderResourceHandler if appropriate for the |
32 // given |request| and |context|, otherwise NULL is returned. The | 32 // given |request| and |context|, otherwise NULL is returned. The |
33 // caller is resposible for deleting the returned handler. | 33 // caller is resposible for deleting the returned handler. |
34 // | 34 // |
35 // |next_handler| is the backup handler that this handler delegates to | 35 // |next_handler| is the backup handler that this handler delegates to |
36 // for the majority of the commands, and must be non-NULL. | 36 // for the majority of the commands, and must be non-NULL. |
37 static PrerenderResourceHandler* MaybeCreate( | 37 static PrerenderResourceHandler* MaybeCreate( |
38 const net::URLRequest& request, | 38 const net::URLRequest& request, |
39 ChromeURLRequestContext* context, | 39 ChromeURLRequestContext* context, |
40 ResourceHandler* next_handler); | 40 ResourceHandler* next_handler, |
41 bool is_from_prerender, int child_id, int route_id); | |
41 | 42 |
42 // OnResponseStarted will ask the |prerender_manager_| to start | 43 // OnResponseStarted will ask the |prerender_manager_| to start |
43 // prerendering the requested resource if it is of an appropriate | 44 // prerendering the requested resource if it is of an appropriate |
44 // content type. The next handler is still invoked. | 45 // content type. The next handler is still invoked. |
45 virtual bool OnResponseStarted(int request_id, | 46 virtual bool OnResponseStarted(int request_id, |
46 ResourceResponse* response); | 47 ResourceResponse* response); |
47 | 48 |
48 // The following methods simply delegate to the next_handler. | 49 // The following methods simply delegate to the next_handler. |
49 virtual bool OnUploadProgress(int request_id, | 50 virtual bool OnUploadProgress(int request_id, |
50 uint64 position, | 51 uint64 position, |
(...skipping 11 matching lines...) Expand all Loading... | |
62 virtual bool OnReadCompleted(int request_id, int* bytes_read); | 63 virtual bool OnReadCompleted(int request_id, int* bytes_read); |
63 | 64 |
64 virtual bool OnResponseCompleted(int request_id, | 65 virtual bool OnResponseCompleted(int request_id, |
65 const net::URLRequestStatus& status, | 66 const net::URLRequestStatus& status, |
66 const std::string& security_info); | 67 const std::string& security_info); |
67 | 68 |
68 virtual void OnRequestClosed(); | 69 virtual void OnRequestClosed(); |
69 | 70 |
70 private: | 71 private: |
71 friend class PrerenderResourceHandlerTest; | 72 friend class PrerenderResourceHandlerTest; |
72 typedef Callback3<const GURL&, | 73 typedef Callback5<std::pair<int, int>, |
mmenke
2011/03/21 21:18:58
You can make all 3 of these "const std::pair<int,
dominich
2011/03/22 15:54:45
Nice catch :)
| |
74 const GURL&, | |
73 const std::vector<GURL>&, | 75 const std::vector<GURL>&, |
74 const GURL&>::Type PrerenderCallback; | 76 const GURL&, |
77 bool>::Type PrerenderCallback; | |
75 | 78 |
76 PrerenderResourceHandler(const net::URLRequest& request, | 79 PrerenderResourceHandler(const net::URLRequest& request, |
77 ResourceHandler* next_handler, | 80 ResourceHandler* next_handler, |
78 PrerenderManager* prerender_manager); | 81 PrerenderManager* prerender_manager, |
82 bool make_pending, int child_id, int route_id); | |
79 | 83 |
80 // This constructor is only used from unit tests. | 84 // This constructor is only used from unit tests. |
81 PrerenderResourceHandler(const net::URLRequest& request, | 85 PrerenderResourceHandler(const net::URLRequest& request, |
82 ResourceHandler* next_handler, | 86 ResourceHandler* next_handler, |
83 PrerenderCallback* callback); | 87 PrerenderCallback* callback); |
84 | 88 |
85 virtual ~PrerenderResourceHandler(); | 89 virtual ~PrerenderResourceHandler(); |
86 | 90 |
87 void RunCallbackFromUIThread(const GURL& url, | 91 void RunCallbackFromUIThread(std::pair<int, int> child_route_id_pair, |
92 const GURL& url, | |
88 const std::vector<GURL>& alias_urls, | 93 const std::vector<GURL>& alias_urls, |
89 const GURL& referrer); | 94 const GURL& referrer, |
90 void StartPrerender(const GURL& url, | 95 bool make_pending); |
96 void StartPrerender(std::pair<int, int> child_route_id_pair, | |
97 const GURL& url, | |
91 const std::vector<GURL>& alias_urls, | 98 const std::vector<GURL>& alias_urls, |
92 const GURL& referrer); | 99 const GURL& referrer, |
100 bool make_pending); | |
93 | 101 |
94 // The set of URLs that are aliases to the URL to be prerendered, | 102 // The set of URLs that are aliases to the URL to be prerendered, |
95 // as a result of redirects, including the final URL. | 103 // as a result of redirects, including the final URL. |
96 std::vector<GURL> alias_urls_; | 104 std::vector<GURL> alias_urls_; |
97 GURL url_; | 105 GURL url_; |
98 scoped_refptr<ResourceHandler> next_handler_; | 106 scoped_refptr<ResourceHandler> next_handler_; |
99 scoped_refptr<PrerenderManager> prerender_manager_; | 107 scoped_refptr<PrerenderManager> prerender_manager_; |
100 scoped_ptr<PrerenderCallback> prerender_callback_; | 108 scoped_ptr<PrerenderCallback> prerender_callback_; |
101 | 109 |
102 // Used to obtain the referrer, but only after any redirections occur, as they | 110 // Used to obtain the referrer, but only after any redirections occur, as they |
103 // can result in the referrer being cleared. | 111 // can result in the referrer being cleared. |
104 const net::URLRequest& request_; | 112 const net::URLRequest& request_; |
105 | 113 |
114 int child_id_; | |
115 int route_id_; | |
116 | |
117 // True if we want to make this a pending prerender for later | |
118 bool make_pending_; | |
119 | |
106 DISALLOW_COPY_AND_ASSIGN(PrerenderResourceHandler); | 120 DISALLOW_COPY_AND_ASSIGN(PrerenderResourceHandler); |
107 }; | 121 }; |
108 | 122 |
109 } // namespace prerender | 123 } // namespace prerender |
110 | 124 |
111 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_HANDLER_H_ | 125 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_HANDLER_H_ |
OLD | NEW |