| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/browser/prerender/prerender_contents.h" | 10 #include "chrome/browser/prerender/prerender_contents.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 EXPECT_EQ(expected_final_status_, final_status()); | 45 EXPECT_EQ(expected_final_status_, final_status()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual void StartPrerendering( | 48 virtual void StartPrerendering( |
| 49 int ALLOW_UNUSED creator_child_id, | 49 int ALLOW_UNUSED creator_child_id, |
| 50 const gfx::Size& ALLOW_UNUSED size, | 50 const gfx::Size& ALLOW_UNUSED size, |
| 51 content::SessionStorageNamespace* ALLOW_UNUSED session_storage_namespace, | 51 content::SessionStorageNamespace* ALLOW_UNUSED session_storage_namespace, |
| 52 bool is_control_group) OVERRIDE; | 52 bool is_control_group) OVERRIDE; |
| 53 | 53 |
| 54 virtual bool GetChildId(int* child_id) const OVERRIDE { | 54 virtual bool GetChildId(int* child_id) const OVERRIDE { |
| 55 *child_id = 0; | 55 // Having a default child_id of -1 forces pending prerenders not to fail |
| 56 // on session storage and cross domain checking. |
| 57 *child_id = -1; |
| 56 return true; | 58 return true; |
| 57 } | 59 } |
| 58 | 60 |
| 59 virtual bool GetRouteId(int* route_id) const OVERRIDE { | 61 virtual bool GetRouteId(int* route_id) const OVERRIDE { |
| 60 *route_id = 0; | 62 *route_id = 0; |
| 61 return true; | 63 return true; |
| 62 } | 64 } |
| 63 | 65 |
| 64 FinalStatus expected_final_status() const { return expected_final_status_; } | 66 FinalStatus expected_final_status() const { return expected_final_status_; } |
| 65 | 67 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 128 |
| 127 void AdvanceTimeTicks(TimeDelta delta) { | 129 void AdvanceTimeTicks(TimeDelta delta) { |
| 128 time_ticks_ += delta; | 130 time_ticks_ += delta; |
| 129 } | 131 } |
| 130 | 132 |
| 131 DummyPrerenderContents* CreateNextPrerenderContents( | 133 DummyPrerenderContents* CreateNextPrerenderContents( |
| 132 const GURL& url, | 134 const GURL& url, |
| 133 FinalStatus expected_final_status) { | 135 FinalStatus expected_final_status) { |
| 134 DummyPrerenderContents* prerender_contents = | 136 DummyPrerenderContents* prerender_contents = |
| 135 new DummyPrerenderContents(this, prerender_tracker_, url, | 137 new DummyPrerenderContents(this, prerender_tracker_, url, |
| 136 ORIGIN_LINK_REL_PRERENDER, | 138 ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN, |
| 137 expected_final_status); | 139 expected_final_status); |
| 138 SetNextPrerenderContents(prerender_contents); | 140 SetNextPrerenderContents(prerender_contents); |
| 139 return prerender_contents; | 141 return prerender_contents; |
| 140 } | 142 } |
| 141 | 143 |
| 142 DummyPrerenderContents* CreateNextPrerenderContents( | 144 DummyPrerenderContents* CreateNextPrerenderContents( |
| 143 const GURL& url, | 145 const GURL& url, |
| 144 Origin origin, | 146 Origin origin, |
| 145 FinalStatus expected_final_status) { | 147 FinalStatus expected_final_status) { |
| 146 DummyPrerenderContents* prerender_contents = | 148 DummyPrerenderContents* prerender_contents = |
| 147 new DummyPrerenderContents(this, prerender_tracker_, url, | 149 new DummyPrerenderContents(this, prerender_tracker_, url, |
| 148 origin, expected_final_status); | 150 origin, expected_final_status); |
| 149 SetNextPrerenderContents(prerender_contents); | 151 SetNextPrerenderContents(prerender_contents); |
| 150 return prerender_contents; | 152 return prerender_contents; |
| 151 } | 153 } |
| 152 | 154 |
| 153 DummyPrerenderContents* CreateNextPrerenderContents( | 155 DummyPrerenderContents* CreateNextPrerenderContents( |
| 154 const GURL& url, | 156 const GURL& url, |
| 155 const std::vector<GURL>& alias_urls, | 157 const std::vector<GURL>& alias_urls, |
| 156 FinalStatus expected_final_status) { | 158 FinalStatus expected_final_status) { |
| 157 DummyPrerenderContents* prerender_contents = | 159 DummyPrerenderContents* prerender_contents = |
| 158 new DummyPrerenderContents(this, prerender_tracker_, url, | 160 new DummyPrerenderContents(this, prerender_tracker_, url, |
| 159 ORIGIN_LINK_REL_PRERENDER, | 161 ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN, |
| 160 expected_final_status); | 162 expected_final_status); |
| 161 for (std::vector<GURL>::const_iterator it = alias_urls.begin(); | 163 for (std::vector<GURL>::const_iterator it = alias_urls.begin(); |
| 162 it != alias_urls.end(); | 164 it != alias_urls.end(); |
| 163 ++it) { | 165 ++it) { |
| 164 EXPECT_TRUE(prerender_contents->AddAliasURL(*it)); | 166 EXPECT_TRUE(prerender_contents->AddAliasURL(*it)); |
| 165 } | 167 } |
| 166 SetNextPrerenderContents(prerender_contents); | 168 SetNextPrerenderContents(prerender_contents); |
| 167 return prerender_contents; | 169 return prerender_contents; |
| 168 } | 170 } |
| 169 | 171 |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 prerender_manager()->CreateNextPrerenderContents( | 1155 prerender_manager()->CreateNextPrerenderContents( |
| 1154 url, FINAL_STATUS_USED); | 1156 url, FINAL_STATUS_USED); |
| 1155 EXPECT_TRUE(AddSimplePrerender(url)); | 1157 EXPECT_TRUE(AddSimplePrerender(url)); |
| 1156 EXPECT_TRUE(second_prerender_contents->prerendering_has_started()); | 1158 EXPECT_TRUE(second_prerender_contents->prerendering_has_started()); |
| 1157 ASSERT_EQ(second_prerender_contents, | 1159 ASSERT_EQ(second_prerender_contents, |
| 1158 prerender_manager()->FindAndUseEntry(url)); | 1160 prerender_manager()->FindAndUseEntry(url)); |
| 1159 EXPECT_FALSE(IsEmptyPrerenderLinkManager()); | 1161 EXPECT_FALSE(IsEmptyPrerenderLinkManager()); |
| 1160 } | 1162 } |
| 1161 | 1163 |
| 1162 } // namespace prerender | 1164 } // namespace prerender |
| OLD | NEW |