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 <deque> | 5 #include <deque> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 default: | 63 default: |
64 return false; | 64 return false; |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 // PrerenderContents that stops the UI message loop on DidStopLoading(). | 68 // PrerenderContents that stops the UI message loop on DidStopLoading(). |
69 class TestPrerenderContents : public PrerenderContents { | 69 class TestPrerenderContents : public PrerenderContents { |
70 public: | 70 public: |
71 TestPrerenderContents( | 71 TestPrerenderContents( |
72 PrerenderManager* prerender_manager, | 72 PrerenderManager* prerender_manager, |
| 73 PrerenderTracker* prerender_tracker, |
73 Profile* profile, | 74 Profile* profile, |
74 const GURL& url, | 75 const GURL& url, |
75 const GURL& referrer, | 76 const GURL& referrer, |
76 int number_of_loads, | 77 int number_of_loads, |
77 FinalStatus expected_final_status) | 78 FinalStatus expected_final_status) |
78 : PrerenderContents(prerender_manager, profile, url, referrer), | 79 : PrerenderContents(prerender_manager, prerender_tracker, profile, |
| 80 url, referrer), |
79 number_of_loads_(0), | 81 number_of_loads_(0), |
80 expected_number_of_loads_(number_of_loads), | 82 expected_number_of_loads_(number_of_loads), |
81 expected_final_status_(expected_final_status), | 83 expected_final_status_(expected_final_status), |
82 new_render_view_host_(NULL), | 84 new_render_view_host_(NULL), |
83 was_hidden_(false), | 85 was_hidden_(false), |
84 was_shown_(false) { | 86 was_shown_(false) { |
85 } | 87 } |
86 | 88 |
87 virtual ~TestPrerenderContents() { | 89 virtual ~TestPrerenderContents() { |
88 EXPECT_EQ(expected_final_status_, final_status()) << | 90 EXPECT_EQ(expected_final_status_, final_status()) << |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 expected_final_status_queue_.resize(expected_final_status_queue.size()); | 198 expected_final_status_queue_.resize(expected_final_status_queue.size()); |
197 std::copy(expected_final_status_queue.begin(), | 199 std::copy(expected_final_status_queue.begin(), |
198 expected_final_status_queue.end(), | 200 expected_final_status_queue.end(), |
199 expected_final_status_queue_.begin()); | 201 expected_final_status_queue_.begin()); |
200 VLOG(1) << "Factory created with queue length " << | 202 VLOG(1) << "Factory created with queue length " << |
201 expected_final_status_queue_.size(); | 203 expected_final_status_queue_.size(); |
202 } | 204 } |
203 | 205 |
204 virtual PrerenderContents* CreatePrerenderContents( | 206 virtual PrerenderContents* CreatePrerenderContents( |
205 PrerenderManager* prerender_manager, | 207 PrerenderManager* prerender_manager, |
| 208 PrerenderTracker* prerender_tracker, |
206 Profile* profile, | 209 Profile* profile, |
207 const GURL& url, | 210 const GURL& url, |
208 const GURL& referrer) OVERRIDE { | 211 const GURL& referrer) OVERRIDE { |
209 CHECK(!expected_final_status_queue_.empty()) << | 212 CHECK(!expected_final_status_queue_.empty()) << |
210 "Creating prerender contents for " << url.path() << | 213 "Creating prerender contents for " << url.path() << |
211 " with no expected final status"; | 214 " with no expected final status"; |
212 FinalStatus expected_final_status = expected_final_status_queue_.front(); | 215 FinalStatus expected_final_status = expected_final_status_queue_.front(); |
213 expected_final_status_queue_.pop_front(); | 216 expected_final_status_queue_.pop_front(); |
214 VLOG(1) << "Creating prerender contents for " << url.path() << | 217 VLOG(1) << "Creating prerender contents for " << url.path() << |
215 " with expected final status " << expected_final_status; | 218 " with expected final status " << expected_final_status; |
216 VLOG(1) << expected_final_status_queue_.size() << " left in the queue."; | 219 VLOG(1) << expected_final_status_queue_.size() << " left in the queue."; |
217 return new TestPrerenderContents(prerender_manager, profile, url, | 220 return new TestPrerenderContents(prerender_manager, prerender_tracker, |
| 221 profile, url, |
218 referrer, number_of_loads_, | 222 referrer, number_of_loads_, |
219 expected_final_status); | 223 expected_final_status); |
220 } | 224 } |
221 | 225 |
222 private: | 226 private: |
223 int number_of_loads_; | 227 int number_of_loads_; |
224 std::deque<FinalStatus> expected_final_status_queue_; | 228 std::deque<FinalStatus> expected_final_status_queue_; |
225 }; | 229 }; |
226 | 230 |
227 } // namespace | 231 } // namespace |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 PrerenderTestURL("files/prerender/prerender_page.html", | 1143 PrerenderTestURL("files/prerender/prerender_page.html", |
1140 FINAL_STATUS_WINDOW_OPENER, | 1144 FINAL_STATUS_WINDOW_OPENER, |
1141 1); | 1145 1); |
1142 OpenDestUrlInNewWindowViaClick(); | 1146 OpenDestUrlInNewWindowViaClick(); |
1143 } | 1147 } |
1144 | 1148 |
1145 // TODO(shishir): Add a test for the case when the page having the | 1149 // TODO(shishir): Add a test for the case when the page having the |
1146 // prerendering link already has an opener set. | 1150 // prerendering link already has an opener set. |
1147 | 1151 |
1148 } // namespace prerender | 1152 } // namespace prerender |
OLD | NEW |